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:
@ -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,
|
||||
|
Reference in New Issue
Block a user