mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-04-30 22:26:28 +00:00

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>
91 lines
2.2 KiB
C
91 lines
2.2 KiB
C
/*
|
|
* Zebra NS header
|
|
* Copyright (C) 2016 Cumulus Networks, Inc.
|
|
* Donald Sharp
|
|
*
|
|
* This file is part of Quagga.
|
|
*
|
|
* Quagga is free software; you can redistribute it and/or modify it
|
|
* under the terms of the GNU General Public License as published by the
|
|
* Free Software Foundation; either version 2, or (at your option) any
|
|
* later version.
|
|
*
|
|
* Quagga is distributed in the hope that it will be useful, but
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along
|
|
* with this program; see the file COPYING; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
#if !defined(__ZEBRA_NS_H__)
|
|
#define __ZEBRA_NS_H__
|
|
|
|
#include <lib/ns.h>
|
|
#include <lib/vrf.h>
|
|
|
|
#include "zebra/rib.h"
|
|
#include "zebra/zebra_vrf.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#ifdef HAVE_NETLINK
|
|
/* Socket interface to kernel */
|
|
struct nlsock {
|
|
int sock;
|
|
int seq;
|
|
struct sockaddr_nl snl;
|
|
char name[64];
|
|
|
|
uint8_t *buf;
|
|
size_t buflen;
|
|
};
|
|
#endif
|
|
|
|
struct zebra_ns {
|
|
/* net-ns name. */
|
|
char name[VRF_NAMSIZ];
|
|
|
|
/* Identifier. */
|
|
ns_id_t ns_id;
|
|
|
|
#ifdef HAVE_NETLINK
|
|
struct nlsock netlink; /* kernel messages */
|
|
struct nlsock netlink_cmd; /* command channel */
|
|
|
|
/* dplane system's channels: one for outgoing programming,
|
|
* for the FIB e.g., and one for incoming events from the OS.
|
|
*/
|
|
struct nlsock netlink_dplane_out;
|
|
struct nlsock netlink_dplane_in;
|
|
struct thread *t_netlink;
|
|
#endif
|
|
|
|
struct route_table *if_table;
|
|
|
|
/* Back pointer */
|
|
struct ns *ns;
|
|
};
|
|
|
|
struct zebra_ns *zebra_ns_lookup(ns_id_t ns_id);
|
|
|
|
int zebra_ns_init(void);
|
|
int zebra_ns_enable(ns_id_t ns_id, void **info);
|
|
int zebra_ns_disabled(struct ns *ns);
|
|
int zebra_ns_early_shutdown(struct ns *ns,
|
|
void *param_in __attribute__((unused)),
|
|
void **param_out __attribute__((unused)));
|
|
int zebra_ns_final_shutdown(struct ns *ns,
|
|
void *param_in __attribute__((unused)),
|
|
void **param_out __attribute__((unused)));
|
|
int zebra_ns_config_write(struct vty *vty, struct ns *ns);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|