From c38df61230a999c75830680d4ac026e340bed09f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Caama=C3=B1o=20Ruiz?= Date: Fri, 10 Jan 2020 20:38:21 +0100 Subject: [PATCH] Replace '.' with '/' on sysctl interface names Interface names with dots in them need to be replaced with slashes when used in sysctl keys using dots as separator. Reference: http://man7.org/linux/man-pages/man5/sysctl.d.5.html --- macvtap.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/macvtap.go b/macvtap.go index c876aff..01cd25f 100644 --- a/macvtap.go +++ b/macvtap.go @@ -19,6 +19,7 @@ import ( "fmt" "net" "runtime" + "strings" "github.com/vishvananda/netlink" @@ -181,8 +182,11 @@ func createMacvtap(conf *NetConf, ifName string, netns ns.NetNS) (*current.Inter func configureArp(macvtapConfig netlink.Link, netns ns.NetNS) error { err := netns.Do(func(_ ns.NetNS) error { + // For sysctl, dots are replaced with forward slashes + name := strings.Replace(macvtapConfig.Attrs().Name, ".", "/", -1) + // TODO: duplicate following lines for ipv6 support, when it will be added in other places - ipv4SysctlValueName := fmt.Sprintf(IPv4InterfaceArpProxySysctlTemplate, macvtapConfig.Attrs().Name) + ipv4SysctlValueName := fmt.Sprintf(IPv4InterfaceArpProxySysctlTemplate, name) if _, err := sysctl.Sysctl(ipv4SysctlValueName, "1"); err != nil { // remove the newly added link and ignore errors, because we already are in a failed state _ = netlink.LinkDel(macvtapConfig)