diff options
-rw-r--r-- | include/net/neighbour.h | 48 | ||||
-rw-r--r-- | net/802/hippi.c | 4 | ||||
-rw-r--r-- | net/core/neighbour.c | 327 | ||||
-rw-r--r-- | net/decnet/dn_neigh.c | 28 | ||||
-rw-r--r-- | net/ipv4/arp.c | 33 | ||||
-rw-r--r-- | net/ipv6/addrconf.c | 12 | ||||
-rw-r--r-- | net/ipv6/ndisc.c | 43 |
7 files changed, 238 insertions, 257 deletions
diff --git a/include/net/neighbour.h b/include/net/neighbour.h index 536501a3e58d..4cb5478e2f6e 100644 --- a/include/net/neighbour.h +++ b/include/net/neighbour.h | |||
@@ -37,6 +37,32 @@ | |||
37 | 37 | ||
38 | struct neighbour; | 38 | struct neighbour; |
39 | 39 | ||
40 | enum { | ||
41 | NEIGH_VAR_MCAST_PROBES, | ||
42 | NEIGH_VAR_UCAST_PROBES, | ||
43 | NEIGH_VAR_APP_PROBES, | ||
44 | NEIGH_VAR_RETRANS_TIME, | ||
45 | NEIGH_VAR_BASE_REACHABLE_TIME, | ||
46 | NEIGH_VAR_DELAY_PROBE_TIME, | ||
47 | NEIGH_VAR_GC_STALETIME, | ||
48 | NEIGH_VAR_QUEUE_LEN_BYTES, | ||
49 | NEIGH_VAR_PROXY_QLEN, | ||
50 | NEIGH_VAR_ANYCAST_DELAY, | ||
51 | NEIGH_VAR_PROXY_DELAY, | ||
52 | NEIGH_VAR_LOCKTIME, | ||
53 | #define NEIGH_VAR_DATA_MAX (NEIGH_VAR_LOCKTIME + 1) | ||
54 | /* Following are used as a second way to access one of the above */ | ||
55 | NEIGH_VAR_QUEUE_LEN, /* same data as NEIGH_VAR_QUEUE_LEN_BYTES */ | ||
56 | NEIGH_VAR_RETRANS_TIME_MS, /* same data as NEIGH_VAR_RETRANS_TIME */ | ||
57 | NEIGH_VAR_BASE_REACHABLE_TIME_MS, /* same data as NEIGH_VAR_BASE_REACHABLE_TIME */ | ||
58 | /* Following are used by "default" only */ | ||
59 | NEIGH_VAR_GC_INTERVAL, | ||
60 | NEIGH_VAR_GC_THRESH1, | ||
61 | NEIGH_VAR_GC_THRESH2, | ||
62 | NEIGH_VAR_GC_THRESH3, | ||
63 | NEIGH_VAR_MAX | ||
64 | }; | ||
65 | |||
40 | struct neigh_parms { | 66 | struct neigh_parms { |
41 | #ifdef CONFIG_NET_NS | 67 | #ifdef CONFIG_NET_NS |
42 | struct net *net; | 68 | struct net *net; |
@@ -53,22 +79,18 @@ struct neigh_parms { | |||
53 | atomic_t refcnt; | 79 | atomic_t refcnt; |
54 | struct rcu_head rcu_head; | 80 | struct rcu_head rcu_head; |
55 | 81 | ||
56 | int base_reachable_time; | ||
57 | int retrans_time; | ||
58 | int gc_staletime; | ||
59 | int reachable_time; | 82 | int reachable_time; |
60 | int delay_probe_time; | 83 | int data[NEIGH_VAR_DATA_MAX]; |
61 | |||
62 | int queue_len_bytes; | ||
63 | int ucast_probes; | ||
64 | int app_probes; | ||
65 | int mcast_probes; | ||
66 | int anycast_delay; | ||
67 | int proxy_delay; | ||
68 | int proxy_qlen; | ||
69 | int locktime; | ||
70 | }; | 84 | }; |
71 | 85 | ||
86 | static inline void neigh_var_set(struct neigh_parms *p, int index, int val) | ||
87 | { | ||
88 | p->data[index] = val; | ||
89 | } | ||
90 | |||
91 | #define NEIGH_VAR(p, attr) ((p)->data[NEIGH_VAR_ ## attr]) | ||
92 | #define NEIGH_VAR_SET(p, attr, val) neigh_var_set(p, NEIGH_VAR_ ## attr, val) | ||
93 | |||
72 | struct neigh_statistics { | 94 | struct neigh_statistics { |
73 | unsigned long allocs; /* number of allocated neighs */ | 95 | unsigned long allocs; /* number of allocated neighs */ |
74 | unsigned long destroys; /* number of destroyed neighs */ | 96 | unsigned long destroys; /* number of destroyed neighs */ |
diff --git a/net/802/hippi.c b/net/802/hippi.c index 51a1f530417d..a97a3bde77bb 100644 --- a/net/802/hippi.c +++ b/net/802/hippi.c | |||
@@ -172,14 +172,14 @@ EXPORT_SYMBOL(hippi_mac_addr); | |||
172 | int hippi_neigh_setup_dev(struct net_device *dev, struct neigh_parms *p) | 172 | int hippi_neigh_setup_dev(struct net_device *dev, struct neigh_parms *p) |
173 | { | 173 | { |
174 | /* Never send broadcast/multicast ARP messages */ | 174 | /* Never send broadcast/multicast ARP messages */ |
175 | p->mcast_probes = 0; | 175 | NEIGH_VAR_SET(p, MCAST_PROBES, 0); |
176 | 176 | ||
177 | /* In IPv6 unicast probes are valid even on NBMA, | 177 | /* In IPv6 unicast probes are valid even on NBMA, |
178 | * because they are encapsulated in normal IPv6 protocol. | 178 | * because they are encapsulated in normal IPv6 protocol. |
179 | * Should be a generic flag. | 179 | * Should be a generic flag. |
180 | */ | 180 | */ |
181 | if (p->tbl->family != AF_INET6) | 181 | if (p->tbl->family != AF_INET6) |
182 | p->ucast_probes = 0; | 182 | NEIGH_VAR_SET(p, UCAST_PROBES, 0); |
183 | return 0; | 183 | return 0; |
184 | } | 184 | } |
185 | EXPORT_SYMBOL(hippi_neigh_setup_dev); | 185 | EXPORT_SYMBOL(hippi_neigh_setup_dev); |
diff --git a/net/core/neighbour.c b/net/core/neighbour.c index ca15f32821fb..742fa10d4372 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c | |||
@@ -497,7 +497,7 @@ struct neighbour *__neigh_create(struct neigh_table *tbl, const void *pkey, | |||
497 | goto out_neigh_release; | 497 | goto out_neigh_release; |
498 | } | 498 | } |
499 | 499 | ||
500 | n->confirmed = jiffies - (n->parms->base_reachable_time << 1); | 500 | n->confirmed = jiffies - (NEIGH_VAR(n->parms, BASE_REACHABLE_TIME) << 1); |
501 | 501 | ||
502 | write_lock_bh(&tbl->lock); | 502 | write_lock_bh(&tbl->lock); |
503 | nht = rcu_dereference_protected(tbl->nht, | 503 | nht = rcu_dereference_protected(tbl->nht, |
@@ -776,7 +776,7 @@ static void neigh_periodic_work(struct work_struct *work) | |||
776 | tbl->last_rand = jiffies; | 776 | tbl->last_rand = jiffies; |
777 | for (p = &tbl->parms; p; p = p->next) | 777 | for (p = &tbl->parms; p; p = p->next) |
778 | p->reachable_time = | 778 | p->reachable_time = |
779 | neigh_rand_reach_time(p->base_reachable_time); | 779 | neigh_rand_reach_time(NEIGH_VAR(p, BASE_REACHABLE_TIME)); |
780 | } | 780 | } |
781 | 781 | ||
782 | for (i = 0 ; i < (1 << nht->hash_shift); i++) { | 782 | for (i = 0 ; i < (1 << nht->hash_shift); i++) { |
@@ -799,7 +799,7 @@ static void neigh_periodic_work(struct work_struct *work) | |||
799 | 799 | ||
800 | if (atomic_read(&n->refcnt) == 1 && | 800 | if (atomic_read(&n->refcnt) == 1 && |
801 | (state == NUD_FAILED || | 801 | (state == NUD_FAILED || |
802 | time_after(jiffies, n->used + n->parms->gc_staletime))) { | 802 | time_after(jiffies, n->used + NEIGH_VAR(n->parms, GC_STALETIME)))) { |
803 | *np = n->next; | 803 | *np = n->next; |
804 | n->dead = 1; | 804 | n->dead = 1; |
805 | write_unlock(&n->lock); | 805 | write_unlock(&n->lock); |
@@ -822,12 +822,12 @@ next_elt: | |||
822 | lockdep_is_held(&tbl->lock)); | 822 | lockdep_is_held(&tbl->lock)); |
823 | } | 823 | } |
824 | out: | 824 | out: |
825 | /* Cycle through all hash buckets every base_reachable_time/2 ticks. | 825 | /* Cycle through all hash buckets every BASE_REACHABLE_TIME/2 ticks. |
826 | * ARP entry timeouts range from 1/2 base_reachable_time to 3/2 | 826 | * ARP entry timeouts range from 1/2 BASE_REACHABLE_TIME to 3/2 |
827 | * base_reachable_time. | 827 | * BASE_REACHABLE_TIME. |
828 | */ | 828 | */ |
829 | schedule_delayed_work(&tbl->gc_work, | 829 | schedule_delayed_work(&tbl->gc_work, |
830 | tbl->parms.base_reachable_time >> 1); | 830 | NEIGH_VAR(&tbl->parms, BASE_REACHABLE_TIME) >> 1); |
831 | write_unlock_bh(&tbl->lock); | 831 | write_unlock_bh(&tbl->lock); |
832 | } | 832 | } |
833 | 833 | ||
@@ -835,8 +835,9 @@ static __inline__ int neigh_max_probes(struct neighbour *n) | |||
835 | { | 835 | { |
836 | struct neigh_parms *p = n->parms; | 836 | struct neigh_parms *p = n->parms; |
837 | return (n->nud_state & NUD_PROBE) ? | 837 | return (n->nud_state & NUD_PROBE) ? |
838 | p->ucast_probes : | 838 | NEIGH_VAR(p, UCAST_PROBES) : |
839 | p->ucast_probes + p->app_probes + p->mcast_probes; | 839 | NEIGH_VAR(p, UCAST_PROBES) + NEIGH_VAR(p, APP_PROBES) + |
840 | NEIGH_VAR(p, MCAST_PROBES); | ||
840 | } | 841 | } |
841 | 842 | ||
842 | static void neigh_invalidate(struct neighbour *neigh) | 843 | static void neigh_invalidate(struct neighbour *neigh) |
@@ -901,12 +902,13 @@ static void neigh_timer_handler(unsigned long arg) | |||
901 | neigh_dbg(2, "neigh %p is still alive\n", neigh); | 902 | neigh_dbg(2, "neigh %p is still alive\n", neigh); |
902 | next = neigh->confirmed + neigh->parms->reachable_time; | 903 | next = neigh->confirmed + neigh->parms->reachable_time; |
903 | } else if (time_before_eq(now, | 904 | } else if (time_before_eq(now, |
904 | neigh->used + neigh->parms->delay_probe_time)) { | 905 | neigh->used + |
906 | NEIGH_VAR(neigh->parms, DELAY_PROBE_TIME))) { | ||
905 | neigh_dbg(2, "neigh %p is delayed\n", neigh); | 907 | neigh_dbg(2, "neigh %p is delayed\n", neigh); |
906 | neigh->nud_state = NUD_DELAY; | 908 | neigh->nud_state = NUD_DELAY; |
907 | neigh->updated = jiffies; | 909 | neigh->updated = jiffies; |
908 | neigh_suspect(neigh); | 910 | neigh_suspect(neigh); |
909 | next = now + neigh->parms->delay_probe_time; | 911 | next = now + NEIGH_VAR(neigh->parms, DELAY_PROBE_TIME); |
910 | } else { | 912 | } else { |
911 | neigh_dbg(2, "neigh %p is suspected\n", neigh); | 913 | neigh_dbg(2, "neigh %p is suspected\n", neigh); |
912 | neigh->nud_state = NUD_STALE; | 914 | neigh->nud_state = NUD_STALE; |
@@ -916,7 +918,8 @@ static void neigh_timer_handler(unsigned long arg) | |||
916 | } | 918 | } |
917 | } else if (state & NUD_DELAY) { | 919 | } else if (state & NUD_DELAY) { |
918 | if (time_before_eq(now, | 920 | if (time_before_eq(now, |
919 | neigh->confirmed + neigh->parms->delay_probe_time)) { | 921 | neigh->confirmed + |
922 | NEIGH_VAR(neigh->parms, DELAY_PROBE_TIME))) { | ||
920 | neigh_dbg(2, "neigh %p is now reachable\n", neigh); | 923 | neigh_dbg(2, "neigh %p is now reachable\n", neigh); |
921 | neigh->nud_state = NUD_REACHABLE; | 924 | neigh->nud_state = NUD_REACHABLE; |
922 | neigh->updated = jiffies; | 925 | neigh->updated = jiffies; |
@@ -928,11 +931,11 @@ static void neigh_timer_handler(unsigned long arg) | |||
928 | neigh->nud_state = NUD_PROBE; | 931 | neigh->nud_state = NUD_PROBE; |
929 | neigh->updated = jiffies; | 932 | neigh->updated = jiffies; |
930 | atomic_set(&neigh->probes, 0); | 933 | atomic_set(&neigh->probes, 0); |
931 | next = now + neigh->parms->retrans_time; | 934 | next = now + NEIGH_VAR(neigh->parms, RETRANS_TIME); |
932 | } | 935 | } |
933 | } else { | 936 | } else { |
934 | /* NUD_PROBE|NUD_INCOMPLETE */ | 937 | /* NUD_PROBE|NUD_INCOMPLETE */ |
935 | next = now + neigh->parms->retrans_time; | 938 | next = now + NEIGH_VAR(neigh->parms, RETRANS_TIME); |
936 | } | 939 | } |
937 | 940 | ||
938 | if ((neigh->nud_state & (NUD_INCOMPLETE | NUD_PROBE)) && | 941 | if ((neigh->nud_state & (NUD_INCOMPLETE | NUD_PROBE)) && |
@@ -973,13 +976,16 @@ int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb) | |||
973 | goto out_unlock_bh; | 976 | goto out_unlock_bh; |
974 | 977 | ||
975 | if (!(neigh->nud_state & (NUD_STALE | NUD_INCOMPLETE))) { | 978 | if (!(neigh->nud_state & (NUD_STALE | NUD_INCOMPLETE))) { |
976 | if (neigh->parms->mcast_probes + neigh->parms->app_probes) { | 979 | if (NEIGH_VAR(neigh->parms, MCAST_PROBES) + |
980 | NEIGH_VAR(neigh->parms, APP_PROBES)) { | ||
977 | unsigned long next, now = jiffies; | 981 | unsigned long next, now = jiffies; |
978 | 982 | ||
979 | atomic_set(&neigh->probes, neigh->parms->ucast_probes); | 983 | atomic_set(&neigh->probes, |
984 | NEIGH_VAR(neigh->parms, UCAST_PROBES)); | ||
980 | neigh->nud_state = NUD_INCOMPLETE; | 985 | neigh->nud_state = NUD_INCOMPLETE; |
981 | neigh->updated = now; | 986 | neigh->updated = now; |
982 | next = now + max(neigh->parms->retrans_time, HZ/2); | 987 | next = now + max(NEIGH_VAR(neigh->parms, RETRANS_TIME), |
988 | HZ/2); | ||
983 | neigh_add_timer(neigh, next); | 989 | neigh_add_timer(neigh, next); |
984 | immediate_probe = true; | 990 | immediate_probe = true; |
985 | } else { | 991 | } else { |
@@ -994,14 +1000,14 @@ int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb) | |||
994 | neigh_dbg(2, "neigh %p is delayed\n", neigh); | 1000 | neigh_dbg(2, "neigh %p is delayed\n", neigh); |
995 | neigh->nud_state = NUD_DELAY; | 1001 | neigh->nud_state = NUD_DELAY; |
996 | neigh->updated = jiffies; | 1002 | neigh->updated = jiffies; |
997 | neigh_add_timer(neigh, | 1003 | neigh_add_timer(neigh, jiffies + |
998 | jiffies + neigh->parms->delay_probe_time); | 1004 | NEIGH_VAR(neigh->parms, DELAY_PROBE_TIME)); |
999 | } | 1005 | } |
1000 | 1006 | ||
1001 | if (neigh->nud_state == NUD_INCOMPLETE) { | 1007 | if (neigh->nud_state == NUD_INCOMPLETE) { |
1002 | if (skb) { | 1008 | if (skb) { |
1003 | while (neigh->arp_queue_len_bytes + skb->truesize > | 1009 | while (neigh->arp_queue_len_bytes + skb->truesize > |
1004 | neigh->parms->queue_len_bytes) { | 1010 | NEIGH_VAR(neigh->parms, QUEUE_LEN_BYTES)) { |
1005 | struct sk_buff *buff; | 1011 | struct sk_buff *buff; |
1006 | 1012 | ||
1007 | buff = __skb_dequeue(&neigh->arp_queue); | 1013 | buff = __skb_dequeue(&neigh->arp_queue); |
@@ -1170,7 +1176,7 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new, | |||
1170 | neigh_update_hhs(neigh); | 1176 | neigh_update_hhs(neigh); |
1171 | if (!(new & NUD_CONNECTED)) | 1177 | if (!(new & NUD_CONNECTED)) |
1172 | neigh->confirmed = jiffies - | 1178 | neigh->confirmed = jiffies - |
1173 | (neigh->parms->base_reachable_time << 1); | 1179 | (NEIGH_VAR(neigh->parms, BASE_REACHABLE_TIME) << 1); |
1174 | notify = 1; | 1180 | notify = 1; |
1175 | } | 1181 | } |
1176 | if (new == old) | 1182 | if (new == old) |
@@ -1391,9 +1397,10 @@ void pneigh_enqueue(struct neigh_table *tbl, struct neigh_parms *p, | |||
1391 | struct sk_buff *skb) | 1397 | struct sk_buff *skb) |
1392 | { | 1398 | { |
1393 | unsigned long now = jiffies; | 1399 | unsigned long now = jiffies; |
1394 | unsigned long sched_next = now + (net_random() % p->proxy_delay); | 1400 | unsigned long sched_next = now + (net_random() % |
1401 | NEIGH_VAR(p, PROXY_DELAY)); | ||
1395 | 1402 | ||
1396 | if (tbl->proxy_queue.qlen > p->proxy_qlen) { | 1403 | if (tbl->proxy_queue.qlen > NEIGH_VAR(p, PROXY_QLEN)) { |
1397 | kfree_skb(skb); | 1404 | kfree_skb(skb); |
1398 | return; | 1405 | return; |
1399 | } | 1406 | } |
@@ -1440,7 +1447,7 @@ struct neigh_parms *neigh_parms_alloc(struct net_device *dev, | |||
1440 | p->tbl = tbl; | 1447 | p->tbl = tbl; |
1441 | atomic_set(&p->refcnt, 1); | 1448 | atomic_set(&p->refcnt, 1); |
1442 | p->reachable_time = | 1449 | p->reachable_time = |
1443 | neigh_rand_reach_time(p->base_reachable_time); | 1450 | neigh_rand_reach_time(NEIGH_VAR(p, BASE_REACHABLE_TIME)); |
1444 | dev_hold(dev); | 1451 | dev_hold(dev); |
1445 | p->dev = dev; | 1452 | p->dev = dev; |
1446 | write_pnet(&p->net, hold_net(net)); | 1453 | write_pnet(&p->net, hold_net(net)); |
@@ -1509,7 +1516,7 @@ static void neigh_table_init_no_netlink(struct neigh_table *tbl) | |||
1509 | write_pnet(&tbl->parms.net, &init_net); | 1516 | write_pnet(&tbl->parms.net, &init_net); |
1510 | atomic_set(&tbl->parms.refcnt, 1); | 1517 | atomic_set(&tbl->parms.refcnt, 1); |
1511 | tbl->parms.reachable_time = | 1518 | tbl->parms.reachable_time = |
1512 | neigh_rand_reach_time(tbl->parms.base_reachable_time); | 1519 | neigh_rand_reach_time(NEIGH_VAR(&tbl->parms, BASE_REACHABLE_TIME)); |
1513 | 1520 | ||
1514 | tbl->stats = alloc_percpu(struct neigh_statistics); | 1521 | tbl->stats = alloc_percpu(struct neigh_statistics); |
1515 | if (!tbl->stats) | 1522 | if (!tbl->stats) |
@@ -1777,24 +1784,32 @@ static int neightbl_fill_parms(struct sk_buff *skb, struct neigh_parms *parms) | |||
1777 | if ((parms->dev && | 1784 | if ((parms->dev && |
1778 | nla_put_u32(skb, NDTPA_IFINDEX, parms->dev->ifindex)) || | 1785 | nla_put_u32(skb, NDTPA_IFINDEX, parms->dev->ifindex)) || |
1779 | nla_put_u32(skb, NDTPA_REFCNT, atomic_read(&parms->refcnt)) || | 1786 | nla_put_u32(skb, NDTPA_REFCNT, atomic_read(&parms->refcnt)) || |
1780 | nla_put_u32(skb, NDTPA_QUEUE_LENBYTES, parms->queue_len_bytes) || | 1787 | nla_put_u32(skb, NDTPA_QUEUE_LENBYTES, |
1788 | NEIGH_VAR(parms, QUEUE_LEN_BYTES)) || | ||
1781 | /* approximative value for deprecated QUEUE_LEN (in packets) */ | 1789 | /* approximative value for deprecated QUEUE_LEN (in packets) */ |
1782 | nla_put_u32(skb, NDTPA_QUEUE_LEN, | 1790 | nla_put_u32(skb, NDTPA_QUEUE_LEN, |
1783 | parms->queue_len_bytes / SKB_TRUESIZE(ETH_FRAME_LEN)) || | 1791 | NEIGH_VAR(parms, QUEUE_LEN_BYTES) / SKB_TRUESIZE(ETH_FRAME_LEN)) || |
1784 | nla_put_u32(skb, NDTPA_PROXY_QLEN, parms->proxy_qlen) || | 1792 | nla_put_u32(skb, NDTPA_PROXY_QLEN, NEIGH_VAR(parms, PROXY_QLEN)) || |
1785 | nla_put_u32(skb, NDTPA_APP_PROBES, parms->app_probes) || | 1793 | nla_put_u32(skb, NDTPA_APP_PROBES, NEIGH_VAR(parms, APP_PROBES)) || |
1786 | nla_put_u32(skb, NDTPA_UCAST_PROBES, parms->ucast_probes) || | 1794 | nla_put_u32(skb, NDTPA_UCAST_PROBES, |
1787 | nla_put_u32(skb, NDTPA_MCAST_PROBES, parms->mcast_probes) || | 1795 | NEIGH_VAR(parms, UCAST_PROBES)) || |
1796 | nla_put_u32(skb, NDTPA_MCAST_PROBES, | ||
1797 | NEIGH_VAR(parms, MCAST_PROBES)) || | ||
1788 | nla_put_msecs(skb, NDTPA_REACHABLE_TIME, parms->reachable_time) || | 1798 | nla_put_msecs(skb, NDTPA_REACHABLE_TIME, parms->reachable_time) || |
1789 | nla_put_msecs(skb, NDTPA_BASE_REACHABLE_TIME, | 1799 | nla_put_msecs(skb, NDTPA_BASE_REACHABLE_TIME, |
1790 | parms->base_reachable_time) || | 1800 | NEIGH_VAR(parms, BASE_REACHABLE_TIME)) || |
1791 | nla_put_msecs(skb, NDTPA_GC_STALETIME, parms->gc_staletime) || | 1801 | nla_put_msecs(skb, NDTPA_GC_STALETIME, |
1802 | NEIGH_VAR(parms, GC_STALETIME)) || | ||
1792 | nla_put_msecs(skb, NDTPA_DELAY_PROBE_TIME, | 1803 | nla_put_msecs(skb, NDTPA_DELAY_PROBE_TIME, |
1793 | parms->delay_probe_time) || | 1804 | NEIGH_VAR(parms, DELAY_PROBE_TIME)) || |
1794 | nla_put_msecs(skb, NDTPA_RETRANS_TIME, parms->retrans_time) || | 1805 | nla_put_msecs(skb, NDTPA_RETRANS_TIME, |
1795 | nla_put_msecs(skb, NDTPA_ANYCAST_DELAY, parms->anycast_delay) || | 1806 | NEIGH_VAR(parms, RETRANS_TIME)) || |
1796 | nla_put_msecs(skb, NDTPA_PROXY_DELAY, parms->proxy_delay) || | 1807 | nla_put_msecs(skb, NDTPA_ANYCAST_DELAY, |
1797 | nla_put_msecs(skb, NDTPA_LOCKTIME, parms->locktime)) | 1808 | NEIGH_VAR(parms, ANYCAST_DELAY)) || |
1809 | nla_put_msecs(skb, NDTPA_PROXY_DELAY, | ||
1810 | NEIGH_VAR(parms, PROXY_DELAY)) || | ||
1811 | nla_put_msecs(skb, NDTPA_LOCKTIME, | ||
1812 | NEIGH_VAR(parms, LOCKTIME))) | ||
1798 | goto nla_put_failure; | 1813 | goto nla_put_failure; |
1799 | return nla_nest_end(skb, nest); | 1814 | return nla_nest_end(skb, nest); |
1800 | 1815 | ||
@@ -2010,44 +2025,54 @@ static int neightbl_set(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
2010 | 2025 | ||
2011 | switch (i) { | 2026 | switch (i) { |
2012 | case NDTPA_QUEUE_LEN: | 2027 | case NDTPA_QUEUE_LEN: |
2013 | p->queue_len_bytes = nla_get_u32(tbp[i]) * | 2028 | NEIGH_VAR_SET(p, QUEUE_LEN_BYTES, |
2014 | SKB_TRUESIZE(ETH_FRAME_LEN); | 2029 | nla_get_u32(tbp[i]) * |
2030 | SKB_TRUESIZE(ETH_FRAME_LEN)); | ||
2015 | break; | 2031 | break; |
2016 | case NDTPA_QUEUE_LENBYTES: | 2032 | case NDTPA_QUEUE_LENBYTES: |
2017 | p->queue_len_bytes = nla_get_u32(tbp[i]); | 2033 | NEIGH_VAR_SET(p, QUEUE_LEN_BYTES, |
2034 | nla_get_u32(tbp[i])); | ||
2018 | break; | 2035 | break; |
2019 | case NDTPA_PROXY_QLEN: | 2036 | case NDTPA_PROXY_QLEN: |
2020 | p->proxy_qlen = nla_get_u32(tbp[i]); | 2037 | NEIGH_VAR_SET(p, PROXY_QLEN, |
2038 | nla_get_u32(tbp[i])); | ||
2021 | break; | 2039 | break; |
2022 | case NDTPA_APP_PROBES: | 2040 | case NDTPA_APP_PROBES: |
2023 | p->app_probes = nla_get_u32(tbp[i]); | 2041 | NEIGH_VAR_SET(p, APP_PROBES, |
2042 | nla_get_u32(tbp[i])); | ||
2024 | break; | 2043 | break; |
2025 | case NDTPA_UCAST_PROBES: | 2044 | case NDTPA_UCAST_PROBES: |
2026 | p->ucast_probes = nla_get_u32(tbp[i]); | 2045 | NEIGH_VAR_SET(p, UCAST_PROBES, |
2046 | nla_get_u32(tbp[i])); | ||
2027 | break; | 2047 | break; |
2028 | case NDTPA_MCAST_PROBES: | 2048 | case NDTPA_MCAST_PROBES: |
2029 | p->mcast_probes = nla_get_u32(tbp[i]); | 2049 | NEIGH_VAR_SET(p, MCAST_PROBES, |
2050 | nla_get_u32(tbp[i])); | ||
2030 | break; | 2051 | break; |
2031 | case NDTPA_BASE_REACHABLE_TIME: | 2052 | case NDTPA_BASE_REACHABLE_TIME: |
2032 | p->base_reachable_time = nla_get_msecs(tbp[i]); | 2053 | NEIGH_VAR_SET(p, BASE_REACHABLE_TIME, |
2054 | nla_get_msecs(tbp[i])); | ||
2033 | break; | 2055 | break; |
2034 | case NDTPA_GC_STALETIME: | 2056 | case NDTPA_GC_STALETIME: |
2035 | p->gc_staletime = nla_get_msecs(tbp[i]); | 2057 | NEIGH_VAR_SET(p, GC_STALETIME, |
2058 | nla_get_msecs(tbp[i])); | ||
2036 | break; | 2059 | break; |
2037 | case NDTPA_DELAY_PROBE_TIME: | 2060 | case NDTPA_DELAY_PROBE_TIME: |
2038 | p->delay_probe_time = nla_get_msecs(tbp[i]); | 2061 | NEIGH_VAR_SET(p, DELAY_PROBE_TIME, |
2062 | nla_get_msecs(tbp[i])); | ||
2039 | break; | 2063 | break; |
2040 | case NDTPA_RETRANS_TIME: | 2064 | case NDTPA_RETRANS_TIME: |
2041 | p->retrans_time = nla_get_msecs(tbp[i]); | 2065 | NEIGH_VAR_SET(p, RETRANS_TIME, |
2066 | nla_get_msecs(tbp[i])); | ||
2042 | break; | 2067 | break; |
2043 | case NDTPA_ANYCAST_DELAY: | 2068 | case NDTPA_ANYCAST_DELAY: |
2044 | p->anycast_delay = nla_get_msecs(tbp[i]); | 2069 | NEIGH_VAR_SET(p, ANYCAST_DELAY, nla_get_msecs(tbp[i])); |
2045 | break; | 2070 | break; |
2046 | case NDTPA_PROXY_DELAY: | 2071 | case NDTPA_PROXY_DELAY: |
2047 | p->proxy_delay = nla_get_msecs(tbp[i]); | 2072 | NEIGH_VAR_SET(p, PROXY_DELAY, nla_get_msecs(tbp[i])); |
2048 | break; | 2073 | break; |
2049 | case NDTPA_LOCKTIME: | 2074 | case NDTPA_LOCKTIME: |
2050 | p->locktime = nla_get_msecs(tbp[i]); | 2075 | NEIGH_VAR_SET(p, LOCKTIME, nla_get_msecs(tbp[i])); |
2051 | break; | 2076 | break; |
2052 | } | 2077 | } |
2053 | } | 2078 | } |
@@ -2788,133 +2813,68 @@ static int proc_unres_qlen(struct ctl_table *ctl, int write, | |||
2788 | return ret; | 2813 | return ret; |
2789 | } | 2814 | } |
2790 | 2815 | ||
2791 | enum { | 2816 | static int neigh_proc_dointvec_zero_intmax(struct ctl_table *ctl, int write, |
2792 | NEIGH_VAR_MCAST_PROBE, | 2817 | void __user *buffer, |
2793 | NEIGH_VAR_UCAST_PROBE, | 2818 | size_t *lenp, loff_t *ppos) |
2794 | NEIGH_VAR_APP_PROBE, | 2819 | { |
2795 | NEIGH_VAR_RETRANS_TIME, | 2820 | struct ctl_table tmp = *ctl; |
2796 | NEIGH_VAR_BASE_REACHABLE_TIME, | 2821 | |
2797 | NEIGH_VAR_DELAY_PROBE_TIME, | 2822 | tmp.extra1 = &zero; |
2798 | NEIGH_VAR_GC_STALETIME, | 2823 | tmp.extra2 = &int_max; |
2799 | NEIGH_VAR_QUEUE_LEN, | 2824 | |
2800 | NEIGH_VAR_QUEUE_LEN_BYTES, | 2825 | return proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); |
2801 | NEIGH_VAR_PROXY_QLEN, | 2826 | } |
2802 | NEIGH_VAR_ANYCAST_DELAY, | 2827 | |
2803 | NEIGH_VAR_PROXY_DELAY, | 2828 | #define NEIGH_PARMS_DATA_OFFSET(index) \ |
2804 | NEIGH_VAR_LOCKTIME, | 2829 | (&((struct neigh_parms *) 0)->data[index]) |
2805 | NEIGH_VAR_RETRANS_TIME_MS, | 2830 | |
2806 | NEIGH_VAR_BASE_REACHABLE_TIME_MS, | 2831 | #define NEIGH_SYSCTL_ENTRY(attr, data_attr, name, mval, proc) \ |
2807 | NEIGH_VAR_GC_INTERVAL, | 2832 | [NEIGH_VAR_ ## attr] = { \ |
2808 | NEIGH_VAR_GC_THRESH1, | 2833 | .procname = name, \ |
2809 | NEIGH_VAR_GC_THRESH2, | 2834 | .data = NEIGH_PARMS_DATA_OFFSET(NEIGH_VAR_ ## data_attr), \ |
2810 | NEIGH_VAR_GC_THRESH3, | 2835 | .maxlen = sizeof(int), \ |
2811 | NEIGH_VAR_MAX | 2836 | .mode = mval, \ |
2812 | }; | 2837 | .proc_handler = proc, \ |
2838 | } | ||
2839 | |||
2840 | #define NEIGH_SYSCTL_ZERO_INTMAX_ENTRY(attr, name) \ | ||
2841 | NEIGH_SYSCTL_ENTRY(attr, attr, name, 0644, neigh_proc_dointvec_zero_intmax) | ||
2842 | |||
2843 | #define NEIGH_SYSCTL_JIFFIES_ENTRY(attr, name) \ | ||
2844 | NEIGH_SYSCTL_ENTRY(attr, attr, name, 0644, proc_dointvec_jiffies) | ||
2845 | |||
2846 | #define NEIGH_SYSCTL_USERHZ_JIFFIES_ENTRY(attr, name) \ | ||
2847 | NEIGH_SYSCTL_ENTRY(attr, attr, name, 0644, proc_dointvec_userhz_jiffies) | ||
2848 | |||
2849 | #define NEIGH_SYSCTL_MS_JIFFIES_ENTRY(attr, name) \ | ||
2850 | NEIGH_SYSCTL_ENTRY(attr, attr, name, 0644, proc_dointvec_ms_jiffies) | ||
2851 | |||
2852 | #define NEIGH_SYSCTL_MS_JIFFIES_REUSED_ENTRY(attr, data_attr, name) \ | ||
2853 | NEIGH_SYSCTL_ENTRY(attr, data_attr, name, 0644, proc_dointvec_ms_jiffies) | ||
2854 | |||
2855 | #define NEIGH_SYSCTL_UNRES_QLEN_REUSED_ENTRY(attr, data_attr, name) \ | ||
2856 | NEIGH_SYSCTL_ENTRY(attr, data_attr, name, 0644, proc_unres_qlen) | ||
2813 | 2857 | ||
2814 | static struct neigh_sysctl_table { | 2858 | static struct neigh_sysctl_table { |
2815 | struct ctl_table_header *sysctl_header; | 2859 | struct ctl_table_header *sysctl_header; |
2816 | struct ctl_table neigh_vars[NEIGH_VAR_MAX + 1]; | 2860 | struct ctl_table neigh_vars[NEIGH_VAR_MAX + 1]; |
2817 | } neigh_sysctl_template __read_mostly = { | 2861 | } neigh_sysctl_template __read_mostly = { |
2818 | .neigh_vars = { | 2862 | .neigh_vars = { |
2819 | [NEIGH_VAR_MCAST_PROBE] = { | 2863 | NEIGH_SYSCTL_ZERO_INTMAX_ENTRY(MCAST_PROBES, "mcast_solicit"), |
2820 | .procname = "mcast_solicit", | 2864 | NEIGH_SYSCTL_ZERO_INTMAX_ENTRY(UCAST_PROBES, "ucast_solicit"), |
2821 | .maxlen = sizeof(int), | 2865 | NEIGH_SYSCTL_ZERO_INTMAX_ENTRY(APP_PROBES, "app_solicit"), |
2822 | .mode = 0644, | 2866 | NEIGH_SYSCTL_USERHZ_JIFFIES_ENTRY(RETRANS_TIME, "retrans_time"), |
2823 | .extra1 = &zero, | 2867 | NEIGH_SYSCTL_JIFFIES_ENTRY(BASE_REACHABLE_TIME, "base_reachable_time"), |
2824 | .extra2 = &int_max, | 2868 | NEIGH_SYSCTL_JIFFIES_ENTRY(DELAY_PROBE_TIME, "delay_first_probe_time"), |
2825 | .proc_handler = proc_dointvec_minmax, | 2869 | NEIGH_SYSCTL_JIFFIES_ENTRY(GC_STALETIME, "gc_stale_time"), |
2826 | }, | 2870 | NEIGH_SYSCTL_ZERO_INTMAX_ENTRY(QUEUE_LEN_BYTES, "unres_qlen_bytes"), |
2827 | [NEIGH_VAR_UCAST_PROBE] = { | 2871 | NEIGH_SYSCTL_ZERO_INTMAX_ENTRY(PROXY_QLEN, "proxy_qlen"), |
2828 | .procname = "ucast_solicit", | 2872 | NEIGH_SYSCTL_USERHZ_JIFFIES_ENTRY(ANYCAST_DELAY, "anycast_delay"), |
2829 | .maxlen = sizeof(int), | 2873 | NEIGH_SYSCTL_USERHZ_JIFFIES_ENTRY(PROXY_DELAY, "proxy_delay"), |
2830 | .mode = 0644, | 2874 | NEIGH_SYSCTL_USERHZ_JIFFIES_ENTRY(LOCKTIME, "locktime"), |
2831 | .extra1 = &zero, | 2875 | NEIGH_SYSCTL_UNRES_QLEN_REUSED_ENTRY(QUEUE_LEN, QUEUE_LEN_BYTES, "unres_qlen"), |
2832 | .extra2 = &int_max, | 2876 | NEIGH_SYSCTL_MS_JIFFIES_REUSED_ENTRY(RETRANS_TIME_MS, RETRANS_TIME, "retrans_time_ms"), |
2833 | .proc_handler = proc_dointvec_minmax, | 2877 | NEIGH_SYSCTL_MS_JIFFIES_REUSED_ENTRY(BASE_REACHABLE_TIME_MS, BASE_REACHABLE_TIME, "base_reachable_time_ms"), |
2834 | }, | ||
2835 | [NEIGH_VAR_APP_PROBE] = { | ||
2836 | .procname = "app_solicit", | ||
2837 | .maxlen = sizeof(int), | ||
2838 | .mode = 0644, | ||
2839 | .extra1 = &zero, | ||
2840 | .extra2 = &int_max, | ||
2841 | .proc_handler = proc_dointvec_minmax, | ||
2842 | }, | ||
2843 | [NEIGH_VAR_RETRANS_TIME] = { | ||
2844 | .procname = "retrans_time", | ||
2845 | .maxlen = sizeof(int), | ||
2846 | .mode = 0644, | ||
2847 | .proc_handler = proc_dointvec_userhz_jiffies, | ||
2848 | }, | ||
2849 | [NEIGH_VAR_BASE_REACHABLE_TIME] = { | ||
2850 | .procname = "base_reachable_time", | ||
2851 | .maxlen = sizeof(int), | ||
2852 | .mode = 0644, | ||
2853 | .proc_handler = proc_dointvec_jiffies, | ||
2854 | }, | ||
2855 | [NEIGH_VAR_DELAY_PROBE_TIME] = { | ||
2856 | .procname = "delay_first_probe_time", | ||
2857 | .maxlen = sizeof(int), | ||
2858 | .mode = 0644, | ||
2859 | .proc_handler = proc_dointvec_jiffies, | ||
2860 | }, | ||
2861 | [NEIGH_VAR_GC_STALETIME] = { | ||
2862 | .procname = "gc_stale_time", | ||
2863 | .maxlen = sizeof(int), | ||
2864 | .mode = 0644, | ||
2865 | .proc_handler = proc_dointvec_jiffies, | ||
2866 | }, | ||
2867 | [NEIGH_VAR_QUEUE_LEN] = { | ||
2868 | .procname = "unres_qlen", | ||
2869 | .maxlen = sizeof(int), | ||
2870 | .mode = 0644, | ||
2871 | .proc_handler = proc_unres_qlen, | ||
2872 | }, | ||
2873 | [NEIGH_VAR_QUEUE_LEN_BYTES] = { | ||
2874 | .procname = "unres_qlen_bytes", | ||
2875 | .maxlen = sizeof(int), | ||
2876 | .mode = 0644, | ||
2877 | .extra1 = &zero, | ||
2878 | .proc_handler = proc_dointvec_minmax, | ||
2879 | }, | ||
2880 | [NEIGH_VAR_PROXY_QLEN] = { | ||
2881 | .procname = "proxy_qlen", | ||
2882 | .maxlen = sizeof(int), | ||
2883 | .mode = 0644, | ||
2884 | .extra1 = &zero, | ||
2885 | .extra2 = &int_max, | ||
2886 | .proc_handler = proc_dointvec_minmax, | ||
2887 | }, | ||
2888 | [NEIGH_VAR_ANYCAST_DELAY] = { | ||
2889 | .procname = "anycast_delay", | ||
2890 | .maxlen = sizeof(int), | ||
2891 | .mode = 0644, | ||
2892 | .proc_handler = proc_dointvec_userhz_jiffies, | ||
2893 | }, | ||
2894 | [NEIGH_VAR_PROXY_DELAY] = { | ||
2895 | .procname = "proxy_delay", | ||
2896 | .maxlen = sizeof(int), | ||
2897 | .mode = 0644, | ||
2898 | .proc_handler = proc_dointvec_userhz_jiffies, | ||
2899 | }, | ||
2900 | [NEIGH_VAR_LOCKTIME] = { | ||
2901 | .procname = "locktime", | ||
2902 | .maxlen = sizeof(int), | ||
2903 | .mode = 0644, | ||
2904 | .proc_handler = proc_dointvec_userhz_jiffies, | ||
2905 | }, | ||
2906 | [NEIGH_VAR_RETRANS_TIME_MS] = { | ||
2907 | .procname = "retrans_time_ms", | ||
2908 | .maxlen = sizeof(int), | ||
2909 | .mode = 0644, | ||
2910 | .proc_handler = proc_dointvec_ms_jiffies, | ||
2911 | }, | ||
2912 | [NEIGH_VAR_BASE_REACHABLE_TIME_MS] = { | ||
2913 | .procname = "base_reachable_time_ms", | ||
2914 | .maxlen = sizeof(int), | ||
2915 | .mode = 0644, | ||
2916 | .proc_handler = proc_dointvec_ms_jiffies, | ||
2917 | }, | ||
2918 | [NEIGH_VAR_GC_INTERVAL] = { | 2878 | [NEIGH_VAR_GC_INTERVAL] = { |
2919 | .procname = "gc_interval", | 2879 | .procname = "gc_interval", |
2920 | .maxlen = sizeof(int), | 2880 | .maxlen = sizeof(int), |
@@ -2952,29 +2912,17 @@ static struct neigh_sysctl_table { | |||
2952 | int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p, | 2912 | int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p, |
2953 | char *p_name, proc_handler *handler) | 2913 | char *p_name, proc_handler *handler) |
2954 | { | 2914 | { |
2915 | int i; | ||
2955 | struct neigh_sysctl_table *t; | 2916 | struct neigh_sysctl_table *t; |
2956 | const char *dev_name_source = NULL; | 2917 | const char *dev_name_source; |
2957 | char neigh_path[ sizeof("net//neigh/") + IFNAMSIZ + IFNAMSIZ ]; | 2918 | char neigh_path[ sizeof("net//neigh/") + IFNAMSIZ + IFNAMSIZ ]; |
2958 | 2919 | ||
2959 | t = kmemdup(&neigh_sysctl_template, sizeof(*t), GFP_KERNEL); | 2920 | t = kmemdup(&neigh_sysctl_template, sizeof(*t), GFP_KERNEL); |
2960 | if (!t) | 2921 | if (!t) |
2961 | goto err; | 2922 | goto err; |
2962 | 2923 | ||
2963 | t->neigh_vars[NEIGH_VAR_MCAST_PROBE].data = &p->mcast_probes; | 2924 | for (i = 0; i < ARRAY_SIZE(t->neigh_vars); i++) |
2964 | t->neigh_vars[NEIGH_VAR_UCAST_PROBE].data = &p->ucast_probes; | 2925 | t->neigh_vars[i].data += (long) p; |
2965 | t->neigh_vars[NEIGH_VAR_APP_PROBE].data = &p->app_probes; | ||
2966 | t->neigh_vars[NEIGH_VAR_RETRANS_TIME].data = &p->retrans_time; | ||
2967 | t->neigh_vars[NEIGH_VAR_BASE_REACHABLE_TIME].data = &p->base_reachable_time; | ||
2968 | t->neigh_vars[NEIGH_VAR_DELAY_PROBE_TIME].data = &p->delay_probe_time; | ||
2969 | t->neigh_vars[NEIGH_VAR_GC_STALETIME].data = &p->gc_staletime; | ||
2970 | t->neigh_vars[NEIGH_VAR_QUEUE_LEN].data = &p->queue_len_bytes; | ||
2971 | t->neigh_vars[NEIGH_VAR_QUEUE_LEN_BYTES].data = &p->queue_len_bytes; | ||
2972 | t->neigh_vars[NEIGH_VAR_PROXY_QLEN].data = &p->proxy_qlen; | ||
2973 | t->neigh_vars[NEIGH_VAR_ANYCAST_DELAY].data = &p->anycast_delay; | ||
2974 | t->neigh_vars[NEIGH_VAR_PROXY_DELAY].data = &p->proxy_delay; | ||
2975 | t->neigh_vars[NEIGH_VAR_LOCKTIME].data = &p->locktime; | ||
2976 | t->neigh_vars[NEIGH_VAR_RETRANS_TIME_MS].data = &p->retrans_time; | ||
2977 | t->neigh_vars[NEIGH_VAR_BASE_REACHABLE_TIME_MS].data = &p->base_reachable_time; | ||
2978 | 2926 | ||
2979 | if (dev) { | 2927 | if (dev) { |
2980 | dev_name_source = dev->name; | 2928 | dev_name_source = dev->name; |
@@ -2989,7 +2937,6 @@ int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p, | |||
2989 | t->neigh_vars[NEIGH_VAR_GC_THRESH3].data = (int *)(p + 1) + 3; | 2937 | t->neigh_vars[NEIGH_VAR_GC_THRESH3].data = (int *)(p + 1) + 3; |
2990 | } | 2938 | } |
2991 | 2939 | ||
2992 | |||
2993 | if (handler) { | 2940 | if (handler) { |
2994 | /* RetransTime */ | 2941 | /* RetransTime */ |
2995 | t->neigh_vars[NEIGH_VAR_RETRANS_TIME].proc_handler = handler; | 2942 | t->neigh_vars[NEIGH_VAR_RETRANS_TIME].proc_handler = handler; |
diff --git a/net/decnet/dn_neigh.c b/net/decnet/dn_neigh.c index f8637f93d318..c8121ceddb9e 100644 --- a/net/decnet/dn_neigh.c +++ b/net/decnet/dn_neigh.c | |||
@@ -102,19 +102,21 @@ struct neigh_table dn_neigh_table = { | |||
102 | .id = "dn_neigh_cache", | 102 | .id = "dn_neigh_cache", |
103 | .parms ={ | 103 | .parms ={ |
104 | .tbl = &dn_neigh_table, | 104 | .tbl = &dn_neigh_table, |
105 | .base_reachable_time = 30 * HZ, | 105 | .reachable_time = 30 * HZ, |
106 | .retrans_time = 1 * HZ, | 106 | .data = { |
107 | .gc_staletime = 60 * HZ, | 107 | [NEIGH_VAR_MCAST_PROBES] = 0, |
108 | .reachable_time = 30 * HZ, | 108 | [NEIGH_VAR_UCAST_PROBES] = 0, |
109 | .delay_probe_time = 5 * HZ, | 109 | [NEIGH_VAR_APP_PROBES] = 0, |
110 | .queue_len_bytes = 64*1024, | 110 | [NEIGH_VAR_RETRANS_TIME] = 1 * HZ, |
111 | .ucast_probes = 0, | 111 | [NEIGH_VAR_BASE_REACHABLE_TIME] = 30 * HZ, |
112 | .app_probes = 0, | 112 | [NEIGH_VAR_DELAY_PROBE_TIME] = 5 * HZ, |
113 | .mcast_probes = 0, | 113 | [NEIGH_VAR_GC_STALETIME] = 60 * HZ, |
114 | .anycast_delay = 0, | 114 | [NEIGH_VAR_QUEUE_LEN_BYTES] = 64*1024, |
115 | .proxy_delay = 0, | 115 | [NEIGH_VAR_PROXY_QLEN] = 0, |
116 | .proxy_qlen = 0, | 116 | [NEIGH_VAR_ANYCAST_DELAY] = 0, |
117 | .locktime = 1 * HZ, | 117 | [NEIGH_VAR_PROXY_DELAY] = 0, |
118 | [NEIGH_VAR_LOCKTIME] = 1 * HZ, | ||
119 | }, | ||
118 | }, | 120 | }, |
119 | .gc_interval = 30 * HZ, | 121 | .gc_interval = 30 * HZ, |
120 | .gc_thresh1 = 128, | 122 | .gc_thresh1 = 128, |
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c index 7808093cede6..3a37c7df2a2f 100644 --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c | |||
@@ -166,18 +166,20 @@ struct neigh_table arp_tbl = { | |||
166 | .id = "arp_cache", | 166 | .id = "arp_cache", |
167 | .parms = { | 167 | .parms = { |
168 | .tbl = &arp_tbl, | 168 | .tbl = &arp_tbl, |
169 | .base_reachable_time = 30 * HZ, | ||
170 | .retrans_time = 1 * HZ, | ||
171 | .gc_staletime = 60 * HZ, | ||
172 | .reachable_time = 30 * HZ, | 169 | .reachable_time = 30 * HZ, |
173 | .delay_probe_time = 5 * HZ, | 170 | .data = { |
174 | .queue_len_bytes = 64*1024, | 171 | [NEIGH_VAR_MCAST_PROBES] = 3, |
175 | .ucast_probes = 3, | 172 | [NEIGH_VAR_UCAST_PROBES] = 3, |
176 | .mcast_probes = 3, | 173 | [NEIGH_VAR_RETRANS_TIME] = 1 * HZ, |
177 | .anycast_delay = 1 * HZ, | 174 | [NEIGH_VAR_BASE_REACHABLE_TIME] = 30 * HZ, |
178 | .proxy_delay = (8 * HZ) / 10, | 175 | [NEIGH_VAR_DELAY_PROBE_TIME] = 5 * HZ, |
179 | .proxy_qlen = 64, | 176 | [NEIGH_VAR_GC_STALETIME] = 60 * HZ, |
180 | .locktime = 1 * HZ, | 177 | [NEIGH_VAR_QUEUE_LEN_BYTES] = 64 * 1024, |
178 | [NEIGH_VAR_PROXY_QLEN] = 64, | ||
179 | [NEIGH_VAR_ANYCAST_DELAY] = 1 * HZ, | ||
180 | [NEIGH_VAR_PROXY_DELAY] = (8 * HZ) / 10, | ||
181 | [NEIGH_VAR_LOCKTIME] = 1 * HZ, | ||
182 | }, | ||
181 | }, | 183 | }, |
182 | .gc_interval = 30 * HZ, | 184 | .gc_interval = 30 * HZ, |
183 | .gc_thresh1 = 128, | 185 | .gc_thresh1 = 128, |
@@ -359,14 +361,14 @@ static void arp_solicit(struct neighbour *neigh, struct sk_buff *skb) | |||
359 | if (!saddr) | 361 | if (!saddr) |
360 | saddr = inet_select_addr(dev, target, RT_SCOPE_LINK); | 362 | saddr = inet_select_addr(dev, target, RT_SCOPE_LINK); |
361 | 363 | ||
362 | probes -= neigh->parms->ucast_probes; | 364 | probes -= NEIGH_VAR(neigh->parms, UCAST_PROBES); |
363 | if (probes < 0) { | 365 | if (probes < 0) { |
364 | if (!(neigh->nud_state & NUD_VALID)) | 366 | if (!(neigh->nud_state & NUD_VALID)) |
365 | pr_debug("trying to ucast probe in NUD_INVALID\n"); | 367 | pr_debug("trying to ucast probe in NUD_INVALID\n"); |
366 | neigh_ha_snapshot(dst_ha, neigh, dev); | 368 | neigh_ha_snapshot(dst_ha, neigh, dev); |
367 | dst_hw = dst_ha; | 369 | dst_hw = dst_ha; |
368 | } else { | 370 | } else { |
369 | probes -= neigh->parms->app_probes; | 371 | probes -= NEIGH_VAR(neigh->parms, APP_PROBES); |
370 | if (probes < 0) { | 372 | if (probes < 0) { |
371 | neigh_app_ns(neigh); | 373 | neigh_app_ns(neigh); |
372 | return; | 374 | return; |
@@ -871,7 +873,7 @@ static int arp_process(struct sk_buff *skb) | |||
871 | 873 | ||
872 | if (NEIGH_CB(skb)->flags & LOCALLY_ENQUEUED || | 874 | if (NEIGH_CB(skb)->flags & LOCALLY_ENQUEUED || |
873 | skb->pkt_type == PACKET_HOST || | 875 | skb->pkt_type == PACKET_HOST || |
874 | in_dev->arp_parms->proxy_delay == 0) { | 876 | NEIGH_VAR(in_dev->arp_parms, PROXY_DELAY) == 0) { |
875 | arp_send(ARPOP_REPLY, ETH_P_ARP, sip, | 877 | arp_send(ARPOP_REPLY, ETH_P_ARP, sip, |
876 | dev, tip, sha, dev->dev_addr, | 878 | dev, tip, sha, dev->dev_addr, |
877 | sha); | 879 | sha); |
@@ -910,7 +912,8 @@ static int arp_process(struct sk_buff *skb) | |||
910 | agents are active. Taking the first reply prevents | 912 | agents are active. Taking the first reply prevents |
911 | arp trashing and chooses the fastest router. | 913 | arp trashing and chooses the fastest router. |
912 | */ | 914 | */ |
913 | override = time_after(jiffies, n->updated + n->parms->locktime); | 915 | override = time_after(jiffies, n->updated + |
916 | NEIGH_VAR(n->parms, LOCKTIME)); | ||
914 | 917 | ||
915 | /* Broadcast replies and request packets | 918 | /* Broadcast replies and request packets |
916 | do not assert neighbour reachability. | 919 | do not assert neighbour reachability. |
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 5087cc5cb810..55dc56f9072c 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c | |||
@@ -1071,7 +1071,7 @@ retry: | |||
1071 | 1071 | ||
1072 | regen_advance = idev->cnf.regen_max_retry * | 1072 | regen_advance = idev->cnf.regen_max_retry * |
1073 | idev->cnf.dad_transmits * | 1073 | idev->cnf.dad_transmits * |
1074 | idev->nd_parms->retrans_time / HZ; | 1074 | NEIGH_VAR(idev->nd_parms, RETRANS_TIME) / HZ; |
1075 | write_unlock_bh(&idev->lock); | 1075 | write_unlock_bh(&idev->lock); |
1076 | 1076 | ||
1077 | /* A temporary address is created only if this calculated Preferred | 1077 | /* A temporary address is created only if this calculated Preferred |
@@ -1888,7 +1888,8 @@ static void ipv6_regen_rndid(unsigned long data) | |||
1888 | 1888 | ||
1889 | expires = jiffies + | 1889 | expires = jiffies + |
1890 | idev->cnf.temp_prefered_lft * HZ - | 1890 | idev->cnf.temp_prefered_lft * HZ - |
1891 | idev->cnf.regen_max_retry * idev->cnf.dad_transmits * idev->nd_parms->retrans_time - | 1891 | idev->cnf.regen_max_retry * idev->cnf.dad_transmits * |
1892 | NEIGH_VAR(idev->nd_parms, RETRANS_TIME) - | ||
1892 | idev->cnf.max_desync_factor * HZ; | 1893 | idev->cnf.max_desync_factor * HZ; |
1893 | if (time_before(expires, jiffies)) { | 1894 | if (time_before(expires, jiffies)) { |
1894 | pr_warn("%s: too short regeneration interval; timer disabled for %s\n", | 1895 | pr_warn("%s: too short regeneration interval; timer disabled for %s\n", |
@@ -3188,7 +3189,8 @@ static void addrconf_dad_timer(unsigned long data) | |||
3188 | } | 3189 | } |
3189 | 3190 | ||
3190 | ifp->dad_probes--; | 3191 | ifp->dad_probes--; |
3191 | addrconf_mod_dad_timer(ifp, ifp->idev->nd_parms->retrans_time); | 3192 | addrconf_mod_dad_timer(ifp, |
3193 | NEIGH_VAR(ifp->idev->nd_parms, RETRANS_TIME)); | ||
3192 | spin_unlock(&ifp->lock); | 3194 | spin_unlock(&ifp->lock); |
3193 | write_unlock(&idev->lock); | 3195 | write_unlock(&idev->lock); |
3194 | 3196 | ||
@@ -3509,7 +3511,7 @@ restart: | |||
3509 | !(ifp->flags&IFA_F_TENTATIVE)) { | 3511 | !(ifp->flags&IFA_F_TENTATIVE)) { |
3510 | unsigned long regen_advance = ifp->idev->cnf.regen_max_retry * | 3512 | unsigned long regen_advance = ifp->idev->cnf.regen_max_retry * |
3511 | ifp->idev->cnf.dad_transmits * | 3513 | ifp->idev->cnf.dad_transmits * |
3512 | ifp->idev->nd_parms->retrans_time / HZ; | 3514 | NEIGH_VAR(ifp->idev->nd_parms, RETRANS_TIME) / HZ; |
3513 | 3515 | ||
3514 | if (age >= ifp->prefered_lft - regen_advance) { | 3516 | if (age >= ifp->prefered_lft - regen_advance) { |
3515 | struct inet6_ifaddr *ifpub = ifp->ifpub; | 3517 | struct inet6_ifaddr *ifpub = ifp->ifpub; |
@@ -4231,7 +4233,7 @@ static int inet6_fill_ifla6_attrs(struct sk_buff *skb, struct inet6_dev *idev) | |||
4231 | ci.max_reasm_len = IPV6_MAXPLEN; | 4233 | ci.max_reasm_len = IPV6_MAXPLEN; |
4232 | ci.tstamp = cstamp_delta(idev->tstamp); | 4234 | ci.tstamp = cstamp_delta(idev->tstamp); |
4233 | ci.reachable_time = jiffies_to_msecs(idev->nd_parms->reachable_time); | 4235 | ci.reachable_time = jiffies_to_msecs(idev->nd_parms->reachable_time); |
4234 | ci.retrans_time = jiffies_to_msecs(idev->nd_parms->retrans_time); | 4236 | ci.retrans_time = jiffies_to_msecs(NEIGH_VAR(idev->nd_parms, RETRANS_TIME)); |
4235 | if (nla_put(skb, IFLA_INET6_CACHEINFO, sizeof(ci), &ci)) | 4237 | if (nla_put(skb, IFLA_INET6_CACHEINFO, sizeof(ci), &ci)) |
4236 | goto nla_put_failure; | 4238 | goto nla_put_failure; |
4237 | nla = nla_reserve(skb, IFLA_INET6_CONF, DEVCONF_MAX * sizeof(s32)); | 4239 | nla = nla_reserve(skb, IFLA_INET6_CONF, DEVCONF_MAX * sizeof(s32)); |
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c index 300865171394..0da0986a9292 100644 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c | |||
@@ -125,17 +125,19 @@ struct neigh_table nd_tbl = { | |||
125 | .id = "ndisc_cache", | 125 | .id = "ndisc_cache", |
126 | .parms = { | 126 | .parms = { |
127 | .tbl = &nd_tbl, | 127 | .tbl = &nd_tbl, |
128 | .base_reachable_time = ND_REACHABLE_TIME, | ||
129 | .retrans_time = ND_RETRANS_TIMER, | ||
130 | .gc_staletime = 60 * HZ, | ||
131 | .reachable_time = ND_REACHABLE_TIME, | 128 | .reachable_time = ND_REACHABLE_TIME, |
132 | .delay_probe_time = 5 * HZ, | 129 | .data = { |
133 | .queue_len_bytes = 64*1024, | 130 | [NEIGH_VAR_MCAST_PROBES] = 3, |
134 | .ucast_probes = 3, | 131 | [NEIGH_VAR_UCAST_PROBES] = 3, |
135 | .mcast_probes = 3, | 132 | [NEIGH_VAR_RETRANS_TIME] = ND_RETRANS_TIMER, |
136 | .anycast_delay = 1 * HZ, | 133 | [NEIGH_VAR_BASE_REACHABLE_TIME] = ND_REACHABLE_TIME, |
137 | .proxy_delay = (8 * HZ) / 10, | 134 | [NEIGH_VAR_DELAY_PROBE_TIME] = 5 * HZ, |
138 | .proxy_qlen = 64, | 135 | [NEIGH_VAR_GC_STALETIME] = 60 * HZ, |
136 | [NEIGH_VAR_QUEUE_LEN_BYTES] = 64 * 1024, | ||
137 | [NEIGH_VAR_PROXY_QLEN] = 64, | ||
138 | [NEIGH_VAR_ANYCAST_DELAY] = 1 * HZ, | ||
139 | [NEIGH_VAR_PROXY_DELAY] = (8 * HZ) / 10, | ||
140 | }, | ||
139 | }, | 141 | }, |
140 | .gc_interval = 30 * HZ, | 142 | .gc_interval = 30 * HZ, |
141 | .gc_thresh1 = 128, | 143 | .gc_thresh1 = 128, |
@@ -656,14 +658,14 @@ static void ndisc_solicit(struct neighbour *neigh, struct sk_buff *skb) | |||
656 | if (skb && ipv6_chk_addr(dev_net(dev), &ipv6_hdr(skb)->saddr, dev, 1)) | 658 | if (skb && ipv6_chk_addr(dev_net(dev), &ipv6_hdr(skb)->saddr, dev, 1)) |
657 | saddr = &ipv6_hdr(skb)->saddr; | 659 | saddr = &ipv6_hdr(skb)->saddr; |
658 | 660 | ||
659 | if ((probes -= neigh->parms->ucast_probes) < 0) { | 661 | if ((probes -= NEIGH_VAR(neigh->parms, UCAST_PROBES)) < 0) { |
660 | if (!(neigh->nud_state & NUD_VALID)) { | 662 | if (!(neigh->nud_state & NUD_VALID)) { |
661 | ND_PRINTK(1, dbg, | 663 | ND_PRINTK(1, dbg, |
662 | "%s: trying to ucast probe in NUD_INVALID: %pI6\n", | 664 | "%s: trying to ucast probe in NUD_INVALID: %pI6\n", |
663 | __func__, target); | 665 | __func__, target); |
664 | } | 666 | } |
665 | ndisc_send_ns(dev, neigh, target, target, saddr); | 667 | ndisc_send_ns(dev, neigh, target, target, saddr); |
666 | } else if ((probes -= neigh->parms->app_probes) < 0) { | 668 | } else if ((probes -= NEIGH_VAR(neigh->parms, APP_PROBES)) < 0) { |
667 | neigh_app_ns(neigh); | 669 | neigh_app_ns(neigh); |
668 | } else { | 670 | } else { |
669 | addrconf_addr_solict_mult(target, &mcaddr); | 671 | addrconf_addr_solict_mult(target, &mcaddr); |
@@ -790,7 +792,7 @@ static void ndisc_recv_ns(struct sk_buff *skb) | |||
790 | if (!(NEIGH_CB(skb)->flags & LOCALLY_ENQUEUED) && | 792 | if (!(NEIGH_CB(skb)->flags & LOCALLY_ENQUEUED) && |
791 | skb->pkt_type != PACKET_HOST && | 793 | skb->pkt_type != PACKET_HOST && |
792 | inc && | 794 | inc && |
793 | idev->nd_parms->proxy_delay != 0) { | 795 | NEIGH_VAR(idev->nd_parms, PROXY_DELAY) != 0) { |
794 | /* | 796 | /* |
795 | * for anycast or proxy, | 797 | * for anycast or proxy, |
796 | * sender should delay its response | 798 | * sender should delay its response |
@@ -1210,7 +1212,7 @@ skip_defrtr: | |||
1210 | rtime = (rtime*HZ)/1000; | 1212 | rtime = (rtime*HZ)/1000; |
1211 | if (rtime < HZ/10) | 1213 | if (rtime < HZ/10) |
1212 | rtime = HZ/10; | 1214 | rtime = HZ/10; |
1213 | in6_dev->nd_parms->retrans_time = rtime; | 1215 | NEIGH_VAR_SET(in6_dev->nd_parms, RETRANS_TIME, rtime); |
1214 | in6_dev->tstamp = jiffies; | 1216 | in6_dev->tstamp = jiffies; |
1215 | inet6_ifinfo_notify(RTM_NEWLINK, in6_dev); | 1217 | inet6_ifinfo_notify(RTM_NEWLINK, in6_dev); |
1216 | } | 1218 | } |
@@ -1222,9 +1224,11 @@ skip_defrtr: | |||
1222 | if (rtime < HZ/10) | 1224 | if (rtime < HZ/10) |
1223 | rtime = HZ/10; | 1225 | rtime = HZ/10; |
1224 | 1226 | ||
1225 | if (rtime != in6_dev->nd_parms->base_reachable_time) { | 1227 | if (rtime != NEIGH_VAR(in6_dev->nd_parms, BASE_REACHABLE_TIME)) { |
1226 | in6_dev->nd_parms->base_reachable_time = rtime; | 1228 | NEIGH_VAR_SET(in6_dev->nd_parms, |
1227 | in6_dev->nd_parms->gc_staletime = 3 * rtime; | 1229 | BASE_REACHABLE_TIME, rtime); |
1230 | NEIGH_VAR_SET(in6_dev->nd_parms, | ||
1231 | GC_STALETIME, 3 * rtime); | ||
1228 | in6_dev->nd_parms->reachable_time = neigh_rand_reach_time(rtime); | 1232 | in6_dev->nd_parms->reachable_time = neigh_rand_reach_time(rtime); |
1229 | in6_dev->tstamp = jiffies; | 1233 | in6_dev->tstamp = jiffies; |
1230 | inet6_ifinfo_notify(RTM_NEWLINK, in6_dev); | 1234 | inet6_ifinfo_notify(RTM_NEWLINK, in6_dev); |
@@ -1665,8 +1669,9 @@ int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write, void __user *bu | |||
1665 | ret = -1; | 1669 | ret = -1; |
1666 | 1670 | ||
1667 | if (write && ret == 0 && dev && (idev = in6_dev_get(dev)) != NULL) { | 1671 | if (write && ret == 0 && dev && (idev = in6_dev_get(dev)) != NULL) { |
1668 | if (ctl->data == &idev->nd_parms->base_reachable_time) | 1672 | if (ctl->data == &NEIGH_VAR(idev->nd_parms, BASE_REACHABLE_TIME)) |
1669 | idev->nd_parms->reachable_time = neigh_rand_reach_time(idev->nd_parms->base_reachable_time); | 1673 | idev->nd_parms->reachable_time = |
1674 | neigh_rand_reach_time(NEIGH_VAR(idev->nd_parms, BASE_REACHABLE_TIME)); | ||
1670 | idev->tstamp = jiffies; | 1675 | idev->tstamp = jiffies; |
1671 | inet6_ifinfo_notify(RTM_NEWLINK, idev); | 1676 | inet6_ifinfo_notify(RTM_NEWLINK, idev); |
1672 | in6_dev_put(idev); | 1677 | in6_dev_put(idev); |