Skip to content

Commit

Permalink
network: delete IP addrs on bridge model to prevent ARP conflict
Browse files Browse the repository at this point in the history
Fixes: kata-containers#1673

Signed-off-by: Zha Bin <[email protected]>
  • Loading branch information
zhabinecho committed May 15, 2019
1 parent 86d51f5 commit bdb1047
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion virtcontainers/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,16 @@ func bridgeNetworkPair(endpoint Endpoint, queues int, disableVhostNet bool) erro
netPair.VirtIface.Name, netPair.Name, err)
}

// Clear the IP addresses from the veth interface to prevent ARP conflict
netPair.VirtIface.Addrs, err = netlink.AddrList(link, netlink.FAMILY_V4)
if err != nil {
return fmt.Errorf("Unable to obtain veth IP addresses: %s", err)
}

if err := clearIPs(link, netPair.VirtIface.Addrs); err != nil {
return fmt.Errorf("Unable to clear veth IP addresses: %s", err)
}

if err := netHandle.LinkSetUp(link); err != nil {
return fmt.Errorf("Could not enable veth %s: %s", netPair.VirtIface.Name, err)
}
Expand Down Expand Up @@ -1001,7 +1011,8 @@ func unBridgeNetworkPair(endpoint Endpoint) error {
return fmt.Errorf("Could not detach veth %s: %s", netPair.VirtIface.Name, err)
}

return nil
// Restore the IPs that were cleared
return setIPs(link, netPair.VirtIface.Addrs)
}

func removeTCFiltering(endpoint Endpoint) error {
Expand Down

0 comments on commit bdb1047

Please sign in to comment.