Lines Matching refs:tbl

57 static int pneigh_ifdown_and_unlock(struct neigh_table *tbl,
123 atomic_dec(&n->tbl->gc_entries); in neigh_mark_dead()
133 write_lock_bh(&n->tbl->lock); in neigh_update_gc_list()
147 atomic_dec(&n->tbl->gc_entries); in neigh_update_gc_list()
150 list_add_tail(&n->gc_list, &n->tbl->gc_list); in neigh_update_gc_list()
151 atomic_inc(&n->tbl->gc_entries); in neigh_update_gc_list()
155 write_unlock_bh(&n->tbl->lock); in neigh_update_gc_list()
162 write_lock_bh(&n->tbl->lock); in neigh_update_managed_list()
173 list_add_tail(&n->managed_list, &n->tbl->managed_list); in neigh_update_managed_list()
176 write_unlock_bh(&n->tbl->lock); in neigh_update_managed_list()
209 struct neigh_table *tbl) in neigh_del() argument
218 lockdep_is_held(&tbl->lock)); in neigh_del()
229 bool neigh_remove_one(struct neighbour *ndel, struct neigh_table *tbl) in neigh_remove_one() argument
237 nht = rcu_dereference_protected(tbl->nht, in neigh_remove_one()
238 lockdep_is_held(&tbl->lock)); in neigh_remove_one()
239 hash_val = tbl->hash(pkey, ndel->dev, nht->hash_rnd); in neigh_remove_one()
244 lockdep_is_held(&tbl->lock)))) { in neigh_remove_one()
246 return neigh_del(n, np, tbl); in neigh_remove_one()
252 static int neigh_forced_gc(struct neigh_table *tbl) in neigh_forced_gc() argument
254 int max_clean = atomic_read(&tbl->gc_entries) - in neigh_forced_gc()
255 READ_ONCE(tbl->gc_thresh2); in neigh_forced_gc()
260 NEIGH_CACHE_STAT_INC(tbl, forced_gc_runs); in neigh_forced_gc()
262 write_lock_bh(&tbl->lock); in neigh_forced_gc()
264 list_for_each_entry_safe(n, tmp, &tbl->gc_list, gc_list) { in neigh_forced_gc()
271 (tbl->is_multicast && in neigh_forced_gc()
272 tbl->is_multicast(n->primary_key)) || in neigh_forced_gc()
277 if (remove && neigh_remove_one(n, tbl)) in neigh_forced_gc()
284 WRITE_ONCE(tbl->last_flush, jiffies); in neigh_forced_gc()
286 write_unlock_bh(&tbl->lock); in neigh_forced_gc()
373 static void neigh_flush_dev(struct neigh_table *tbl, struct net_device *dev, in neigh_flush_dev() argument
379 nht = rcu_dereference_protected(tbl->nht, in neigh_flush_dev()
380 lockdep_is_held(&tbl->lock)); in neigh_flush_dev()
387 lockdep_is_held(&tbl->lock))) != NULL) { in neigh_flush_dev()
398 lockdep_is_held(&tbl->lock))); in neigh_flush_dev()
427 void neigh_changeaddr(struct neigh_table *tbl, struct net_device *dev) in neigh_changeaddr() argument
429 write_lock_bh(&tbl->lock); in neigh_changeaddr()
430 neigh_flush_dev(tbl, dev, false); in neigh_changeaddr()
431 write_unlock_bh(&tbl->lock); in neigh_changeaddr()
435 static int __neigh_ifdown(struct neigh_table *tbl, struct net_device *dev, in __neigh_ifdown() argument
438 write_lock_bh(&tbl->lock); in __neigh_ifdown()
439 neigh_flush_dev(tbl, dev, skip_perm); in __neigh_ifdown()
440 pneigh_ifdown_and_unlock(tbl, dev); in __neigh_ifdown()
441 pneigh_queue_purge(&tbl->proxy_queue, dev ? dev_net(dev) : NULL, in __neigh_ifdown()
442 tbl->family); in __neigh_ifdown()
443 if (skb_queue_empty_lockless(&tbl->proxy_queue)) in __neigh_ifdown()
444 del_timer_sync(&tbl->proxy_timer); in __neigh_ifdown()
448 int neigh_carrier_down(struct neigh_table *tbl, struct net_device *dev) in neigh_carrier_down() argument
450 __neigh_ifdown(tbl, dev, true); in neigh_carrier_down()
455 int neigh_ifdown(struct neigh_table *tbl, struct net_device *dev) in neigh_ifdown() argument
457 __neigh_ifdown(tbl, dev, false); in neigh_ifdown()
462 static struct neighbour *neigh_alloc(struct neigh_table *tbl, in neigh_alloc() argument
473 entries = atomic_inc_return(&tbl->gc_entries) - 1; in neigh_alloc()
474 gc_thresh3 = READ_ONCE(tbl->gc_thresh3); in neigh_alloc()
476 (entries >= READ_ONCE(tbl->gc_thresh2) && in neigh_alloc()
477 time_after(now, READ_ONCE(tbl->last_flush) + 5 * HZ))) { in neigh_alloc()
478 if (!neigh_forced_gc(tbl) && entries >= gc_thresh3) { in neigh_alloc()
480 tbl->id); in neigh_alloc()
481 NEIGH_CACHE_STAT_INC(tbl, table_fulls); in neigh_alloc()
487 n = kzalloc(tbl->entry_size + dev->neigh_priv_len, GFP_ATOMIC); in neigh_alloc()
499 n->parms = neigh_parms_clone(&tbl->parms); in neigh_alloc()
502 NEIGH_CACHE_STAT_INC(tbl, allocs); in neigh_alloc()
503 n->tbl = tbl; in neigh_alloc()
509 atomic_inc(&tbl->entries); in neigh_alloc()
515 atomic_dec(&tbl->gc_entries); in neigh_alloc()
570 static struct neigh_hash_table *neigh_hash_grow(struct neigh_table *tbl, in neigh_hash_grow() argument
576 NEIGH_CACHE_STAT_INC(tbl, hash_grows); in neigh_hash_grow()
578 old_nht = rcu_dereference_protected(tbl->nht, in neigh_hash_grow()
579 lockdep_is_held(&tbl->lock)); in neigh_hash_grow()
588 lockdep_is_held(&tbl->lock)); in neigh_hash_grow()
591 hash = tbl->hash(n->primary_key, n->dev, in neigh_hash_grow()
596 lockdep_is_held(&tbl->lock)); in neigh_hash_grow()
601 lockdep_is_held(&tbl->lock))); in neigh_hash_grow()
606 rcu_assign_pointer(tbl->nht, new_nht); in neigh_hash_grow()
611 struct neighbour *neigh_lookup(struct neigh_table *tbl, const void *pkey, in neigh_lookup() argument
616 NEIGH_CACHE_STAT_INC(tbl, lookups); in neigh_lookup()
619 n = __neigh_lookup_noref(tbl, pkey, dev); in neigh_lookup()
623 NEIGH_CACHE_STAT_INC(tbl, hits); in neigh_lookup()
632 ___neigh_create(struct neigh_table *tbl, const void *pkey, in ___neigh_create() argument
636 u32 hash_val, key_len = tbl->key_len; in ___neigh_create()
641 n = neigh_alloc(tbl, dev, flags, exempt_from_gc); in ___neigh_create()
642 trace_neigh_create(tbl, dev, pkey, n, exempt_from_gc); in ___neigh_create()
653 if (tbl->constructor && (error = tbl->constructor(n)) < 0) { in ___neigh_create()
675 write_lock_bh(&tbl->lock); in ___neigh_create()
676 nht = rcu_dereference_protected(tbl->nht, in ___neigh_create()
677 lockdep_is_held(&tbl->lock)); in ___neigh_create()
679 if (atomic_read(&tbl->entries) > (1 << nht->hash_shift)) in ___neigh_create()
680 nht = neigh_hash_grow(tbl, nht->hash_shift + 1); in ___neigh_create()
682 hash_val = tbl->hash(n->primary_key, dev, nht->hash_rnd) >> (32 - nht->hash_shift); in ___neigh_create()
690 lockdep_is_held(&tbl->lock)); in ___neigh_create()
693 lockdep_is_held(&tbl->lock))) { in ___neigh_create()
704 list_add_tail(&n->gc_list, &n->tbl->gc_list); in ___neigh_create()
706 list_add_tail(&n->managed_list, &n->tbl->managed_list); in ___neigh_create()
711 lockdep_is_held(&tbl->lock))); in ___neigh_create()
713 write_unlock_bh(&tbl->lock); in ___neigh_create()
719 write_unlock_bh(&tbl->lock); in ___neigh_create()
722 atomic_dec(&tbl->gc_entries); in ___neigh_create()
727 struct neighbour *__neigh_create(struct neigh_table *tbl, const void *pkey, in __neigh_create() argument
730 return ___neigh_create(tbl, pkey, dev, 0, false, want_ref); in __neigh_create()
760 struct pneigh_entry *__pneigh_lookup(struct neigh_table *tbl, in __pneigh_lookup() argument
763 unsigned int key_len = tbl->key_len; in __pneigh_lookup()
766 return __pneigh_lookup_1(tbl->phash_buckets[hash_val], in __pneigh_lookup()
771 struct pneigh_entry * pneigh_lookup(struct neigh_table *tbl, in pneigh_lookup() argument
776 unsigned int key_len = tbl->key_len; in pneigh_lookup()
779 read_lock_bh(&tbl->lock); in pneigh_lookup()
780 n = __pneigh_lookup_1(tbl->phash_buckets[hash_val], in pneigh_lookup()
782 read_unlock_bh(&tbl->lock); in pneigh_lookup()
798 if (tbl->pconstructor && tbl->pconstructor(n)) { in pneigh_lookup()
805 write_lock_bh(&tbl->lock); in pneigh_lookup()
806 n->next = tbl->phash_buckets[hash_val]; in pneigh_lookup()
807 tbl->phash_buckets[hash_val] = n; in pneigh_lookup()
808 write_unlock_bh(&tbl->lock); in pneigh_lookup()
815 int pneigh_delete(struct neigh_table *tbl, struct net *net, const void *pkey, in pneigh_delete() argument
819 unsigned int key_len = tbl->key_len; in pneigh_delete()
822 write_lock_bh(&tbl->lock); in pneigh_delete()
823 for (np = &tbl->phash_buckets[hash_val]; (n = *np) != NULL; in pneigh_delete()
828 write_unlock_bh(&tbl->lock); in pneigh_delete()
829 if (tbl->pdestructor) in pneigh_delete()
830 tbl->pdestructor(n); in pneigh_delete()
836 write_unlock_bh(&tbl->lock); in pneigh_delete()
840 static int pneigh_ifdown_and_unlock(struct neigh_table *tbl, in pneigh_ifdown_and_unlock() argument
847 np = &tbl->phash_buckets[h]; in pneigh_ifdown_and_unlock()
858 write_unlock_bh(&tbl->lock); in pneigh_ifdown_and_unlock()
862 if (tbl->pdestructor) in pneigh_ifdown_and_unlock()
863 tbl->pdestructor(n); in pneigh_ifdown_and_unlock()
886 NEIGH_CACHE_STAT_INC(neigh->tbl, destroys); in neigh_destroy()
910 atomic_dec(&neigh->tbl->entries); in neigh_destroy()
941 struct neigh_table *tbl = container_of(work, struct neigh_table, gc_work.work); in neigh_periodic_work() local
947 NEIGH_CACHE_STAT_INC(tbl, periodic_gc_runs); in neigh_periodic_work()
949 write_lock_bh(&tbl->lock); in neigh_periodic_work()
950 nht = rcu_dereference_protected(tbl->nht, in neigh_periodic_work()
951 lockdep_is_held(&tbl->lock)); in neigh_periodic_work()
957 if (time_after(jiffies, tbl->last_rand + 300 * HZ)) { in neigh_periodic_work()
960 WRITE_ONCE(tbl->last_rand, jiffies); in neigh_periodic_work()
961 list_for_each_entry(p, &tbl->parms_list, list) in neigh_periodic_work()
966 if (atomic_read(&tbl->entries) < READ_ONCE(tbl->gc_thresh1)) in neigh_periodic_work()
973 lockdep_is_held(&tbl->lock))) != NULL) { in neigh_periodic_work()
995 lockdep_is_held(&tbl->lock))); in neigh_periodic_work()
1010 write_unlock_bh(&tbl->lock); in neigh_periodic_work()
1012 write_lock_bh(&tbl->lock); in neigh_periodic_work()
1013 nht = rcu_dereference_protected(tbl->nht, in neigh_periodic_work()
1014 lockdep_is_held(&tbl->lock)); in neigh_periodic_work()
1021 queue_delayed_work(system_power_efficient_wq, &tbl->gc_work, in neigh_periodic_work()
1022 NEIGH_VAR(&tbl->parms, BASE_REACHABLE_TIME) >> 1); in neigh_periodic_work()
1023 write_unlock_bh(&tbl->lock); in neigh_periodic_work()
1040 NEIGH_CACHE_STAT_INC(neigh->tbl, res_failed); in neigh_invalidate()
1225 NEIGH_CACHE_STAT_INC(neigh->tbl, unres_discards); in __neigh_event_send()
1503 struct neighbour *neigh_event_ns(struct neigh_table *tbl, in neigh_event_ns() argument
1507 struct neighbour *neigh = __neigh_lookup(tbl, saddr, dev, in neigh_event_ns()
1520 __be16 prot = n->tbl->protocol; in neigh_hh_init()
1602 struct neigh_table *tbl = container_of(work, struct neigh_table, in neigh_managed_work() local
1606 write_lock_bh(&tbl->lock); in neigh_managed_work()
1607 list_for_each_entry(neigh, &tbl->managed_list, managed_list) in neigh_managed_work()
1609 queue_delayed_work(system_power_efficient_wq, &tbl->managed_work, in neigh_managed_work()
1610 NEIGH_VAR(&tbl->parms, INTERVAL_PROBE_TIME_MS)); in neigh_managed_work()
1611 write_unlock_bh(&tbl->lock); in neigh_managed_work()
1616 struct neigh_table *tbl = from_timer(tbl, t, proxy_timer); in neigh_proxy_process() local
1621 spin_lock(&tbl->proxy_queue.lock); in neigh_proxy_process()
1623 skb_queue_walk_safe(&tbl->proxy_queue, skb, n) { in neigh_proxy_process()
1629 neigh_parms_qlen_dec(dev, tbl->family); in neigh_proxy_process()
1630 __skb_unlink(skb, &tbl->proxy_queue); in neigh_proxy_process()
1632 if (tbl->proxy_redo && netif_running(dev)) { in neigh_proxy_process()
1634 tbl->proxy_redo(skb); in neigh_proxy_process()
1644 del_timer(&tbl->proxy_timer); in neigh_proxy_process()
1646 mod_timer(&tbl->proxy_timer, jiffies + sched_next); in neigh_proxy_process()
1647 spin_unlock(&tbl->proxy_queue.lock); in neigh_proxy_process()
1661 void pneigh_enqueue(struct neigh_table *tbl, struct neigh_parms *p, in pneigh_enqueue() argument
1674 spin_lock(&tbl->proxy_queue.lock); in pneigh_enqueue()
1675 if (del_timer(&tbl->proxy_timer)) { in pneigh_enqueue()
1676 if (time_before(tbl->proxy_timer.expires, sched_next)) in pneigh_enqueue()
1677 sched_next = tbl->proxy_timer.expires; in pneigh_enqueue()
1681 __skb_queue_tail(&tbl->proxy_queue, skb); in pneigh_enqueue()
1683 mod_timer(&tbl->proxy_timer, sched_next); in pneigh_enqueue()
1684 spin_unlock(&tbl->proxy_queue.lock); in pneigh_enqueue()
1688 static inline struct neigh_parms *lookup_neigh_parms(struct neigh_table *tbl, in lookup_neigh_parms() argument
1693 list_for_each_entry(p, &tbl->parms_list, list) { in lookup_neigh_parms()
1703 struct neigh_table *tbl) in neigh_parms_alloc() argument
1709 p = kmemdup(&tbl->parms, sizeof(*p), GFP_KERNEL); in neigh_parms_alloc()
1711 p->tbl = tbl; in neigh_parms_alloc()
1727 write_lock_bh(&tbl->lock); in neigh_parms_alloc()
1728 list_add(&p->list, &tbl->parms.list); in neigh_parms_alloc()
1729 write_unlock_bh(&tbl->lock); in neigh_parms_alloc()
1745 void neigh_parms_release(struct neigh_table *tbl, struct neigh_parms *parms) in neigh_parms_release() argument
1747 if (!parms || parms == &tbl->parms) in neigh_parms_release()
1749 write_lock_bh(&tbl->lock); in neigh_parms_release()
1752 write_unlock_bh(&tbl->lock); in neigh_parms_release()
1767 void neigh_table_init(int index, struct neigh_table *tbl) in neigh_table_init() argument
1772 INIT_LIST_HEAD(&tbl->parms_list); in neigh_table_init()
1773 INIT_LIST_HEAD(&tbl->gc_list); in neigh_table_init()
1774 INIT_LIST_HEAD(&tbl->managed_list); in neigh_table_init()
1776 list_add(&tbl->parms.list, &tbl->parms_list); in neigh_table_init()
1777 write_pnet(&tbl->parms.net, &init_net); in neigh_table_init()
1778 refcount_set(&tbl->parms.refcnt, 1); in neigh_table_init()
1779 tbl->parms.reachable_time = in neigh_table_init()
1780 neigh_rand_reach_time(NEIGH_VAR(&tbl->parms, BASE_REACHABLE_TIME)); in neigh_table_init()
1781 tbl->parms.qlen = 0; in neigh_table_init()
1783 tbl->stats = alloc_percpu(struct neigh_statistics); in neigh_table_init()
1784 if (!tbl->stats) in neigh_table_init()
1788 if (!proc_create_seq_data(tbl->id, 0, init_net.proc_net_stat, in neigh_table_init()
1789 &neigh_stat_seq_ops, tbl)) in neigh_table_init()
1793 RCU_INIT_POINTER(tbl->nht, neigh_hash_alloc(3)); in neigh_table_init()
1796 tbl->phash_buckets = kzalloc(phsize, GFP_KERNEL); in neigh_table_init()
1798 if (!tbl->nht || !tbl->phash_buckets) in neigh_table_init()
1801 if (!tbl->entry_size) in neigh_table_init()
1802 tbl->entry_size = ALIGN(offsetof(struct neighbour, primary_key) + in neigh_table_init()
1803 tbl->key_len, NEIGH_PRIV_ALIGN); in neigh_table_init()
1805 WARN_ON(tbl->entry_size % NEIGH_PRIV_ALIGN); in neigh_table_init()
1807 rwlock_init(&tbl->lock); in neigh_table_init()
1809 INIT_DEFERRABLE_WORK(&tbl->gc_work, neigh_periodic_work); in neigh_table_init()
1810 queue_delayed_work(system_power_efficient_wq, &tbl->gc_work, in neigh_table_init()
1811 tbl->parms.reachable_time); in neigh_table_init()
1812 INIT_DEFERRABLE_WORK(&tbl->managed_work, neigh_managed_work); in neigh_table_init()
1813 queue_delayed_work(system_power_efficient_wq, &tbl->managed_work, 0); in neigh_table_init()
1815 timer_setup(&tbl->proxy_timer, neigh_proxy_process, 0); in neigh_table_init()
1816 skb_queue_head_init_class(&tbl->proxy_queue, in neigh_table_init()
1819 tbl->last_flush = now; in neigh_table_init()
1820 tbl->last_rand = now + tbl->parms.reachable_time * 20; in neigh_table_init()
1822 neigh_tables[index] = tbl; in neigh_table_init()
1826 int neigh_table_clear(int index, struct neigh_table *tbl) in neigh_table_clear() argument
1830 cancel_delayed_work_sync(&tbl->managed_work); in neigh_table_clear()
1831 cancel_delayed_work_sync(&tbl->gc_work); in neigh_table_clear()
1832 del_timer_sync(&tbl->proxy_timer); in neigh_table_clear()
1833 pneigh_queue_purge(&tbl->proxy_queue, NULL, tbl->family); in neigh_table_clear()
1834 neigh_ifdown(tbl, NULL); in neigh_table_clear()
1835 if (atomic_read(&tbl->entries)) in neigh_table_clear()
1838 call_rcu(&rcu_dereference_protected(tbl->nht, 1)->rcu, in neigh_table_clear()
1840 tbl->nht = NULL; in neigh_table_clear()
1842 kfree(tbl->phash_buckets); in neigh_table_clear()
1843 tbl->phash_buckets = NULL; in neigh_table_clear()
1845 remove_proc_entry(tbl->id, init_net.proc_net_stat); in neigh_table_clear()
1847 free_percpu(tbl->stats); in neigh_table_clear()
1848 tbl->stats = NULL; in neigh_table_clear()
1856 struct neigh_table *tbl = NULL; in neigh_find_table() local
1860 tbl = neigh_tables[NEIGH_ARP_TABLE]; in neigh_find_table()
1863 tbl = neigh_tables[NEIGH_ND_TABLE]; in neigh_find_table()
1867 return tbl; in neigh_find_table()
1893 struct neigh_table *tbl; in neigh_delete() local
1917 tbl = neigh_find_table(ndm->ndm_family); in neigh_delete()
1918 if (tbl == NULL) in neigh_delete()
1921 if (nla_len(dst_attr) < (int)tbl->key_len) { in neigh_delete()
1927 err = pneigh_delete(tbl, net, nla_data(dst_attr), dev); in neigh_delete()
1934 neigh = neigh_lookup(tbl, nla_data(dst_attr), dev); in neigh_delete()
1943 write_lock_bh(&tbl->lock); in neigh_delete()
1945 neigh_remove_one(neigh, tbl); in neigh_delete()
1946 write_unlock_bh(&tbl->lock); in neigh_delete()
1960 struct neigh_table *tbl; in neigh_add() local
2003 tbl = neigh_find_table(ndm->ndm_family); in neigh_add()
2004 if (tbl == NULL) in neigh_add()
2007 if (nla_len(tb[NDA_DST]) < (int)tbl->key_len) { in neigh_add()
2026 pn = pneigh_lookup(tbl, net, dst, dev, 1); in neigh_add()
2041 if (tbl->allow_add && !tbl->allow_add(dev, extack)) { in neigh_add()
2046 neigh = neigh_lookup(tbl, dst, dev); in neigh_add()
2062 neigh = ___neigh_create(tbl, dst, dev, in neigh_add()
2154 static int neightbl_fill_info(struct sk_buff *skb, struct neigh_table *tbl, in neightbl_fill_info() argument
2166 read_lock_bh(&tbl->lock); in neightbl_fill_info()
2167 ndtmsg->ndtm_family = tbl->family; in neightbl_fill_info()
2171 if (nla_put_string(skb, NDTA_NAME, tbl->id) || in neightbl_fill_info()
2172 nla_put_msecs(skb, NDTA_GC_INTERVAL, READ_ONCE(tbl->gc_interval), in neightbl_fill_info()
2174 nla_put_u32(skb, NDTA_THRESH1, READ_ONCE(tbl->gc_thresh1)) || in neightbl_fill_info()
2175 nla_put_u32(skb, NDTA_THRESH2, READ_ONCE(tbl->gc_thresh2)) || in neightbl_fill_info()
2176 nla_put_u32(skb, NDTA_THRESH3, READ_ONCE(tbl->gc_thresh3))) in neightbl_fill_info()
2180 long flush_delta = now - READ_ONCE(tbl->last_flush); in neightbl_fill_info()
2181 long rand_delta = now - READ_ONCE(tbl->last_rand); in neightbl_fill_info()
2184 .ndtc_key_len = tbl->key_len, in neightbl_fill_info()
2185 .ndtc_entry_size = tbl->entry_size, in neightbl_fill_info()
2186 .ndtc_entries = atomic_read(&tbl->entries), in neightbl_fill_info()
2189 .ndtc_proxy_qlen = READ_ONCE(tbl->proxy_queue.qlen), in neightbl_fill_info()
2193 nht = rcu_dereference(tbl->nht); in neightbl_fill_info()
2211 st = per_cpu_ptr(tbl->stats, cpu); in neightbl_fill_info()
2230 BUG_ON(tbl->parms.dev); in neightbl_fill_info()
2231 if (neightbl_fill_parms(skb, &tbl->parms) < 0) in neightbl_fill_info()
2234 read_unlock_bh(&tbl->lock); in neightbl_fill_info()
2239 read_unlock_bh(&tbl->lock); in neightbl_fill_info()
2245 struct neigh_table *tbl, in neightbl_fill_param_info() argument
2259 read_lock_bh(&tbl->lock); in neightbl_fill_param_info()
2260 ndtmsg->ndtm_family = tbl->family; in neightbl_fill_param_info()
2264 if (nla_put_string(skb, NDTA_NAME, tbl->id) < 0 || in neightbl_fill_param_info()
2268 read_unlock_bh(&tbl->lock); in neightbl_fill_param_info()
2272 read_unlock_bh(&tbl->lock); in neightbl_fill_param_info()
2308 struct neigh_table *tbl; in neightbl_set() local
2327 tbl = neigh_tables[tidx]; in neightbl_set()
2328 if (!tbl) in neightbl_set()
2330 if (ndtmsg->ndtm_family && tbl->family != ndtmsg->ndtm_family) in neightbl_set()
2332 if (nla_strcmp(tb[NDTA_NAME], tbl->id) == 0) { in neightbl_set()
2345 write_lock_bh(&tbl->lock); in neightbl_set()
2361 p = lookup_neigh_parms(tbl, net, ifindex); in neightbl_set()
2451 WRITE_ONCE(tbl->gc_thresh1, nla_get_u32(tb[NDTA_THRESH1])); in neightbl_set()
2454 WRITE_ONCE(tbl->gc_thresh2, nla_get_u32(tb[NDTA_THRESH2])); in neightbl_set()
2457 WRITE_ONCE(tbl->gc_thresh3, nla_get_u32(tb[NDTA_THRESH3])); in neightbl_set()
2460 WRITE_ONCE(tbl->gc_interval, nla_get_msecs(tb[NDTA_GC_INTERVAL])); in neightbl_set()
2465 write_unlock_bh(&tbl->lock); in neightbl_set()
2501 struct neigh_table *tbl; in neightbl_dump_info() local
2515 tbl = neigh_tables[tidx]; in neightbl_dump_info()
2516 if (!tbl) in neightbl_dump_info()
2519 if (tidx < tbl_skip || (family && tbl->family != family)) in neightbl_dump_info()
2522 if (neightbl_fill_info(skb, tbl, NETLINK_CB(cb->skb).portid, in neightbl_dump_info()
2528 p = list_next_entry(&tbl->parms, list); in neightbl_dump_info()
2529 list_for_each_entry_from(p, &tbl->parms_list, list) { in neightbl_dump_info()
2536 if (neightbl_fill_param_info(skb, tbl, p, in neightbl_dump_info()
2579 if (nla_put(skb, NDA_DST, neigh->tbl->key_len, neigh->primary_key)) in neigh_fill_info()
2619 struct neigh_table *tbl) in pneigh_fill_info() argument
2633 ndm->ndm_family = tbl->family; in pneigh_fill_info()
2641 if (nla_put(skb, NDA_DST, tbl->key_len, pn->key)) in pneigh_fill_info()
2697 static int neigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb, in neigh_dump_table() argument
2712 nht = rcu_dereference(tbl->nht); in neigh_dump_table()
2744 static int pneigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb, in pneigh_dump_table() argument
2757 read_lock_bh(&tbl->lock); in pneigh_dump_table()
2762 for (n = tbl->phash_buckets[h], idx = 0; n; n = n->next) { in pneigh_dump_table()
2770 RTM_NEWNEIGH, flags, tbl) < 0) { in pneigh_dump_table()
2771 read_unlock_bh(&tbl->lock); in pneigh_dump_table()
2780 read_unlock_bh(&tbl->lock); in pneigh_dump_table()
2854 struct neigh_table *tbl; in neigh_dump_info() local
2875 tbl = neigh_tables[t]; in neigh_dump_info()
2877 if (!tbl) in neigh_dump_info()
2879 if (t < s_t || (family && tbl->family != family)) in neigh_dump_info()
2885 err = pneigh_dump_table(tbl, skb, cb, &filter); in neigh_dump_info()
2887 err = neigh_dump_table(tbl, skb, cb, &filter); in neigh_dump_info()
2897 struct neigh_table **tbl, in neigh_valid_get_req() argument
2929 *tbl = neigh_find_table(ndm->ndm_family); in neigh_valid_get_req()
2930 if (*tbl == NULL) { in neigh_valid_get_req()
2941 if (nla_len(tb[i]) != (int)(*tbl)->key_len) { in neigh_valid_get_req()
2997 u32 pid, u32 seq, struct neigh_table *tbl) in pneigh_get_reply() argument
3006 err = pneigh_fill_info(skb, neigh, pid, seq, RTM_NEWNEIGH, 0, tbl); in pneigh_get_reply()
3022 struct neigh_table *tbl = NULL; in neigh_get() local
3029 err = neigh_valid_get_req(nlh, &tbl, &dst, &dev_idx, &ndm_flags, in neigh_get()
3050 pn = pneigh_lookup(tbl, net, dst, dev, 0); in neigh_get()
3056 nlh->nlmsg_seq, tbl); in neigh_get()
3064 neigh = neigh_lookup(tbl, dst, dev); in neigh_get()
3078 void neigh_for_each(struct neigh_table *tbl, void (*cb)(struct neighbour *, void *), void *cookie) in neigh_for_each() argument
3084 nht = rcu_dereference(tbl->nht); in neigh_for_each()
3086 read_lock_bh(&tbl->lock); /* avoid resizes */ in neigh_for_each()
3095 read_unlock_bh(&tbl->lock); in neigh_for_each()
3101 void __neigh_for_each_release(struct neigh_table *tbl, in __neigh_for_each_release() argument
3107 nht = rcu_dereference_protected(tbl->nht, in __neigh_for_each_release()
3108 lockdep_is_held(&tbl->lock)); in __neigh_for_each_release()
3115 lockdep_is_held(&tbl->lock))) != NULL) { in __neigh_for_each_release()
3123 lockdep_is_held(&tbl->lock))); in __neigh_for_each_release()
3140 struct neigh_table *tbl; in neigh_xmit() local
3143 tbl = neigh_tables[index]; in neigh_xmit()
3144 if (!tbl) in neigh_xmit()
3152 neigh = __neigh_lookup_noref(tbl, addr, dev); in neigh_xmit()
3155 neigh = __neigh_create(tbl, addr, dev, false); in neigh_xmit()
3287 struct neigh_table *tbl = state->tbl; in pneigh_get_first() local
3293 pn = tbl->phash_buckets[bucket]; in pneigh_get_first()
3310 struct neigh_table *tbl = state->tbl; in pneigh_get_next() local
3319 pn = tbl->phash_buckets[state->bucket]; in pneigh_get_next()
3360 void *neigh_seq_start(struct seq_file *seq, loff_t *pos, struct neigh_table *tbl, unsigned int neig… in neigh_seq_start() argument
3361 __acquires(tbl->lock) in neigh_seq_start()
3366 state->tbl = tbl; in neigh_seq_start()
3371 state->nht = rcu_dereference(tbl->nht); in neigh_seq_start()
3372 read_lock_bh(&tbl->lock); in neigh_seq_start()
3406 __releases(tbl->lock) in neigh_seq_stop()
3410 struct neigh_table *tbl = state->tbl; in neigh_seq_stop() local
3412 read_unlock_bh(&tbl->lock); in neigh_seq_stop()
3421 struct neigh_table *tbl = pde_data(file_inode(seq->file)); in neigh_stat_seq_start() local
3431 return per_cpu_ptr(tbl->stats, cpu); in neigh_stat_seq_start()
3438 struct neigh_table *tbl = pde_data(file_inode(seq->file)); in neigh_stat_seq_next() local
3445 return per_cpu_ptr(tbl->stats, cpu); in neigh_stat_seq_next()
3458 struct neigh_table *tbl = pde_data(file_inode(seq->file)); in neigh_stat_seq_show() local
3469 atomic_read(&tbl->entries), in neigh_stat_seq_show()
3807 struct neigh_table *tbl = p->tbl; in neigh_sysctl_register() local
3809 t->neigh_vars[NEIGH_VAR_GC_INTERVAL].data = &tbl->gc_interval; in neigh_sysctl_register()
3810 t->neigh_vars[NEIGH_VAR_GC_THRESH1].data = &tbl->gc_thresh1; in neigh_sysctl_register()
3811 t->neigh_vars[NEIGH_VAR_GC_THRESH2].data = &tbl->gc_thresh2; in neigh_sysctl_register()
3812 t->neigh_vars[NEIGH_VAR_GC_THRESH3].data = &tbl->gc_thresh3; in neigh_sysctl_register()