Defalke test target pkg/tcpip/stack:bridge_test.

There is a race in the test between WritePacketToRemote and FindFDBEntry, even
though it rarely happens, we just enforce FindFDBEntry to wait for
WritePacketToRemote's completion here.

PiperOrigin-RevId: 721747159
This commit is contained in:
Jing Chen
2025-01-31 06:10:20 -08:00
committed by gVisor bot
parent e0435b9a53
commit a500a2c751
+6 -1
View File
@@ -17,6 +17,7 @@ package bridge_test
import (
"os"
"testing"
"time"
"gvisor.dev/gvisor/pkg/buffer"
"gvisor.dev/gvisor/pkg/refs"
@@ -240,7 +241,11 @@ func TestBridgeFDB(t *testing.T) {
// When forwarding the packet via the bridge device, the packet's
// source MAC address will be used as lookup key to the bridge
// FDB.
if e := bridgeEndpoint.FindFDBEntry(veth2.LinkAddress()); e.PortLinkAddress() != veth1.LinkAddress() {
var e stack.BridgeFDBEntry
start := time.Now()
for e = bridgeEndpoint.FindFDBEntry(veth2.LinkAddress()); len(e.PortLinkAddress()) == 0 && time.Since(start) < 30*time.Second; {
}
if e.PortLinkAddress() != veth1.LinkAddress() {
t.Fatalf("bridgeEndpoint.FindFDBEntry(%s) = %s, want = %s", veth2.LinkAddress(), e.PortLinkAddress(), veth1.LinkAddress())
}
// No FDB entry is expected for devices other than veth1.