This patch implements Enhanced DAD algorithm described in
draft-ietf-6man-enhanced-dad-13.
Problem description:
hiren@ reported that an aggregation of multiple interfaces could
cause a looped back NS message which prevented DAD from working. The
following command lines simulate the situation:
- ifconfig epair0 create
- ifconfig epair0a up
- ifconfig epair0b up
- ifconfig lagg0 create laggproto loadbalance laggport epair0a laggport epair0b up
- ifconfig lagg0 inet6 2001:db8::1/64
DAD always fails. This looks unrealistic but can happen in a practical configuration, too.
Disabling DAD by setting net.inet6.ip6.dad_count to 0 is a workaround. However, it is a vnet-wide knob and disables DAD on all of the interfaces unintentionally.
Setting V_dad_ignore_ns variable (not a sysctl, though) makes it unconditionally ignore NS messages during a DAD period. While this may be another workaround for the looped back NS message issue, it has another fundamental problem with DAD functionality that DAD never fails when two nodes attempt a DAD at almost the same time because no NA message is sent in that case. This patch removes this variable because it had not been enabled for a long time and not useful.
Enhanced DAD algorithm:
draft-ietf-6man-enhanced-dad-13 uses a Nonce option (RFC 3971), which
was originally introduced for SeND, to detect a looped backed NS
message. It simply adds a nonce for an outgoing DAD probe NS message
and check if a received NS message has the same nonce. If it matches
each other, the probe message is recognized as a looped back one and
discarded. In the old behavior, this looped back probe is recognized
as a probe from another node and results in a DAD failure.
Implementation:
ns6_ns_output() has an integer argument for whether it is called for
DAD or not. The patch changes it to accept a pointer to a buffer
which contains a random nonce. If a nonce is supplied, DAD will be
performed and ND_OPT_NONCE (type=14) is always added to a probe NS
message.
A nonce is calculated by arc4random(). RFC 3971 says length of a
nonce must be longer than 6 bytes. An NS message will be in 8 bytes
long when a nonce with the shortest length is used (NS message must be in
units of 8 bytes). The patch uses 14 bytes for a nonce (i.e. total
length of a probe message is 16 bytes). There is a room for
discussion. 6 bytes may be enough because collision probability is
still low and it does not change length of a probe message from the
current implementation.