diff options
| author | Donald Sharp <sharpd@nvidia.com> | 2022-02-02 13:28:42 -0500 | 
|---|---|---|
| committer | Donald Sharp <sharpd@nvidia.com> | 2022-02-08 17:28:19 -0500 | 
| commit | 2cf7651f0b1b0123dc5568ebad00ac84a9b3c348 (patch) | |
| tree | 8d9ecc0e1094e399bfba0339c8b7fe96f17671d4 /zebra/zebra_dplane.c | |
| parent | d4000d7ba3242c0e6adfa56544a34312b0f566a9 (diff) | |
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>
Diffstat (limited to 'zebra/zebra_dplane.c')
| -rw-r--r-- | zebra/zebra_dplane.c | 4 | 
1 files changed, 4 insertions, 0 deletions
diff --git a/zebra/zebra_dplane.c b/zebra/zebra_dplane.c index 05297e143b..4d32e54d1f 100644 --- a/zebra/zebra_dplane.c +++ b/zebra/zebra_dplane.c @@ -1469,7 +1469,11 @@ int dplane_ctx_get_ns_sock(const struct zebra_dplane_ctx *ctx)  {  	DPLANE_CTX_VALID(ctx); +#ifdef HAVE_NETLINK  	return ctx->zd_ns_info.sock; +#else +	return -1; +#endif  }  /* Accessors for nexthop information */  | 
