Skip to content

Commit 8b5c171

Browse files
Eric Dumazetdavem330
authored andcommitted
neigh: new unresolved queue limits
Le mercredi 09 novembre 2011 à 16:21 -0500, David Miller a écrit : > From: David Miller <davem@davemloft.net> > Date: Wed, 09 Nov 2011 16:16:44 -0500 (EST) > > > From: Eric Dumazet <eric.dumazet@gmail.com> > > Date: Wed, 09 Nov 2011 12:14:09 +0100 > > > >> unres_qlen is the number of frames we are able to queue per unresolved > >> neighbour. Its default value (3) was never changed and is responsible > >> for strange drops, especially if IP fragments are used, or multiple > >> sessions start in parallel. Even a single tcp flow can hit this limit. > > ... > > > > Ok, I've applied this, let's see what happens :-) > > Early answer, build fails. > > Please test build this patch with DECNET enabled and resubmit. The > decnet neigh layer still refers to the removed ->queue_len member. > > Thanks. Ouch, this was fixed on one machine yesterday, but not the other one I used this morning, sorry. [PATCH V5 net-next] neigh: new unresolved queue limits unres_qlen is the number of frames we are able to queue per unresolved neighbour. Its default value (3) was never changed and is responsible for strange drops, especially if IP fragments are used, or multiple sessions start in parallel. Even a single tcp flow can hit this limit. $ arp -d 192.168.20.108 ; ping -c 2 -s 8000 192.168.20.108 PING 192.168.20.108 (192.168.20.108) 8000(8028) bytes of data. 8008 bytes from 192.168.20.108: icmp_seq=2 ttl=64 time=0.322 ms Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 292d139 commit 8b5c171

8 files changed

Lines changed: 128 additions & 56 deletions

File tree

‎Documentation/networking/ip-sysctl.txt‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ neigh/default/gc_thresh3 - INTEGER
3131
when using large numbers of interfaces and when communicating
3232
with large numbers of directly-connected peers.
3333

34+
neigh/default/unres_qlen_bytes - INTEGER
35+
The maximum number of bytes which may be used by packets
36+
queued for each unresolved address by other network layers.
37+
(added in linux 3.3)
38+
39+
neigh/default/unres_qlen - INTEGER
40+
The maximum number of packets which may be queued for each
41+
unresolved address by other network layers.
42+
(deprecated in linux 3.3) : use unres_qlen_bytes instead.
43+
3444
mtu_expires - INTEGER
3545
Time, in seconds, that cached PMTU information is kept.
3646

‎include/linux/neighbour.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ enum {
116116
NDTPA_PROXY_DELAY, /* u64, msecs */
117117
NDTPA_PROXY_QLEN, /* u32 */
118118
NDTPA_LOCKTIME, /* u64, msecs */
119+
NDTPA_QUEUE_LENBYTES, /* u32 */
119120
__NDTPA_MAX
120121
};
121122
#define NDTPA_MAX (__NDTPA_MAX - 1)

‎include/net/neighbour.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ struct neigh_parms {
5959
int reachable_time;
6060
int delay_probe_time;
6161

62-
int queue_len;
62+
int queue_len_bytes;
6363
int ucast_probes;
6464
int app_probes;
6565
int mcast_probes;
@@ -99,6 +99,7 @@ struct neighbour {
9999
rwlock_t lock;
100100
atomic_t refcnt;
101101
struct sk_buff_head arp_queue;
102+
unsigned int arp_queue_len_bytes;
102103
struct timer_list timer;
103104
unsigned long used;
104105
atomic_t probes;

‎net/atm/clip.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ static struct neigh_table clip_tbl = {
329329
.gc_staletime = 60 * HZ,
330330
.reachable_time = 30 * HZ,
331331
.delay_probe_time = 5 * HZ,
332-
.queue_len = 3,
332+
.queue_len_bytes = 64 * 1024,
333333
.ucast_probes = 3,
334334
.mcast_probes = 3,
335335
.anycast_delay = 1 * HZ,

‎net/core/neighbour.c‎

Lines changed: 111 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ static void neigh_flush_dev(struct neigh_table *tbl, struct net_device *dev)
238238
it to safe state.
239239
*/
240240
skb_queue_purge(&n->arp_queue);
241+
n->arp_queue_len_bytes = 0;
241242
n->output = neigh_blackhole;
242243
if (n->nud_state & NUD_VALID)
243244
n->nud_state = NUD_NOARP;
@@ -702,6 +703,7 @@ void neigh_destroy(struct neighbour *neigh)
702703
printk(KERN_WARNING "Impossible event.\n");
703704

704705
skb_queue_purge(&neigh->arp_queue);
706+
neigh->arp_queue_len_bytes = 0;
705707

706708
dev_put(neigh->dev);
707709
neigh_parms_put(neigh->parms);
@@ -842,6 +844,7 @@ static void neigh_invalidate(struct neighbour *neigh)
842844
write_lock(&neigh->lock);
843845
}
844846
skb_queue_purge(&neigh->arp_queue);
847+
neigh->arp_queue_len_bytes = 0;
845848
}
846849

847850
static void neigh_probe(struct neighbour *neigh)
@@ -980,15 +983,20 @@ int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb)
980983

