]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: Zebra nexthop group re-work checkpatch fixes
authorStephen Worley <sworley@cumulusnetworks.com>
Tue, 3 Sep 2019 20:12:06 +0000 (16:12 -0400)
committerStephen Worley <sworley@cumulusnetworks.com>
Fri, 25 Oct 2019 15:13:43 +0000 (11:13 -0400)
Checkpatch fixes for the zebra nexthop group re-work.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
zebra/interface.c
zebra/rt_netlink.c
zebra/zebra_mpls.c
zebra/zebra_nhg.c
zebra/zebra_rib.c
zebra/zebra_vty.c

index 4754762b979c67bbdd2239b6406a863137adc290..76d5d2a2463a33b565ce4f5af78074c6bffbb7b1 100644 (file)
@@ -195,7 +195,7 @@ static void if_nhg_dependents_release(struct interface *ifp)
                struct nhg_connected *rb_node_dep = NULL;
                struct zebra_if *zif = (struct zebra_if *)ifp->info;
 
-               frr_each (nhg_connected_tree, &zif->nhg_dependents,
+               frr_each(nhg_connected_tree, &zif->nhg_dependents,
                          rb_node_dep) {
                        rb_node_dep->nhe->ifp = NULL;
                        zebra_nhg_set_invalid(rb_node_dep->nhe);
@@ -1004,7 +1004,7 @@ static void if_down_nhg_dependents(const struct interface *ifp)
                struct nhg_connected *rb_node_dep = NULL;
                struct zebra_if *zif = (struct zebra_if *)ifp->info;
 
-               frr_each (nhg_connected_tree, &zif->nhg_dependents,
+               frr_each(nhg_connected_tree, &zif->nhg_dependents,
                          rb_node_dep) {
                        zebra_nhg_set_invalid(rb_node_dep->nhe);
                }
index f6267050853a565abb968463e5d2f68c1b2104da..c24745cf1c5fe75335f412e8299e8b1b0185e60c 100644 (file)
@@ -75,7 +75,7 @@
 
 static vlanid_t filter_vlan = 0;
 
-static bool supports_nh = false;
+static bool supports_nh;
 
 struct gw_family_t {
        uint16_t filler;
@@ -1974,7 +1974,7 @@ static int netlink_nexthop(int cmd, struct zebra_dplane_ctx *ctx)
        req.n.nlmsg_pid = dplane_ctx_get_ns(ctx)->nls.snl.nl_pid;
 
        req.nhm.nh_family = AF_UNSPEC;
-       // TODO: Scope?
+       /* TODO: Scope? */
 
        uint32_t id = dplane_ctx_get_nhe_id(ctx);
 
@@ -2139,7 +2139,6 @@ enum zebra_dplane_result kernel_nexthop_update(struct zebra_dplane_ctx *ctx)
                        "Context received for kernel nexthop update with incorrect OP code (%u)",
                        dplane_ctx_get_op(ctx));
                return ZEBRA_DPLANE_REQUEST_FAILURE;
-               break;
        }
 
        ret = netlink_nexthop(cmd, ctx);
@@ -2548,7 +2547,7 @@ static int netlink_vxlan_flood_update_ctx(const struct zebra_dplane_ctx *ctx,
        req.n.nlmsg_type = cmd;
        req.ndm.ndm_family = PF_BRIDGE;
        req.ndm.ndm_state = NUD_NOARP | NUD_PERMANENT;
-       req.ndm.ndm_flags |= NTF_SELF; // Handle by "self", not "master"
+       req.ndm.ndm_flags |= NTF_SELF; /* Handle by "self", not "master" */
 
 
        addattr_l(&req.n, sizeof(req),
index 42d8c70f4911571184b5bf0a16a7c87e644bb526..331ca44c677e19606a4ec7559c7fa6a9a86b8796 100644 (file)
@@ -2669,7 +2669,7 @@ int mpls_ftn_update(int add, struct zebra_vrf *zvrf, enum lsp_types_t type,
 
        nexthops_free(new_grp.nexthop);
 
-       return (found ? 0 : -1);
+       return found ? 0 : -1;
 }
 
 int mpls_ftn_uninstall(struct zebra_vrf *zvrf, enum lsp_types_t type,
index 8fb4f3357b0ae11d56966f55adacfbcaa6c862a8..720c09397f98c0dc27dfe2d2b1cb46147d032589 100644 (file)
@@ -80,7 +80,7 @@ void nhg_connected_tree_free(struct nhg_connected_tree_head *head)
        struct nhg_connected *rb_node_dep = NULL;
 
        if (!nhg_connected_tree_is_empty(head)) {
-               frr_each_safe (nhg_connected_tree, head, rb_node_dep) {
+               frr_each_safe(nhg_connected_tree, head, rb_node_dep) {
                        nhg_connected_tree_del(head, rb_node_dep);
                        nhg_connected_free(rb_node_dep);
                }
@@ -89,7 +89,7 @@ void nhg_connected_tree_free(struct nhg_connected_tree_head *head)
 
 bool nhg_connected_tree_is_empty(const struct nhg_connected_tree_head *head)
 {
-       return (nhg_connected_tree_count(head) ? false : true);
+       return nhg_connected_tree_count(head) ? false : true;
 }
 
 struct nhg_connected *
@@ -130,7 +130,7 @@ nhg_connected_tree_decrement_ref(struct nhg_connected_tree_head *head)
 {
        struct nhg_connected *rb_node_dep = NULL;
 
-       frr_each_safe (nhg_connected_tree, head, rb_node_dep) {
+       frr_each_safe(nhg_connected_tree, head, rb_node_dep) {
                zebra_nhg_decrement_ref(rb_node_dep->nhe);
        }
 }
@@ -140,7 +140,7 @@ nhg_connected_tree_increment_ref(struct nhg_connected_tree_head *head)
 {
        struct nhg_connected *rb_node_dep = NULL;
 
-       frr_each (nhg_connected_tree, head, rb_node_dep) {
+       frr_each(nhg_connected_tree, head, rb_node_dep) {
                zebra_nhg_increment_ref(rb_node_dep->nhe);
        }
 }
@@ -209,7 +209,7 @@ static void zebra_nhg_depends_release(struct nhg_hash_entry *nhe)
        if (!zebra_nhg_depends_is_empty(nhe)) {
                struct nhg_connected *rb_node_dep = NULL;
 
-               frr_each_safe (nhg_connected_tree, &nhe->nhg_depends,
+               frr_each_safe(nhg_connected_tree, &nhe->nhg_depends,
                               rb_node_dep) {
                        zebra_nhg_dependents_del(rb_node_dep->nhe, nhe);
                }
@@ -249,7 +249,7 @@ static void zebra_nhg_dependents_release(struct nhg_hash_entry *nhe)
        if (!zebra_nhg_dependents_is_empty(nhe)) {
                struct nhg_connected *rb_node_dep = NULL;
 
-               frr_each_safe (nhg_connected_tree, &nhe->nhg_dependents,
+               frr_each_safe(nhg_connected_tree, &nhe->nhg_dependents,
                               rb_node_dep) {
                        zebra_nhg_depends_del(rb_node_dep->nhe, nhe);
                }
@@ -295,7 +295,7 @@ zebra_nhg_connect_depends(struct nhg_hash_entry *nhe,
        /* Attach backpointer to anything that it depends on */
        zebra_nhg_dependents_init(nhe);
        if (!zebra_nhg_depends_is_empty(nhe)) {
-               frr_each (nhg_connected_tree, &nhe->nhg_depends, rb_node_dep) {
+               frr_each(nhg_connected_tree, &nhe->nhg_depends, rb_node_dep) {
                        zebra_nhg_dependents_add(rb_node_dep->nhe, nhe);
                }
        }
@@ -667,7 +667,7 @@ static bool zebra_nhg_contains_dup(struct nhg_hash_entry *nhe)
 {
        struct nhg_connected *rb_node_dep = NULL;
 
-       frr_each (nhg_connected_tree, &nhe->nhg_depends, rb_node_dep) {
+       frr_each(nhg_connected_tree, &nhe->nhg_depends, rb_node_dep) {
                if (CHECK_FLAG(rb_node_dep->nhe->flags,
                               NEXTHOP_GROUP_DUPLICATE))
                        return true;
@@ -770,7 +770,7 @@ static int nhg_ctx_process_new(struct nhg_ctx *ctx)
                                          nhg_ctx_get_grp(ctx), count)) {
                        depends_decrement_free(&nhg_depends);
                        nexthop_group_free_delete(&nhg);
-                       return ENOENT;
+                       return -ENOENT;
                }
 
                if (!zebra_nhg_find(&nhe, id, nhg, &nhg_depends, vrf_id, type,
@@ -891,7 +891,7 @@ int nhg_ctx_process(struct nhg_ctx *ctx)
        switch (nhg_ctx_get_op(ctx)) {
        case NHG_CTX_OP_NEW:
                ret = nhg_ctx_process_new(ctx);
-               if (nhg_ctx_get_count(ctx) && ret == ENOENT
+               if (nhg_ctx_get_count(ctx) && ret == -ENOENT
                    && nhg_ctx_get_status(ctx) != NHG_CTX_REQUEUED) {
                        /* Depends probably came before group, re-queue.
                         *
@@ -1093,7 +1093,7 @@ void zebra_nhg_set_invalid(struct nhg_hash_entry *nhe)
                struct nhg_connected *rb_node_dep = NULL;
 
                /* If anthing else in the group is valid, the group is valid */
-               frr_each (nhg_connected_tree, &nhe->nhg_dependents,
+               frr_each(nhg_connected_tree, &nhe->nhg_dependents,
                          rb_node_dep) {
                        if (CHECK_FLAG(rb_node_dep->nhe->flags,
                                       NEXTHOP_GROUP_VALID))
@@ -1108,7 +1108,7 @@ void zebra_nhg_set_invalid(struct nhg_hash_entry *nhe)
        if (!zebra_nhg_dependents_is_empty(nhe)) {
                struct nhg_connected *rb_node_dep = NULL;
 
-               frr_each (nhg_connected_tree, &nhe->nhg_dependents,
+               frr_each(nhg_connected_tree, &nhe->nhg_dependents,
                          rb_node_dep) {
                        zebra_nhg_set_invalid(rb_node_dep->nhe);
                }
@@ -1732,7 +1732,7 @@ uint8_t zebra_nhg_nhe2grp(struct nh_grp *grp, struct nhg_hash_entry *nhe,
        struct nhg_hash_entry *depend = NULL;
        uint8_t i = 0;
 
-       frr_each (nhg_connected_tree, &nhe->nhg_depends, rb_node_dep) {
+       frr_each(nhg_connected_tree, &nhe->nhg_depends, rb_node_dep) {
                bool duplicate = false;
 
                depend = rb_node_dep->nhe;
@@ -1780,7 +1780,7 @@ void zebra_nhg_install_kernel(struct nhg_hash_entry *nhe)
        nhe = zebra_nhg_resolve(nhe);
 
        /* Make sure all depends are installed/queued */
-       frr_each (nhg_connected_tree, &nhe->nhg_depends, rb_node_dep) {
+       frr_each(nhg_connected_tree, &nhe->nhg_depends, rb_node_dep) {
                zebra_nhg_install_kernel(rb_node_dep->nhe);
        }
 
@@ -1846,8 +1846,9 @@ static void zebra_nhg_uninstall_created(struct hash_bucket *bucket, void *arg)
 
 void zebra_nhg_cleanup_tables(struct hash *hash)
 {
-       // TODO: These should only be uninstalled via route cleanup
-       // path?
+       /*
+        * TODO: These should only be uninstalled via route cleanup path?
+        */
        return;
        hash_iterate(hash, zebra_nhg_uninstall_created, NULL);
 }
index d4abb61f22b3c3246dfbd839a4d965e84dd3d5e1..337a2f09c5d9a27ab89ccab2ed63a4fdd4359e1a 100644 (file)
@@ -2865,27 +2865,30 @@ void rib_delete(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type,
                        same = re;
                        break;
                }
+
                /* Make sure that the route found has the same gateway. */
-               else if (nhe_id && re->nhe_id == nhe_id) {
+               if (nhe_id && re->nhe_id == nhe_id) {
                        same = re;
                        break;
-               } else {
-                       if (nh == NULL) {
+               }
+
+               if (nh == NULL) {
+                       same = re;
+                       break;
+               }
+               for (ALL_NEXTHOPS_PTR(re->ng, rtnh)) {
+                       /*
+                        * No guarantee all kernel send nh with labels
+                        * on delete.
+                        */
+                       if (nexthop_same_no_labels(rtnh, nh)) {
                                same = re;
                                break;
                        }
-                       for (ALL_NEXTHOPS_PTR(re->ng, rtnh))
-                               /*
-                                * No guarantee all kernel send nh with labels
-                                * on delete.
-                                */
-                               if (nexthop_same_no_labels(rtnh, nh)) {
-                                       same = re;
-                                       break;
-                               }
-                       if (same)
-                               break;
                }
+
+               if (same)
+                       break;
        }
        /* If same type of route can't be found and this message is from
           kernel. */
index e12d16333ff8305f8282b62f8d9afa2b4afc4a7f..7f569cdb0eefd6c70eda836fe302c850a300f32b 100644 (file)
@@ -1122,9 +1122,9 @@ static void show_nexthop_group_out(struct vty *vty, struct nhg_hash_entry *nhe)
        else
                vty_out(vty, "     VRF: UNKNOWN\n");
 
-       if (CHECK_FLAG(nhe->flags, NEXTHOP_GROUP_DUPLICATE)) {
+       if (CHECK_FLAG(nhe->flags, NEXTHOP_GROUP_DUPLICATE))
                vty_out(vty, "     Duplicate - from kernel not hashable\n");
-       }
+
        if (CHECK_FLAG(nhe->flags, NEXTHOP_GROUP_VALID)) {
                vty_out(vty, "     Valid");
                if (CHECK_FLAG(nhe->flags, NEXTHOP_GROUP_INSTALLED))
@@ -1136,7 +1136,7 @@ static void show_nexthop_group_out(struct vty *vty, struct nhg_hash_entry *nhe)
 
        if (!zebra_nhg_depends_is_empty(nhe)) {
                vty_out(vty, "     Depends:");
-               frr_each (nhg_connected_tree, &nhe->nhg_depends, rb_node_dep) {
+               frr_each(nhg_connected_tree, &nhe->nhg_depends, rb_node_dep) {
                        vty_out(vty, " (%u)", rb_node_dep->nhe->id);
                }
                vty_out(vty, "\n");
@@ -1162,7 +1162,7 @@ static void show_nexthop_group_out(struct vty *vty, struct nhg_hash_entry *nhe)
                case NEXTHOP_TYPE_IPV6_IFINDEX:
                        vty_out(vty, " %s",
                                inet_ntop(AF_INET6, &nexthop->gate.ipv6, buf,
-                                         sizeof buf));
+                                         sizeof(buf)));
                        if (nexthop->ifindex)
                                vty_out(vty, ", %s",
                                        ifindex2ifname(nexthop->ifindex,
@@ -1215,7 +1215,7 @@ static void show_nexthop_group_out(struct vty *vty, struct nhg_hash_entry *nhe)
                case NEXTHOP_TYPE_IPV4_IFINDEX:
                        if (nexthop->src.ipv4.s_addr) {
                                if (inet_ntop(AF_INET, &nexthop->src.ipv4, buf,
-                                             sizeof buf))
+                                             sizeof(buf)))
                                        vty_out(vty, ", src %s", buf);
                        }
                        break;
@@ -1223,7 +1223,7 @@ static void show_nexthop_group_out(struct vty *vty, struct nhg_hash_entry *nhe)
                case NEXTHOP_TYPE_IPV6_IFINDEX:
                        if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any)) {
                                if (inet_ntop(AF_INET6, &nexthop->src.ipv6, buf,
-                                             sizeof buf))
+                                             sizeof(buf)))
                                        vty_out(vty, ", src %s", buf);
                        }
                        break;
@@ -1236,7 +1236,7 @@ static void show_nexthop_group_out(struct vty *vty, struct nhg_hash_entry *nhe)
                        vty_out(vty, ", label %s",
                                mpls_label2str(nexthop->nh_label->num_labels,
                                               nexthop->nh_label->label, buf,
-                                              sizeof buf, 1));
+                                              sizeof(buf), 1));
                }
 
                vty_out(vty, "\n");
@@ -1244,7 +1244,7 @@ static void show_nexthop_group_out(struct vty *vty, struct nhg_hash_entry *nhe)
 
        if (!zebra_nhg_dependents_is_empty(nhe)) {
                vty_out(vty, "     Dependents:");
-               frr_each (nhg_connected_tree, &nhe->nhg_dependents,
+               frr_each(nhg_connected_tree, &nhe->nhg_dependents,
                          rb_node_dep) {
                        vty_out(vty, " (%u)", rb_node_dep->nhe->id);
                }
@@ -1299,7 +1299,7 @@ static void if_nexthop_group_dump_vty(struct vty *vty, struct interface *ifp)
        if (!if_nhg_dependents_is_empty(ifp)) {
                vty_out(vty, "Interface %s:\n", ifp->name);
 
-               frr_each (nhg_connected_tree, &zebra_if->nhg_dependents,
+               frr_each(nhg_connected_tree, &zebra_if->nhg_dependents,
                          rb_node_dep) {
                        vty_out(vty, "   ");
                        show_nexthop_group_out(vty, rb_node_dep->nhe);