From 5e53dce31eff6dbc1455cdd22a5ce006cbaa8c4a Mon Sep 17 00:00:00 2001 From: Tuetuopay Date: Wed, 6 Mar 2019 19:10:02 +0100 Subject: [PATCH] bgpd, zebra: Rename variables of EVPN instance Rename {bgp,zvrf}_def{ault} to {bgp,zvrf}_evpn where it makes sense, i.e. when they contain the EVPN instance. Signed-off-by: Tuetuopay Sponsored-by: Scaleway --- bgpd/bgp_evpn.c | 102 ++++++++++++++++++++++---------------------- bgpd/bgp_evpn_vty.c | 36 ++++++++-------- zebra/zebra_vxlan.c | 8 ++-- 3 files changed, 73 insertions(+), 73 deletions(-) diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c index caba9647da..ca13ee951e 100644 --- a/bgpd/bgp_evpn.c +++ b/bgpd/bgp_evpn.c @@ -172,11 +172,11 @@ static bool vrf_import_rt_hash_cmp(const void *p1, const void *p2) */ static struct vrf_irt_node *vrf_import_rt_new(struct ecommunity_val *rt) { - struct bgp *bgp_def = NULL; + struct bgp *bgp_evpn = NULL; struct vrf_irt_node *irt; - bgp_def = bgp_get_evpn(); - if (!bgp_def) { + bgp_evpn = bgp_get_evpn(); + if (!bgp_evpn) { flog_err(EC_BGP_NO_DFLT, "vrf import rt new - evpn instance not created yet"); return NULL; @@ -189,7 +189,7 @@ static struct vrf_irt_node *vrf_import_rt_new(struct ecommunity_val *rt) irt->vrfs = list_new(); /* Add to hash */ - if (!hash_get(bgp_def->vrf_import_rt_hash, irt, hash_alloc_intern)) { + if (!hash_get(bgp_evpn->vrf_import_rt_hash, irt, hash_alloc_intern)) { XFREE(MTYPE_BGP_EVPN_VRF_IMPORT_RT, irt); return NULL; } @@ -202,16 +202,16 @@ static struct vrf_irt_node *vrf_import_rt_new(struct ecommunity_val *rt) */ static void vrf_import_rt_free(struct vrf_irt_node *irt) { - struct bgp *bgp_def = NULL; + struct bgp *bgp_evpn = NULL; - bgp_def = bgp_get_evpn(); - if (!bgp_def) { + bgp_evpn = bgp_get_evpn(); + if (!bgp_evpn) { flog_err(EC_BGP_NO_DFLT, "vrf import rt free - evpn instance not created yet"); return; } - hash_release(bgp_def->vrf_import_rt_hash, irt); + hash_release(bgp_evpn->vrf_import_rt_hash, irt); list_delete(&irt->vrfs); XFREE(MTYPE_BGP_EVPN_VRF_IMPORT_RT, irt); } @@ -222,12 +222,12 @@ static void vrf_import_rt_free(struct vrf_irt_node *irt) */ static struct vrf_irt_node *lookup_vrf_import_rt(struct ecommunity_val *rt) { - struct bgp *bgp_def = NULL; + struct bgp *bgp_evpn = NULL; struct vrf_irt_node *irt; struct vrf_irt_node tmp; - bgp_def = bgp_get_evpn(); - if (!bgp_def) { + bgp_evpn = bgp_get_evpn(); + if (!bgp_evpn) { flog_err( EC_BGP_NO_DFLT, "vrf import rt lookup - evpn instance not created yet"); @@ -236,7 +236,7 @@ static struct vrf_irt_node *lookup_vrf_import_rt(struct ecommunity_val *rt) memset(&tmp, 0, sizeof(struct vrf_irt_node)); memcpy(&tmp.rt, rt, ECOMMUNITY_SIZE); - irt = hash_lookup(bgp_def->vrf_import_rt_hash, &tmp); + irt = hash_lookup(bgp_evpn->vrf_import_rt_hash, &tmp); return irt; } @@ -1421,7 +1421,7 @@ static int update_evpn_type4_route(struct bgp *bgp, return 0; } -static int update_evpn_type5_route_entry(struct bgp *bgp_def, +static int update_evpn_type5_route_entry(struct bgp *bgp_evpn, struct bgp *bgp_vrf, afi_t afi, safi_t safi, struct bgp_node *rn, struct attr *attr, int *route_changed) @@ -1436,7 +1436,7 @@ static int update_evpn_type5_route_entry(struct bgp *bgp_def, /* locate the local route entry if any */ for (tmp_pi = bgp_node_get_bgp_path_info(rn); tmp_pi; tmp_pi = tmp_pi->next) { - if (tmp_pi->peer == bgp_def->peer_self + if (tmp_pi->peer == bgp_evpn->peer_self && tmp_pi->type == ZEBRA_ROUTE_BGP && tmp_pi->sub_type == BGP_ROUTE_STATIC) local_pi = tmp_pi; @@ -1456,7 +1456,7 @@ static int update_evpn_type5_route_entry(struct bgp *bgp_def, /* create the route info from attribute */ pi = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, 0, - bgp_def->peer_self, attr_new, rn); + bgp_evpn->peer_self, attr_new, rn); SET_FLAG(pi->flags, BGP_PATH_VALID); /* Type-5 routes advertise the L3-VNI */ @@ -1502,11 +1502,11 @@ static int update_evpn_type5_route(struct bgp *bgp_vrf, struct prefix_evpn *evp, safi_t safi = SAFI_EVPN; struct attr attr; struct bgp_node *rn = NULL; - struct bgp *bgp_def = NULL; + struct bgp *bgp_evpn = NULL; int route_changed = 0; - bgp_def = bgp_get_evpn(); - if (!bgp_def) + bgp_evpn = bgp_get_evpn(); + if (!bgp_evpn) return 0; /* Build path attribute for this route - use the source attr, if @@ -1528,17 +1528,17 @@ static int update_evpn_type5_route(struct bgp *bgp_vrf, struct prefix_evpn *evp, build_evpn_type5_route_extcomm(bgp_vrf, &attr); /* get the route node in global table */ - rn = bgp_afi_node_get(bgp_def->rib[afi][safi], afi, safi, + rn = bgp_afi_node_get(bgp_evpn->rib[afi][safi], afi, safi, (struct prefix *)evp, &bgp_vrf->vrf_prd); assert(rn); /* create or update the route entry within the route node */ - update_evpn_type5_route_entry(bgp_def, bgp_vrf, afi, safi, rn, &attr, + update_evpn_type5_route_entry(bgp_evpn, bgp_vrf, afi, safi, rn, &attr, &route_changed); /* schedule for processing and unlock node */ if (route_changed) { - bgp_process(bgp_def, rn, afi, safi); + bgp_process(bgp_evpn, rn, afi, safi); bgp_unlock_node(rn); } @@ -1925,21 +1925,21 @@ static int delete_evpn_type5_route(struct bgp *bgp_vrf, struct prefix_evpn *evp) safi_t safi = SAFI_EVPN; struct bgp_node *rn = NULL; struct bgp_path_info *pi = NULL; - struct bgp *bgp_def = NULL; /* default bgp instance */ + struct bgp *bgp_evpn = NULL; /* evpn bgp instance */ - bgp_def = bgp_get_evpn(); - if (!bgp_def) + bgp_evpn = bgp_get_evpn(); + if (!bgp_evpn) return 0; /* locate the global route entry for this type-5 prefix */ - rn = bgp_afi_node_lookup(bgp_def->rib[afi][safi], afi, safi, + rn = bgp_afi_node_lookup(bgp_evpn->rib[afi][safi], afi, safi, (struct prefix *)evp, &bgp_vrf->vrf_prd); if (!rn) return 0; - delete_evpn_route_entry(bgp_def, afi, safi, rn, &pi); + delete_evpn_route_entry(bgp_evpn, afi, safi, rn, &pi); if (pi) - bgp_process(bgp_def, rn, afi, safi); + bgp_process(bgp_evpn, rn, afi, safi); bgp_unlock_node(rn); return 0; } @@ -2953,19 +2953,19 @@ static int install_uninstall_routes_for_vrf(struct bgp *bgp_vrf, int install) struct bgp_path_info *pi; int ret; char buf[PREFIX_STRLEN]; - struct bgp *bgp_def = NULL; + struct bgp *bgp_evpn = NULL; afi = AFI_L2VPN; safi = SAFI_EVPN; - bgp_def = bgp_get_evpn(); - if (!bgp_def) + bgp_evpn = bgp_get_evpn(); + if (!bgp_evpn) return -1; /* Walk entire global routing table and evaluate routes which could be * imported into this VRF. Note that we need to loop through all global * routes to determine which route matches the import rt on vrf */ - for (rd_rn = bgp_table_top(bgp_def->rib[afi][safi]); rd_rn; + for (rd_rn = bgp_table_top(bgp_evpn->rib[afi][safi]); rd_rn; rd_rn = bgp_route_next(rd_rn)) { table = bgp_node_get_bgp_table_info(rd_rn); if (!table) @@ -4112,14 +4112,14 @@ static void free_vni_entry(struct hash_bucket *bucket, struct bgp *bgp) */ static void evpn_auto_rt_import_add_for_vrf(struct bgp *bgp_vrf) { - struct bgp *bgp_def = NULL; + struct bgp *bgp_evpn = NULL; form_auto_rt(bgp_vrf, bgp_vrf->l3vni, bgp_vrf->vrf_import_rtl); UNSET_FLAG(bgp_vrf->vrf_flags, BGP_VRF_IMPORT_RT_CFGD); /* Map RT to VRF */ - bgp_def = bgp_get_evpn(); - if (!bgp_def) + bgp_evpn = bgp_get_evpn(); + if (!bgp_evpn) return; bgp_evpn_map_vrf_to_its_rts(bgp_vrf); } @@ -4151,12 +4151,12 @@ static void evpn_auto_rt_export_delete_for_vrf(struct bgp *bgp_vrf) static void bgp_evpn_handle_export_rt_change_for_vrf(struct bgp *bgp_vrf) { - struct bgp *bgp_def = NULL; + struct bgp *bgp_evpn = NULL; struct listnode *node = NULL; struct bgpevpn *vpn = NULL; - bgp_def = bgp_get_evpn(); - if (!bgp_def) + bgp_evpn = bgp_get_evpn(); + if (!bgp_evpn) return; /* update all type-5 routes */ @@ -4164,7 +4164,7 @@ static void bgp_evpn_handle_export_rt_change_for_vrf(struct bgp *bgp_vrf) /* update all type-2 routes */ for (ALL_LIST_ELEMENTS_RO(bgp_vrf->l2vnis, node, vpn)) - update_routes_for_vni(bgp_def, vpn); + update_routes_for_vni(bgp_evpn, vpn); } /* @@ -5378,10 +5378,10 @@ static void link_l2vni_hash_to_l3vni(struct hash_bucket *bucket, struct bgp *bgp_vrf) { struct bgpevpn *vpn = (struct bgpevpn *)bucket->data; - struct bgp *bgp_def = NULL; + struct bgp *bgp_evpn = NULL; - bgp_def = bgp_get_evpn(); - assert(bgp_def); + bgp_evpn = bgp_get_evpn(); + assert(bgp_evpn); if (vpn->tenant_vrf_id == bgp_vrf->vrf_id) bgpevpn_link_to_l3vni(vpn); @@ -5392,7 +5392,7 @@ int bgp_evpn_local_l3vni_add(vni_t l3vni, vrf_id_t vrf_id, struct ethaddr *rmac, ifindex_t svi_ifindex) { struct bgp *bgp_vrf = NULL; /* bgp VRF instance */ - struct bgp *bgp_def = NULL; /* default bgp instance */ + struct bgp *bgp_evpn = NULL; /* EVPN bgp instance */ struct listnode *node = NULL; struct bgpevpn *vpn = NULL; as_t as = 0; @@ -5400,15 +5400,15 @@ int bgp_evpn_local_l3vni_add(vni_t l3vni, vrf_id_t vrf_id, struct ethaddr *rmac, /* get the EVPN instance - required to get the AS number for VRF * auto-creatio */ - bgp_def = bgp_get_evpn(); - if (!bgp_def) { + bgp_evpn = bgp_get_evpn(); + if (!bgp_evpn) { flog_err( EC_BGP_NO_DFLT, "Cannot process L3VNI %u ADD - EVPN BGP instance not yet created", l3vni); return -1; } - as = bgp_def->as; + as = bgp_evpn->as; /* if the BGP vrf instance doesn't exist - create one */ bgp_vrf = bgp_lookup_by_vrf_id(vrf_id); @@ -5461,7 +5461,7 @@ int bgp_evpn_local_l3vni_add(vni_t l3vni, vrf_id_t vrf_id, struct ethaddr *rmac, bgp_evpn_derive_auto_rd_for_vrf(bgp_vrf); /* link all corresponding l2vnis */ - hash_iterate(bgp_def->vnihash, + hash_iterate(bgp_evpn->vnihash, (void (*)(struct hash_bucket *, void *))link_l2vni_hash_to_l3vni, bgp_vrf); @@ -5471,7 +5471,7 @@ int bgp_evpn_local_l3vni_add(vni_t l3vni, vrf_id_t vrf_id, struct ethaddr *rmac, */ if (!filter) for (ALL_LIST_ELEMENTS_RO(bgp_vrf->l2vnis, node, vpn)) - update_routes_for_vni(bgp_def, vpn); + update_routes_for_vni(bgp_evpn, vpn); /* advertise type-5 routes if needed */ update_advertise_vrf_routes(bgp_vrf); @@ -5486,7 +5486,7 @@ int bgp_evpn_local_l3vni_add(vni_t l3vni, vrf_id_t vrf_id, struct ethaddr *rmac, int bgp_evpn_local_l3vni_del(vni_t l3vni, vrf_id_t vrf_id) { struct bgp *bgp_vrf = NULL; /* bgp vrf instance */ - struct bgp *bgp_def = NULL; /* default bgp instance */ + struct bgp *bgp_evpn = NULL; /* EVPN bgp instance */ struct listnode *node = NULL; struct listnode *next = NULL; struct bgpevpn *vpn = NULL; @@ -5500,8 +5500,8 @@ int bgp_evpn_local_l3vni_del(vni_t l3vni, vrf_id_t vrf_id) return -1; } - bgp_def = bgp_get_evpn(); - if (!bgp_def) { + bgp_evpn = bgp_get_evpn(); + if (!bgp_evpn) { flog_err( EC_BGP_NO_DFLT, "Cannot process L3VNI %u Del - Could not find EVPN BGP instance", @@ -5542,7 +5542,7 @@ int bgp_evpn_local_l3vni_del(vni_t l3vni, vrf_id_t vrf_id) if (!CHECK_FLAG(bgp_vrf->vrf_flags, BGP_VRF_L3VNI_PREFIX_ROUTES_ONLY)) { for (ALL_LIST_ELEMENTS_RO(bgp_vrf->l2vnis, node, vpn)) { UNSET_FLAG(vpn->flags, VNI_FLAG_USE_TWO_LABELS); - update_routes_for_vni(bgp_def, vpn); + update_routes_for_vni(bgp_evpn, vpn); } } diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c index 7f74ad48f2..08f487e497 100644 --- a/bgpd/bgp_evpn_vty.c +++ b/bgpd/bgp_evpn_vty.c @@ -1958,9 +1958,9 @@ static int evpn_delete_vni(struct bgp *bgp, struct bgpevpn *vpn) /* * Display import RT mapping to VRFs (vty handler) - * bgp_def: default bgp instance + * bgp_evpn: evpn bgp instance */ -static void evpn_show_vrf_import_rts(struct vty *vty, struct bgp *bgp_def, +static void evpn_show_vrf_import_rts(struct vty *vty, struct bgp *bgp_evpn, json_object *json) { void *args[2]; @@ -1968,7 +1968,7 @@ static void evpn_show_vrf_import_rts(struct vty *vty, struct bgp *bgp_def, args[0] = vty; args[1] = json; - hash_iterate(bgp_def->vrf_import_rt_hash, + hash_iterate(bgp_evpn->vrf_import_rt_hash, (void (*)(struct hash_bucket *, void *))show_vrf_import_rt_entry, args); @@ -3451,7 +3451,7 @@ DEFUN(show_bgp_l2vpn_evpn_vni, "VNI number\n" JSON_STR) { - struct bgp *bgp_def; + struct bgp *bgp_evpn; vni_t vni; int idx = 0; bool uj = false; @@ -3464,8 +3464,8 @@ DEFUN(show_bgp_l2vpn_evpn_vni, uj = use_json(argc, argv); - bgp_def = bgp_get_evpn(); - if (!bgp_def) + bgp_evpn = bgp_get_evpn(); + if (!bgp_evpn) return CMD_WARNING; if (!argv_find(argv, argc, "evpn", &idx)) @@ -3476,7 +3476,7 @@ DEFUN(show_bgp_l2vpn_evpn_vni, if ((uj && argc == ((idx + 1) + 2)) || (!uj && argc == (idx + 1) + 1)) { - num_l2vnis = hashcount(bgp_def->vnihash); + num_l2vnis = hashcount(bgp_evpn->vnihash); for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp_temp)) { if (bgp_temp->l3vni) @@ -3485,7 +3485,7 @@ DEFUN(show_bgp_l2vpn_evpn_vni, num_vnis = num_l2vnis + num_l3vnis; if (uj) { json_object_string_add(json, "advertiseGatewayMacip", - bgp_def->advertise_gw_macip + bgp_evpn->advertise_gw_macip ? "Enabled" : "Disabled"); json_object_string_add(json, "advertiseAllVnis", @@ -3493,7 +3493,7 @@ DEFUN(show_bgp_l2vpn_evpn_vni, : "Disabled"); json_object_string_add( json, "flooding", - bgp_def->vxlan_flood_ctrl + bgp_evpn->vxlan_flood_ctrl == VXLAN_FLOOD_HEAD_END_REPL ? "Head-end replication" : "Disabled"); @@ -3502,22 +3502,22 @@ DEFUN(show_bgp_l2vpn_evpn_vni, json_object_int_add(json, "numL3Vnis", num_l3vnis); } else { vty_out(vty, "Advertise Gateway Macip: %s\n", - bgp_def->advertise_gw_macip ? "Enabled" + bgp_evpn->advertise_gw_macip ? "Enabled" : "Disabled"); vty_out(vty, "Advertise SVI Macip: %s\n", - bgp_def->evpn_info->advertise_svi_macip ? "Enabled" + bgp_evpn->evpn_info->advertise_svi_macip ? "Enabled" : "Disabled"); vty_out(vty, "Advertise All VNI flag: %s\n", is_evpn_enabled() ? "Enabled" : "Disabled"); vty_out(vty, "BUM flooding: %s\n", - bgp_def->vxlan_flood_ctrl + bgp_evpn->vxlan_flood_ctrl == VXLAN_FLOOD_HEAD_END_REPL ? "Head-end replication" : "Disabled"); vty_out(vty, "Number of L2 VNIs: %u\n", num_l2vnis); vty_out(vty, "Number of L3 VNIs: %u\n", num_l3vnis); } - evpn_show_all_vnis(vty, bgp_def, json); + evpn_show_all_vnis(vty, bgp_evpn, json); } else { int vni_idx = 0; @@ -3526,7 +3526,7 @@ DEFUN(show_bgp_l2vpn_evpn_vni, /* Display specific VNI */ vni = strtoul(argv[vni_idx + 1]->arg, NULL, 10); - evpn_show_vni(vty, bgp_def, vni, json); + evpn_show_vni(vty, bgp_evpn, vni, json); } if (uj) { @@ -4138,18 +4138,18 @@ DEFUN(show_bgp_l2vpn_evpn_vrf_import_rt, JSON_STR) { bool uj = false; - struct bgp *bgp_def = NULL; + struct bgp *bgp_evpn = NULL; json_object *json = NULL; - bgp_def = bgp_get_evpn(); - if (!bgp_def) + bgp_evpn = bgp_get_evpn(); + if (!bgp_evpn) return CMD_WARNING; uj = use_json(argc, argv); if (uj) json = json_object_new_object(); - evpn_show_vrf_import_rts(vty, bgp_def, json); + evpn_show_vrf_import_rts(vty, bgp_evpn, json); if (uj) { vty_out(vty, "%s\n", json_object_to_json_string_ext( diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c index 33e4655a1d..9b7eadf728 100644 --- a/zebra/zebra_vxlan.c +++ b/zebra/zebra_vxlan.c @@ -8581,10 +8581,10 @@ int zebra_vxlan_process_vrf_vni_cmd(struct zebra_vrf *zvrf, vni_t vni, int add) { zebra_l3vni_t *zl3vni = NULL; - struct zebra_vrf *zvrf_default = NULL; + struct zebra_vrf *zvrf_evpn = NULL; - zvrf_default = zebra_vrf_get_evpn(); - if (!zvrf_default) + zvrf_evpn = zebra_vrf_get_evpn(); + if (!zvrf_evpn) return -1; if (IS_ZEBRA_DEBUG_VXLAN) @@ -8638,7 +8638,7 @@ int zebra_vxlan_process_vrf_vni_cmd(struct zebra_vrf *zvrf, vni_t vni, zl3vni->svi_if = zl3vni_map_to_svi_if(zl3vni); /* formulate l2vni list */ - hash_iterate(zvrf_default->vni_table, zvni_add_to_l3vni_list, + hash_iterate(zvrf_evpn->vni_table, zvni_add_to_l3vni_list, zl3vni); if (is_l3vni_oper_up(zl3vni)) -- 2.39.5