mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-01 16:14:13 +08:00
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>
This commit is contained in:
parent
5cd8d46ea1
commit
896585d48e
@ -179,7 +179,7 @@ static void addrconf_dad_start(struct inet6_ifaddr *ifp);
|
||||
static void addrconf_dad_work(struct work_struct *w);
|
||||
static void addrconf_dad_completed(struct inet6_ifaddr *ifp, bool bump_id,
|
||||
bool send_na);
|
||||
static void addrconf_dad_run(struct inet6_dev *idev);
|
||||
static void addrconf_dad_run(struct inet6_dev *idev, bool restart);
|
||||
static void addrconf_rs_timer(struct timer_list *t);
|
||||
static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifa);
|
||||
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,
|
||||
void *ptr)
|
||||
{
|
||||
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
|
||||
struct netdev_notifier_change_info *change_info;
|
||||
struct netdev_notifier_changeupper_info *info;
|
||||
struct inet6_dev *idev = __in6_dev_get(dev);
|
||||
struct net *net = dev_net(dev);
|
||||
@ -3513,7 +3514,7 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
|
||||
break;
|
||||
}
|
||||
|
||||
if (idev) {
|
||||
if (!IS_ERR_OR_NULL(idev)) {
|
||||
if (idev->if_flags & IF_READY) {
|
||||
/* device is already configured -
|
||||
* but resend MLD reports, we might
|
||||
@ -3521,6 +3522,9 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
|
||||
* multicast snooping switches
|
||||
*/
|
||||
ipv6_mc_up(idev);
|
||||
change_info = ptr;
|
||||
if (change_info->flags_changed & IFF_NOARP)
|
||||
addrconf_dad_run(idev, true);
|
||||
rt6_sync_up(dev, RTNH_F_LINKDOWN);
|
||||
break;
|
||||
}
|
||||
@ -3555,7 +3559,7 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
|
||||
|
||||
if (!IS_ERR_OR_NULL(idev)) {
|
||||
if (run_pending)
|
||||
addrconf_dad_run(idev);
|
||||
addrconf_dad_run(idev, false);
|
||||
|
||||
/* Device has an address by now */
|
||||
rt6_sync_up(dev, RTNH_F_DEAD);
|
||||
@ -4173,16 +4177,19 @@ static void addrconf_dad_completed(struct inet6_ifaddr *ifp, bool bump_id,
|
||||
addrconf_verify_rtnl();
|
||||
}
|
||||
|
||||
static void addrconf_dad_run(struct inet6_dev *idev)
|
||||
static void addrconf_dad_run(struct inet6_dev *idev, bool restart)
|
||||
{
|
||||
struct inet6_ifaddr *ifp;
|
||||
|
||||
read_lock_bh(&idev->lock);
|
||||
list_for_each_entry(ifp, &idev->addr_list, if_list) {
|
||||
spin_lock(&ifp->lock);
|
||||
if (ifp->flags & IFA_F_TENTATIVE &&
|
||||
ifp->state == INET6_IFADDR_STATE_DAD)
|
||||
if ((ifp->flags & IFA_F_TENTATIVE &&
|
||||
ifp->state == INET6_IFADDR_STATE_DAD) || restart) {
|
||||
if (restart)
|
||||
ifp->state = INET6_IFADDR_STATE_PREDAD;
|
||||
addrconf_dad_kick(ifp);
|
||||
}
|
||||
spin_unlock(&ifp->lock);
|
||||
}
|
||||
read_unlock_bh(&idev->lock);
|
||||
|
Loading…
Reference in New Issue
Block a user