plugins/*: Don't error if the device doesn't exist

I wasn't able to test or update the dhcp plugin but from a code read it
should be fine. All the other plugins are tested and fixed
This commit is contained in:
Tom Denham
2017-03-20 15:49:35 -07:00
parent b87126377a
commit 13824487c6
11 changed files with 254 additions and 14 deletions

View File

@ -191,9 +191,18 @@ func cmdDel(args *skel.CmdArgs) error {
return nil
}
return ns.WithNetNSPath(args.Netns, func(_ ns.NetNS) error {
return ip.DelLinkByName(args.IfName)
// There is a netns so try to clean up. Delete can be called multiple times
// so don't return an error if the device is already removed.
err = ns.WithNetNSPath(args.Netns, func(_ ns.NetNS) error {
if _, err := ip.DelLinkByNameAddr(args.IfName, netlink.FAMILY_V4); err != nil {
if err != ip.ErrLinkNotFound {
return err
}
}
return nil
})
return err
}
func main() {