Skip to content

Commit 896585d

Browse files
liuhangbindavem330
authored andcommitted
net/ipv6: re-do dad when interface has IFF_NOARP flag change
When we add a new IPv6 address, we should also join corresponding solicited-node multicast address, unless the interface has IFF_NOARP flag, as function addrconf_join_solict() did. But if we remove IFF_NOARP flag later, we do not do dad and add the mcast address. So we will drop corresponding neighbour discovery message that came from other nodes. A typical example is after creating a ipvlan with mode l3, setting up an ipv6 address and changing the mode to l2. Then we will not be able to ping this address as the interface doesn't join related solicited-node mcast address. Fix it by re-doing dad when interface changed IFF_NOARP flag. Then we will add corresponding mcast group and check if there is a duplicate address on the network. Reported-by: Jianlin Shi <jishi@redhat.com> Reviewed-by: Stefano Brivio <sbrivio@redhat.com> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 5cd8d46 commit 896585d

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

‎net/ipv6/addrconf.c‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ static void addrconf_dad_start(struct inet6_ifaddr *ifp);
179179
static void addrconf_dad_work(struct work_struct *w);
180180
static void addrconf_dad_completed(struct inet6_ifaddr *ifp, bool bump_id,
181181
bool send_na);
182-
static void addrconf_dad_run(struct inet6_dev *idev);
182+
static void addrconf_dad_run(struct inet6_dev *idev, bool restart);
183183
static void addrconf_rs_timer(struct timer_list *t);
184184
static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifa);
185185
static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifa);
@@ -3439,6 +3439,7 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
34393439
void *ptr)
34403440
{
34413441
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
3442+
struct netdev_notifier_change_info *change_info;
34423443
struct netdev_notifier_changeupper_info *info;
34433444
struct inet6_dev *idev = __in6_dev_get(dev);
34443445
struct net *net = dev_net(dev);
@@ -3513,14 +3514,17 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
35133514
break;
35143515
}
35153516

3516-
if (idev) {
3517+
if (!IS_ERR_OR_NULL(idev)) {
35173518
if (idev->if_flags & IF_READY) {
35183519
/* device is already configured -
35193520
* but resend MLD reports, we might
35203521
* have roamed and need to update
35213522
* multicast snooping switches
35223523
*/
35233524
ipv6_mc_up(idev);
3525+
change_info = ptr;
3526+
if (change_info->flags_changed & IFF_NOARP)
3527+
addrconf_dad_run(idev, true);
35243528
rt6_sync_up(dev, RTNH_F_LINKDOWN);
35253529
break;
35263530
}
@@ -3555,7 +3559,7 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
35553559

35563560
if (!IS_ERR_OR_NULL(idev)) {
35573561
if (run_pending)
3558-
addrconf_dad_run(idev);
3562+
addrconf_dad_run(idev, false);
35593563

35603564
/* Device has an address by now */
35613565
rt6_sync_up(dev, RTNH_F_DEAD);
@@ -4173,16 +4177,19 @@ static void addrconf_dad_completed(struct inet6_ifaddr *ifp, bool bump_id,
41734177
addrconf_verify_rtnl();
41744178
}
41754179

4176-
static void addrconf_dad_run(struct inet6_dev *idev)
4180+
static void addrconf_dad_run(struct inet6_dev *idev, bool restart)
41774181
{
41784182
struct inet6_ifaddr *ifp;
41794183

41804184
read_lock_bh(&idev->lock);
41814185
list_for_each_entry(ifp, &idev->addr_list, if_list) {
41824186
spin_lock(&ifp->lock);
4183-
if (ifp->flags & IFA_F_TENTATIVE &&
4184-
ifp->state == INET6_IFADDR_STATE_DAD)
4187+
if ((ifp->flags & IFA_F_TENTATIVE &&
4188+
ifp->state == INET6_IFADDR_STATE_DAD) || restart) {
4189+
if (restart)
4190+
ifp->state = INET6_IFADDR_STATE_PREDAD;
41854191
addrconf_dad_kick(ifp);
4192+
}
41864193
spin_unlock(&ifp->lock);
41874194
}
41884195
read_unlock_bh(&idev->lock);

0 commit comments

Comments
 (0)