Review feedback: tidied up function names
This commit is contained in:
1 parent
1ee4039681
commit
5ff22a1a77
5 files changed
+10
-10
No files matched your search
+1
-1
@@ -10,7 +10,7 @@ import (
|
|||||||
// Configure the ARP cache parameters for the given interface. This
|
// Configure the ARP cache parameters for the given interface. This
|
||||||
// makes containers react more quickly to a change in the MAC address
|
// makes containers react more quickly to a change in the MAC address
|
||||||
// associated with an IP address.
|
// associated with an IP address.
|
||||||
func ConfigureARPCache(procPath, name string) error {
|
func configureARPCache(procPath, name string) error {
|
||||||
if err := sysctl(procPath, fmt.Sprintf("net/ipv4/neigh/%s/base_reachable_time", name), "5"); err != nil {
|
if err := sysctl(procPath, fmt.Sprintf("net/ipv4/neigh/%s/base_reachable_time", name), "5"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -275,7 +275,7 @@ func EnsureBridge(procPath string, config *BridgeConfig, log *logrus.Logger) (Br
|
|||||||
return bridgeType, err
|
return bridgeType, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := ConfigureARPCache(procPath, config.WeaveBridgeName); err != nil {
|
if err := configureARPCache(procPath, config.WeaveBridgeName); err != nil {
|
||||||
return bridgeType, errors.Wrapf(err, "configuring ARP cache on bridge %q", config.WeaveBridgeName)
|
return bridgeType, errors.Wrapf(err, "configuring ARP cache on bridge %q", config.WeaveBridgeName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -15,7 +15,7 @@ type Dev struct {
|
|||||||
CIDRs []*net.IPNet `json:"CIDRs,omitempty"`
|
CIDRs []*net.IPNet `json:"CIDRs,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func LinkToNetDev(link netlink.Link) (Dev, error) {
|
func linkToNetDev(link netlink.Link) (Dev, error) {
|
||||||
addrs, err := netlink.AddrList(link, netlink.FAMILY_V4)
|
addrs, err := netlink.AddrList(link, netlink.FAMILY_V4)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Dev{}, err
|
return Dev{}, err
|
||||||
@@ -103,7 +103,7 @@ func GetNetDevsByVethPeerIds(processID int, peerIDs []int) ([]Dev, error) {
|
|||||||
|
|
||||||
for _, link := range links {
|
for _, link := range links {
|
||||||
if _, found := indexes[link.Attrs().Index]; found {
|
if _, found := indexes[link.Attrs().Index]; found {
|
||||||
netdev, err := LinkToNetDev(link)
|
netdev, err := linkToNetDev(link)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -124,5 +124,5 @@ func GetBridgeNetDev(bridgeName string) (Dev, error) {
|
|||||||
return Dev{}, err
|
return Dev{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return LinkToNetDev(link)
|
return linkToNetDev(link)
|
||||||
}
|
}
|
||||||
+4
-4
@@ -220,14 +220,14 @@ func setupIface(ifaceName, newIfName string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// This is only called by AttachContainer which is only called in host pid namespace
|
// This is only called by AttachContainer which is only called in host pid namespace
|
||||||
if err := ConfigureARPCache("/proc", newIfName); err != nil {
|
if err := configureARPCache("/proc", newIfName); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return ipt.Append("filter", "INPUT", "-i", newIfName, "-d", "224.0.0.0/4", "-j", "DROP")
|
return ipt.Append("filter", "INPUT", "-i", newIfName, "-d", "224.0.0.0/4", "-j", "DROP")
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConfigureARP is a helper for the Docker plugin which doesn't set the addresses itself
|
// configureARP is a helper for the Docker plugin which doesn't set the addresses itself
|
||||||
func ConfigureArp(prefix, rootPath string) error {
|
func ConfigureARP(prefix, rootPath string) error {
|
||||||
links, err := netlink.LinkList()
|
links, err := netlink.LinkList()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -235,7 +235,7 @@ func ConfigureArp(prefix, rootPath string) error {
|
|||||||
for _, link := range links {
|
for _, link := range links {
|
||||||
ifName := link.Attrs().Name
|
ifName := link.Attrs().Name
|
||||||
if strings.HasPrefix(ifName, prefix) {
|
if strings.HasPrefix(ifName, prefix) {
|
||||||
ConfigureARPCache(rootPath+"/proc", ifName)
|
configureARPCache(rootPath+"/proc", ifName)
|
||||||
if addrs, err := netlink.AddrList(link, netlink.FAMILY_V4); err == nil {
|
if addrs, err := netlink.AddrList(link, netlink.FAMILY_V4); err == nil {
|
||||||
for _, addr := range addrs {
|
for _, addr := range addrs {
|
||||||
arping.GratuitousArpOverIfaceByName(addr.IPNet.IP, ifName)
|
arping.GratuitousArpOverIfaceByName(addr.IPNet.IP, ifName)
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ func (w *watcher) ContainerStarted(id string) {
|
|||||||
}
|
}
|
||||||
netNSPath := weavenet.NSPathByPidWithRoot(rootDir, info.State.Pid)
|
netNSPath := weavenet.NSPathByPidWithRoot(rootDir, info.State.Pid)
|
||||||
if err := weavenet.WithNetNSByPath(netNSPath, func() error {
|
if err := weavenet.WithNetNSByPath(netNSPath, func() error {
|
||||||
return weavenet.ConfigureArp(weavenet.VethName, rootDir)
|
return weavenet.ConfigureARP(weavenet.VethName, rootDir)
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
w.driver.warn("ContainerStarted", "unable to configure interfaces: %s", err)
|
w.driver.warn("ContainerStarted", "unable to configure interfaces: %s", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user