Deflake TestRouterSolicitation

Before this change, transmission of the first router solicitation races
with the adding of an IPv6 link-local address. This change creates the
NIC in the disabled state and is only enabled after the address is added
(if required) to avoid this race.

PiperOrigin-RevId: 384493553
This commit is contained in:
Ghanan Gowripalan
2021-07-13 10:22:05 -07:00
committed by gVisor bot
parent e35d20f79c
commit b4caeaf78f
+7 -2
View File
@@ -5356,8 +5356,9 @@ func TestRouterSolicitation(t *testing.T) {
RandSource: &randSource,
})
if err := s.CreateNIC(nicID, &e); err != nil {
t.Fatalf("CreateNIC(%d, _) = %s", nicID, err)
opts := stack.NICOptions{Disabled: true}
if err := s.CreateNICWithOptions(nicID, &e, opts); err != nil {
t.Fatalf("CreateNICWithOptions(%d, _, %#v) = %s", nicID, opts, err)
}
if addr := test.nicAddr; addr != "" {
@@ -5366,6 +5367,10 @@ func TestRouterSolicitation(t *testing.T) {
}
}
if err := s.EnableNIC(nicID); err != nil {
t.Fatalf("EnableNIC(%d): %s", nicID, err)
}
// Make sure each RS is sent at the right time.
remaining := test.maxRtrSolicit
if remaining != 0 {