From baeef4856ffb15812c42952cc1d29169de987f06 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Wed, 11 Jul 2018 10:15:20 -0400 Subject: [PATCH] Use arping when claiming egress IPs --- pkg/network/node/egressip.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pkg/network/node/egressip.go b/pkg/network/node/egressip.go index 48916751d02b..5da25514e6dd 100644 --- a/pkg/network/node/egressip.go +++ b/pkg/network/node/egressip.go @@ -5,8 +5,10 @@ package node import ( "fmt" "net" + "os/exec" "sync" "syscall" + "time" "github.com/golang/glog" @@ -151,6 +153,17 @@ func (eip *egressIPWatcher) assignEgressIP(egressIP, mark string) error { return fmt.Errorf("could not add egress IP %q to %s: %v", egressIPNet, eip.localEgressLink.Attrs().Name, err) } } + // Use arping to try to update other hosts ARP caches, in case this IP was + // previously active on another node. (Based on code from "ifup".) + go func() { + out, err := exec.Command("/sbin/arping", "-q", "-A", "-c", "1", "-I", eip.localEgressLink.Attrs().Name, egressIP).CombinedOutput() + if err != nil { + glog.Warning("Failed to send ARP claim for egress IP %q: %v (%s)", egressIP, err, string(out)) + return + } + time.Sleep(2 * time.Second) + _ = exec.Command("/sbin/arping", "-q", "-U", "-c", "1", "-I", eip.localEgressLink.Attrs().Name, egressIP).Run() + }() if err := eip.iptables.AddEgressIPRules(egressIP, mark); err != nil { return fmt.Errorf("could not add egress IP iptables rule: %v", err)