summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2018-08-06 11:47:07 -0700
committerShentubot <shentubot@google.com>2018-08-06 11:48:29 -0700
commitbc9a1fca23870b21e16e024220e0c87e236c6cf5 (patch)
tree1acb3badaee09f06de20bef84d67496c86a8da0d
parent42086fe8e1244d93e87f0cada9d0b1a8b764c6a8 (diff)
Tiny reordering to network code
PiperOrigin-RevId: 207581723 Change-Id: I6e4eb1227b5ed302de5e6c891040b670955f1eea
-rw-r--r--runsc/sandbox/network.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/runsc/sandbox/network.go b/runsc/sandbox/network.go
index d6685fd66..d0ce6228b 100644
--- a/runsc/sandbox/network.go
+++ b/runsc/sandbox/network.go
@@ -221,12 +221,6 @@ func createInterfacesAndRoutesFromNS(conn *urpc.Client, nsPath string) error {
continue
}
- // Get the link for the interface.
- ifaceLink, err := netlink.LinkByName(iface.Name)
- if err != nil {
- return fmt.Errorf("error getting link for interface %q: %v", iface.Name, err)
- }
-
// Create the socket.
const protocol = 0x0300 // htons(ETH_P_ALL)
fd, err := syscall.Socket(syscall.AF_PACKET, syscall.SOCK_RAW, protocol)
@@ -238,7 +232,7 @@ func createInterfacesAndRoutesFromNS(conn *urpc.Client, nsPath string) error {
// Bind to the appropriate device.
ll := syscall.SockaddrLinklayer{
Protocol: protocol,
- Ifindex: ifaceLink.Attrs().Index,
+ Ifindex: iface.Index,
Hatype: 0, // No ARP type.
Pkttype: syscall.PACKET_OTHERHOST,
}
@@ -266,6 +260,12 @@ func createInterfacesAndRoutesFromNS(conn *urpc.Client, nsPath string) error {
Routes: routes,
}
+ // Get the link for the interface.
+ ifaceLink, err := netlink.LinkByName(iface.Name)
+ if err != nil {
+ return fmt.Errorf("error getting link for interface %q: %v", iface.Name, err)
+ }
+
// Collect the addresses for the interface, enable forwarding,
// and remove them from the host.
for _, addr := range ip4addrs {