]> git.puffer.fish Git - mirror/frr.git/commitdiff
nhrpd: Cleanup multicast nflog handler function
authorReuben Dowle <reuben.dowle@4rf.com>
Tue, 16 Mar 2021 22:33:53 +0000 (11:33 +1300)
committerReuben Dowle <reuben.dowle@4rf.com>
Mon, 5 Apr 2021 21:23:42 +0000 (09:23 +1200)
Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
nhrpd/nhrp_multicast.c

index 822a63b5f3276ad59a11e80a9df32c3b961d5d56..0d675301aa188306289d4682df9d73f2f6742241 100644 (file)
@@ -101,26 +101,23 @@ static void netlink_mcast_log_handler(struct nlmsghdr *msg, struct zbuf *zb)
 {
        struct nfgenmsg *nf;
        struct rtattr *rta;
-       struct zbuf rtapl, pktpl;
-       struct interface *ifp;
+       struct zbuf rtapl;
        uint32_t *out_ndx = NULL;
        afi_t afi;
        struct mcast_ctx ctx;
 
-       debugf(NHRP_DEBUG_COMMON, "Inside %s\n", __func__);
-
        nf = znl_pull(zb, sizeof(*nf));
        if (!nf)
                return;
 
-       memset(&pktpl, 0, sizeof(pktpl));
+       ctx.pkt = NULL;
        while ((rta = znl_rta_pull(zb, &rtapl)) != NULL) {
                switch (rta->rta_type) {
                case NFULA_IFINDEX_OUTDEV:
                        out_ndx = znl_pull(&rtapl, sizeof(*out_ndx));
                        break;
                case NFULA_PAYLOAD:
-                       pktpl = rtapl;
+                       ctx.pkt = &rtapl;
                        break;
                        /* NFULA_HWHDR exists and is supposed to contain source
                         * hardware address. However, for ip_gre it seems to be
@@ -130,21 +127,18 @@ static void netlink_mcast_log_handler(struct nlmsghdr *msg, struct zbuf *zb)
                }
        }
 
-       if (!out_ndx || !zbuf_used(&pktpl))
+       if (!out_ndx || !ctx.pkt)
                return;
 
-       ifp = if_lookup_by_index(htonl(*out_ndx), VRF_DEFAULT);
-       if (!ifp)
+       ctx.ifp = if_lookup_by_index(htonl(*out_ndx), VRF_DEFAULT);
+       if (!ctx.ifp)
                return;
 
-       debugf(NHRP_DEBUG_COMMON, "Outgoing interface = %s\n", ifp->name);
-
-       ctx = (struct mcast_ctx){
-               .ifp = ifp, .pkt = &pktpl,
-       };
+       debugf(NHRP_DEBUG_COMMON, "Received multicast packet on %s len %zu\n",
+                  ctx.ifp->name, zbuf_used(ctx.pkt));
 
        for (afi = 0; afi < AFI_MAX; afi++) {
-               nhrp_multicast_foreach(ifp, afi, nhrp_multicast_forward,
+               nhrp_multicast_foreach(ctx.ifp, afi, nhrp_multicast_forward,
                                       (void *)&ctx);
        }
 }