From fec211ad95a3a2967e72d49ab3036ae01e4b3762 Mon Sep 17 00:00:00 2001 From: Stephen Worley Date: Tue, 3 Sep 2019 16:12:06 -0400 Subject: [PATCH] zebra: Zebra nexthop group re-work checkpatch fixes Checkpatch fixes for the zebra nexthop group re-work. Signed-off-by: Stephen Worley --- zebra/interface.c | 4 ++-- zebra/rt_netlink.c | 7 +++---- zebra/zebra_mpls.c | 2 +- zebra/zebra_nhg.c | 33 +++++++++++++++++---------------- zebra/zebra_rib.c | 31 +++++++++++++++++-------------- zebra/zebra_vty.c | 18 +++++++++--------- 6 files changed, 49 insertions(+), 46 deletions(-) diff --git a/zebra/interface.c b/zebra/interface.c index 4754762b97..76d5d2a246 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -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); } diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index f626705085..c24745cf1c 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -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), diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c index 42d8c70f49..331ca44c67 100644 --- a/zebra/zebra_mpls.c +++ b/zebra/zebra_mpls.c @@ -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, diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c index 8fb4f3357b..720c09397f 100644 --- a/zebra/zebra_nhg.c +++ b/zebra/zebra_nhg.c @@ -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); } diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index d4abb61f22..337a2f09c5 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -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. */ diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index e12d16333f..7f569cdb0e 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -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); -- 2.39.5