]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib, zebra: Ensure route encoding has enough space 4435/head
authorDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 31 May 2019 12:51:07 +0000 (08:51 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 31 May 2019 14:25:18 +0000 (10:25 -0400)
When you have compiled FRR with a large multipath number
then encoding large ecmp routes between zebra and the
routing daemons.  There exists a theoritical size
of multipath that will cause the encoding to be larger
than the ZEBRA_MAX_PACKET_SIZ.  In the cases where
we have allocated streams that will encode routes
then let's ensure that whatever size we have will
auto-fit what we say we can send.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
lib/zclient.c
lib/zclient.h
zebra/zapi_msg.c
zebra/zserv.c

index 0972590ca695e9dfd70a1102e22dca1301c8b7c7..e9b4f5a58b1797473f6b6f368ff3746a086f105c 100644 (file)
@@ -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;
 
index 09f0acad844cbdbb04f6754a654115440b0f1a17..c61c8d4226d8199152c48fd44702f3a27bfc7a53 100644 (file)
@@ -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
index 94bfa34b38c127dbf82d54c5d55d0dd3c7741688..49e43f4942e759bee6a440c3a45e67097030ed9b 100644 (file)
@@ -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) {
index fbb5af875db20fd9c14db0f4e49d72bda7f4219a..49fb302ba82e71eb163d5bd09d523097ba40a539 100644 (file)
@@ -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);