diff options
-rw-r--r-- | drivers/net/ipvlan/ipvlan_core.c | 5 | ||||
-rw-r--r-- | drivers/net/ipvlan/ipvlan_main.c | 12 |
2 files changed, 13 insertions, 4 deletions
diff --git a/drivers/net/ipvlan/ipvlan_core.c b/drivers/net/ipvlan/ipvlan_core.c index 2a175006028b..8a542b9340c4 100644 --- a/drivers/net/ipvlan/ipvlan_core.c +++ b/drivers/net/ipvlan/ipvlan_core.c | |||
@@ -81,12 +81,13 @@ void ipvlan_ht_addr_add(struct ipvl_dev *ipvlan, struct ipvl_addr *addr) | |||
81 | hash = (addr->atype == IPVL_IPV6) ? | 81 | hash = (addr->atype == IPVL_IPV6) ? |
82 | ipvlan_get_v6_hash(&addr->ip6addr) : | 82 | ipvlan_get_v6_hash(&addr->ip6addr) : |
83 | ipvlan_get_v4_hash(&addr->ip4addr); | 83 | ipvlan_get_v4_hash(&addr->ip4addr); |
84 | hlist_add_head_rcu(&addr->hlnode, &port->hlhead[hash]); | 84 | if (hlist_unhashed(&addr->hlnode)) |
85 | hlist_add_head_rcu(&addr->hlnode, &port->hlhead[hash]); | ||
85 | } | 86 | } |
86 | 87 | ||
87 | void ipvlan_ht_addr_del(struct ipvl_addr *addr, bool sync) | 88 | void ipvlan_ht_addr_del(struct ipvl_addr *addr, bool sync) |
88 | { | 89 | { |
89 | hlist_del_rcu(&addr->hlnode); | 90 | hlist_del_init_rcu(&addr->hlnode); |
90 | if (sync) | 91 | if (sync) |
91 | synchronize_rcu(); | 92 | synchronize_rcu(); |
92 | } | 93 | } |
diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c index 4f4099d5603d..1eb3f33e11cc 100644 --- a/drivers/net/ipvlan/ipvlan_main.c +++ b/drivers/net/ipvlan/ipvlan_main.c | |||
@@ -622,7 +622,11 @@ static int ipvlan_add_addr6(struct ipvl_dev *ipvlan, struct in6_addr *ip6_addr) | |||
622 | addr->atype = IPVL_IPV6; | 622 | addr->atype = IPVL_IPV6; |
623 | list_add_tail_rcu(&addr->anode, &ipvlan->addrs); | 623 | list_add_tail_rcu(&addr->anode, &ipvlan->addrs); |
624 | ipvlan->ipv6cnt++; | 624 | ipvlan->ipv6cnt++; |
625 | ipvlan_ht_addr_add(ipvlan, addr); | 625 | /* If the interface is not up, the address will be added to the hash |
626 | * list by ipvlan_open. | ||
627 | */ | ||
628 | if (netif_running(ipvlan->dev)) | ||
629 | ipvlan_ht_addr_add(ipvlan, addr); | ||
626 | 630 | ||
627 | return 0; | 631 | return 0; |
628 | } | 632 | } |
@@ -690,7 +694,11 @@ static int ipvlan_add_addr4(struct ipvl_dev *ipvlan, struct in_addr *ip4_addr) | |||
690 | addr->atype = IPVL_IPV4; | 694 | addr->atype = IPVL_IPV4; |
691 | list_add_tail_rcu(&addr->anode, &ipvlan->addrs); | 695 | list_add_tail_rcu(&addr->anode, &ipvlan->addrs); |
692 | ipvlan->ipv4cnt++; | 696 | ipvlan->ipv4cnt++; |
693 | ipvlan_ht_addr_add(ipvlan, addr); | 697 | /* If the interface is not up, the address will be added to the hash |
698 | * list by ipvlan_open. | ||
699 | */ | ||
700 | if (netif_running(ipvlan->dev)) | ||
701 | ipvlan_ht_addr_add(ipvlan, addr); | ||
694 | ipvlan_set_broadcast_mac_filter(ipvlan, true); | 702 | ipvlan_set_broadcast_mac_filter(ipvlan, true); |
695 | 703 | ||
696 | return 0; | 704 | return 0; |