Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core, ipv6: enable optimistic_dad instead of completely disabling Duplicate Address Detection #261

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 34 additions & 9 deletions src/network/core_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -799,11 +799,20 @@ impl CoreUtils {
}

if ipv6_enabled {
// Disable duplicate address detection if ipv6 enabled
// Enable optimistic_dad on interface if ipv6 is enabled
// Do not accept Router Advertisements if ipv6 is enabled
let br_accept_dad = format!("/proc/sys/net/ipv6/conf/{}/accept_dad", ifname);
let br_optimistic_dad =
format!("/proc/sys/net/ipv6/conf/{}/optimistic_dad", ifname);
let br_use_optimistic =
format!("/proc/sys/net/ipv6/conf/{}/use_optimistic", ifname);
let br_accept_ra = format!("net/ipv6/conf/{}/accept_ra", ifname);
Copy link
Collaborator Author

@flouthoc flouthoc Mar 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question not sure about this but do we need to enable Router Advertisements ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know. I think this was copied from cni.

if let Err(e) = CoreUtils::apply_sysctl_value(&br_accept_dad, "0") {
if let Err(e) = CoreUtils::apply_sysctl_value(&br_optimistic_dad, "1") {
return Err(std::io::Error::new(
std::io::ErrorKind::Other,
format!("{}", e),
));
}
if let Err(e) = CoreUtils::apply_sysctl_value(&br_use_optimistic, "1") {
return Err(std::io::Error::new(
std::io::ErrorKind::Other,
format!("{}", e),
Expand Down Expand Up @@ -934,10 +943,18 @@ impl CoreUtils {
}

if ipv6_enabled {
// Disable dad inside the container too
let disable_dad_in_container =
format!("/proc/sys/net/ipv6/conf/{}/accept_dad", container_veth);
if let Err(e) = CoreUtils::apply_sysctl_value(&disable_dad_in_container, "0") {
// Enable optimistic_dad on interface if ipv6 is enabled
let optimistic_dad_in_container =
format!("/proc/sys/net/ipv6/conf/{}/optimistic_dad", container_veth);
if let Err(e) = CoreUtils::apply_sysctl_value(&optimistic_dad_in_container, "1") {
return Err(std::io::Error::new(
std::io::ErrorKind::Other,
format!("{}", e),
));
}
let use_optimistic_in_container =
format!("/proc/sys/net/ipv6/conf/{}/use_optimistic", container_veth);
if let Err(e) = CoreUtils::apply_sysctl_value(&use_optimistic_in_container, "1") {
return Err(std::io::Error::new(
std::io::ErrorKind::Other,
format!("{}", e),
Expand Down Expand Up @@ -1095,8 +1112,8 @@ impl CoreUtils {
}
if ipv6_enabled {
// Disable duplicate address detection on host veth if ipv6 enabled
let k = format!("/proc/sys/net/ipv6/conf/{}/accept_dad", &host_veth);
match CoreUtils::apply_sysctl_value(&k, "0") {
let k = format!("/proc/sys/net/ipv6/conf/{}/optimistic_dad", &host_veth);
match CoreUtils::apply_sysctl_value(&k, "1") {
Ok(_) => {}
Err(err) => {
return Err(std::io::Error::new(
Expand All @@ -1105,6 +1122,14 @@ impl CoreUtils {
))
}
}
let use_optimistic_in_container =
format!("/proc/sys/net/ipv6/conf/{}/use_optimistic", &host_veth);
if let Err(e) = CoreUtils::apply_sysctl_value(&use_optimistic_in_container, "1") {
return Err(std::io::Error::new(
std::io::ErrorKind::Other,
format!("{}", e),
));
}
}
// ip link set <veth_name> master <bridge>
let mut links = handle
Expand Down