Skip to content

Commit f1a31ed

Browse files
committed
Add static FDB entry to OVS for shared MAC
The FDB lookup is only used for non-destined shared MAC traffic. When OVN or the host send a packet that hits a NORMAL action it will initate MAC learning and can drive up the CPU of OVS. We still need NORMAL action to account for sending to unknown ports like localnet ports, but we do not want to learn the shared MAC. Therefore create a static entry binding it to the LOCAL port. Signed-off-by: Tim Rozet <[email protected]>
1 parent abc2b83 commit f1a31ed

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
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_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)