]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: export netlink function and change return
authorRafael Zalamena <rzalamena@opensourcerouting.org>
Wed, 4 Dec 2019 13:37:40 +0000 (10:37 -0300)
committerRafael Zalamena <rzalamena@opensourcerouting.org>
Tue, 14 Apr 2020 14:44:39 +0000 (11:44 -0300)
Instead of retuning always `0`, lets return the amount of used bytes for
the message. This will be used by the new FPM interface to know how many
bytes we must reserve for the output buffer.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
zebra/rt_netlink.c
zebra/rt_netlink.h

index 43f12145f4a48a60eaa486e118282e5bf68a255d..cda69045171334d7437e3db774c2939736f9278b 100644 (file)
@@ -1531,8 +1531,8 @@ static bool nexthop_set_src(const struct nexthop *nexthop, int family,
 /*
  * Routing table change via netlink interface, using a dataplane context object
  */
-static int netlink_route_multipath(int cmd, struct zebra_dplane_ctx *ctx,
-                                  uint8_t *data, size_t datalen)
+ssize_t netlink_route_multipath(int cmd, struct zebra_dplane_ctx *ctx,
+                               uint8_t *data, size_t datalen)
 {
        int bytelen;
        struct nexthop *nexthop = NULL;
@@ -1636,7 +1636,7 @@ static int netlink_route_multipath(int cmd, struct zebra_dplane_ctx *ctx,
         * it.
         */
        if (cmd == RTM_DELROUTE)
-               return 0;
+               return req->n.nlmsg_len;
 
        if (dplane_ctx_get_mtu(ctx) || dplane_ctx_get_nh_mtu(ctx)) {
                char buf[NL_PKT_BUF_SIZE];
@@ -1680,7 +1680,8 @@ static int netlink_route_multipath(int cmd, struct zebra_dplane_ctx *ctx,
                                addattr_l(&req->n, datalen, RTA_PREFSRC,
                                          &src.ipv6, bytelen);
                }
-               return 0;
+
+               return req->n.nlmsg_len;
        }
 
        /* Count overall nexthops so we can decide whether to use singlepath
@@ -1719,7 +1720,7 @@ static int netlink_route_multipath(int cmd, struct zebra_dplane_ctx *ctx,
                                        req->r.rtm_type = RTN_BLACKHOLE;
                                        break;
                                }
-                               return 0;
+                               return req->n.nlmsg_len;
                        }
                        if (CHECK_FLAG(nexthop->flags,
                                       NEXTHOP_FLAG_RECURSIVE)) {
@@ -1818,7 +1819,7 @@ static int netlink_route_multipath(int cmd, struct zebra_dplane_ctx *ctx,
                        zlog_debug("%s: No useful nexthop.", __func__);
        }
 
-       return 0;
+       return req->n.nlmsg_len;
 }
 
 int kernel_get_ipmr_sg_stats(struct zebra_vrf *zvrf, void *in)
index 2b4b145149c801c633b80522d26dea6cb40467e5..64109e50e6ac8cb6887b65434aff515719c1fb0f 100644 (file)
@@ -66,6 +66,9 @@ void rt_netlink_init(void);
 /* MPLS label forwarding table change, using dataplane context information. */
 extern int netlink_mpls_multipath(int cmd, struct zebra_dplane_ctx *ctx);
 
+extern ssize_t netlink_route_multipath(int cmd, struct zebra_dplane_ctx *ctx,
+                                      uint8_t *data, size_t datalen);
+
 extern int netlink_route_change(struct nlmsghdr *h, ns_id_t ns_id, int startup);
 extern int netlink_route_read(struct zebra_ns *zns);