]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: modify mlag code to only need 1 stream when generating data
authorDonald Sharp <sharpd@nvidia.com>
Wed, 23 Sep 2020 16:26:13 +0000 (12:26 -0400)
committerIgor Ryzhov <iryzhov@nfware.com>
Tue, 6 Oct 2020 12:54:25 +0000 (15:54 +0300)
The normal pattern of writing the type/length at the beginning
of the packet was not being quite followed.  Modify the mlag
code to respect the proper way of doing things and get rid
of a stream_new and copy.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
zebra/zebra_mlag.c

index 3cf4ba8d393d599a6d1a403e5c58f37505e18a6d..fb8798ebd9857297eb702e4fdfcb11168d098688 100644 (file)
@@ -111,10 +111,13 @@ void zebra_mlag_send_deregister(void)
 void zebra_mlag_process_mlag_data(uint8_t *data, uint32_t len)
 {
        struct stream *s = NULL;
-       struct stream *s1 = NULL;
        int msg_type = 0;
 
        s = stream_new(ZEBRA_MAX_PACKET_SIZ);
+       /*
+        * Place holder we need the message type first
+        */
+       stream_putl(s, msg_type);
        msg_type = zebra_mlag_protobuf_decode_message(s, data, len);
 
        if (msg_type <= 0) {
@@ -128,12 +131,9 @@ void zebra_mlag_process_mlag_data(uint8_t *data, uint32_t len)
        /*
         * additional four bytes are for message type
         */
-       s1 = stream_new(stream_get_endp(s) + ZEBRA_MLAG_METADATA_LEN);
-       stream_putl(s1, msg_type);
-       stream_put(s1, s->data, stream_get_endp(s));
+       stream_putl_at(s, 0, msg_type);
        thread_add_event(zrouter.master, zebra_mlag_post_data_from_main_thread,
-                        s1, 0, NULL);
-       stream_free(s);
+                        s, 0, NULL);
 }
 
 /**********************End of MLAG Interaction********************************/