All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] ipvlan: fix addr hash list corruption
@ 2015-03-23 21:10 Jiri Benc
  2015-03-24  1:10 ` Mahesh Bandewar
  2015-03-24 17:00 ` David Miller
  0 siblings, 2 replies; 16+ messages in thread
From: Jiri Benc @ 2015-03-23 21:10 UTC (permalink / raw)
  To: netdev; +Cc: Mahesh Bandewar, Dan Williams

When ipvlan interface with IP addresses attached is brought down and then
deleted, the assigned addresses are deleted twice from the address hash
list, first on the interface down and second on the link deletion.
Similarly, when an address is added while the interface is down, it is added
second time once the interface is brought up.

Check the interface status before adding/removing to the hash list in the
notifiers.

Reported-by: Dan Williams <dcbw@redhat.com>
Signed-off-by: Jiri Benc <jbenc@redhat.com>
---
 drivers/net/ipvlan/ipvlan_main.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c
index 4f4099d5603d..04cfa7a13645 100644
--- a/drivers/net/ipvlan/ipvlan_main.c
+++ b/drivers/net/ipvlan/ipvlan_main.c
@@ -504,7 +504,8 @@ static void ipvlan_link_delete(struct net_device *dev, struct list_head *head)
 
 	if (ipvlan->ipv6cnt > 0 || ipvlan->ipv4cnt > 0) {
 		list_for_each_entry_safe(addr, next, &ipvlan->addrs, anode) {
-			ipvlan_ht_addr_del(addr, !dev->dismantle);
+			if (netif_running(dev))
+				ipvlan_ht_addr_del(addr, !dev->dismantle);
 			list_del_rcu(&addr->anode);
 		}
 	}
@@ -622,7 +623,8 @@ static int ipvlan_add_addr6(struct ipvl_dev *ipvlan, struct in6_addr *ip6_addr)
 	addr->atype = IPVL_IPV6;
 	list_add_tail_rcu(&addr->anode, &ipvlan->addrs);
 	ipvlan->ipv6cnt++;
-	ipvlan_ht_addr_add(ipvlan, addr);
+	if (netif_running(ipvlan->dev))
+		ipvlan_ht_addr_add(ipvlan, addr);
 
 	return 0;
 }
@@ -635,7 +637,8 @@ static void ipvlan_del_addr6(struct ipvl_dev *ipvlan, struct in6_addr *ip6_addr)
 	if (!addr)
 		return;
 
-	ipvlan_ht_addr_del(addr, true);
+	if (netif_running(ipvlan->dev))
+		ipvlan_ht_addr_del(addr, true);
 	list_del_rcu(&addr->anode);
 	ipvlan->ipv6cnt--;
 	WARN_ON(ipvlan->ipv6cnt < 0);
@@ -690,7 +693,8 @@ static int ipvlan_add_addr4(struct ipvl_dev *ipvlan, struct in_addr *ip4_addr)
 	addr->atype = IPVL_IPV4;
 	list_add_tail_rcu(&addr->anode, &ipvlan->addrs);
 	ipvlan->ipv4cnt++;
-	ipvlan_ht_addr_add(ipvlan, addr);
+	if (netif_running(ipvlan->dev))
+		ipvlan_ht_addr_add(ipvlan, addr);
 	ipvlan_set_broadcast_mac_filter(ipvlan, true);
 
 	return 0;
@@ -704,7 +708,8 @@ static void ipvlan_del_addr4(struct ipvl_dev *ipvlan, struct in_addr *ip4_addr)
 	if (!addr)
 		return;
 
-	ipvlan_ht_addr_del(addr, true);
+	if (netif_running(ipvlan->dev))
+		ipvlan_ht_addr_del(addr, true);
 	list_del_rcu(&addr->anode);
 	ipvlan->ipv4cnt--;
 	WARN_ON(ipvlan->ipv4cnt < 0);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2015-03-27  5:01 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-23 21:10 [PATCH net] ipvlan: fix addr hash list corruption Jiri Benc
2015-03-24  1:10 ` Mahesh Bandewar
2015-03-24  8:58   ` Jiri Benc
2015-03-24 17:00 ` David Miller
2015-03-24 17:06   ` Jiri Benc
2015-03-24 23:16     ` Mahesh Bandewar
2015-03-25  1:18       ` David Miller
2015-03-25  8:58       ` Jiri Benc
2015-03-25 15:46         ` David Miller
2015-03-25 18:11           ` Mahesh Bandewar
2015-03-25 18:47             ` Dan Williams
2015-03-25 23:21             ` Jiri Benc
2015-03-25 23:49               ` Jiri Benc
2015-03-26  2:15               ` Mahesh Bandewar
2015-03-26  8:45                 ` Jiri Benc
2015-03-27  5:00                   ` Mahesh Bandewar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.