net: neigh: decrement the family specific qlen
authorThomas Zeitlhofer <thomas.zeitlhofer+lkml@ze-it.at>
Tue, 15 Nov 2022 22:09:41 +0000 (23:09 +0100)
committerSalvatore Bonaccorso <carnil@debian.org>
Thu, 1 Dec 2022 06:42:33 +0000 (06:42 +0000)
commit08a745cbe1854e61b81425afc803f286b786eac2
treee567fe84bee074e48da3e8f3ed8dac6804981e98
parent7b1f55b152d1f362078c81d70cf06782963149ff
net: neigh: decrement the family specific qlen

Origin: https://git.kernel.org/linus/8207f253a097fe15c93d85ac15ebb73c5e39e1e1
Bug-Debian: https://bugs.debian.org/1024070

Commit 0ff4eb3d5ebb ("neighbour: make proxy_queue.qlen limit
per-device") introduced the length counter qlen in struct neigh_parms.
There are separate neigh_parms instances for IPv4/ARP and IPv6/ND, and
while the family specific qlen is incremented in pneigh_enqueue(), the
mentioned commit decrements always the IPv4/ARP specific qlen,
regardless of the currently processed family, in pneigh_queue_purge()
and neigh_proxy_process().

As a result, with IPv6/ND, the family specific qlen is only incremented
(and never decremented) until it exceeds PROXY_QLEN, and then, according
to the check in pneigh_enqueue(), neighbor solicitations are not
answered anymore. As an example, this is noted when using the
subnet-router anycast address to access a Linux router. After a certain
amount of time (in the observed case, qlen exceeded PROXY_QLEN after two
days), the Linux router stops answering neighbor solicitations for its
subnet-router anycast address and effectively becomes unreachable.

Another result with IPv6/ND is that the IPv4/ARP specific qlen is
decremented more often than incremented. This leads to negative qlen
values, as a signed integer has been used for the length counter qlen,
and potentially to an integer overflow.

Fix this by introducing the helper function neigh_parms_qlen_dec(),
which decrements the family specific qlen. Thereby, make use of the
existing helper function neigh_get_dev_parms_rcu(), whose definition
therefore needs to be placed earlier in neighbour.c. Take the family
member from struct neigh_table to determine the currently processed
family and appropriately call neigh_parms_qlen_dec() from
pneigh_queue_purge() and neigh_proxy_process().

Additionally, use an unsigned integer for the length counter qlen.

Fixes: 0ff4eb3d5ebb ("neighbour: make proxy_queue.qlen limit per-device")
Signed-off-by: Thomas Zeitlhofer <thomas.zeitlhofer+lkml@ze-it.at>
Signed-off-by: David S. Miller <davem@davemloft.net>
Gbp-Pq: Topic bugfix/all
Gbp-Pq: Name net-neigh-decrement-the-family-specific-qlen.patch
include/net/neighbour.h
net/core/neighbour.c