981984
if (neigh->nud_state == NUD_INCOMPLETE) {
982985
if (skb) {
983-
if (skb_queue_len(&neigh->arp_queue) >=
984-
neigh->parms->queue_len) {
986+
while (neigh->arp_queue_len_bytes + skb->truesize >
987+
neigh->parms->queue_len_bytes) {
985988
struct sk_buff *buff;
989+
986990
buff = __skb_dequeue(&neigh->arp_queue);
991+
if (!buff)
992+
break;
993+
neigh->arp_queue_len_bytes -= buff->truesize;
987994
kfree_skb(buff);
988995
NEIGH_CACHE_STAT_INC(neigh->tbl, unres_discards);
989996
}
990997
skb_dst_force(skb);
991998
__skb_queue_tail(&neigh->arp_queue, skb);
999+
neigh->arp_queue_len_bytes += skb->truesize;
9921000
}
9931001
rc = 1;
9941002
}
@@ -1175,6 +1183,7 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new,
11751183
write_lock_bh(&neigh->lock);
11761184
}
11771185
skb_queue_purge(&neigh->arp_queue);
1186+
neigh->arp_queue_len_bytes = 0;
11781187
}
11791188
out:
11801189
if (update_isrouter) {
@@ -1747,7 +1756,11 @@ static int neightbl_fill_parms(struct sk_buff *skb, struct neigh_parms *parms)
17471756
NLA_PUT_U32(skb, NDTPA_IFINDEX, parms->dev->ifindex);
17481757

17491758
NLA_PUT_U32(skb, NDTPA_REFCNT, atomic_read(&parms->refcnt));
1750-
NLA_PUT_U32(skb, NDTPA_QUEUE_LEN, parms->queue_len);
1759+
NLA_PUT_U32(skb, NDTPA_QUEUE_LENBYTES, parms->queue_len_bytes);
1760+
/* approximative value for deprecated QUEUE_LEN (in packets) */
1761+
NLA_PUT_U32(skb, NDTPA_QUEUE_LEN,
1762+
DIV_ROUND_UP(parms->queue_len_bytes,
1763+
SKB_TRUESIZE(ETH_FRAME_LEN)));
17511764
NLA_PUT_U32(skb, NDTPA_PROXY_QLEN, parms->proxy_qlen);
17521765
NLA_PUT_U32(skb, NDTPA_APP_PROBES, parms->app_probes);
17531766
NLA_PUT_U32(skb, NDTPA_UCAST_PROBES, parms->ucast_probes);
@@ -1974,7 +1987,11 @@ static int neightbl_set(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
19741987

19751988
switch (i) {
19761989
case NDTPA_QUEUE_LEN:
1977-
p->queue_len = nla_get_u32(tbp[i]);
1990+
p->queue_len_bytes = nla_get_u32(tbp[i]) *
1991+
SKB_TRUESIZE(ETH_FRAME_LEN);
1992+
break;
1993+
case NDTPA_QUEUE_LENBYTES:
1994+
p->queue_len_bytes = nla_get_u32(tbp[i]);
19781995
break;
19791996
case NDTPA_PROXY_QLEN:
19801997
p->proxy_qlen = nla_get_u32(tbp[i]);
@@ -2635,117 +2652,158 @@ EXPORT_SYMBOL(neigh_app_ns);
26352652

26362653
#ifdef CONFIG_SYSCTL
26372654

2638-
#define NEIGH_VARS_MAX 19
2655+
static int proc_unres_qlen(ctl_table *ctl, int write, void __user *buffer,
2656+
size_t *lenp, loff_t *ppos)
2657+
{
2658+
int size, ret;
2659+
ctl_table tmp = *ctl;
2660+
2661+
tmp.data = &size;
2662+
size = DIV_ROUND_UP(*(int *)ctl->data, SKB_TRUESIZE(ETH_FRAME_LEN));
2663+
ret = proc_dointvec(&tmp, write, buffer, lenp, ppos);
2664+
if (write && !ret)
2665+
*(int *)ctl->data = size * SKB_TRUESIZE(ETH_FRAME_LEN);
2666+
return ret;
2667+
}
2668+
2669+
enum {
2670+
NEIGH_VAR_MCAST_PROBE,
2671+
NEIGH_VAR_UCAST_PROBE,
2672+
NEIGH_VAR_APP_PROBE,
2673+
NEIGH_VAR_RETRANS_TIME,
2674+
NEIGH_VAR_BASE_REACHABLE_TIME,
2675+
NEIGH_VAR_DELAY_PROBE_TIME,
2676+
NEIGH_VAR_GC_STALETIME,
2677+
NEIGH_VAR_QUEUE_LEN,
2678+
NEIGH_VAR_QUEUE_LEN_BYTES,
2679+
NEIGH_VAR_PROXY_QLEN,
2680+
NEIGH_VAR_ANYCAST_DELAY,
2681+
NEIGH_VAR_PROXY_DELAY,
2682+
NEIGH_VAR_LOCKTIME,
2683+
NEIGH_VAR_RETRANS_TIME_MS,
2684+
NEIGH_VAR_BASE_REACHABLE_TIME_MS,
2685+
NEIGH_VAR_GC_INTERVAL,
2686+
NEIGH_VAR_GC_THRESH1,
2687+
NEIGH_VAR_GC_THRESH2,
2688+
NEIGH_VAR_GC_THRESH3,
2689+
NEIGH_VAR_MAX
2690+
};
26392691

26402692
static struct neigh_sysctl_table {
26412693
struct ctl_table_header *sysctl_header;
2642-
struct ctl_table neigh_vars[NEIGH_VARS_MAX];
2694+
struct ctl_table neigh_vars[NEIGH_VAR_MAX + 1];
26432695
char *dev_name;
26442696
} neigh_sysctl_template __read_mostly = {
26452697
.neigh_vars = {
2646-
{
2698+
[NEIGH_VAR_MCAST_PROBE] = {
26472699
.procname = "mcast_solicit",
26482700
.maxlen = sizeof(int),
26492701
.mode = 0644,
26502702
.proc_handler = proc_dointvec,
26512703
},
2652-
{
2704+
[NEIGH_VAR_UCAST_PROBE] = {
26532705
.procname = "ucast_solicit",
26542706
.maxlen = sizeof(int),
26552707
.mode = 0644,
26562708
.proc_handler = proc_dointvec,
26572709
},
2658-
{
2710+
[NEIGH_VAR_APP_PROBE] = {
26592711
.procname = "app_solicit",
26602712
.maxlen = sizeof(int),
26612713
.mode = 0644,
26622714
.proc_handler = proc_dointvec,
26632715
},
2664-
{
2716+
[NEIGH_VAR_RETRANS_TIME] = {
26652717
.procname = "retrans_time",
26662718
.maxlen = sizeof(int),
26672719
.mode = 0644,
26682720
.proc_handler = proc_dointvec_userhz_jiffies,
26692721
},
2670-
{
2722+
[NEIGH_VAR_BASE_REACHABLE_TIME] = {
26712723
.procname = "base_reachable_time",
26722724
.maxlen = sizeof(int),
26732725
.mode = 0644,
26742726
.proc_handler = proc_dointvec_jiffies,
26752727
},
2676-
{
2728+
[NEIGH_VAR_DELAY_PROBE_TIME] = {
26772729
.procname = "delay_first_probe_time",
26782730
.maxlen = sizeof(int),
26792731
.mode = 0644,
26802732
.proc_handler = proc_dointvec_jiffies,
26812733
},
2682-
{
2734+
[NEIGH_VAR_GC_STALETIME] = {
26832735
.procname = "gc_stale_time",
26842736
.maxlen = sizeof(int),
26852737
.mode = 0644,
26862738
.proc_handler = proc_dointvec_jiffies,
26872739
},
2688-
{
2740+
[NEIGH_VAR_QUEUE_LEN] = {
26892741
.procname = "unres_qlen",
26902742
.maxlen = sizeof(int),
26912743
.mode = 0644,
2744+
.proc_handler = proc_unres_qlen,
2745+
},
2746+
[NEIGH_VAR_QUEUE_LEN_BYTES] = {
2747+
.procname = "unres_qlen_bytes",
2748+
.maxlen = sizeof(int),
2749+
.mode = 0644,
26922750
.proc_handler = proc_dointvec,
26932751
},
2694-
{
2752+
[NEIGH_VAR_PROXY_QLEN] = {
26952753
.procname = "proxy_qlen",
26962754
.maxlen = sizeof(int),
26972755
.mode = 0644,
26982756
.proc_handler = proc_dointvec,
26992757
},
2700-
{
2758+
[NEIGH_VAR_ANYCAST_DELAY] = {
27012759
.procname = "anycast_delay",
27022760
.maxlen = sizeof(int),
27032761
.mode = 0644,
27042762
.proc_handler = proc_dointvec_userhz_jiffies,
27052763
},
2706-
{
2764+
[NEIGH_VAR_PROXY_DELAY] = {
27072765
.procname = "proxy_delay",
27082766
.maxlen = sizeof(int),
27092767
.mode = 0644,
27102768
.proc_handler = proc_dointvec_userhz_jiffies,
27112769
},
2712-
{
2770+
[NEIGH_VAR_LOCKTIME] = {
27132771
.procname = "locktime",
27142772
.maxlen = sizeof(int),
27152773
.mode = 0644,
27162774
.proc_handler = proc_dointvec_userhz_jiffies,
27172775
},
2718-
{
2776+
[NEIGH_VAR_RETRANS_TIME_MS] = {
27192777
.procname = "retrans_time_ms",
27202778
.maxlen = sizeof(int),
27212779
.mode = 0644,
27222780
.proc_handler = proc_dointvec_ms_jiffies,
27232781
},
2724-
{
2782+
[NEIGH_VAR_BASE_REACHABLE_TIME_MS] = {
27252783
.procname = "base_reachable_time_ms",
27262784
.maxlen = sizeof(int),
27272785
.mode = 0644,
27282786
.proc_handler = proc_dointvec_ms_jiffies,
27292787
},
2730-
{
2788+
[NEIGH_VAR_GC_INTERVAL] = {
27312789
.procname = "gc_interval",
27322790
.maxlen = sizeof(int),
27332791
.mode = 0644,
27342792
.proc_handler = proc_dointvec_jiffies,
27352793
},
2736-
{
2794+
[NEIGH_VAR_GC_THRESH1] = {
27372795
.procname = "gc_thresh1",
27382796
.maxlen = sizeof(int),
27392797
.mode = 0644,
27402798
.proc_handler = proc_dointvec,
27412799
},
2742-
{
2800+
[NEIGH_VAR_GC_THRESH2] = {
27432801
.procname = "gc_thresh2",
27442802
.maxlen = sizeof(int),
27452803
.mode = 0644,
27462804
.proc_handler = proc_dointvec,
27472805
},
2748-
{
2806+
[NEIGH_VAR_GC_THRESH3] = {
27492807
.procname = "gc_thresh3",
27502808
.maxlen = sizeof(int),
27512809
.mode = 0644,
@@ -2778,47 +2836,49 @@ int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p,
27782836
if (!t)
27792837
goto err;
27802838

2781-
t->neigh_vars[0].data = &p->mcast_probes;
2782-
t->neigh_vars[1].data = &p->ucast_probes;
2783-
t->neigh_vars[2].data = &p->app_probes;
2784-
t->neigh_vars[3].data = &p->retrans_time;
2785-
t->neigh_vars[4].data = &p->base_reachable_time;
2786-
t->neigh_vars[5].data = &p->delay_probe_time;
2787-
t->neigh_vars[6].data = &p->gc_staletime;
2788-
t->neigh_vars[7].data = &p->queue_len;
2789-
t->neigh_vars[8].data = &p->proxy_qlen;
2790-
t->neigh_vars[9].data = &p->anycast_delay;
2791-
t->neigh_vars[10].data = &p->proxy_delay;
2792-
t->neigh_vars[11].data = &p->locktime;
2793-
t->neigh_vars[12].data = &p->retrans_time;
2794-
t->neigh_vars[13].data = &p->base_reachable_time;
2839+
t->neigh_vars[NEIGH_VAR_MCAST_PROBE].data = &p->mcast_probes;
2840+
t->neigh_vars[NEIGH_VAR_UCAST_PROBE].data = &p->ucast_probes;
2841+
t->neigh_vars[NEIGH_VAR_APP_PROBE].data = &p->app_probes;
2842+
t->neigh_vars[NEIGH_VAR_RETRANS_TIME].data = &p->retrans_time;
2843+
t->neigh_vars[NEIGH_VAR_BASE_REACHABLE_TIME].data = &p->base_reachable_time;
2844+
t->neigh_vars[NEIGH_VAR_DELAY_PROBE_TIME].data = &p->delay_probe_time;
2845+
t->neigh_vars[NEIGH_VAR_GC_STALETIME].data = &p->gc_staletime;
2846+
t->neigh_vars[NEIGH_VAR_QUEUE_LEN].data = &p->queue_len_bytes;
2847+
t->neigh_vars[NEIGH_VAR_QUEUE_LEN_BYTES].data = &p->queue_len_bytes;
2848+
t->neigh_vars[NEIGH_VAR_PROXY_QLEN].data = &p->proxy_qlen;
2849+
t->neigh_vars[NEIGH_VAR_ANYCAST_DELAY].data = &p->anycast_delay;
2850+
t->neigh_vars[NEIGH_VAR_PROXY_DELAY].data = &p->proxy_delay;
2851+
t->neigh_vars[NEIGH_VAR_LOCKTIME].data = &p->locktime;
2852+
t->neigh_vars[NEIGH_VAR_RETRANS_TIME_MS].data = &p->retrans_time;
2853+
t->neigh_vars[NEIGH_VAR_BASE_REACHABLE_TIME_MS].data = &p->base_reachable_time;
27952854

27962855
if (dev) {
27972856
dev_name_source = dev->name;
27982857
/* Terminate the table early */
2799-
memset(&t->neigh_vars[14], 0, sizeof(t->neigh_vars[14]));
2858+
memset(&t->neigh_vars[NEIGH_VAR_GC_INTERVAL], 0,
2859+
sizeof(t->neigh_vars[NEIGH_VAR_GC_INTERVAL]));
28002860
} else {
28012861
dev_name_source = neigh_path[NEIGH_CTL_PATH_DEV].procname;
2802-
t->neigh_vars[14].data = (int *)(p + 1);
2803-
t->neigh_vars[15].data = (int *)(p + 1) + 1;
2804-
t->neigh_vars[16].data = (int *)(p + 1) + 2;
2805-
t->neigh_vars[17].data = (int *)(p + 1) + 3;
2862+
t->neigh_vars[NEIGH_VAR_GC_INTERVAL].data = (int *)(p + 1);
2863+
t->neigh_vars[NEIGH_VAR_GC_THRESH1].data = (int *)(p + 1) + 1;
2864+
t->neigh_vars[NEIGH_VAR_GC_THRESH2].data = (int *)(p + 1) + 2;
2865+
t->neigh_vars[NEIGH_VAR_GC_THRESH3].data = (int *)(p + 1) + 3;
28062866
}
28072867

28082868

28092869
if (handler) {
28102870
/* RetransTime */
2811-
t->neigh_vars[3].proc_handler = handler;
2812-
t->neigh_vars[3].extra1 = dev;
2871+
t->neigh_vars[NEIGH_VAR_RETRANS_TIME].proc_handler = handler;
2872+
t->neigh_vars[NEIGH_VAR_RETRANS_TIME].extra1 = dev;
28132873
/* ReachableTime */
2814-
t->neigh_vars[4].proc_handler = handler;
2815-
t->neigh_vars[4].extra1 = dev;
2874+
t->neigh_vars[NEIGH_VAR_BASE_REACHABLE_TIME].proc_handler = handler;
2875+
t->neigh_vars[NEIGH_VAR_BASE_REACHABLE_TIME].extra1 = dev;
28162876
/* RetransTime (in milliseconds)*/
2817-
t->neigh_vars[12].proc_handler = handler;
2818-
t->neigh_vars[12].extra1 = dev;
2877+
t->neigh_vars[NEIGH_VAR_RETRANS_TIME_MS].proc_handler = handler;
2878+
t->neigh_vars[NEIGH_VAR_RETRANS_TIME_MS].extra1 = dev;
28192879
/* ReachableTime (in milliseconds) */
2820-
t->neigh_vars[13].proc_handler = handler;
2821-
t->neigh_vars[13].extra1 = dev;
2880+
t->neigh_vars[NEIGH_VAR_BASE_REACHABLE_TIME_MS].proc_handler = handler;
2881+
t->neigh_vars[NEIGH_VAR_BASE_REACHABLE_TIME_MS].extra1 = dev;
28222882
}
28232883

28242884
t->dev_name = kstrdup(dev_name_source, GFP_KERNEL);

‎net/decnet/dn_neigh.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ struct neigh_table dn_neigh_table = {
107107
.gc_staletime = 60 * HZ,
108108
.reachable_time = 30 * HZ,
109109
.delay_probe_time = 5 * HZ,
110-
.queue_len = 3,
110+
.queue_len_bytes = 64*1024,
111111
.ucast_probes = 0,
112112
.app_probes = 0,
113113
.mcast_probes = 0,

0 commit comments

Comments
 (0)