Use Stack.NextNICID() to generate network device ID-s

PiperOrigin-RevId: 647450216
This commit is contained in:
Andrei Vagin
2024-06-27 14:38:44 -07:00
committed by gVisor bot
parent 3546fab741
commit fd74c07a41
+3 -4
View File
@@ -247,7 +247,6 @@ func (n *Network) CreateLinksAndRoutes(args *CreateLinksAndRoutesArgs, _ *struct
return fmt.Errorf("args.FilePayload.Files has %d FDs but we need %d entries based on FDBasedLinks, XDPLinks, and PCAP", got, wantFDs)
}
var nicID tcpip.NICID
nicids := make(map[string]tcpip.NICID)
// Collect routes from all links.
@@ -255,7 +254,7 @@ func (n *Network) CreateLinksAndRoutes(args *CreateLinksAndRoutesArgs, _ *struct
// Loopback normally appear before other interfaces.
for _, link := range args.LoopbackLinks {
nicID = n.Stack.NextNICID()
nicID := n.Stack.NextNICID()
nicids[link.Name] = nicID
linkEP := ethernet.New(loopback.New())
@@ -298,7 +297,7 @@ func (n *Network) CreateLinksAndRoutes(args *CreateLinksAndRoutesArgs, _ *struct
}
for _, link := range args.FDBasedLinks {
nicID++
nicID := n.Stack.NextNICID()
nicids[link.Name] = nicID
FDs := make([]int, 0, link.NumChannels)
@@ -387,7 +386,7 @@ func (n *Network) CreateLinksAndRoutes(args *CreateLinksAndRoutesArgs, _ *struct
return fmt.Errorf("XDP only supports one link device, but got %d", nlinks)
}
link := args.XDPLinks[0]
nicID++
nicID := n.Stack.NextNICID()
nicids[link.Name] = nicID
// Get the AF_XDP socket.