diff --git a/pkg/danmep/danmep.go b/pkg/danmep/danmep.go index 0320a7eb..2b0e87e5 100644 --- a/pkg/danmep/danmep.go +++ b/pkg/danmep/danmep.go @@ -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"}, @@ -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)