summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/zclient.c7
-rw-r--r--lib/zclient.h2
-rw-r--r--zebra/zapi_msg.c4
-rw-r--r--zebra/zserv.c6
4 files changed, 13 insertions, 6 deletions
diff --git a/lib/zclient.c b/lib/zclient.c
index 0972590ca6..e9b4f5a58b 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -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;
diff --git a/lib/zclient.h b/lib/zclient.h
index 09f0acad84..c61c8d4226 100644
--- a/lib/zclient.h
+++ b/lib/zclient.h
@@ -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
diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c
index 94bfa34b38..49e43f4942 100644
--- a/zebra/zapi_msg.c
+++ b/zebra/zapi_msg.c
@@ -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) {
diff --git a/zebra/zserv.c b/zebra/zserv.c
index fbb5af875d..49fb302ba8 100644
--- a/zebra/zserv.c
+++ b/zebra/zserv.c
@@ -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);