]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: Add pass up through zapi what zebra is capable of handling 2086/head
authorDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 18 Apr 2018 15:10:27 +0000 (11:10 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 18 Apr 2018 15:10:27 +0000 (11:10 -0400)
Zebra is starting to have some run-time capabilites that would be
useful to pass up to the higher level protocols so that they
can act in an appropriate manner when needed.

Send the ecmp value zebra is being run with and whether or not
we believe mpls is enabled in the kernel or not.

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

index e1ce40ce70ca5d7dcbf4c440d2469535bf4f4642..ff4a2c70278c14a9304df9cd9c7c18601aab65b9 100644 (file)
@@ -2480,6 +2480,25 @@ void zebra_read_pw_status_update(int command, struct zclient *zclient,
        pw->status = stream_getl(s);
 }
 
+static void zclient_capability_decode(int command, struct zclient *zclient,
+                                     zebra_size_t length, vrf_id_t vrf_id)
+{
+       struct zclient_capabilities cap;
+       struct stream *s = zclient->ibuf;
+       uint8_t mpls_enabled;
+
+       memset(&cap, 0, sizeof(cap));
+       STREAM_GETC(s, mpls_enabled);
+       cap.mpls_enabled = !!mpls_enabled;
+       STREAM_GETL(s, cap.ecmp);
+
+       if (zclient->zebra_capabilities)
+               (*zclient->zebra_capabilities)(&cap);
+
+stream_failure:
+       return;
+}
+
 /* Zebra client message read function. */
 static int zclient_read(struct thread *thread)
 {
@@ -2577,6 +2596,9 @@ static int zclient_read(struct thread *thread)
                           (void *)zclient, command, vrf_id);
 
        switch (command) {
+       case ZEBRA_CAPABILITIES:
+               zclient_capability_decode(command, zclient, length, vrf_id);
+               break;
        case ZEBRA_ROUTER_ID_UPDATE:
                if (zclient->router_id_update)
                        (*zclient->router_id_update)(command, zclient, length,
index 985239b3260a6de7a30ae8e92c08df54c9549cff..71f5b383843bb39155609de6e7149a70d0654a6d 100644 (file)
@@ -85,6 +85,7 @@ typedef enum {
        ZEBRA_ROUTER_ID_DELETE,
        ZEBRA_ROUTER_ID_UPDATE,
        ZEBRA_HELLO,
+       ZEBRA_CAPABILITIES,
        ZEBRA_NEXTHOP_REGISTER,
        ZEBRA_NEXTHOP_UNREGISTER,
        ZEBRA_NEXTHOP_UPDATE,
@@ -162,6 +163,11 @@ struct redist_proto {
        struct list *instances;
 };
 
+struct zclient_capabilities {
+       uint32_t ecmp;
+       bool mpls_enabled;
+};
+
 /* Structure for the zebra client. */
 struct zclient {
        /* The thread master we schedule ourselves on */
@@ -206,6 +212,7 @@ struct zclient {
 
        /* Pointer to the callback functions. */
        void (*zebra_connected)(struct zclient *);
+       void (*zebra_capabilities)(struct zclient_capabilities *cap);
        int (*router_id_update)(int, struct zclient *, uint16_t, vrf_id_t);
        int (*interface_add)(int, struct zclient *, uint16_t, vrf_id_t);
        int (*interface_delete)(int, struct zclient *, uint16_t, vrf_id_t);
index 94c20c1d136812ec3e0dabaa6f256686eeb4ec20..fa1679b387d92f8274f3a265429c1d90012fc141 100644 (file)
@@ -2148,6 +2148,18 @@ static void zread_router_id_delete(ZAPI_HANDLER_ARGS)
        vrf_bitmap_unset(client->ridinfo, zvrf_id(zvrf));
 }
 
+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_putc(s, mpls_enabled);
+       stream_putl(s, multipath_num);
+
+       stream_putw_at(s, 0, stream_get_endp(s));
+       zebra_server_send_message(client, s);
+}
+
 /* Tie up route-type and client->sock */
 static void zread_hello(ZAPI_HANDLER_ARGS)
 {
@@ -2175,6 +2187,7 @@ static void zread_hello(ZAPI_HANDLER_ARGS)
                client->instance = instance;
        }
 
+       zsend_capabilities(client, zvrf);
 stream_failure:
        return;
 }