Skip to content

Commit 613d297

Browse files
committed
core, ipv6: enable optimistic_dad instead of completely disabling Duplicate Address Detection
We are disabling duplicate address detection for `ipv6` complelety which might not be needed so instead of setting `accept_dad` to `0` we can still do `optimistic_dad` to `1` for required interface. Some cons of using `optimistic_dad` * Might be still slower than disabling DAD. * Not good support for older kernels since it was added in later released of `3.x` Signed-off-by: Aditya R <[email protected]>
1 parent 17f896c commit 613d297

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/network/core_utils.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -799,11 +799,12 @@ impl CoreUtils {
799799
}
800800

801801
if ipv6_enabled {
802-
// Disable duplicate address detection if ipv6 enabled
802+
// Enable optimistic_dad on interface if ipv6 is enabled
803803
// Do not accept Router Advertisements if ipv6 is enabled
804-
let br_accept_dad = format!("/proc/sys/net/ipv6/conf/{}/accept_dad", ifname);
804+
let br_optimistic_dad =
805+
format!("/proc/sys/net/ipv6/conf/{}/optimistic_dad", ifname);
805806
let br_accept_ra = format!("net/ipv6/conf/{}/accept_ra", ifname);
806-
if let Err(e) = CoreUtils::apply_sysctl_value(&br_accept_dad, "0") {
807+
if let Err(e) = CoreUtils::apply_sysctl_value(&br_optimistic_dad, "1") {
807808
return Err(std::io::Error::new(
808809
std::io::ErrorKind::Other,
809810
format!("{}", e),
@@ -934,10 +935,10 @@ impl CoreUtils {
934935
}
935936

936937
if ipv6_enabled {
937-
// Disable dad inside the container too
938-
let disable_dad_in_container =
939-
format!("/proc/sys/net/ipv6/conf/{}/accept_dad", container_veth);
940-
if let Err(e) = CoreUtils::apply_sysctl_value(&disable_dad_in_container, "0") {
938+
// Enable optimistic_dad on interface if ipv6 is enabled
939+
let optimistic_dad_in_container =
940+
format!("/proc/sys/net/ipv6/conf/{}/optimistic_dad", container_veth);
941+
if let Err(e) = CoreUtils::apply_sysctl_value(&optimistic_dad_in_container, "1") {
941942
return Err(std::io::Error::new(
942943
std::io::ErrorKind::Other,
943944
format!("{}", e),
@@ -1095,8 +1096,8 @@ impl CoreUtils {
10951096
}
10961097
if ipv6_enabled {
10971098
// Disable duplicate address detection on host veth if ipv6 enabled
1098-
let k = format!("/proc/sys/net/ipv6/conf/{}/accept_dad", &host_veth);
1099-
match CoreUtils::apply_sysctl_value(&k, "0") {
1099+
let k = format!("/proc/sys/net/ipv6/conf/{}/optimistic_dad", &host_veth);
1100+
match CoreUtils::apply_sysctl_value(&k, "1") {
11001101
Ok(_) => {}
11011102
Err(err) => {
11021103
return Err(std::io::Error::new(

0 commit comments

Comments
 (0)