From ede00047db734cbfd44bf6a8057c3ccc32f743a7 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Mon, 23 May 2016 12:46:52 +0100 Subject: [PATCH 1/2] Send out arp update from CNI plugin --- .gitmodules | 3 +++ plugin/net/cni.go | 2 ++ vendor/github.com/j-keck/arping | 1 + 3 files changed, 6 insertions(+) create mode 160000 vendor/github.com/j-keck/arping diff --git a/.gitmodules b/.gitmodules index 58ec72d5..acb88c3e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -70,3 +70,6 @@ [submodule "vendor/github.com/coreos/go-iptables"] path = vendor/github.com/coreos/go-iptables url = https://github.com/coreos/go-iptables +[submodule "vendor/github.com/j-keck/arping"] + path = vendor/github.com/j-keck/arping + url = https://github.com/j-keck/arping diff --git a/plugin/net/cni.go b/plugin/net/cni.go index 8d529b10..3682a721 100644 --- a/plugin/net/cni.go +++ b/plugin/net/cni.go @@ -10,6 +10,7 @@ import ( "github.com/appc/cni/pkg/ipam" "github.com/appc/cni/pkg/skel" "github.com/appc/cni/pkg/types" + "github.com/j-keck/arping" "github.com/vishvananda/netlink" "github.com/vishvananda/netns" weaveapi "github.com/weaveworks/weave/api" @@ -151,6 +152,7 @@ func setupGuestIP4(origName, name string, ipnet net.IPNet, gw net.IP, routes []t if err = netlink.AddrAdd(guest, &netlink.Addr{IPNet: &ipnet}); err != nil { return fmt.Errorf("failed to add IP address to %q: %v", name, err) } + arping.GratuitousArpOverIfaceByName(ipnet.IP, name) for _, r := range routes { if r.GW != nil { err = addRoute(guest, netlink.SCOPE_UNIVERSE, &r.Dst, r.GW) diff --git a/vendor/github.com/j-keck/arping b/vendor/github.com/j-keck/arping new file mode 160000 index 00000000..af9a9003 --- /dev/null +++ b/vendor/github.com/j-keck/arping @@ -0,0 +1 @@ +Subproject commit af9a9003cfd88231902ab8959023d743f4ea93d7 From f695b3fd173ac3afd00b933776bbc95a7a6df2c2 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Tue, 24 May 2016 17:57:52 +0100 Subject: [PATCH 2/2] Smoke-test CNI arp update --- test/830_cni_plugin_test.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/test/830_cni_plugin_test.sh b/test/830_cni_plugin_test.sh index 07aa6cf6..fa8ad8d1 100755 --- a/test/830_cni_plugin_test.sh +++ b/test/830_cni_plugin_test.sh @@ -6,7 +6,8 @@ start_suite "Test CNI plugin" cni_connect() { pid=$(container_pid $1 $2) - run_on $1 CNI_VERSION=1 CNI_COMMAND=ADD CNI_CONTAINERID=c1 CNI_IFNAME=eth0 \ + id=$(docker_on $1 inspect -f '{{.Id}}' $2) + run_on $1 CNI_VERSION=1 CNI_COMMAND=ADD CNI_CONTAINERID=$id CNI_IFNAME=eth0 \ CNI_NETNS=/proc/$pid/ns/net CNI_PATH=/opt/cni/bin /opt/cni/bin/weave-net } @@ -42,4 +43,16 @@ C2IP=$(container_ip $HOST1 c2) assert_raises "exec_on $HOST1 c1 $PING $C2IP" assert_raises "exec_on $HOST1 c2 $PING $C1IP" +# Now remove and start a new container to see if IP address re-use breaks things +docker_on $HOST1 rm -f c2 +sleep 1 + +docker_on $HOST1 run --net=none --name=c3 -dt $SMALL_IMAGE /bin/sh + +cni_connect $HOST1 c3 <