Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

neigh: increase queue_len_bytes to match wmem_default

Florian reported UDP xmit drops that could be root caused to the
too small neigh limit.

Current limit is 64 KB, meaning that even a single UDP socket would hit
it, since its default sk_sndbuf comes from net.core.wmem_default
(~212992 bytes on 64bit arches).

Once ARP/ND resolution is in progress, we should allow a little more
packets to be queued, at least for one producer.

Once neigh arp_queue is filled, a rogue socket should hit its sk_sndbuf
limit and either block in sendmsg() or return -EAGAIN.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Eric Dumazet and committed by
David S. Miller
eaa72dc4 0dd5759d

+19 -16
+5 -2
Documentation/networking/ip-sysctl.txt
··· 109 109 queued for each unresolved address by other network layers. 110 110 (added in linux 3.3) 111 111 Setting negative value is meaningless and will return error. 112 - Default: 65536 Bytes(64KB) 112 + Default: SK_WMEM_MAX, (same as net.core.wmem_default). 113 + Exact value depends on architecture and kernel options, 114 + but should be enough to allow queuing 256 packets 115 + of medium size. 113 116 114 117 neigh/default/unres_qlen - INTEGER 115 118 The maximum number of packets which may be queued for each ··· 122 119 unexpected packet loss. The current default value is calculated 123 120 according to default value of unres_qlen_bytes and true size of 124 121 packet. 125 - Default: 31 122 + Default: 101 126 123 127 124 mtu_expires - INTEGER 128 125 Time, in seconds, that cached PMTU information is kept.
+10
include/net/sock.h
··· 2368 2368 2369 2369 void sk_get_meminfo(const struct sock *sk, u32 *meminfo); 2370 2370 2371 + /* Take into consideration the size of the struct sk_buff overhead in the 2372 + * determination of these values, since that is non-constant across 2373 + * platforms. This makes socket queueing behavior and performance 2374 + * not depend upon such differences. 2375 + */ 2376 + #define _SK_MEM_PACKETS 256 2377 + #define _SK_MEM_OVERHEAD SKB_TRUESIZE(256) 2378 + #define SK_WMEM_MAX (_SK_MEM_OVERHEAD * _SK_MEM_PACKETS) 2379 + #define SK_RMEM_MAX (_SK_MEM_OVERHEAD * _SK_MEM_PACKETS) 2380 + 2371 2381 extern __u32 sysctl_wmem_max; 2372 2382 extern __u32 sysctl_rmem_max; 2373 2383
-10
net/core/sock.c
··· 307 307 static struct lock_class_key af_elock_keys[AF_MAX]; 308 308 static struct lock_class_key af_kern_callback_keys[AF_MAX]; 309 309 310 - /* Take into consideration the size of the struct sk_buff overhead in the 311 - * determination of these values, since that is non-constant across 312 - * platforms. This makes socket queueing behavior and performance 313 - * not depend upon such differences. 314 - */ 315 - #define _SK_MEM_PACKETS 256 316 - #define _SK_MEM_OVERHEAD SKB_TRUESIZE(256) 317 - #define SK_WMEM_MAX (_SK_MEM_OVERHEAD * _SK_MEM_PACKETS) 318 - #define SK_RMEM_MAX (_SK_MEM_OVERHEAD * _SK_MEM_PACKETS) 319 - 320 310 /* Run time adjustable parameters. */ 321 311 __u32 sysctl_wmem_max __read_mostly = SK_WMEM_MAX; 322 312 EXPORT_SYMBOL(sysctl_wmem_max);
+1 -1
net/decnet/dn_neigh.c
··· 94 94 [NEIGH_VAR_BASE_REACHABLE_TIME] = 30 * HZ, 95 95 [NEIGH_VAR_DELAY_PROBE_TIME] = 5 * HZ, 96 96 [NEIGH_VAR_GC_STALETIME] = 60 * HZ, 97 - [NEIGH_VAR_QUEUE_LEN_BYTES] = 64*1024, 97 + [NEIGH_VAR_QUEUE_LEN_BYTES] = SK_WMEM_MAX, 98 98 [NEIGH_VAR_PROXY_QLEN] = 0, 99 99 [NEIGH_VAR_ANYCAST_DELAY] = 0, 100 100 [NEIGH_VAR_PROXY_DELAY] = 0,
+1 -1
net/ipv4/arp.c
··· 171 171 [NEIGH_VAR_BASE_REACHABLE_TIME] = 30 * HZ, 172 172 [NEIGH_VAR_DELAY_PROBE_TIME] = 5 * HZ, 173 173 [NEIGH_VAR_GC_STALETIME] = 60 * HZ, 174 - [NEIGH_VAR_QUEUE_LEN_BYTES] = 64 * 1024, 174 + [NEIGH_VAR_QUEUE_LEN_BYTES] = SK_WMEM_MAX, 175 175 [NEIGH_VAR_PROXY_QLEN] = 64, 176 176 [NEIGH_VAR_ANYCAST_DELAY] = 1 * HZ, 177 177 [NEIGH_VAR_PROXY_DELAY] = (8 * HZ) / 10,
+1 -1
net/ipv4/tcp_input.c
··· 6086 6086 struct tcp_sock *tp = tcp_sk(sk); 6087 6087 struct net *net = sock_net(sk); 6088 6088 struct sock *fastopen_sk = NULL; 6089 - struct dst_entry *dst = NULL; 6090 6089 struct request_sock *req; 6091 6090 bool want_cookie = false; 6091 + struct dst_entry *dst; 6092 6092 struct flowi fl; 6093 6093 6094 6094 /* TW buckets are converted to open requests without
+1 -1
net/ipv6/ndisc.c
··· 127 127 [NEIGH_VAR_BASE_REACHABLE_TIME] = ND_REACHABLE_TIME, 128 128 [NEIGH_VAR_DELAY_PROBE_TIME] = 5 * HZ, 129 129 [NEIGH_VAR_GC_STALETIME] = 60 * HZ, 130 - [NEIGH_VAR_QUEUE_LEN_BYTES] = 64 * 1024, 130 + [NEIGH_VAR_QUEUE_LEN_BYTES] = SK_WMEM_MAX, 131 131 [NEIGH_VAR_PROXY_QLEN] = 64, 132 132 [NEIGH_VAR_ANYCAST_DELAY] = 1 * HZ, 133 133 [NEIGH_VAR_PROXY_DELAY] = (8 * HZ) / 10,