Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use arping when claiming egress IPs #20286

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions pkg/network/node/egressip.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ package node
import (
"fmt"
"net"
"os/exec"
"sync"
"syscall"
"time"

"github.com/golang/glog"

Expand Down Expand Up @@ -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)
Expand Down