Skip to content

Commit 256b38c

Browse files
authored
Merge pull request #5334 from trozet/fix_fdb_learning
Fixes FDB learning and usage of NORMAL action
2 parents f25f775 + 3735ec2 commit 256b38c

File tree

5 files changed

+33
-3
lines changed

5 files changed

+33
-3
lines changed

go-controller/pkg/node/gateway.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,11 @@ func gatewayInitInternal(nodeName, gwIntf, egressGatewayIntf string, gwNextHops
424424
}
425425
}
426426

427+
// Set static FDB entry for LOCAL port
428+
if err := util.SetStaticFDBEntry(gatewayBridge.bridgeName, gatewayBridge.bridgeName, gatewayBridge.macAddress); err != nil {
429+
return nil, nil, err
430+
}
431+
427432
l3GwConfig := util.L3GatewayConfig{
428433
Mode: config.Gateway.Mode,
429434
ChassisID: chassisID,

go-controller/pkg/node/gateway_init_linux_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ func shareGatewayInterfaceTest(app *cli.App, testNS ns.NetNS,
195195
Cmd: "ovs-vsctl --timeout=15 --if-exists get Open_vSwitch . other_config:hw-offload",
196196
Output: fmt.Sprintf("%t", hwOffload),
197197
})
198+
fexec.AddFakeCmdsNoOutputNoError([]string{
199+
"ovs-appctl --timeout=15 fdb/add breth0 breth0 0 " + eth0MAC,
200+
})
198201
fexec.AddFakeCmd(&ovntest.ExpectedCmd{
199202
Cmd: "ovs-vsctl --timeout=15 get Interface patch-breth0_node1-to-br-int ofport",
200203
Output: "5",
@@ -633,6 +636,9 @@ func shareGatewayInterfaceDPUTest(app *cli.App, testNS ns.NetNS,
633636
Cmd: "ovs-vsctl --timeout=15 --if-exists get Open_vSwitch . other_config:hw-offload",
634637
Output: "false",
635638
})
639+
fexec.AddFakeCmdsNoOutputNoError([]string{
640+
fmt.Sprintf("ovs-appctl --timeout=15 fdb/add %s %s 0 %s", brphys, brphys, hostMAC),
641+
})
636642
// GetDPUHostInterface
637643
fexec.AddFakeCmd(&ovntest.ExpectedCmd{
638644
Cmd: "ovs-vsctl --timeout=15 list-ports " + brphys,
@@ -1086,6 +1092,9 @@ OFPT_GET_CONFIG_REPLY (xid=0x4): frags=normal miss_send_len=0`
10861092
Cmd: "ovs-vsctl --timeout=15 --if-exists get Open_vSwitch . other_config:hw-offload",
10871093
Output: "false",
10881094
})
1095+
fexec.AddFakeCmdsNoOutputNoError([]string{
1096+
"ovs-appctl --timeout=15 fdb/add breth0 breth0 0 " + eth0MAC,
1097+
})
10891098
fexec.AddFakeCmd(&ovntest.ExpectedCmd{
10901099
Cmd: "ovs-vsctl --timeout=15 get Interface patch-breth0_node1-to-br-int ofport",
10911100
Output: "5",

go-controller/pkg/node/gateway_shared_intf.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1897,10 +1897,10 @@ func commonFlows(hostSubnets []*net.IPNet, bridge *bridgeConfiguration) ([]strin
18971897
for _, netConfig := range bridge.patchedNetConfigs() {
18981898
actions += "output:" + netConfig.ofPortPatch + ","
18991899
}
1900-
actions += strip_vlan + "output:" + ofPortHost
1900+
actions += strip_vlan + "NORMAL"
19011901
dftFlows = append(dftFlows,
1902-
fmt.Sprintf("cookie=%s, priority=10, table=0, in_port=%s, %s dl_dst=%s, actions=%s",
1903-
defaultOpenFlowCookie, ofPortPhys, match_vlan, bridgeMacAddress, actions))
1902+
fmt.Sprintf("cookie=%s, priority=10, table=0, %s dl_dst=%s, actions=%s",
1903+
defaultOpenFlowCookie, match_vlan, bridgeMacAddress, actions))
19041904
}
19051905

19061906
// table 0, check packets coming from OVN have the correct mac address. Low priority flows that are a catch all

go-controller/pkg/node/gateway_udn_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ func setUpGatewayFakeOVSCommands(fexec *ovntest.FakeExec) {
171171
Cmd: "ovs-vsctl --timeout=15 --if-exists get Open_vSwitch . other_config:hw-offload",
172172
Output: "false",
173173
})
174+
fexec.AddFakeCmdsNoOutputNoError([]string{
175+
"ovs-appctl --timeout=15 fdb/add breth0 breth0 0 00:00:00:55:66:99",
176+
})
174177
fexec.AddFakeCmd(&ovntest.ExpectedCmd{
175178
Cmd: "ovs-vsctl --timeout=15 get Interface patch-breth0_worker1-to-br-int ofport",
176179
Output: "5",

go-controller/pkg/util/ovs.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bytes"
55
"encoding/json"
66
"fmt"
7+
"net"
78
"regexp"
89
"runtime"
910
"strings"
@@ -819,6 +820,18 @@ func DetectCheckPktLengthSupport(bridge string) (bool, error) {
819820
return false, nil
820821
}
821822

823+
// SetStaticFDBEntry programs a static MAC entry into the OVS FIB and disables MAC learning for this entry
824+
func SetStaticFDBEntry(bridge, port string, mac net.HardwareAddr) error {
825+
// Assume default VLAN for local port
826+
vlan := "0"
827+
stdout, stderr, err := RunOVSAppctl("fdb/add", bridge, port, vlan, mac.String())
828+
if err != nil {
829+
return fmt.Errorf("failed to add FDB entry to OVS for LOCAL port, "+
830+
"stdout: %q, stderr: %q, error: %v", stdout, stderr, err)
831+
}
832+
return nil
833+
}
834+
822835
// IsOvsHwOffloadEnabled checks if OvS Hardware Offload is enabled.
823836
func IsOvsHwOffloadEnabled() (bool, error) {
824837
stdout, stderr, err := RunOVSVsctl("--if-exists", "get",

0 commit comments

Comments
 (0)