plugins: set MAC addresses based on IP

This will give deterministic MAC addresses for all interfaces CNI
creates and manages the IP for:
* bridge: container veth and host bridge
* macvlan: container veth
* ptp: container veth and host veth
This commit is contained in:
Stefan Junker
2016-06-28 17:46:17 -07:00
parent 3a1354cff6
commit 924b30b57d
7 changed files with 69 additions and 42 deletions

View File

@ -64,6 +64,10 @@ func setupContainerVeth(netns, ifName string, mtu int, pr *types.Result) (string
return err
}
if err := ip.SetHWAddrByIP(hostVeth, pr.IP4.IP.IP, nil /* TODO IPv6 */); err != nil {
return fmt.Errorf("failed to set hardware addr by IP: %v", err)
}
if err = ipam.ConfigureIface(ifName, pr); err != nil {
return err
}
@ -73,6 +77,10 @@ func setupContainerVeth(netns, ifName string, mtu int, pr *types.Result) (string
return fmt.Errorf("failed to look up %q: %v", ifName, err)
}
if err := ip.SetHWAddrByIP(contVeth, pr.IP4.IP.IP, nil /* TODO IPv6 */); err != nil {
return fmt.Errorf("failed to set hardware addr by IP: %v", err)
}
// Delete the route that was automatically added
route := netlink.Route{
LinkIndex: contVeth.Attrs().Index,