Skip to content

Commit c76fe2d

Browse files
dsaherndavem330
authored andcommitted
net: ipv6: send unsolicited NA after DAD
Unsolicited IPv6 neighbor advertisements should be sent after DAD completes. Update ndisc_send_unsol_na to skip tentative, non-optimistic addresses and have those sent by addrconf_dad_completed after DAD. Fixes: 4a6e3c5 ("net: ipv6: send unsolicited NA on admin up") Reported-by: Vivek Venkatraman <[email protected]> Signed-off-by: David Ahern <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 202a0a7 commit c76fe2d

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

net/ipv6/addrconf.c

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ static struct rt6_info *addrconf_get_prefix_route(const struct in6_addr *pfx,
186186

187187
static void addrconf_dad_start(struct inet6_ifaddr *ifp);
188188
static void addrconf_dad_work(struct work_struct *w);
189-
static void addrconf_dad_completed(struct inet6_ifaddr *ifp, bool bump_id);
189+
static void addrconf_dad_completed(struct inet6_ifaddr *ifp, bool bump_id,
190+
bool send_na);
190191
static void addrconf_dad_run(struct inet6_dev *idev);
191192
static void addrconf_rs_timer(struct timer_list *t);
192193
static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifa);
@@ -3838,12 +3839,17 @@ static void addrconf_dad_begin(struct inet6_ifaddr *ifp)
38383839
idev->cnf.accept_dad < 1) ||
38393840
!(ifp->flags&IFA_F_TENTATIVE) ||
38403841
ifp->flags & IFA_F_NODAD) {
3842+
bool send_na = false;
3843+
3844+
if (ifp->flags & IFA_F_TENTATIVE &&
3845+
!(ifp->flags & IFA_F_OPTIMISTIC))
3846+
send_na = true;
38413847
bump_id = ifp->flags & IFA_F_TENTATIVE;
38423848
ifp->flags &= ~(IFA_F_TENTATIVE|IFA_F_OPTIMISTIC|IFA_F_DADFAILED);
38433849
spin_unlock(&ifp->lock);
38443850
read_unlock_bh(&idev->lock);
38453851

3846-
addrconf_dad_completed(ifp, bump_id);
3852+
addrconf_dad_completed(ifp, bump_id, send_na);
38473853
return;
38483854
}
38493855

@@ -3972,16 +3978,21 @@ static void addrconf_dad_work(struct work_struct *w)
39723978
}
39733979

39743980
if (ifp->dad_probes == 0) {
3981+
bool send_na = false;
3982+
39753983
/*
39763984
* DAD was successful
39773985
*/
39783986

3987+
if (ifp->flags & IFA_F_TENTATIVE &&
3988+
!(ifp->flags & IFA_F_OPTIMISTIC))
3989+
send_na = true;
39793990
bump_id = ifp->flags & IFA_F_TENTATIVE;
39803991
ifp->flags &= ~(IFA_F_TENTATIVE|IFA_F_OPTIMISTIC|IFA_F_DADFAILED);
39813992
spin_unlock(&ifp->lock);
39823993
write_unlock_bh(&idev->lock);
39833994

3984-
addrconf_dad_completed(ifp, bump_id);
3995+
addrconf_dad_completed(ifp, bump_id, send_na);
39853996

39863997
goto out;
39873998
}
@@ -4019,7 +4030,8 @@ static bool ipv6_lonely_lladdr(struct inet6_ifaddr *ifp)
40194030
return true;
40204031
}
40214032

4022-
static void addrconf_dad_completed(struct inet6_ifaddr *ifp, bool bump_id)
4033+
static void addrconf_dad_completed(struct inet6_ifaddr *ifp, bool bump_id,
4034+
bool send_na)
40234035
{
40244036
struct net_device *dev = ifp->idev->dev;
40254037
struct in6_addr lladdr;
@@ -4051,6 +4063,16 @@ static void addrconf_dad_completed(struct inet6_ifaddr *ifp, bool bump_id)
40514063
if (send_mld)
40524064
ipv6_mc_dad_complete(ifp->idev);
40534065

4066+
/* send unsolicited NA if enabled */
4067+
if (send_na &&
4068+
(ifp->idev->cnf.ndisc_notify ||
4069+
dev_net(dev)->ipv6.devconf_all->ndisc_notify)) {
4070+
ndisc_send_na(dev, &in6addr_linklocal_allnodes, &ifp->addr,
4071+
/*router=*/ !!ifp->idev->cnf.forwarding,
4072+
/*solicited=*/ false, /*override=*/ true,
4073+
/*inc_opt=*/ true);
4074+
}
4075+
40544076
if (send_rs) {
40554077
/*
40564078
* If a host as already performed a random delay

net/ipv6/ndisc.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,11 @@ static void ndisc_send_unsol_na(struct net_device *dev)
566566

567567
read_lock_bh(&idev->lock);
568568
list_for_each_entry(ifa, &idev->addr_list, if_list) {
569+
/* skip tentative addresses until dad completes */
570+
if (ifa->flags & IFA_F_TENTATIVE &&
571+
!(ifa->flags & IFA_F_OPTIMISTIC))
572+
continue;
573+
569574
ndisc_send_na(dev, &in6addr_linklocal_allnodes, &ifa->addr,
570575
/*router=*/ !!idev->cnf.forwarding,
571576
/*solicited=*/ false, /*override=*/ true,

0 commit comments

Comments
 (0)