Skip to content

Commit

Permalink
More sysctls to set for IPv6
Browse files Browse the repository at this point in the history
  • Loading branch information
TothFerenc committed Apr 16, 2019
1 parent 57911a5 commit 99c4dd1
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pkg/danmep/danmep.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ type sysctlData struct {
var sysctls = map[string][]sysctlData {
"enable_ipv6_on_iface": {
{"net.ipv6.conf.%s.disable_ipv6", "0"},
{"net.ipv6.conf.%s.autoconf", "0"},
{"net.ipv6.conf.%s.accept_ra", "0"},
},
"disable_ipv6_on_iface": {
{"net.ipv6.conf.%s.disable_ipv6", "1"},
Expand Down Expand Up @@ -139,8 +141,16 @@ func SetDanmEpSysctls(ep danmtypes.DanmEp) error {
podNs.Close()
origNs.Set()
}()
// set sysctls for IPv6 (since IPv6 is enabled on all interfaces, let's disable on those where it is not needed)
if ep.Spec.Iface.AddressIPv6 == "" {
// set sysctls on those interfaces where IPv6 is needed
if ep.Spec.Iface.AddressIPv6 != "" {
for _, s := range sysctls["enable_ipv6_on_iface"] {
sstr := fmt.Sprintf(s.sysctlName, ep.Spec.Iface.Name)
_, err = sysctl.Sysctl(sstr, s.sysctlValue)
if err != nil {
return errors.New("failed to set sysctl due to:" + err.Error())
}
}
} else { // let's disable IPv6 on those interfaces where it is not needed
for _, s := range sysctls["disable_ipv6_on_iface"] {
sstr := fmt.Sprintf(s.sysctlName, ep.Spec.Iface.Name)
_, err = sysctl.Sysctl(sstr, s.sysctlValue)
Expand Down

0 comments on commit 99c4dd1

Please sign in to comment.