chore: cherrypick hotfix iface

This commit is contained in:
braginini 2021-08-26 15:32:05 +02:00
parent 737866c149
commit d4a24ac001

View File

@ -71,6 +71,20 @@ func assignAddr(address, name string) error {
attrs: &attrs,
}
//delete existing addresses
list, err := netlink.AddrList(&link, 0)
if err != nil {
return err
}
if len(list) > 0 {
for _, a := range list {
err = netlink.AddrDel(&link, &a)
if err != nil {
return err
}
}
}
log.Debugf("adding address %s to interface: %s", address, attrs.Name)
addr, _ := netlink.ParseAddr(address)
err = netlink.AddrAdd(&link, addr)