33 #include <linux/netdevice.h>
35 #include <linux/if_vlan.h>
37 #include <linux/slab.h>
38 #include <linux/export.h>
47 #define VLAN_NONE 0xfff
68 static inline unsigned int arp_hash(
u32 key,
int ifindex,
71 return jhash_2words(key, ifindex, 0) & (d->
nentries - 1);
78 neigh_release(e->
neigh);
110 skb_queue_walk_safe(&e->
arpq, skb, tmp) {
111 __skb_unlink(skb, &e->
arpq);
125 __skb_queue_tail(&e->
arpq, skb);
135 spin_lock_bh(&e->
lock);
138 spin_unlock_bh(&e->
lock);
142 spin_lock_bh(&e->
lock);
145 spin_unlock_bh(&e->
lock);
148 arpq_enqueue(e, skb);
149 spin_unlock_bh(&e->
lock);
165 spin_lock_bh(&e->
lock);
166 if (!skb_queue_empty(&e->
arpq))
167 setup_l2e_send_pending(dev, skb, e);
170 spin_unlock_bh(&e->
lock);
184 spin_lock_bh(&e->
lock);
188 spin_unlock_bh(&e->
lock);
193 spin_lock_bh(&e->
lock);
196 spin_unlock_bh(&e->
lock);
199 spin_unlock_bh(&e->
lock);
242 for (p = &d->
l2tab[hash].first; *p; p = &(*p)->
next)
265 spin_lock_bh(&e->
lock);
268 neigh_release(e->
neigh);
272 spin_unlock_bh(&e->
lock);
284 unsigned int nud_state;
288 if (neigh != e->
neigh)
289 neigh_replace(e, neigh);
298 spin_unlock(&e->
lock);
314 neigh = dst_neigh_lookup(dst, daddr);
319 ifidx = neigh->
dev->ifindex;
323 p = netdev_priv(dev);
330 hash = arp_hash(addr, ifidx, d);
333 for (e = d->
l2tab[hash].first; e; e = e->
next)
338 reuse_entry(e, neigh);
353 neigh_replace(e, neigh);
358 spin_unlock(&e->
lock);
364 neigh_release(neigh);
383 skb_queue_walk_safe(arpq, skb, tmp) {
386 __skb_unlink(skb, arpq);
404 int ifidx = neigh->
dev->ifindex;
405 int hash = arp_hash(addr, ifidx, d);
408 for (e = d->
l2tab[hash].first; e; e = e->
next)
417 __skb_queue_head_init(&arpq);
421 if (neigh != e->
neigh)
422 neigh_replace(e, neigh);
426 skb_queue_splice_init(&e->
arpq, &arpq);
428 setup_l2e_send_pending(dev,
NULL, e);
433 setup_l2e_send_pending(dev,
NULL, e);
436 spin_unlock_bh(&e->
lock);
438 if (!skb_queue_empty(&arpq))
439 handle_failed_resolution(dev, &arpq);
445 int i,
size =
sizeof(*d) + l2t_capacity *
sizeof(
struct l2t_entry);
451 d->nentries = l2t_capacity;
452 d->rover = &d->l2tab[1];
456 for (i = 0; i < l2t_capacity; ++
i) {
459 __skb_queue_head_init(&d->l2tab[i].arpq);