Skip to content

Commit

Permalink
health: Configure sysctl when IPv6 is disabled
Browse files Browse the repository at this point in the history
When IPv6 is disabled, ensure that the health endpoint's device is
configured to disable IPv6 so that it doesn't emit any IPv6 autoconf
frames or similar.

Signed-off-by: Joe Stringer <joe@cilium.io>
  • Loading branch information
joestringer authored and aanm committed Sep 27, 2019
1 parent 697da04 commit 7797aa5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cilium-health/launch/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import (
"github.com/cilium/cilium/pkg/node"
"github.com/cilium/cilium/pkg/option"
"github.com/cilium/cilium/pkg/pidfile"
"github.com/cilium/cilium/pkg/sysctl"

"github.com/containernetworking/plugins/pkg/ns"
"github.com/vishvananda/netlink"
Expand Down Expand Up @@ -120,7 +121,12 @@ func configureHealthInterface(netNS ns.NetNS, ifName string, ip4Addr, ip6Addr *n
return err
}

if ip6Addr != nil {
if ip6Addr == nil {
name := fmt.Sprintf("net.ipv6.conf.%s.disable_ipv6", ifName)
// Ignore the error; if IPv6 is completely disabled
// then it's okay if we can't write the sysctl.
_ = sysctl.Write(name, "1")
} else {
if err = netlink.AddrAdd(link, &netlink.Addr{IPNet: ip6Addr}); err != nil {
return err
}
Expand Down

0 comments on commit 7797aa5

Please sign in to comment.