mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-05-29 23:09:34 +00:00
Merge pull request #4435 from donaldsharp/zclient_buffer_sizing
lib, zebra: Ensure route encoding has enough space
This commit is contained in:
commit
32e4ce5fd5
@ -62,10 +62,13 @@ struct zclient *zclient_new(struct thread_master *master,
|
||||
struct zclient_options *opt)
|
||||
{
|
||||
struct zclient *zclient;
|
||||
size_t stream_size =
|
||||
MAX(ZEBRA_MAX_PACKET_SIZ, sizeof(struct zapi_route));
|
||||
|
||||
zclient = XCALLOC(MTYPE_ZCLIENT, sizeof(struct zclient));
|
||||
|
||||
zclient->ibuf = stream_new(ZEBRA_MAX_PACKET_SIZ);
|
||||
zclient->obuf = stream_new(ZEBRA_MAX_PACKET_SIZ);
|
||||
zclient->ibuf = stream_new(stream_size);
|
||||
zclient->obuf = stream_new(stream_size);
|
||||
zclient->wb = buffer_new(0);
|
||||
zclient->master = master;
|
||||
|
||||
|
@ -39,7 +39,7 @@
|
||||
#include "mlag.h"
|
||||
|
||||
/* For input/output buffer to zebra. */
|
||||
#define ZEBRA_MAX_PACKET_SIZ 16384
|
||||
#define ZEBRA_MAX_PACKET_SIZ 16384U
|
||||
|
||||
/* Zebra header size. */
|
||||
#define ZEBRA_HEADER_SIZE 10
|
||||
|
@ -524,6 +524,8 @@ int zsend_redistribute_route(int cmd, struct zserv *client,
|
||||
struct nexthop *nexthop;
|
||||
int count = 0;
|
||||
afi_t afi;
|
||||
size_t stream_size =
|
||||
MAX(ZEBRA_MAX_PACKET_SIZ, sizeof(struct zapi_route));
|
||||
|
||||
memset(&api, 0, sizeof(api));
|
||||
api.vrf_id = re->vrf_id;
|
||||
@ -605,7 +607,7 @@ int zsend_redistribute_route(int cmd, struct zserv *client,
|
||||
SET_FLAG(api.message, ZAPI_MESSAGE_MTU);
|
||||
api.mtu = re->mtu;
|
||||
|
||||
struct stream *s = stream_new(ZEBRA_MAX_PACKET_SIZ);
|
||||
struct stream *s = stream_new(stream_size);
|
||||
|
||||
/* Encode route and send. */
|
||||
if (zapi_route_encode(cmd, s, &api) < 0) {
|
||||
|
@ -682,6 +682,8 @@ static int zserv_handle_client_fail(struct thread *thread)
|
||||
static struct zserv *zserv_client_create(int sock)
|
||||
{
|
||||
struct zserv *client;
|
||||
size_t stream_size =
|
||||
MAX(ZEBRA_MAX_PACKET_SIZ, sizeof(struct zapi_route));
|
||||
int i;
|
||||
afi_t afi;
|
||||
|
||||
@ -691,8 +693,8 @@ static struct zserv *zserv_client_create(int sock)
|
||||
client->sock = sock;
|
||||
client->ibuf_fifo = stream_fifo_new();
|
||||
client->obuf_fifo = stream_fifo_new();
|
||||
client->ibuf_work = stream_new(ZEBRA_MAX_PACKET_SIZ);
|
||||
client->obuf_work = stream_new(ZEBRA_MAX_PACKET_SIZ);
|
||||
client->ibuf_work = stream_new(stream_size);
|
||||
client->obuf_work = stream_new(stream_size);
|
||||
pthread_mutex_init(&client->ibuf_mtx, NULL);
|
||||
pthread_mutex_init(&client->obuf_mtx, NULL);
|
||||
client->wb = buffer_new(0);
|
||||
|
Loading…
Reference in New Issue
Block a user