cleanup, ensure haproxy is running and disallow writes to followers
This commit is contained in:
parent
0965f95ab0
commit
fef86deac8
9 changed files with 49 additions and 183 deletions
38
pkg/vip/arp_linux.go
Normal file
38
pkg/vip/arp_linux.go
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
package vip
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/mdlayher/arp"
|
||||
"github.com/mdlayher/ethernet"
|
||||
)
|
||||
|
||||
func sendARP(ip net.IP, iface *net.Interface) error {
|
||||
c, err := arp.Dial(iface)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, op := range []arp.Operation{arp.OperationRequest, arp.OperationReply} {
|
||||
pkt, err := arp.NewPacket(op, iface.HardwareAddr, ip, ethernet.Broadcast, ip)
|
||||
if err != nil {
|
||||
return fmt.Errorf("assembling %q gratuitous packet for %q: %s", op, ip, err)
|
||||
}
|
||||
if err = c.WriteTo(pkt, ethernet.Broadcast); err != nil {
|
||||
return fmt.Errorf("writing %q gratuitous packet for %q: %s", op, ip, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func ARPSendGratuitous(cidr, iface string) error {
|
||||
i, err := net.InterfaceByName(iface)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get interface %q: %v", iface, err)
|
||||
}
|
||||
ip, _, err := net.ParseCIDR(cidr)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to parse cidr: %s", cidr)
|
||||
}
|
||||
return sendARP(ip, i)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue