Skip to content

Commit fd5e791

Browse files
committed
[node/gateway] nodePortWatcher should use its own bridgeConfiguration.
It used to require addressManager to updateGatewayIPs only to get bridgeConfig from it. We can just give nodePortWatcher its own reference to the bridgeConfig. Signed-off-by: Nadia Pinaeva <[email protected]>
1 parent a0c90f2 commit fd5e791

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

go-controller/pkg/node/gateway_localnet_linux_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ func initFakeNodePortWatcher(iptV4, iptV6 util.IPTablesHelper) *nodePortWatcher
7070
defaultBridge: defaultBridge,
7171
},
7272
networkManager: networkmanager.Default().Interface(),
73+
gwBridge: bridgeconfig.TestBridgeConfig(""),
7374
}
7475
return &fNPW
7576
}

go-controller/pkg/node/gateway_shared_intf.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ type nodePortWatcher struct {
190190
gatewayIPv6 string
191191
gatewayIPLock sync.Mutex
192192
ofportPhys string
193-
gwBridge string
193+
gwBridge *bridgeconfig.BridgeConfiguration
194194
// Map of service name to programmed iptables/OF rules
195195
serviceInfo map[ktypes.NamespacedName]*serviceConfig
196196
serviceInfoLock sync.Mutex
@@ -216,9 +216,9 @@ type cidrAndFlags struct {
216216
validLifetime int
217217
}
218218

219-
func (npw *nodePortWatcher) updateGatewayIPs(addressManager *addressManager) {
219+
func (npw *nodePortWatcher) updateGatewayIPs() {
220220
// Get Physical IPs of Node, Can be IPV4 IPV6 or both
221-
gatewayIPv4, gatewayIPv6 := getGatewayFamilyAddrs(addressManager.gatewayBridge.GetIPs())
221+
gatewayIPv4, gatewayIPv6 := getGatewayFamilyAddrs(npw.gwBridge.GetIPs())
222222

223223
npw.gatewayIPLock.Lock()
224224
defer npw.gatewayIPLock.Unlock()
@@ -368,7 +368,7 @@ func (npw *nodePortWatcher) updateServiceFlowCache(service *corev1.Service, netI
368368
var ofPorts []string
369369
// don't get the ports unless we need to as it is a costly operation
370370
if (len(extParsedIPs) > 0 || len(ingParsedIPs) > 0) && add {
371-
ofPorts, err = util.GetOpenFlowPorts(npw.gwBridge, false)
371+
ofPorts, err = util.GetOpenFlowPorts(npw.gwBridge.GetGatewayIface(), false)
372372
if err != nil {
373373
// in the odd case that getting all ports from the bridge should not work,
374374
// simply output to LOCAL (this should work well in the vast majority of cases, anyway)
@@ -1517,7 +1517,7 @@ func newGateway(
15171517
}
15181518
if gw.nodePortWatcher != nil {
15191519
npw, _ := gw.nodePortWatcher.(*nodePortWatcher)
1520-
npw.updateGatewayIPs(gw.nodeIPManager)
1520+
npw.updateGatewayIPs()
15211521
}
15221522
// Services create OpenFlow flows as well, need to update them all
15231523
if gw.servicesRetryFramework != nil {
@@ -1624,7 +1624,7 @@ func newNodePortWatcher(
16241624
gatewayIPv4: gatewayIPv4,
16251625
gatewayIPv6: gatewayIPv6,
16261626
ofportPhys: ofportPhys,
1627-
gwBridge: gwBridge.GetGatewayIface(),
1627+
gwBridge: gwBridge,
16281628
serviceInfo: make(map[ktypes.NamespacedName]*serviceConfig),
16291629
nodeIPManager: nodeIPManager,
16301630
ofm: ofm,

0 commit comments

Comments
 (0)