]> git.puffer.fish Git - matthieu/frr.git/commitdiff
libs,zebra: remove zapi nhg encode and decode public apis
authorMark Stapp <mjs@voltanet.io>
Mon, 4 Jan 2021 17:50:19 +0000 (12:50 -0500)
committerMark Stapp <mjs@voltanet.io>
Tue, 19 Jan 2021 13:48:54 +0000 (08:48 -0500)
The raw zapi apis to encode and decode NHGs don't need to be
public; also add a little more validity-checking.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
lib/zclient.c
lib/zclient.h
zebra/zapi_msg.c

index f16c94369b65c86cd882ac66ed976d7363c119cc..bfdf4971bbc0ee1e71dc94f55d75633f8e757a84 100644 (file)
@@ -996,7 +996,7 @@ done:
        return ret;
 }
 
-int zapi_nhg_encode(struct stream *s, int cmd, struct zapi_nhg *api_nhg)
+static int zapi_nhg_encode(struct stream *s, int cmd, struct zapi_nhg *api_nhg)
 {
        int i;
 
@@ -1007,6 +1007,13 @@ int zapi_nhg_encode(struct stream *s, int cmd, struct zapi_nhg *api_nhg)
                return -1;
        }
 
+       if (api_nhg->nexthop_num >= MULTIPATH_NUM ||
+           api_nhg->backup_nexthop_num >= MULTIPATH_NUM) {
+               flog_err(EC_LIB_ZAPI_ENCODE,
+                        "%s: zapi NHG encode with invalid input\n", __func__);
+               return -1;
+       }
+
        stream_reset(s);
        zclient_create_header(s, cmd, VRF_DEFAULT);
 
@@ -1024,7 +1031,6 @@ int zapi_nhg_encode(struct stream *s, int cmd, struct zapi_nhg *api_nhg)
                        zapi_nexthop_encode(s, &api_nhg->nexthops[i], 0, 0);
 
                /* Backup nexthops */
-
                stream_putw(s, api_nhg->backup_nexthop_num);
 
                for (i = 0; i < api_nhg->backup_nexthop_num; i++)
index 57bad7c2e6cdcef53c8cf310d2393e23f5d77e11..cf52ea91a0019e1716395b3d49d95a270c1a1cec 100644 (file)
@@ -1021,9 +1021,7 @@ bool zapi_ipset_notify_decode(struct stream *s,
                              uint32_t *unique,
                             enum zapi_ipset_notify_owner *note);
 
-
-extern int zapi_nhg_encode(struct stream *s, int cmd, struct zapi_nhg *api_nhg);
-extern int zapi_nhg_decode(struct stream *s, int cmd, struct zapi_nhg *api_nhg);
+/* Nexthop-group message apis */
 extern enum zclient_send_status
 zclient_nhg_send(struct zclient *zclient, int cmd, struct zapi_nhg *api_nhg);
 
index 90c6a24e7b6621d3bfb535cd2443394f1b590387..a62e020e4a63abddb0d0597e54743b1899325c22 100644 (file)
@@ -62,6 +62,8 @@
 #include "zebra/zebra_opaque.h"
 #include "zebra/zebra_srte.h"
 
+static int zapi_nhg_decode(struct stream *s, int cmd, struct zapi_nhg *api_nhg);
+
 /* Encoding helpers -------------------------------------------------------- */
 
 static void zserv_encode_interface(struct stream *s, struct interface *ifp)
@@ -1742,7 +1744,7 @@ static bool zapi_read_nexthops(struct zserv *client, struct prefix *p,
        return true;
 }
 
-int zapi_nhg_decode(struct stream *s, int cmd, struct zapi_nhg *api_nhg)
+static int zapi_nhg_decode(struct stream *s, int cmd, struct zapi_nhg *api_nhg)
 {
        uint16_t i;
        struct zapi_nexthop *znh;