Replace usage of WithNetNSUnsafe in plugin/net/watcher.go with safer version

Unsafe version was in ConfigureARPforVeths; replacement is via `weaveutil configure-arp`
This commit is contained in:
Martynas Pumputis authored and Bryan Boreham committed 2016-10-06 15:25:05 +01:00
1 parent 7f92c8c4c6
commit 4a49ff3083
4 files changed
+37 -20

No files matched your search

+1
View File
@@ -23,6 +23,7 @@ func init() {
"process-addrs": processAddrs,
"attach-container": attach,
"detach-container": detach,
"configure-arp": configureARP,
}
}
+35
View File
@@ -0,0 +1,35 @@
package main
import (
"strings"
"github.com/j-keck/arping"
"github.com/vishvananda/netlink"
weavenet "github.com/weaveworks/weave/net"
)
func configureARP(args []string) error {
if len(args) != 1 {
cmdUsage("configure-arp", "<iface-name-prefix>")
}
prefix := args[0]
links, err := netlink.LinkList()
if err != nil {
return err
}
for _, link := range links {
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 nil
}