]> git.proxmox.com Git - mirror_frr.git/commit - zebra/kernel_netlink.h
zebra: Make netlink buffer reads resizeable when needed
authorDonald Sharp <sharpd@nvidia.com>
Wed, 2 Feb 2022 18:28:42 +0000 (13:28 -0500)
committerDonald Sharp <sharpd@nvidia.com>
Tue, 8 Feb 2022 22:28:19 +0000 (17:28 -0500)
commit2cf7651f0b1b0123dc5568ebad00ac84a9b3c348
tree8d9ecc0e1094e399bfba0339c8b7fe96f17671d4
parentd4000d7ba3242c0e6adfa56544a34312b0f566a9
zebra: Make netlink buffer reads resizeable when needed

Currently when the kernel sends netlink messages to FRR
the buffers to receive this data is of fixed length.
The kernel, with certain configurations, will send
netlink messages that are larger than this fixed length.
This leads to situations where, on startup, zebra gets
really confused about the state of the kernel.  Effectively
the current algorithm is this:

read up to buffer in size
while (data to parse)
     get netlink message header, look at size
        parse if you can

The problem is that there is a 32k buffer we read.
We get the first message that is say 1k in size,
subtract that 1k to 31k left to parse.  We then
get the next header and notice that the length
of the message is 33k.  Which is obviously larger
than what we read in.  FRR has no recover mechanism
nor is there a way to know, a priori, what the maximum
size the kernel will send us.

Modify FRR to look at the kernel message and see if the
buffer is large enough, if not, make it large enough to
read in the message.

This code has to be per netlink socket because of the usage
of pthreads.  So add to `struct nlsock` the buffer and current
buffer length.  Growing it as necessary.

Fixes: #10404
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
zebra/kernel_netlink.c
zebra/kernel_netlink.h
zebra/zebra_dplane.c
zebra/zebra_ns.h