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:
@ -149,6 +149,14 @@ func cmdAdd(args *skel.CmdArgs) error {
|
||||
}
|
||||
|
||||
err = netns.Do(func(_ ns.NetNS) error {
|
||||
contVethLink, err := netlink.LinkByName(args.IfName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to lookup %q: %v", args.IfName, err)
|
||||
}
|
||||
if err := ip.SetHWAddrByIP(contVethLink, result.IP4.IP.IP, nil /* TODO IPv6 */); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return ipam.ConfigureIface(args.IfName, result)
|
||||
})
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user