From fd74c07a410c328b87a3696a0afec78a2c4caf71 Mon Sep 17 00:00:00 2001 From: Andrei Vagin Date: Thu, 27 Jun 2024 14:35:27 -0700 Subject: [PATCH] Use Stack.NextNICID() to generate network device ID-s PiperOrigin-RevId: 647450216 --- runsc/boot/network.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/runsc/boot/network.go b/runsc/boot/network.go index dd68df57b..e8933550b 100644 --- a/runsc/boot/network.go +++ b/runsc/boot/network.go @@ -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.