func cmdDel(args *skel.CmdArgs) error { args.IfName = "lo" // ignore config, this only works for loopback err := ns.WithNetNSPath(args.Netns, false, func(hostNS *os.File) error { link, err := netlink.LinkByName(args.IfName) if err != nil { return err // not tested } err = netlink.LinkSetDown(link) if err != nil { return err // not tested } return nil }) if err != nil { return err // not tested } return nil }
func rpcCall(method string, args *skel.CmdArgs, result interface{}) error { client, err := rpc.DialHTTP("unix", socketPath) if err != nil { return fmt.Errorf("error dialing DHCP daemon: %v", err) } // The daemon may be running under a different working dir // so make sure the netns path is absolute. netns, err := filepath.Abs(args.Netns) if err != nil { return fmt.Errorf("failed to make %q an absolute path: %v", args.Netns, err) } args.Netns = netns err = client.Call(method, args, result) if err != nil { return fmt.Errorf("error calling %v: %v", method, err) } return nil }