Skip to content

Commit

Permalink
Merge pull request #3815 from weaveworks/ignore-ipv6-not-found
Browse files Browse the repository at this point in the history
Don't exit if machine has no ipv6 installed
  • Loading branch information
bboreham committed Jun 4, 2020
2 parents 9be65b4 + 7174738 commit 3d79b07
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
8 changes: 8 additions & 0 deletions net/arp.go
Expand Up @@ -41,3 +41,11 @@ func sysctl(procPath, variable, value string) error {

return nil
}

func sysctlIfExists(procPath, variable, value string) error {
err := sysctl(procPath, variable, value)
if err != nil && os.IsNotExist(err) {
err = nil // ignore 'not found' errors
}
return err
}
2 changes: 1 addition & 1 deletion net/bridge.go
Expand Up @@ -281,7 +281,7 @@ func EnsureBridge(procPath string, config *BridgeConfig, log *logrus.Logger, ips
}
}
// No ipv6 router advertisments please
if err := sysctl(procPath, "net/ipv6/conf/"+config.WeaveBridgeName+"/accept_ra", "0"); err != nil {
if err := sysctlIfExists(procPath, "net/ipv6/conf/"+config.WeaveBridgeName+"/accept_ra", "0"); err != nil {
return bridgeType, errors.Wrap(err, "setting accept_ra to 0")
}

Expand Down
4 changes: 2 additions & 2 deletions net/veth.go
Expand Up @@ -50,10 +50,10 @@ func CreateAndAttachVeth(procPath, name, peerName, bridgeName string, mtu int, k
return cleanup("attaching veth %q to %q: %s", name, bridgeName, err)
}
// No ipv6 router advertisments please
if err := sysctl(procPath, "net/ipv6/conf/"+name+"/accept_ra", "0"); err != nil {
if err := sysctlIfExists(procPath, "net/ipv6/conf/"+name+"/accept_ra", "0"); err != nil {
return cleanup("setting accept_ra to 0: %s", err)
}
if err := sysctl(procPath, "net/ipv6/conf/"+peerName+"/accept_ra", "0"); err != nil {
if err := sysctlIfExists(procPath, "net/ipv6/conf/"+peerName+"/accept_ra", "0"); err != nil {
return cleanup("setting accept_ra to 0: %s", err)
}
if !bridgeType.IsFastdp() && !keepTXOn {
Expand Down

0 comments on commit 3d79b07

Please sign in to comment.