]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra, lib: send VRF backend to the client daemons
authorRenato Westphal <renato@opensourcerouting.org>
Sat, 19 Jan 2019 19:19:13 +0000 (17:19 -0200)
committerRenato Westphal <renato@opensourcerouting.org>
Sun, 20 Jan 2019 00:46:37 +0000 (22:46 -0200)
Add a new field in the ZEBRA_CAPABILITIES zapi message specifying
the VRF backend in use.

For simplicity, make the zclient code call vrf_configure_backend()
to apply the received value automatically instead of requiring
the daemons to do that themselves in their zebra_capabilities()
callbacks.

Additionally, call zebra_vrf_update_all() only after sending the
capabilities message to the client, so that it will know which VRF
backend is in use when processing the VRF messages.

This commit fixes a couple of bugs in the "interface" CLI command and
associated northbound callbacks, which behave differently depending
on the VRF backend in use. Before this commit, the vrf_backend
variable would always be set to VRF_BACKEND_NETNS in the client
daemons, even when zebra was started without the --vrfwnetns option.
This could lead to inconsistent behavior and subtle bugs under
specific circumstances.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
lib/zclient.c
zebra/zapi_msg.c
zebra/zserv.c

index cc936d47d773ce6fd442d543eb76c205bf20184d..0a2bea0c9f172132105ecf03c9547e8d1af8d4db 100644 (file)
@@ -2372,8 +2372,12 @@ static void zclient_capability_decode(int command, struct zclient *zclient,
 {
        struct zclient_capabilities cap;
        struct stream *s = zclient->ibuf;
+       int vrf_backend;
        uint8_t mpls_enabled;
 
+       STREAM_GETL(s, vrf_backend);
+       vrf_configure_backend(vrf_backend);
+
        memset(&cap, 0, sizeof(cap));
        STREAM_GETC(s, mpls_enabled);
        cap.mpls_enabled = !!mpls_enabled;
index 15f9da0cba747b09d2e1f36aff9ea43ece465f58..a9a4f5d2ac60ae501d07318d01bdcaa4d71981c2 100644 (file)
@@ -1656,6 +1656,7 @@ static void zsend_capabilities(struct zserv *client, struct zebra_vrf *zvrf)
        struct stream *s = stream_new(ZEBRA_MAX_PACKET_SIZ);
 
        zclient_create_header(s, ZEBRA_CAPABILITIES, zvrf->vrf->vrf_id);
+       stream_putl(s, vrf_get_backend());
        stream_putc(s, mpls_enabled);
        stream_putl(s, multipath_num);
        stream_putc(s, zebra_mlag_get_role());
@@ -1692,6 +1693,7 @@ static void zread_hello(ZAPI_HANDLER_ARGS)
        }
 
        zsend_capabilities(client, zvrf);
+       zebra_vrf_update_all(client);
 stream_failure:
        return;
 }
index 502186d226a2e4742d5164818b2ea9b2fdc3eccd..766dd54fb3467249c370e3312f71c286e346faf8 100644 (file)
@@ -723,8 +723,6 @@ static struct zserv *zserv_client_create(int sock)
                frr_pthread_new(&zclient_pthr_attrs, "Zebra API client thread",
                                "zebra_apic");
 
-       zebra_vrf_update_all(client);
-
        /* start read loop */
        zserv_client_event(client, ZSERV_CLIENT_READ);