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/kernel_netlink.h | |
| 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/kernel_netlink.h')
| -rw-r--r-- | zebra/kernel_netlink.h | 2 | 
1 files changed, 1 insertions, 1 deletions
diff --git a/zebra/kernel_netlink.h b/zebra/kernel_netlink.h index ae88f3372b..9421ea1c61 100644 --- a/zebra/kernel_netlink.h +++ b/zebra/kernel_netlink.h @@ -96,7 +96,7 @@ extern const char *nl_family_to_str(uint8_t family);  extern const char *nl_rttype_to_str(uint8_t rttype);  extern int netlink_parse_info(int (*filter)(struct nlmsghdr *, ns_id_t, int), -			      const struct nlsock *nl, +			      struct nlsock *nl,  			      const struct zebra_dplane_info *dp_info,  			      int count, bool startup);  extern int netlink_talk_filter(struct nlmsghdr *h, ns_id_t ns, int startup);  | 
