Refactor: move SetupIface code from weaveutil to net package
This commit is contained in:
1 parent
052fdb30c0
commit
97e0fcb765
2 files changed
+27
-22
No files matched your search
@@ -6,7 +6,6 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/coreos/go-iptables/iptables"
|
||||
"github.com/j-keck/arping"
|
||||
"github.com/vishvananda/netlink"
|
||||
|
||||
@@ -48,27 +47,7 @@ func setupIface(args []string) error {
|
||||
ifaceName := args[0]
|
||||
newIfName := args[1]
|
||||
|
||||
ipt, err := iptables.New()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
link, err := netlink.LinkByName(ifaceName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := netlink.LinkSetName(link, newIfName); err != nil {
|
||||
return err
|
||||
}
|
||||
// This is only called by AttachContainer which is only called in host pid namespace
|
||||
if err := weavenet.ConfigureARPCache("/proc", newIfName); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := ipt.Append("filter", "INPUT", "-i", newIfName, "-d", "224.0.0.0/4", "-j", "DROP"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return weavenet.SetupIface(ifaceName, newIfName)
|
||||
}
|
||||
|
||||
func configureARP(args []string) error {
|
||||
|
||||
Reference in new issue
Block a user