Perform arp configuration for plugin-connected containers

This commit is contained in:
Bryan Boreham committed 2016-06-14 17:53:34 +01:00
1 parent c71c630cf6
commit 8bb8f70bb6
3 files changed
+25

No files matched your search

+19
View File
@@ -6,6 +6,7 @@ import (
"os"
"strings"
"github.com/j-keck/arping"
"github.com/vishvananda/netlink"
"github.com/vishvananda/netns"
@@ -34,6 +35,7 @@ type NetDev struct {
}
// Search the network namespace of a process for interfaces matching a predicate
// Note that the predicate is called while the goroutine is inside the process' netns
func FindNetDevs(processID int, match func(link netlink.Link) bool) ([]NetDev, error) {
var netDevs []NetDev
@@ -137,3 +139,20 @@ func GetBridgeNetDev(bridgeName string) ([]NetDev, error) {
return link.Attrs().Name == bridgeName
})
}
// Do post-attach configuration of all veths we have created
func ConfigureARPforVeths(processID int, prefix string) error {
_, err := FindNetDevs(processID, func(link netlink.Link) bool {
ifName := link.Attrs().Name
if strings.HasPrefix(ifName, prefix) {
weavenet.ConfigureARPCache(ifName)
if addrs, err := netlink.AddrList(link, netlink.FAMILY_V4); err == nil {
for _, addr := range addrs {
arping.GratuitousArpOverIfaceByName(addr.IPNet.IP, ifName)
}
}
}
return false
})
return err
}