18 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
20 #include <linux/slab.h>
21 #include <linux/types.h>
22 #include <linux/kernel.h>
23 #include <linux/module.h>
24 #include <linux/socket.h>
25 #include <linux/netdevice.h>
28 #include <linux/sysctl.h>
37 #include <linux/rtnetlink.h>
38 #include <linux/random.h>
39 #include <linux/string.h>
44 #define NEIGH_PRINTK(x...) printk(x)
45 #define NEIGH_NOPRINTK(x...) do { ; } while(0)
46 #define NEIGH_PRINTK1 NEIGH_NOPRINTK
47 #define NEIGH_PRINTK2 NEIGH_NOPRINTK
51 #define NEIGH_PRINTK1 NEIGH_PRINTK
55 #define NEIGH_PRINTK2 NEIGH_PRINTK
58 #define PNEIGH_HASHMASK 0xF
60 static void neigh_timer_handler(
unsigned long arg);
62 static void neigh_update_notify(
struct neighbour *neigh);
109 static void neigh_cleanup_and_release(
struct neighbour *neigh)
111 if (neigh->
parms->neigh_cleanup)
112 neigh->
parms->neigh_cleanup(neigh);
115 neigh_release(neigh);
126 return base ? (
net_random() % base) + (base >> 1) : 0;
131 static int neigh_forced_gc(
struct neigh_table *tbl)
141 lockdep_is_held(&tbl->
lock));
142 for (i = 0; i < (1 << nht->
hash_shift); i++) {
148 lockdep_is_held(&tbl->
lock))) !=
NULL) {
158 lockdep_is_held(&tbl->
lock)));
162 neigh_cleanup_and_release(n);
177 static void neigh_add_timer(
struct neighbour *n,
unsigned long when)
181 printk(
"NEIGH: BUG, double timer add, state is %x\n",
187 static int neigh_del_timer(
struct neighbour *n)
213 lockdep_is_held(&tbl->
lock));
215 for (i = 0; i < (1 << nht->
hash_shift); i++) {
220 lockdep_is_held(&tbl->
lock))) !=
NULL) {
221 if (dev && n->
dev != dev) {
227 lockdep_is_held(&tbl->
lock)));
244 n->
output = neigh_blackhole;
252 neigh_cleanup_and_release(n);
260 neigh_flush_dev(tbl, dev);
268 neigh_flush_dev(tbl, dev);
269 pneigh_ifdown(tbl, dev);
288 if (!neigh_forced_gc(tbl) &&
296 int sz =
sizeof(*n) + tbl->
key_len;
310 n->
output = neigh_blackhole;
327 static void neigh_get_hash_rnd(
u32 *
x)
356 neigh_get_hash_rnd(&ret->
hash_rnd[i]);
376 unsigned long new_shift)
378 unsigned int i,
hash;
384 lockdep_is_held(&tbl->
lock));
385 new_nht = neigh_hash_alloc(new_shift);
389 for (i = 0; i < (1 << old_nht->
hash_shift); i++) {
393 lockdep_is_held(&tbl->
lock));
401 lockdep_is_held(&tbl->
lock));
406 lockdep_is_held(&tbl->
lock)));
441 rcu_read_unlock_bh();
464 net_eq(dev_net(n->
dev), net)) {
472 rcu_read_unlock_bh();
483 struct neighbour *n1, *
rc, *n = neigh_alloc(tbl, dev);
498 goto out_neigh_release;
502 error = dev->
netdev_ops->ndo_neigh_construct(n);
505 goto out_neigh_release;
510 if (n->
parms->neigh_setup &&
511 (error = n->
parms->neigh_setup(n)) < 0) {
513 goto out_neigh_release;
520 lockdep_is_held(&tbl->
lock));
523 nht = neigh_hash_grow(tbl, nht->
hash_shift + 1);
527 if (n->
parms->dead) {
533 lockdep_is_held(&tbl->
lock));
536 lockdep_is_held(&tbl->
lock))) {
550 lockdep_is_held(&tbl->
lock)));
567 u32 hash_val = *(
u32 *)(pkey + key_len - 4);
568 hash_val ^= (hash_val >> 16);
569 hash_val ^= hash_val >> 8;
570 hash_val ^= hash_val >> 4;
583 net_eq(pneigh_net(n), net) &&
584 (n->
dev == dev || !n->
dev))
592 struct net *net,
const void *pkey,
struct net_device *dev)
595 u32 hash_val = pneigh_hash(pkey, key_len);
598 net, pkey, key_len, dev);
603 struct net *net,
const void *pkey,
608 u32 hash_val = pneigh_hash(pkey, key_len);
612 net, pkey, key_len, dev);
654 u32 hash_val = pneigh_hash(pkey, key_len);
660 net_eq(pneigh_net(n), net)) {
667 release_net(pneigh_net(n));
683 while ((n = *np) !=
NULL) {
684 if (!dev || n->
dev == dev) {
690 release_net(pneigh_net(n));
705 neigh_parms_destroy(parms);
719 pr_warn(
"Destroying alive neighbour %p\n", neigh);
724 if (neigh_del_timer(neigh))
734 neigh_parms_put(neigh->
parms);
748 static void neigh_suspect(
struct neighbour *neigh)
760 static void neigh_connect(
struct neighbour *neigh)
764 neigh->
output = neigh->
ops->connected_output;
779 lockdep_is_held(&tbl->
lock));
793 for (i = 0 ; i < (1 << nht->
hash_shift); i++) {
797 lockdep_is_held(&tbl->
lock))) !=
NULL) {
817 neigh_cleanup_and_release(n);
833 lockdep_is_held(&tbl->
lock));
840 tbl->
parms.base_reachable_time >> 1);
852 static void neigh_invalidate(
struct neighbour *neigh)
870 neigh->
ops->error_report(neigh, skb);
877 static void neigh_probe(
struct neighbour *neigh)
885 neigh->
ops->solicit(neigh, skb);
892 static void neigh_timer_handler(
unsigned long arg)
894 unsigned long now,
next;
914 neigh->
used + neigh->
parms->delay_probe_time)) {
918 neigh_suspect(neigh);
919 next = now + neigh->
parms->delay_probe_time;
924 neigh_suspect(neigh);
933 neigh_connect(neigh);
941 next = now + neigh->
parms->retrans_time;
945 next = now + neigh->
parms->retrans_time;
952 neigh_invalidate(neigh);
969 neigh_update_notify(neigh);
971 neigh_release(neigh);
977 bool immediate_probe =
false;
986 if (neigh->
parms->mcast_probes + neigh->
parms->app_probes) {
992 next = now +
max(neigh->
parms->retrans_time, HZ/2);
993 neigh_add_timer(neigh, next);
994 immediate_probe =
true;
1007 neigh_add_timer(neigh,
1014 neigh->
parms->queue_len_bytes) {
1017 buff = __skb_dequeue(&neigh->
arp_queue);
1025 __skb_queue_tail(&neigh->
arp_queue, skb);
1031 if (immediate_probe)
1040 static void neigh_update_hhs(
struct neighbour *neigh)
1046 if (neigh->
dev->header_ops)
1047 update = neigh->
dev->header_ops->cache_update;
1089 int update_isrouter = 0;
1102 neigh_del_timer(neigh);
1104 neigh_suspect(neigh);
1110 neigh_invalidate(neigh);
1120 }
else if (lladdr) {
1150 update_isrouter = 0;
1167 neigh_del_timer(neigh);
1168 if (
new & NUD_IN_TIMER)
1169 neigh_add_timer(neigh, (
jiffies +
1170 ((
new & NUD_REACHABLE) ?
1171 neigh->
parms->reachable_time :
1176 if (lladdr != neigh->
ha) {
1177 write_seqlock(&neigh->
ha_lock);
1179 write_sequnlock(&neigh->
ha_lock);
1180 neigh_update_hhs(neigh);
1183 (neigh->
parms->base_reachable_time << 1);
1189 neigh_connect(neigh);
1191 neigh_suspect(neigh);
1192 if (!(old & NUD_VALID)) {
1214 n2 = dst_neigh_lookup_skb(dst, skb);
1229 if (update_isrouter) {
1237 neigh_update_notify(neigh);
1247 struct neighbour *neigh = __neigh_lookup(tbl, saddr, dev,
1283 __skb_pull(skb, skb_network_offset(skb));
1304 if (!neigh_event_send(neigh, skb)) {
1310 neigh_hh_init(neigh, dst);
1313 __skb_pull(skb, skb_network_offset(skb));
1314 seq = read_seqbegin(&neigh->
ha_lock);
1317 }
while (read_seqretry(&neigh->
ha_lock, seq));
1345 __skb_pull(skb, skb_network_offset(skb));
1346 seq = read_seqbegin(&neigh->
ha_lock);
1349 }
while (read_seqretry(&neigh->
ha_lock, seq));
1367 static void neigh_proxy_process(
unsigned long arg)
1370 long sched_next = 0;
1377 long tdif =
NEIGH_CB(skb)->sched_next - now;
1392 }
else if (!sched_next || tdif < sched_next)
1412 NEIGH_CB(skb)->sched_next = sched_next;
1429 struct net *net,
int ifindex)
1434 if ((p->
dev && p->
dev->ifindex == ifindex && net_eq(neigh_parms_net(p), net)) ||
1435 (!p->
dev && !ifindex))
1446 struct net *net = dev_net(dev);
1449 ref = lookup_neigh_parms(tbl, net, 0);
1478 static void neigh_rcu_free_parms(
struct rcu_head *head)
1483 neigh_parms_put(parms);
1490 if (!parms || parms == &tbl->
parms)
1493 for (p = &tbl->
parms.next; *p; p = &(*p)->
next) {
1499 dev_put(parms->
dev);
1509 static void neigh_parms_destroy(
struct neigh_parms *parms)
1511 release_net(neigh_parms_net(parms));
1517 static void neigh_table_init_no_netlink(
struct neigh_table *tbl)
1520 unsigned long phsize;
1524 tbl->
parms.reachable_time =
1529 panic(
"cannot create neighbour cache statistics");
1531 #ifdef CONFIG_PROC_FS
1533 &neigh_stat_seq_fops, tbl))
1534 panic(
"cannot create neighbour proc dir entry");
1543 panic(
"cannot allocate neighbour cache hashes");
1550 &neigh_table_proxy_queue_class);
1560 neigh_table_init_no_netlink(tbl);
1562 for (tmp = neigh_tables;
tmp; tmp = tmp->
next) {
1566 tbl->
next = neigh_tables;
1571 pr_err(
"Registering multiple tables for family %d\n",
1588 pr_crit(
"neighbour leakage\n");
1590 for (tp = &neigh_tables; *tp; tp = &(*tp)->
next) {
1599 neigh_hash_free_rcu);
1614 static int neigh_delete(
struct sk_buff *skb,
struct nlmsghdr *nlh,
void *arg)
1616 struct net *net = sock_net(skb->
sk);
1624 if (nlmsg_len(nlh) <
sizeof(*ndm))
1627 dst_attr = nlmsg_find_attr(nlh,
sizeof(*ndm),
NDA_DST);
1628 if (dst_attr ==
NULL)
1631 ndm = nlmsg_data(nlh);
1641 for (tbl = neigh_tables; tbl; tbl = tbl->
next) {
1648 if (nla_len(dst_attr) < tbl->
key_len)
1660 if (neigh ==
NULL) {
1668 neigh_release(neigh);
1678 static int neigh_add(
struct sk_buff *skb,
struct nlmsghdr *nlh,
void *arg)
1680 struct net *net = sock_net(skb->
sk);
1688 err = nlmsg_parse(nlh,
sizeof(*ndm), tb,
NDA_MAX,
NULL);
1696 ndm = nlmsg_data(nlh);
1709 for (tbl = neigh_tables; tbl; tbl = tbl->
next) {
1720 dst = nla_data(tb[NDA_DST]);
1739 if (neigh ==
NULL) {
1745 neigh = __neigh_lookup_errno(tbl, dst, dev);
1746 if (IS_ERR(neigh)) {
1747 err = PTR_ERR(neigh);
1753 neigh_release(neigh);
1762 neigh_event_send(neigh,
NULL);
1766 neigh_release(neigh);
1806 goto nla_put_failure;
1807 return nla_nest_end(skb, nest);
1810 nla_nest_cancel(skb, nest);
1820 nlh = nlmsg_put(skb, pid, seq, type,
sizeof(*ndtmsg), flags);
1824 ndtmsg = nlmsg_data(nlh);
1836 goto nla_put_failure;
1839 unsigned int flush_delta = now - tbl->
last_flush;
1840 unsigned int rand_delta = now - tbl->
last_rand;
1855 rcu_read_unlock_bh();
1858 goto nla_put_failure;
1865 memset(&ndst, 0,
sizeof(ndst));
1871 ndst.ndts_allocs += st->
allocs;
1872 ndst.ndts_destroys += st->
destroys;
1875 ndst.ndts_lookups += st->
lookups;
1876 ndst.ndts_hits += st->
hits;
1884 goto nla_put_failure;
1888 if (neightbl_fill_parms(skb, &tbl->
parms) < 0)
1889 goto nla_put_failure;
1892 return nlmsg_end(skb, nlh);
1896 nlmsg_cancel(skb, nlh);
1900 static int neightbl_fill_param_info(
struct sk_buff *skb,
1903 u32 pid,
u32 seq,
int type,
1906 struct ndtmsg *ndtmsg;
1909 nlh = nlmsg_put(skb, pid, seq, type,
sizeof(*ndtmsg), flags);
1913 ndtmsg = nlmsg_data(nlh);
1920 if (nla_put_string(skb,
NDTA_NAME, tbl->
id) < 0 ||
1921 neightbl_fill_parms(skb, parms) < 0)
1925 return nlmsg_end(skb, nlh);
1928 nlmsg_cancel(skb, nlh);
1957 static int neightbl_set(
struct sk_buff *skb,
struct nlmsghdr *nlh,
void *arg)
1959 struct net *net = sock_net(skb->
sk);
1961 struct ndtmsg *ndtmsg;
1965 err = nlmsg_parse(nlh,
sizeof(*ndtmsg), tb,
NDTA_MAX,
1966 nl_neightbl_policy);
1975 ndtmsg = nlmsg_data(nlh);
1977 for (tbl = neigh_tables; tbl; tbl = tbl->
next) {
2001 err = nla_parse_nested(tbp,
NDTPA_MAX, tb[NDTA_PARMS],
2002 nl_ntbl_parm_policy);
2004 goto errout_tbl_lock;
2007 ifindex = nla_get_u32(tbp[NDTPA_IFINDEX]);
2009 p = lookup_neigh_parms(tbl, net, ifindex);
2012 goto errout_tbl_lock;
2058 p->
locktime = nla_get_msecs(tbp[i]);
2065 tbl->
gc_thresh1 = nla_get_u32(tb[NDTA_THRESH1]);
2068 tbl->
gc_thresh2 = nla_get_u32(tb[NDTA_THRESH2]);
2071 tbl->
gc_thresh3 = nla_get_u32(tb[NDTA_THRESH3]);
2074 tbl->
gc_interval = nla_get_msecs(tb[NDTA_GC_INTERVAL]);
2088 struct net *net = sock_net(skb->
sk);
2090 int tbl_skip = cb->
args[0];
2091 int neigh_skip = cb->
args[1];
2097 for (tbl = neigh_tables, tidx = 0; tbl; tbl = tbl->
next, tidx++) {
2100 if (tidx < tbl_skip || (family && tbl->
family != family))
2103 if (neightbl_fill_info(skb, tbl,
NETLINK_CB(cb->
skb).portid,
2108 for (nidx = 0, p = tbl->
parms.next; p; p = p->
next) {
2109 if (!net_eq(neigh_parms_net(p), net))
2112 if (nidx < neigh_skip)
2115 if (neightbl_fill_param_info(skb, tbl, p,
2136 u32 pid,
u32 seq,
int type,
unsigned int flags)
2143 nlh = nlmsg_put(skb, pid, seq, type,
sizeof(*ndm), flags);
2147 ndm = nlmsg_data(nlh);
2156 goto nla_put_failure;
2163 neigh_ha_snapshot(haddr, neigh, neigh->
dev);
2164 if (
nla_put(skb, NDA_LLADDR, neigh->
dev->addr_len, haddr) < 0) {
2166 goto nla_put_failure;
2178 goto nla_put_failure;
2180 return nlmsg_end(skb, nlh);
2183 nlmsg_cancel(skb, nlh);
2188 u32 pid,
u32 seq,
int type,
unsigned int flags,
2194 nlh = nlmsg_put(skb, pid, seq, type,
sizeof(*ndm), flags);
2198 ndm = nlmsg_data(nlh);
2208 goto nla_put_failure;
2210 return nlmsg_end(skb, nlh);
2213 nlmsg_cancel(skb, nlh);
2217 static void neigh_update_notify(
struct neighbour *neigh)
2226 struct net *net = sock_net(skb->
sk);
2229 int idx, s_idx = idx = cb->
args[2];
2235 for (h = s_h; h < (1 << nht->
hash_shift); h++) {
2241 if (!net_eq(dev_net(n->
dev), net))
2258 rcu_read_unlock_bh();
2268 struct net *net = sock_net(skb->
sk);
2270 int idx, s_idx = idx = cb->
args[4];
2278 if (dev_net(n->
dev) != net)
2317 if (nlmsg_len(cb->
nlh) >=
sizeof(
struct ndmsg) &&
2323 for (tbl = neigh_tables, t = 0; tbl;
2324 tbl = tbl->
next, t++) {
2325 if (t < s_t || (family && tbl->
family != family))
2329 sizeof(cb->
args[0]));
2331 err = pneigh_dump_table(tbl, skb, cb);
2333 err = neigh_dump_table(tbl, skb, cb);
2352 for (chain = 0; chain < (1 << nht->
hash_shift); chain++) {
2361 rcu_read_unlock_bh();
2373 lockdep_is_held(&tbl->
lock));
2374 for (chain = 0; chain < (1 << nht->
hash_shift); chain++) {
2380 lockdep_is_held(&tbl->
lock))) !=
NULL) {
2388 lockdep_is_held(&tbl->
lock)));
2394 neigh_cleanup_and_release(n);
2400 #ifdef CONFIG_PROC_FS
2405 struct net *net = seq_file_net(seq);
2408 int bucket = state->
bucket;
2411 for (bucket = 0; bucket < (1 << nht->
hash_shift); bucket++) {
2415 if (!net_eq(dev_net(n->
dev), net))
2446 struct net *net = seq_file_net(seq);
2458 if (!net_eq(dev_net(n->
dev), net))
2491 struct neighbour *n = neigh_get_first(seq);
2496 n = neigh_get_next(seq, n, pos);
2501 return *pos ?
NULL :
n;
2507 struct net *net = seq_file_net(seq);
2510 int bucket = state->
bucket;
2515 while (pn && !net_eq(pneigh_net(pn), net))
2530 struct net *net = seq_file_net(seq);
2535 }
while (pn && !net_eq(pneigh_net(pn), net));
2541 while (pn && !net_eq(pneigh_net(pn), net))
2560 pn = pneigh_get_next(seq, pn, pos);
2568 static void *neigh_get_idx_any(
struct seq_file *seq, loff_t *pos)
2572 loff_t idxpos = *
pos;
2574 rc = neigh_get_idx(seq, &idxpos);
2576 rc = pneigh_get_idx(seq, &idxpos);
2603 rc = neigh_get_first(seq);
2609 rc = neigh_get_next(seq, v,
NULL);
2613 rc = pneigh_get_first(seq);
2616 rc = pneigh_get_next(seq, v,
NULL);
2627 rcu_read_unlock_bh();
2633 static void *neigh_stat_seq_start(
struct seq_file *seq, loff_t *pos)
2650 static void *neigh_stat_seq_next(
struct seq_file *seq,
void *v, loff_t *pos)
2655 for (cpu = *pos; cpu < nr_cpu_ids; ++
cpu) {
2664 static void neigh_stat_seq_stop(
struct seq_file *seq,
void *v)
2669 static int neigh_stat_seq_show(
struct seq_file *seq,
void *v)
2675 seq_printf(seq,
"entries allocs destroys hash_grows lookups hits res_failed rcv_probes_mcast rcv_probes_ucast periodic_gc_runs forced_gc_runs unresolved_discards\n");
2679 seq_printf(seq,
"%08x %08lx %08lx %08lx %08lx %08lx %08lx "
2680 "%08lx %08lx %08lx %08lx %08lx\n",
2704 .
start = neigh_stat_seq_start,
2705 .next = neigh_stat_seq_next,
2706 .stop = neigh_stat_seq_stop,
2707 .show = neigh_stat_seq_show,
2712 int ret =
seq_open(file, &neigh_stat_seq_ops);
2716 sf->
private = PDE(inode)->data;
2723 .open = neigh_stat_seq_open,
2731 static inline size_t neigh_nlmsg_size(
void)
2737 + nla_total_size(4);
2740 static void __neigh_notify(
struct neighbour *n,
int type,
int flags)
2742 struct net *net = dev_net(n->
dev);
2746 skb = nlmsg_new(neigh_nlmsg_size(),
GFP_ATOMIC);
2750 err = neigh_fill_info(skb, n, 0, 0, type, flags);
2772 #ifdef CONFIG_SYSCTL
2775 size_t *lenp, loff_t *ppos)
2789 NEIGH_VAR_MCAST_PROBE,
2790 NEIGH_VAR_UCAST_PROBE,
2791 NEIGH_VAR_APP_PROBE,
2792 NEIGH_VAR_RETRANS_TIME,
2793 NEIGH_VAR_BASE_REACHABLE_TIME,
2794 NEIGH_VAR_DELAY_PROBE_TIME,
2795 NEIGH_VAR_GC_STALETIME,
2796 NEIGH_VAR_QUEUE_LEN,
2797 NEIGH_VAR_QUEUE_LEN_BYTES,
2798 NEIGH_VAR_PROXY_QLEN,
2799 NEIGH_VAR_ANYCAST_DELAY,
2800 NEIGH_VAR_PROXY_DELAY,
2802 NEIGH_VAR_RETRANS_TIME_MS,
2803 NEIGH_VAR_BASE_REACHABLE_TIME_MS,
2804 NEIGH_VAR_GC_INTERVAL,
2805 NEIGH_VAR_GC_THRESH1,
2806 NEIGH_VAR_GC_THRESH2,
2807 NEIGH_VAR_GC_THRESH3,
2811 static struct neigh_sysctl_table {
2813 struct ctl_table neigh_vars[NEIGH_VAR_MAX + 1];
2816 [NEIGH_VAR_MCAST_PROBE] = {
2817 .procname =
"mcast_solicit",
2818 .maxlen =
sizeof(
int),
2822 [NEIGH_VAR_UCAST_PROBE] = {
2823 .procname =
"ucast_solicit",
2824 .maxlen =
sizeof(
int),
2828 [NEIGH_VAR_APP_PROBE] = {
2829 .procname =
"app_solicit",
2830 .maxlen =
sizeof(
int),
2834 [NEIGH_VAR_RETRANS_TIME] = {
2835 .procname =
"retrans_time",
2836 .maxlen =
sizeof(
int),
2840 [NEIGH_VAR_BASE_REACHABLE_TIME] = {
2841 .procname =
"base_reachable_time",
2842 .maxlen =
sizeof(
int),
2846 [NEIGH_VAR_DELAY_PROBE_TIME] = {
2847 .procname =
"delay_first_probe_time",
2848 .maxlen =
sizeof(
int),
2852 [NEIGH_VAR_GC_STALETIME] = {
2853 .procname =
"gc_stale_time",
2854 .maxlen =
sizeof(
int),
2858 [NEIGH_VAR_QUEUE_LEN] = {
2859 .procname =
"unres_qlen",
2860 .maxlen =
sizeof(
int),
2864 [NEIGH_VAR_QUEUE_LEN_BYTES] = {
2865 .procname =
"unres_qlen_bytes",
2866 .maxlen =
sizeof(
int),
2870 [NEIGH_VAR_PROXY_QLEN] = {
2871 .procname =
"proxy_qlen",
2872 .maxlen =
sizeof(
int),
2876 [NEIGH_VAR_ANYCAST_DELAY] = {
2877 .procname =
"anycast_delay",
2878 .maxlen =
sizeof(
int),
2882 [NEIGH_VAR_PROXY_DELAY] = {
2883 .procname =
"proxy_delay",
2884 .maxlen =
sizeof(
int),
2888 [NEIGH_VAR_LOCKTIME] = {
2889 .procname =
"locktime",
2890 .maxlen =
sizeof(
int),
2894 [NEIGH_VAR_RETRANS_TIME_MS] = {
2895 .procname =
"retrans_time_ms",
2896 .maxlen =
sizeof(
int),
2900 [NEIGH_VAR_BASE_REACHABLE_TIME_MS] = {
2901 .procname =
"base_reachable_time_ms",
2902 .maxlen =
sizeof(
int),
2906 [NEIGH_VAR_GC_INTERVAL] = {
2907 .procname =
"gc_interval",
2908 .maxlen =
sizeof(
int),
2912 [NEIGH_VAR_GC_THRESH1] = {
2913 .procname =
"gc_thresh1",
2914 .maxlen =
sizeof(
int),
2918 [NEIGH_VAR_GC_THRESH2] = {
2919 .procname =
"gc_thresh2",
2920 .maxlen =
sizeof(
int),
2924 [NEIGH_VAR_GC_THRESH3] = {
2925 .procname =
"gc_thresh3",
2926 .maxlen =
sizeof(
int),
2937 struct neigh_sysctl_table *
t;
2938 const char *dev_name_source =
NULL;
2945 t->neigh_vars[NEIGH_VAR_MCAST_PROBE].data = &p->
mcast_probes;
2946 t->neigh_vars[NEIGH_VAR_UCAST_PROBE].data = &p->
ucast_probes;
2947 t->neigh_vars[NEIGH_VAR_APP_PROBE].data = &p->
app_probes;
2948 t->neigh_vars[NEIGH_VAR_RETRANS_TIME].data = &p->
retrans_time;
2951 t->neigh_vars[NEIGH_VAR_GC_STALETIME].data = &p->
gc_staletime;
2954 t->neigh_vars[NEIGH_VAR_PROXY_QLEN].data = &p->
proxy_qlen;
2955 t->neigh_vars[NEIGH_VAR_ANYCAST_DELAY].data = &p->
anycast_delay;
2956 t->neigh_vars[NEIGH_VAR_PROXY_DELAY].data = &p->
proxy_delay;
2957 t->neigh_vars[NEIGH_VAR_LOCKTIME].data = &p->
locktime;
2958 t->neigh_vars[NEIGH_VAR_RETRANS_TIME_MS].data = &p->
retrans_time;
2962 dev_name_source = dev->
name;
2964 memset(&t->neigh_vars[NEIGH_VAR_GC_INTERVAL], 0,
2965 sizeof(t->neigh_vars[NEIGH_VAR_GC_INTERVAL]));
2967 dev_name_source =
"default";
2968 t->neigh_vars[NEIGH_VAR_GC_INTERVAL].data = (
int *)(p + 1);
2969 t->neigh_vars[NEIGH_VAR_GC_THRESH1].data = (
int *)(p + 1) + 1;
2970 t->neigh_vars[NEIGH_VAR_GC_THRESH2].data = (
int *)(p + 1) + 2;
2971 t->neigh_vars[NEIGH_VAR_GC_THRESH3].data = (
int *)(p + 1) + 3;
2977 t->neigh_vars[NEIGH_VAR_RETRANS_TIME].proc_handler = handler;
2978 t->neigh_vars[NEIGH_VAR_RETRANS_TIME].extra1 =
dev;
2980 t->neigh_vars[NEIGH_VAR_BASE_REACHABLE_TIME].proc_handler = handler;
2981 t->neigh_vars[NEIGH_VAR_BASE_REACHABLE_TIME].extra1 =
dev;
2983 t->neigh_vars[NEIGH_VAR_RETRANS_TIME_MS].proc_handler = handler;
2984 t->neigh_vars[NEIGH_VAR_RETRANS_TIME_MS].extra1 =
dev;
2986 t->neigh_vars[NEIGH_VAR_BASE_REACHABLE_TIME_MS].proc_handler = handler;
2987 t->neigh_vars[NEIGH_VAR_BASE_REACHABLE_TIME_MS].extra1 =
dev;
2990 snprintf(neigh_path,
sizeof(neigh_path),
"net/%s/neigh/%s",
2991 p_name, dev_name_source);
2994 if (!t->sysctl_header)
3020 static int __init neigh_init(
void)