From e6adfe939a0d4586fe3451b8a6967e33fdedb1b0 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Mon, 28 Nov 2016 09:33:39 -0600 Subject: [PATCH] macvlan/ipvlan: use common RenameLink method --- ip/link.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ip/link.go b/ip/link.go index 43b37390..6431bb41 100644 --- a/ip/link.go +++ b/ip/link.go @@ -90,6 +90,14 @@ func RandomVethName() (string, error) { return fmt.Sprintf("veth%x", entropy), nil } +func RenameLink(curName, newName string) error { + link, err := netlink.LinkByName(curName) + if err == nil { + err = netlink.LinkSetName(link, newName) + } + return err +} + // SetupVeth sets up a virtual ethernet link. // Should be in container netns, and will switch back to hostNS to set the host // veth end up.