diff options
author | Darren 'Tadgy' Austin <darren@afterdark.org.uk> | 2018-08-21 16:44:36 +0100 |
---|---|---|
committer | Robby Workman <rworkman@slackware.com> | 2018-11-25 20:03:04 -0600 |
commit | 15b6fc1b646b28a9f7895c88c1ad37dac9f7ed1a (patch) | |
tree | 9c039366a81495817abf2e4c6be47403bd87d379 | |
parent | e5923958f49481b634c1720b1121759d033a18ce (diff) | |
download | slacknetsetup-15b6fc1b646b28a9f7895c88c1ad37dac9f7ed1a.tar.xz |
Mitigate a race condition with Duplicate Address Detection
https://www.agwa.name/blog/post/beware_the_ipv6_dad_race_condition
This removes the need to sleep for 3 seconds after setting up the
interfaces, but does mean we lose detection of address clashes on
the inteface - it's a trade off
Signed-off-by: Robby Workman <rworkman@slackware.com>
-rw-r--r-- | rc.inet1 | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -224,6 +224,11 @@ if_up() { fi fi if [ "${USE_DHCP[$i]}" != "yes" ] && [ -n "${IPADDR[$i]}" ]; then # add a fixed v4 IP to the interface + # IPv6's Duplicate Address Detection (DAD) causes a race condition when bringing up interfaces, as + # described here: https://www.agwa.name/blog/post/beware_the_ipv6_dad_race_condition + # Disable DAD while bringing up the interface - but note that this means the loss of detection of a + # duplicate address. It's a trade off, unfortunately. + echo "0" >/proc/sys/net/ipv6/conf/$1/accept_dad if [ -z "${NETMASK[$i]}" ]; then echo "/etc/rc.d/rc.inet1: no NETMASK set for ${1} - assuming 24 (aka, 255.255.255.0)" | $LOGGER NETMASK[$i]="24" @@ -272,6 +277,11 @@ if_up() { done fi if [ -n "${IPALIASES6[$i]}" ]; then + # IPv6's Duplicate Address Detection (DAD) causes a race condition when bringing up interfaces, as + # described here: https://www.agwa.name/blog/post/beware_the_ipv6_dad_race_condition + # Disable DAD while bringing up the interface - but note that this means the loss of detection of a + # duplicate address. It's a trade off, unfortunately. + echo "0" >/proc/sys/net/ipv6/conf/$1/accept_dad for ipalias in ${IPALIASES6[$i]}; do ip="${ipalias%/*}" nm="${ipalias#*/}" @@ -292,10 +302,8 @@ if_up() { echo "/etc/rc.d/rc.inet1: /sbin/ip link set dev ${1} promisc on" | $LOGGER /sbin/ip link set dev ${1} promisc on fi - # Some settings need a small time to come into effect on the interface. - # This mostly affects IPv6, which needs time to make the interfaces available for the - # daemons to bind() - without this delay, they fail to bind() v6 addresses. - sleep 3 + # Reset accept_dad back to default now all the IPs are configured: + cat /proc/sys/net/ipv6/conf/default/accept_dad >/proc/sys/net/ipv6/conf/$1/accept_dad fi else debug_log "${1} is already up, skipping" |