]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib, zebra: Allow zapi to send down the tableid
authorDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 9 Feb 2018 23:38:02 +0000 (18:38 -0500)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 9 Mar 2018 16:07:41 +0000 (11:07 -0500)
Allow the calling daemon to pass down what table-id we
want to use to install the route.  Useful for PBR.

The vrf id passed must be the VRF_DEFAULT else this
value is ignored.

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

index f853824bbba3d819a0b3d0f4bb0b130f68b3ddf3..3f2021a5b541c77a3d3658ab28c41cf1298122a5 100644 (file)
@@ -1058,6 +1058,8 @@ int zapi_route_encode(u_char cmd, struct stream *s, struct zapi_route *api)
                stream_putl(s, api->tag);
        if (CHECK_FLAG(api->message, ZAPI_MESSAGE_MTU))
                stream_putl(s, api->mtu);
+       if (CHECK_FLAG(api->message, ZAPI_MESSAGE_TABLEID))
+               stream_putl(s, api->tableid);
 
        /* Put length at the first point of the stream. */
        stream_putw_at(s, 0, stream_get_endp(s));
@@ -1207,6 +1209,8 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)
                STREAM_GETL(s, api->tag);
        if (CHECK_FLAG(api->message, ZAPI_MESSAGE_MTU))
                STREAM_GETL(s, api->mtu);
+       if (CHECK_FLAG(api->message, ZAPI_MESSAGE_TABLEID))
+               STREAM_GETL(s, api->tableid);
 
 stream_failure:
        return 0;
index 1848440db29fe149055ad72de1ef2d2f0f126e4b..39566b17398081b1abeeb572b57a64348db682ea 100644 (file)
@@ -225,6 +225,12 @@ struct zclient {
 #define ZAPI_MESSAGE_MTU      0x10
 #define ZAPI_MESSAGE_SRCPFX   0x20
 #define ZAPI_MESSAGE_LABEL    0x40
+/*
+ * This should only be used by a DAEMON that needs to communicate
+ * the table being used is not in the VRF.  You must pass the
+ * default vrf, else this will be ignored.
+ */
+#define ZAPI_MESSAGE_TABLEID  0x80
 
 /* Zserv protocol message header */
 struct zserv_header {
@@ -289,6 +295,8 @@ struct zapi_route {
 
        vrf_id_t vrf_id;
 
+       uint32_t tableid;
+
        struct ethaddr rmac;
 };
 
index 8275ee1a3c1ea451a5866a14f9c5d70c49908821..d245e097244a1ae14d19b3d6a30bda58815302d5 100644 (file)
@@ -1164,7 +1164,10 @@ static int zread_route_add(struct zserv *client, u_short length,
        re->flags = api.flags;
        re->uptime = time(NULL);
        re->vrf_id = vrf_id;
-       re->table = zvrf->table_id;
+       if (api.tableid && vrf_id == VRF_DEFAULT)
+               re->table = api.tableid;
+       else
+               re->table = zvrf->table_id;
 
        if (CHECK_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP)) {
                for (i = 0; i < api.nexthop_num; i++) {