aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ipvlan/ipvlan_core.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ipvlan/ipvlan_core.c')
-rw-r--r--drivers/net/ipvlan/ipvlan_core.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/drivers/net/ipvlan/ipvlan_core.c b/drivers/net/ipvlan/ipvlan_core.c
index 2a175006028b..b7877a194cfe 100644
--- a/drivers/net/ipvlan/ipvlan_core.c
+++ b/drivers/net/ipvlan/ipvlan_core.c
@@ -81,19 +81,20 @@ 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
87void ipvlan_ht_addr_del(struct ipvl_addr *addr, bool sync) 88void 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}
93 94
94bool ipvlan_addr_busy(struct ipvl_dev *ipvlan, void *iaddr, bool is_v6) 95struct ipvl_addr *ipvlan_find_addr(const struct ipvl_dev *ipvlan,
96 const void *iaddr, bool is_v6)
95{ 97{
96 struct ipvl_port *port = ipvlan->port;
97 struct ipvl_addr *addr; 98 struct ipvl_addr *addr;
98 99
99 list_for_each_entry(addr, &ipvlan->addrs, anode) { 100 list_for_each_entry(addr, &ipvlan->addrs, anode) {
@@ -101,12 +102,21 @@ bool ipvlan_addr_busy(struct ipvl_dev *ipvlan, void *iaddr, bool is_v6)
101 ipv6_addr_equal(&addr->ip6addr, iaddr)) || 102 ipv6_addr_equal(&addr->ip6addr, iaddr)) ||
102 (!is_v6 && addr->atype == IPVL_IPV4 && 103 (!is_v6 && addr->atype == IPVL_IPV4 &&
103 addr->ip4addr.s_addr == ((struct in_addr *)iaddr)->s_addr)) 104 addr->ip4addr.s_addr == ((struct in_addr *)iaddr)->s_addr))
104 return true; 105 return addr;
105 } 106 }
107 return NULL;
108}
109
110bool ipvlan_addr_busy(struct ipvl_port *port, void *iaddr, bool is_v6)
111{
112 struct ipvl_dev *ipvlan;
106 113
107 if (ipvlan_ht_addr_lookup(port, iaddr, is_v6)) 114 ASSERT_RTNL();
108 return true;
109 115
116 list_for_each_entry(ipvlan, &port->ipvlans, pnode) {
117 if (ipvlan_find_addr(ipvlan, iaddr, is_v6))
118 return true;
119 }
110 return false; 120 return false;
111} 121}
112 122
@@ -192,7 +202,8 @@ static void ipvlan_multicast_frame(struct ipvl_port *port, struct sk_buff *skb,
192 if (skb->protocol == htons(ETH_P_PAUSE)) 202 if (skb->protocol == htons(ETH_P_PAUSE))
193 return; 203 return;
194 204
195 list_for_each_entry(ipvlan, &port->ipvlans, pnode) { 205 rcu_read_lock();
206 list_for_each_entry_rcu(ipvlan, &port->ipvlans, pnode) {
196 if (local && (ipvlan == in_dev)) 207 if (local && (ipvlan == in_dev))
197 continue; 208 continue;
198 209
@@ -219,6 +230,7 @@ static void ipvlan_multicast_frame(struct ipvl_port *port, struct sk_buff *skb,
219mcast_acct: 230mcast_acct:
220 ipvlan_count_rx(ipvlan, len, ret == NET_RX_SUCCESS, true); 231 ipvlan_count_rx(ipvlan, len, ret == NET_RX_SUCCESS, true);
221 } 232 }
233 rcu_read_unlock();
222 234
223 /* Locally generated? ...Forward a copy to the main-device as 235 /* Locally generated? ...Forward a copy to the main-device as
224 * well. On the RX side we'll ignore it (wont give it to any 236 * well. On the RX side we'll ignore it (wont give it to any