diff options
Diffstat (limited to 'bgpd')
43 files changed, 933 insertions, 796 deletions
diff --git a/bgpd/bgp_bfd.c b/bgpd/bgp_bfd.c index 47dffd146a..663bc4894a 100644 --- a/bgpd/bgp_bfd.c +++ b/bgpd/bgp_bfd.c @@ -530,7 +530,7 @@ void bgp_bfd_peer_config_write(struct vty *vty, struct peer *peer, char *addr) /* * bgp_bfd_show_info - Show the peer BFD information. */ -void bgp_bfd_show_info(struct vty *vty, struct peer *peer, uint8_t use_json, +void bgp_bfd_show_info(struct vty *vty, struct peer *peer, bool use_json, json_object *json_neigh) { bfd_show_info(vty, (struct bfd_info *)peer->bfd_info, diff --git a/bgpd/bgp_bfd.h b/bgpd/bgp_bfd.h index a3cfca9c0d..caa5651e3a 100644 --- a/bgpd/bgp_bfd.h +++ b/bgpd/bgp_bfd.h @@ -34,8 +34,8 @@ extern void bgp_bfd_deregister_peer(struct peer *peer); extern void bgp_bfd_peer_config_write(struct vty *vty, struct peer *peer, char *addr); -extern void bgp_bfd_show_info(struct vty *vty, struct peer *peer, - uint8_t use_json, json_object *json_neigh); +extern void bgp_bfd_show_info(struct vty *vty, struct peer *peer, bool use_json, + json_object *json_neigh); extern int bgp_bfd_is_peer_multihop(struct peer *peer); diff --git a/bgpd/bgp_damp.c b/bgpd/bgp_damp.c index bce6056ded..071ee6b9c6 100644 --- a/bgpd/bgp_damp.c +++ b/bgpd/bgp_damp.c @@ -523,7 +523,7 @@ void bgp_config_write_damp(struct vty *vty) } static const char *bgp_get_reuse_time(unsigned int penalty, char *buf, - size_t len, uint8_t use_json, + size_t len, bool use_json, json_object *json) { time_t reuse_time = 0; @@ -641,7 +641,7 @@ void bgp_damp_info_vty(struct vty *vty, struct bgp_info *binfo, } const char *bgp_damp_reuse_time_vty(struct vty *vty, struct bgp_info *binfo, - char *timebuf, size_t len, uint8_t use_json, + char *timebuf, size_t len, bool use_json, json_object *json) { struct bgp_damp_info *bdi; diff --git a/bgpd/bgp_damp.h b/bgpd/bgp_damp.h index d3b0ae42aa..8326bae697 100644 --- a/bgpd/bgp_damp.h +++ b/bgpd/bgp_damp.h @@ -140,9 +140,10 @@ extern int bgp_damp_decay(time_t, int); extern void bgp_config_write_damp(struct vty *); extern void bgp_damp_info_vty(struct vty *, struct bgp_info *, json_object *json_path); -extern const char *bgp_damp_reuse_time_vty(struct vty *, struct bgp_info *, - char *, size_t, uint8_t, - json_object *); +extern const char *bgp_damp_reuse_time_vty(struct vty *vty, + struct bgp_info *binfo, + char *timebuf, size_t len, + bool use_json, json_object *json); extern int bgp_show_dampening_parameters(struct vty *vty, afi_t, safi_t); #endif /* _QUAGGA_BGP_DAMP_H */ diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c index b553cb42a5..a6cc2d9b53 100644 --- a/bgpd/bgp_evpn_vty.c +++ b/bgpd/bgp_evpn_vty.c @@ -983,7 +983,7 @@ static void show_vni_entry(struct hash_backet *backet, void *args[]) static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd, enum bgp_show_type type, void *output_arg, - int option, uint8_t use_json) + int option, bool use_json) { afi_t afi = AFI_L2VPN; struct bgp *bgp; @@ -1276,7 +1276,7 @@ DEFUN(show_ip_bgp_l2vpn_evpn_all_neighbor_routes, union sockunion su; struct peer *peer; int ret; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); argv_find(argv, argc, "A.B.C.D", &idx_ipv4); @@ -1336,7 +1336,7 @@ DEFUN(show_ip_bgp_l2vpn_evpn_rd_neighbor_routes, union sockunion su; struct peer *peer; struct prefix_rd prd; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); argv_find(argv, argc, "ASN:NN_OR_IP-ADDRESS:NN", &idx_ext_community); argv_find(argv, argc, "A.B.C.D", &idx_ipv4); @@ -1409,7 +1409,7 @@ DEFUN(show_ip_bgp_l2vpn_evpn_all_neighbor_advertised_routes, int ret; struct peer *peer; union sockunion su; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); argv_find(argv, argc, "A.B.C.D", &idx_ipv4); @@ -1467,7 +1467,7 @@ DEFUN(show_ip_bgp_l2vpn_evpn_rd_neighbor_advertised_routes, struct peer *peer; struct prefix_rd prd; union sockunion su; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); argv_find(argv, argc, "ASN:NN_OR_IP-ADDRESS:NN", &idx_ext_community); argv_find(argv, argc, "A.B.C.D", &idx_ipv4); @@ -3172,7 +3172,7 @@ DEFUN(show_bgp_l2vpn_evpn_vni, struct bgp *bgp_def; vni_t vni; int idx = 0; - uint8_t uj = 0; + bool uj = false; json_object *json = NULL; uint32_t num_l2vnis = 0; uint32_t num_l3vnis = 0; @@ -3255,7 +3255,7 @@ DEFUN(show_bgp_l2vpn_evpn_es, JSON_STR) { int idx = 0; - uint8_t uj = 0; + bool uj = false; esi_t esi; json_object *json = NULL; struct bgp *bgp = NULL; @@ -3312,7 +3312,7 @@ DEFUN(show_bgp_l2vpn_evpn_summary, JSON_STR) { int idx_vrf = 0; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); char *vrf = NULL; if (argv_find(argv, argc, "vrf", &idx_vrf)) @@ -3341,7 +3341,7 @@ DEFUN(show_bgp_l2vpn_evpn_route, struct bgp *bgp; int type_idx = 0; int type = 0; - uint8_t uj = 0; + bool uj = false; json_object *json = NULL; uj = use_json(argc, argv); @@ -3404,7 +3404,7 @@ DEFUN(show_bgp_l2vpn_evpn_route_rd, int type = 0; int rd_idx = 0; int type_idx = 0; - int uj = 0; + bool uj = false; json_object *json = NULL; bgp = bgp_get_default(); @@ -3477,7 +3477,7 @@ DEFUN(show_bgp_l2vpn_evpn_route_rd_macip, int rd_idx = 0; int mac_idx = 0; int ip_idx = 0; - int uj = 0; + bool uj = false; json_object *json = NULL; memset(&mac, 0, sizeof(struct ethaddr)); @@ -3541,7 +3541,7 @@ DEFUN(show_bgp_l2vpn_evpn_route_esi, "ESI ID\n" JSON_STR) { - int uj = 0; + bool uj = false; esi_t esi; struct bgp *bgp = NULL; json_object *json = NULL; @@ -3597,7 +3597,7 @@ DEFUN(show_bgp_l2vpn_evpn_route_vni, show_bgp_l2vpn_evpn_route_vni_cmd, struct in_addr vtep_ip; int type = 0; int idx = 0; - int uj = 0; + bool uj = false; json_object *json = NULL; bgp = bgp_get_default(); @@ -3669,7 +3669,7 @@ DEFUN(show_bgp_l2vpn_evpn_route_vni_macip, struct ethaddr mac; struct ipaddr ip; int idx = 0; - int uj = 0; + bool uj = false; json_object *json = NULL; bgp = bgp_get_default(); @@ -3737,7 +3737,7 @@ DEFUN(show_bgp_l2vpn_evpn_route_vni_multicast, int ret; struct in_addr orig_ip; int idx = 0; - int uj = 0; + bool uj = false; json_object *json = NULL; bgp = bgp_get_default(); @@ -3793,7 +3793,7 @@ DEFUN(show_bgp_l2vpn_evpn_route_vni_all, struct bgp *bgp; struct in_addr vtep_ip; int idx = 0; - int uj = 0; + bool uj = false; json_object *json = NULL; bgp = bgp_get_default(); @@ -3841,7 +3841,7 @@ DEFUN(show_bgp_l2vpn_evpn_vrf_import_rt, "Show vrf import route target\n" JSON_STR) { - uint8_t uj = 0; + bool uj = false; struct bgp *bgp_def = NULL; json_object *json = NULL; @@ -3878,7 +3878,7 @@ DEFUN(show_bgp_l2vpn_evpn_import_rt, JSON_STR) { struct bgp *bgp; - uint8_t uj = 0; + bool uj = false; json_object *json = NULL; bgp = bgp_get_default(); @@ -4359,7 +4359,7 @@ DEFUN (show_bgp_vrf_l3vni_info, json_object *json_vnis = NULL; json_object *json_export_rts = NULL; json_object *json_import_rts = NULL; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); if (uj) { json = json_object_new_object(); diff --git a/bgpd/bgp_filter.c b/bgpd/bgp_filter.c index ae9d805b05..c7977a9af4 100644 --- a/bgpd/bgp_filter.c +++ b/bgpd/bgp_filter.c @@ -391,16 +391,25 @@ static int as_list_dup_check(struct as_list *aslist, struct as_filter *new) return 0; } -DEFUN (ip_as_path, - ip_as_path_cmd, - "ip as-path access-list WORD <deny|permit> LINE...", - IP_STR - "BGP autonomous system path filter\n" - "Specify an access list name\n" - "Regular expression access list name\n" - "Specify packets to reject\n" - "Specify packets to forward\n" - "A regular-expression to match the BGP AS paths\n") +static int config_bgp_aspath_validate(const char *regstr) +{ + char valid_chars[] = "1234567890_^|[,{}() ]$*+.?-"; + + if (strspn(regstr, valid_chars) == strlen(regstr)) + return 1; + + return 0; +} + +DEFUN(ip_as_path, ip_as_path_cmd, + "ip as-path access-list WORD <deny|permit> LINE...", + IP_STR + "BGP autonomous system path filter\n" + "Specify an access list name\n" + "Regular expression access list name\n" + "Specify packets to reject\n" + "Specify packets to forward\n" + "A regular-expression (1234567890_(^|[,{}() ]|$)) to match the BGP AS paths\n") { int idx = 0; enum as_filter_type type; @@ -428,6 +437,12 @@ DEFUN (ip_as_path, return CMD_WARNING_CONFIG_FAILED; } + if (!config_bgp_aspath_validate(regstr)) { + vty_out(vty, "Invalid character in as-path access-list %s\n", + regstr); + return CMD_WARNING_CONFIG_FAILED; + } + asfilter = as_filter_make(regex, regstr, type); XFREE(MTYPE_TMP, regstr); @@ -444,17 +459,15 @@ DEFUN (ip_as_path, return CMD_SUCCESS; } -DEFUN (no_ip_as_path, - no_ip_as_path_cmd, - "no ip as-path access-list WORD <deny|permit> LINE...", - NO_STR - IP_STR - "BGP autonomous system path filter\n" - "Specify an access list name\n" - "Regular expression access list name\n" - "Specify packets to reject\n" - "Specify packets to forward\n" - "A regular-expression to match the BGP AS paths\n") +DEFUN(no_ip_as_path, no_ip_as_path_cmd, + "no ip as-path access-list WORD <deny|permit> LINE...", + NO_STR IP_STR + "BGP autonomous system path filter\n" + "Specify an access list name\n" + "Regular expression access list name\n" + "Specify packets to reject\n" + "Specify packets to forward\n" + "A regular-expression (1234567890_(^|[,{}() ]|$)) to match the BGP AS paths\n") { int idx = 0; enum as_filter_type type; @@ -488,6 +501,12 @@ DEFUN (no_ip_as_path, argv_find(argv, argc, "LINE", &idx); regstr = argv_concat(argv, argc, idx); + if (!config_bgp_aspath_validate(regstr)) { + vty_out(vty, "Invalid character in as-path access-list %s\n", + regstr); + return CMD_WARNING_CONFIG_FAILED; + } + regex = bgp_regcomp(regstr); if (!regex) { vty_out(vty, "can't compile regexp %s\n", regstr); diff --git a/bgpd/bgp_keepalives.c b/bgpd/bgp_keepalives.c index f81836cc83..aeb95f91ba 100644 --- a/bgpd/bgp_keepalives.c +++ b/bgpd/bgp_keepalives.c @@ -180,11 +180,7 @@ void *bgp_keepalives_start(void *arg) pthread_cond_init(peerhash_cond, &attrs); pthread_condattr_destroy(&attrs); -#ifdef GNU_LINUX - pthread_setname_np(fpt->thread, "bgpd_ka"); -#elif defined(OPEN_BSD) - pthread_set_name_np(fpt->thread, "bgpd_ka"); -#endif + frr_pthread_set_name(fpt, NULL, "bgpd_ka"); /* initialize peer hashtable */ peerhash = hash_create_size(2048, peer_hash_key, peer_hash_cmp, NULL); diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c index 138788194d..e0834604b2 100644 --- a/bgpd/bgp_main.c +++ b/bgpd/bgp_main.c @@ -266,6 +266,12 @@ static int bgp_vrf_enable(struct vrf *vrf) bgp = bgp_lookup_by_name(vrf->name); if (bgp) { + if (bgp->name && strmatch(vrf->name, VRF_DEFAULT_NAME)) { + XFREE(MTYPE_BGP, bgp->name); + bgp->name = NULL; + XFREE(MTYPE_BGP, bgp->name_pretty); + bgp->name_pretty = XSTRDUP(MTYPE_BGP, "VRF default"); + } old_vrf_id = bgp->vrf_id; /* We have instance configured, link to VRF and make it "up". */ bgp_vrf_link(bgp, vrf); @@ -332,7 +338,8 @@ static int bgp_vrf_disable(struct vrf *vrf) static void bgp_vrf_init(void) { - vrf_init(bgp_vrf_new, bgp_vrf_enable, bgp_vrf_disable, bgp_vrf_delete); + vrf_init(bgp_vrf_new, bgp_vrf_enable, bgp_vrf_disable, + bgp_vrf_delete, NULL); } static void bgp_vrf_terminate(void) diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index b89edfe459..459775c8ec 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -1775,7 +1775,7 @@ DEFUN (no_vpnv6_network, int bgp_show_mpls_vpn(struct vty *vty, afi_t afi, struct prefix_rd *prd, enum bgp_show_type type, void *output_arg, int tags, - uint8_t use_json) + bool use_json) { struct bgp *bgp; struct bgp_table *table; @@ -1953,7 +1953,7 @@ DEFUN (show_ip_bgp_vpn_all_neighbor_routes, union sockunion su; struct peer *peer; int ret; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); afi_t afi; int idx = 0; @@ -2017,7 +2017,7 @@ DEFUN (show_ip_bgp_vpn_rd_neighbor_routes, union sockunion su; struct peer *peer; struct prefix_rd prd; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); afi_t afi; int idx = 0; @@ -2095,7 +2095,7 @@ DEFUN (show_ip_bgp_vpn_all_neighbor_advertised_routes, int ret; struct peer *peer; union sockunion su; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); afi_t afi; int idx = 0; @@ -2157,7 +2157,7 @@ DEFUN (show_ip_bgp_vpn_rd_neighbor_advertised_routes, struct peer *peer; struct prefix_rd prd; union sockunion su; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); afi_t afi; int idx = 0; diff --git a/bgpd/bgp_mplsvpn.h b/bgpd/bgp_mplsvpn.h index 122ae9e905..61b87392a2 100644 --- a/bgpd/bgp_mplsvpn.h +++ b/bgpd/bgp_mplsvpn.h @@ -50,7 +50,7 @@ extern int argv_find_and_parse_vpnvx(struct cmd_token **argv, int argc, int *index, afi_t *afi); extern int bgp_show_mpls_vpn(struct vty *vty, afi_t afi, struct prefix_rd *prd, enum bgp_show_type type, void *output_arg, - int tags, uint8_t use_json); + int tags, bool use_json); extern void vpn_leak_from_vrf_update(struct bgp *bgp_vpn, struct bgp *bgp_vrf, struct bgp_info *info_vrf); diff --git a/bgpd/bgp_open.c b/bgpd/bgp_open.c index 7fbc030242..5bdee5f512 100644 --- a/bgpd/bgp_open.c +++ b/bgpd/bgp_open.c @@ -52,8 +52,8 @@ Next, if we send capability to the peer we want to set my capabilty inforation at each peer. */ -void bgp_capability_vty_out(struct vty *vty, struct peer *peer, - uint8_t use_json, json_object *json_neigh) +void bgp_capability_vty_out(struct vty *vty, struct peer *peer, bool use_json, + json_object *json_neigh) { char *pnt; char *end; diff --git a/bgpd/bgp_open.h b/bgpd/bgp_open.h index 42ebe97f2e..0fc321bdf3 100644 --- a/bgpd/bgp_open.h +++ b/bgpd/bgp_open.h @@ -86,8 +86,8 @@ struct graceful_restart_af { extern int bgp_open_option_parse(struct peer *, uint8_t, int *); extern void bgp_open_capability(struct stream *, struct peer *); -extern void bgp_capability_vty_out(struct vty *, struct peer *, uint8_t, - json_object *); +extern void bgp_capability_vty_out(struct vty *vty, struct peer *peer, + bool use_json, json_object *json_neigh); extern as_t peek_for_as4_capability(struct peer *, uint8_t); #endif /* _QUAGGA_BGP_OPEN_H */ diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 50c484d7de..50ffea27bf 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -6755,7 +6755,7 @@ void route_vty_out(struct vty *vty, struct prefix *p, struct bgp_info *binfo, /* called from terminal list command */ void route_vty_out_tmp(struct vty *vty, struct prefix *p, struct attr *attr, - safi_t safi, uint8_t use_json, json_object *json_ar) + safi_t safi, bool use_json, json_object *json_ar) { json_object *json_status = NULL; json_object *json_net = NULL; @@ -7084,7 +7084,7 @@ void route_vty_out_overlay(struct vty *vty, struct prefix *p, /* dampening route */ static void damp_route_vty_out(struct vty *vty, struct prefix *p, struct bgp_info *binfo, int display, safi_t safi, - uint8_t use_json, json_object *json) + bool use_json, json_object *json) { struct attr *attr; int len; @@ -7147,7 +7147,7 @@ static void damp_route_vty_out(struct vty *vty, struct prefix *p, /* flap route */ static void flap_route_vty_out(struct vty *vty, struct prefix *p, struct bgp_info *binfo, int display, safi_t safi, - uint8_t use_json, json_object *json) + bool use_json, json_object *json) { struct attr *attr; struct bgp_damp_info *bdi; @@ -8160,12 +8160,12 @@ static int bgp_show_regexp(struct vty *vty, struct bgp *bgp, const char *regstr, afi_t afi, safi_t safi, enum bgp_show_type type); static int bgp_show_community(struct vty *vty, struct bgp *bgp, const char *comstr, int exact, afi_t afi, - safi_t safi, uint8_t use_json); + safi_t safi, bool use_json); static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, struct bgp_table *table, enum bgp_show_type type, - void *output_arg, uint8_t use_json, char *rd, + void *output_arg, bool use_json, char *rd, int is_last, unsigned long *output_cum, unsigned long *total_cum, unsigned long *json_header_depth) @@ -8452,8 +8452,7 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, safi_t safi, struct bgp_table *table, struct prefix_rd *prd_match, - enum bgp_show_type type, void *output_arg, - uint8_t use_json) + enum bgp_show_type type, void *output_arg, bool use_json) { struct bgp_node *rn, *next; unsigned long output_cum = 0; @@ -8493,7 +8492,7 @@ int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, safi_t safi, return CMD_SUCCESS; } static int bgp_show(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, - enum bgp_show_type type, void *output_arg, uint8_t use_json) + enum bgp_show_type type, void *output_arg, bool use_json) { struct bgp_table *table; unsigned long json_header_depth = 0; @@ -8531,16 +8530,18 @@ static int bgp_show(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, } static void bgp_show_all_instances_routes_vty(struct vty *vty, afi_t afi, - safi_t safi, uint8_t use_json) + safi_t safi, bool use_json) { struct listnode *node, *nnode; struct bgp *bgp; int is_first = 1; + bool route_output = false; if (use_json) vty_out(vty, "{\n"); for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { + route_output = true; if (use_json) { if (!is_first) vty_out(vty, ",\n"); @@ -8563,6 +8564,8 @@ static void bgp_show_all_instances_routes_vty(struct vty *vty, afi_t afi, if (use_json) vty_out(vty, "}\n"); + else if (!route_output) + vty_out(vty, "%% BGP instance not found\n"); } /* Header of detailed BGP route information */ @@ -8748,8 +8751,7 @@ static int bgp_show_route_in_table(struct vty *vty, struct bgp *bgp, struct bgp_table *rib, const char *ip_str, afi_t afi, safi_t safi, struct prefix_rd *prd, int prefix_check, - enum bgp_path_type pathtype, - uint8_t use_json) + enum bgp_path_type pathtype, bool use_json) { int ret; int header; @@ -8885,7 +8887,7 @@ static int bgp_show_route_in_table(struct vty *vty, struct bgp *bgp, static int bgp_show_route(struct vty *vty, struct bgp *bgp, const char *ip_str, afi_t afi, safi_t safi, struct prefix_rd *prd, int prefix_check, enum bgp_path_type pathtype, - uint8_t use_json) + bool use_json) { if (!bgp) { bgp = bgp_get_default(); @@ -8994,7 +8996,7 @@ DEFUN (show_ip_bgp_large_community_list, safi = bgp_vty_safi_from_str(argv[idx]->text); } - int uj = use_json(argc, argv); + bool uj = use_json(argc, argv); struct bgp *bgp = bgp_lookup_by_name(vrf); if (bgp == NULL) { @@ -9037,7 +9039,7 @@ DEFUN (show_ip_bgp_large_community, safi = bgp_vty_safi_from_str(argv[idx]->text); } - int uj = use_json(argc, argv); + bool uj = use_json(argc, argv); struct bgp *bgp = bgp_lookup_by_name(vrf); if (bgp == NULL) { @@ -9121,7 +9123,7 @@ DEFUN (show_ip_bgp, int idx = 0; bgp_vty_find_and_parse_afi_safi_bgp(vty, argv, argc, &idx, &afi, &safi, - &bgp); + &bgp, false); if (!idx) return CMD_WARNING; @@ -9197,16 +9199,16 @@ DEFUN (show_ip_bgp_json, int idx = 0; int idx_community_type = 0; int exact_match = 0; + bool uj = use_json(argc, argv); + + if (uj) + argc--; bgp_vty_find_and_parse_afi_safi_bgp(vty, argv, argc, &idx, &afi, &safi, - &bgp); + &bgp, uj); if (!idx) return CMD_WARNING; - int uj = use_json(argc, argv); - if (uj) - argc--; - if (argv_find(argv, argc, "cidr-only", &idx)) return bgp_show(vty, bgp, afi, safi, bgp_show_type_cidr_only, NULL, uj); @@ -9275,12 +9277,12 @@ DEFUN (show_ip_bgp_route, char *prefix = NULL; struct bgp *bgp = NULL; enum bgp_path_type path_type; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); int idx = 0; bgp_vty_find_and_parse_afi_safi_bgp(vty, argv, argc, &idx, &afi, &safi, - &bgp); + &bgp, uj); if (!idx) return CMD_WARNING; @@ -9343,7 +9345,7 @@ DEFUN (show_ip_bgp_regexp, int idx = 0; bgp_vty_find_and_parse_afi_safi_bgp(vty, argv, argc, &idx, &afi, &safi, - &bgp); + &bgp, false); if (!idx) return CMD_WARNING; @@ -9372,17 +9374,17 @@ DEFUN (show_ip_bgp_instance_all, afi_t afi = AFI_IP; safi_t safi = SAFI_UNICAST; struct bgp *bgp = NULL; - int idx = 0; - bgp_vty_find_and_parse_afi_safi_bgp(vty, argv, argc, &idx, &afi, &safi, - &bgp); - if (!idx) - return CMD_WARNING; + bool uj = use_json(argc, argv); - int uj = use_json(argc, argv); if (uj) argc--; + bgp_vty_find_and_parse_afi_safi_bgp(vty, argv, argc, &idx, &afi, &safi, + &bgp, uj); + if (!idx) + return CMD_WARNING; + bgp_show_all_instances_routes_vty(vty, afi, safi, uj); return CMD_SUCCESS; } @@ -9453,7 +9455,7 @@ static int bgp_show_route_map(struct vty *vty, struct bgp *bgp, static int bgp_show_community(struct vty *vty, struct bgp *bgp, const char *comstr, int exact, afi_t afi, - safi_t safi, uint8_t use_json) + safi_t safi, bool use_json) { struct community *com; int ret = 0; @@ -9512,7 +9514,7 @@ static int bgp_show_prefix_longer(struct vty *vty, struct bgp *bgp, } static struct peer *peer_lookup_in_view(struct vty *vty, struct bgp *bgp, - const char *ip_str, uint8_t use_json) + const char *ip_str, bool use_json) { int ret; struct peer *peer; @@ -9899,7 +9901,7 @@ static int bgp_peer_count_walker(struct thread *t) } static int bgp_peer_counts(struct vty *vty, struct peer *peer, afi_t afi, - safi_t safi, uint8_t use_json) + safi_t safi, bool use_json) { struct peer_pcounts pcounts = {.peer = peer}; unsigned int i; @@ -10009,16 +10011,16 @@ DEFUN (show_ip_bgp_instance_neighbor_prefix_counts, struct peer *peer; int idx = 0; struct bgp *bgp = NULL; + bool uj = use_json(argc, argv); + + if (uj) + argc--; bgp_vty_find_and_parse_afi_safi_bgp(vty, argv, argc, &idx, &afi, &safi, - &bgp); + &bgp, uj); if (!idx) return CMD_WARNING; - int uj = use_json(argc, argv); - if (uj) - argc--; - argv_find(argv, argc, "neighbors", &idx); peer = peer_lookup_in_view(vty, bgp, argv[idx + 1]->arg, uj); if (!peer) @@ -10045,7 +10047,7 @@ DEFUN (show_ip_bgp_vpn_neighbor_prefix_counts, { int idx_peer = 6; struct peer *peer; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); peer = peer_lookup_in_view(vty, NULL, argv[idx_peer]->arg, uj); if (!peer) @@ -10118,7 +10120,7 @@ DEFUN (show_ip_bgp_l2vpn_evpn_all_route_prefix, static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, enum bgp_show_adj_route_type type, - const char *rmap_name, uint8_t use_json, + const char *rmap_name, bool use_json, json_object *json) { struct bgp_table *table; @@ -10389,7 +10391,7 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi, static int peer_adj_routes(struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, enum bgp_show_adj_route_type type, - const char *rmap_name, uint8_t use_json) + const char *rmap_name, bool use_json) { json_object *json = NULL; @@ -10463,18 +10465,17 @@ DEFUN (show_ip_bgp_instance_neighbor_advertised_route, struct bgp *bgp = NULL; struct peer *peer; enum bgp_show_adj_route_type type = bgp_show_adj_route_advertised; - int idx = 0; - bgp_vty_find_and_parse_afi_safi_bgp(vty, argv, argc, &idx, &afi, &safi, - &bgp); - if (!idx) - return CMD_WARNING; - - int uj = use_json(argc, argv); + bool uj = use_json(argc, argv); if (uj) argc--; + bgp_vty_find_and_parse_afi_safi_bgp(vty, argv, argc, &idx, &afi, &safi, + &bgp, uj); + if (!idx) + return CMD_WARNING; + /* neighbors <A.B.C.D|X:X::X:X|WORD> */ argv_find(argv, argc, "neighbors", &idx); peerstr = argv[++idx]->arg; @@ -10536,7 +10537,7 @@ DEFUN (show_ip_bgp_neighbor_received_prefix_filter, argv_find(argv, argc, "neighbors", &idx); peerstr = argv[++idx]->arg; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); ret = str2sockunion(peerstr, &su); if (ret < 0) { @@ -10580,7 +10581,7 @@ DEFUN (show_ip_bgp_neighbor_received_prefix_filter, static int bgp_show_neighbor_route(struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, - enum bgp_show_type type, uint8_t use_json) + enum bgp_show_type type, bool use_json) { /* labeled-unicast routes live in the unicast table */ if (safi == SAFI_LABELED_UNICAST) @@ -10620,14 +10621,17 @@ DEFUN (show_ip_bgp_flowspec_routes_detailed, safi_t safi = SAFI_UNICAST; struct bgp *bgp = NULL; int idx = 0; + bool uj = use_json(argc, argv); + + if (uj) + argc--; bgp_vty_find_and_parse_afi_safi_bgp(vty, argv, argc, &idx, &afi, &safi, - &bgp); + &bgp, uj); if (!idx) return CMD_WARNING; - return bgp_show(vty, bgp, afi, safi, - bgp_show_type_detail, NULL, use_json(argc, argv)); + return bgp_show(vty, bgp, afi, safi, bgp_show_type_detail, NULL, uj); } DEFUN (show_ip_bgp_neighbor_routes, @@ -10655,18 +10659,17 @@ DEFUN (show_ip_bgp_neighbor_routes, safi_t safi = SAFI_UNICAST; struct peer *peer; enum bgp_show_type sh_type = bgp_show_type_neighbor; - int idx = 0; + bool uj = use_json(argc, argv); + + if (uj) + argc--; bgp_vty_find_and_parse_afi_safi_bgp(vty, argv, argc, &idx, &afi, &safi, - &bgp); + &bgp, uj); if (!idx) return CMD_WARNING; - int uj = use_json(argc, argv); - if (uj) - argc--; - /* neighbors <A.B.C.D|X:X::X:X|WORD> */ argv_find(argv, argc, "neighbors", &idx); peerstr = argv[++idx]->arg; diff --git a/bgpd/bgp_route.h b/bgpd/bgp_route.h index dfef9a8f79..476bb3aa05 100644 --- a/bgpd/bgp_route.h +++ b/bgpd/bgp_route.h @@ -435,8 +435,9 @@ extern void route_vty_out(struct vty *, struct prefix *, struct bgp_info *, int, safi_t, json_object *); extern void route_vty_out_tag(struct vty *, struct prefix *, struct bgp_info *, int, safi_t, json_object *); -extern void route_vty_out_tmp(struct vty *, struct prefix *, struct attr *, - safi_t, uint8_t, json_object *); +extern void route_vty_out_tmp(struct vty *vty, struct prefix *p, + struct attr *attr, safi_t safi, bool use_json, + json_object *json_ar); extern void route_vty_out_overlay(struct vty *vty, struct prefix *p, struct bgp_info *binfo, int display, json_object *json); @@ -484,5 +485,5 @@ extern void route_vty_out_detail(struct vty *vty, struct bgp *bgp, extern int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, safi_t safi, struct bgp_table *table, struct prefix_rd *prd, enum bgp_show_type type, void *output_arg, - uint8_t use_json); + bool use_json); #endif /* _QUAGGA_BGP_ROUTE_H */ diff --git a/bgpd/bgp_vpn.c b/bgpd/bgp_vpn.c index a771eedf0f..2b4477ddde 100644 --- a/bgpd/bgp_vpn.c +++ b/bgpd/bgp_vpn.c @@ -32,7 +32,7 @@ int show_adj_route_vpn(struct vty *vty, struct peer *peer, struct prefix_rd *prd, afi_t afi, safi_t safi, - uint8_t use_json) + bool use_json) { struct bgp *bgp; struct bgp_table *table; diff --git a/bgpd/bgp_vpn.h b/bgpd/bgp_vpn.h index 98b4d9f180..a2e86476a2 100644 --- a/bgpd/bgp_vpn.h +++ b/bgpd/bgp_vpn.h @@ -25,6 +25,6 @@ extern int show_adj_route_vpn(struct vty *vty, struct peer *peer, struct prefix_rd *prd, afi_t afi, safi_t safi, - uint8_t use_json); + bool use_json); #endif /* _QUAGGA_BGP_VPN_H */ diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 1460a26215..3669ea7736 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -301,7 +301,7 @@ int argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, struct cmd_token **argv, int argc, int *idx, afi_t *afi, safi_t *safi, - struct bgp **bgp) + struct bgp **bgp, bool use_json) { char *vrf_name = NULL; @@ -312,18 +312,24 @@ int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, if (argv_find(argv, argc, "ip", idx)) *afi = AFI_IP; - if (argv_find(argv, argc, "view", idx) - || argv_find(argv, argc, "vrf", idx)) { + if (argv_find(argv, argc, "view", idx)) vrf_name = argv[*idx + 1]->arg; - + else if (argv_find(argv, argc, "vrf", idx)) { + vrf_name = argv[*idx + 1]->arg; + if (strmatch(vrf_name, VRF_DEFAULT_NAME)) + vrf_name = NULL; + } + if (vrf_name) { if (strmatch(vrf_name, "all")) *bgp = NULL; else { *bgp = bgp_lookup_by_name(vrf_name); if (!*bgp) { - vty_out(vty, - "View/Vrf specified is unknown: %s\n", - vrf_name); + if (use_json) + vty_out(vty, "{}\n"); + else + vty_out(vty, "View/Vrf %s is unknown\n", + vrf_name); *idx = 0; return 0; } @@ -331,7 +337,11 @@ int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, } else { *bgp = bgp_get_default(); if (!*bgp) { - vty_out(vty, "Unable to find default BGP instance\n"); + if (use_json) + vty_out(vty, "{}\n"); + else + vty_out(vty, + "Default BGP instance not found\n"); *idx = 0; return 0; } @@ -910,9 +920,12 @@ DEFUN_NOSH (router_bgp, if (argc > 3) { name = argv[idx_vrf]->arg; - if (!strcmp(argv[idx_view_vrf]->text, "vrf")) - inst_type = BGP_INSTANCE_TYPE_VRF; - else if (!strcmp(argv[idx_view_vrf]->text, "view")) + if (!strcmp(argv[idx_view_vrf]->text, "vrf")) { + if (strmatch(name, VRF_DEFAULT_NAME)) + name = NULL; + else + inst_type = BGP_INSTANCE_TYPE_VRF; + } else if (!strcmp(argv[idx_view_vrf]->text, "view")) inst_type = BGP_INSTANCE_TYPE_VIEW; } @@ -7144,13 +7157,17 @@ DEFUN (clear_ip_bgp_all, if (argv_find(argv, argc, "ip", &idx)) afi = AFI_IP; - /* [<view|vrf> VIEWVRFNAME] */ - if (argv_find(argv, argc, "view", &idx) - || argv_find(argv, argc, "vrf", &idx)) { + /* [<vrf> VIEWVRFNAME] */ + if (argv_find(argv, argc, "vrf", &idx)) { + vrf = argv[idx + 1]->arg; + idx += 2; + if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) + vrf = NULL; + } else if (argv_find(argv, argc, "view", &idx)) { + /* [<view> VIEWVRFNAME] */ vrf = argv[idx + 1]->arg; idx += 2; } - /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) argv_find_and_parse_safi(argv, argc, &idx, &safi); @@ -7215,8 +7232,16 @@ DEFUN (clear_ip_bgp_prefix, int idx = 0; /* [<view|vrf> VIEWVRFNAME] */ - if (argv_find(argv, argc, "VIEWVRFNAME", &idx)) - vrf = argv[idx]->arg; + if (argv_find(argv, argc, "vrf", &idx)) { + vrf = argv[idx + 1]->arg; + idx += 2; + if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) + vrf = NULL; + } else if (argv_find(argv, argc, "view", &idx)) { + /* [<view> VIEWVRFNAME] */ + vrf = argv[idx + 1]->arg; + idx += 2; + } prefix = argv[argc - 1]->arg; @@ -7258,16 +7283,23 @@ DEFUN (clear_bgp_instance_ipv6_safi_prefix, "Clear bestpath and re-advertise\n" "IPv6 prefix\n") { - int idx_word = 3; int idx_safi = 0; + int idx_vrfview = 0; int idx_ipv6_prefix = 0; safi_t safi = SAFI_UNICAST; char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? argv[idx_ipv6_prefix]->arg : NULL; - /* [<view|vrf> VIEWVRFNAME] */ - char *vrfview = argv_find(argv, argc, "VIEWVRFNAME", &idx_word) ? - argv[idx_word]->arg : NULL; + char *vrfview = NULL; + /* [<view|vrf> VIEWVRFNAME] */ + if (argv_find(argv, argc, "vrf", &idx_vrfview)) { + vrfview = argv[idx_vrfview + 1]->arg; + if (vrfview && strmatch(vrfview, VRF_DEFAULT_NAME)) + vrfview = NULL; + } else if (argv_find(argv, argc, "view", &idx_vrfview)) { + /* [<view> VIEWVRFNAME] */ + vrfview = argv[idx_vrfview + 1]->arg; + } argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); return bgp_clear_prefix( @@ -7317,7 +7349,7 @@ DEFUN (show_bgp_vrfs, struct list *inst = bm->bgp; struct listnode *node; struct bgp *bgp; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); json_object *json = NULL; json_object *json_vrfs = NULL; int count = 0; @@ -7458,10 +7490,18 @@ DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, { struct bgp *bgp = NULL; int idx = 0; - - if (argv_find(argv, argc, "view", &idx) - || argv_find(argv, argc, "vrf", &idx)) - bgp = bgp_lookup_by_name(argv[idx + 1]->arg); + char *name = NULL; + + /* [<vrf> VIEWVRFNAME] */ + if (argv_find(argv, argc, "vrf", &idx)) { + name = argv[idx + 1]->arg; + if (name && strmatch(name, VRF_DEFAULT_NAME)) + name = NULL; + } else if (argv_find(argv, argc, "view", &idx)) + /* [<view> VIEWVRFNAME] */ + name = argv[idx + 1]->arg; + if (name) + bgp = bgp_lookup_by_name(name); else bgp = bgp_get_default(); @@ -7638,7 +7678,7 @@ static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) /* Show BGP peer's summary information. */ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, - uint8_t use_json, json_object *json) + bool use_json, json_object *json) { struct peer *peer; struct listnode *node, *nnode; @@ -8055,14 +8095,14 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, } static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, - int safi, uint8_t use_json, + int safi, bool use_json, json_object *json) { int is_first = 1; int afi_wildcard = (afi == AFI_MAX); int safi_wildcard = (safi == SAFI_MAX); int is_wildcard = (afi_wildcard || safi_wildcard); - bool json_output = false; + bool nbr_output = false; if (use_json && is_wildcard) vty_out(vty, "{\n"); @@ -8073,7 +8113,7 @@ static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, safi = 1; /* SAFI_UNICAST */ while (safi < SAFI_MAX) { if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { - json_output = true; + nbr_output = true; if (is_wildcard) { /* * So limit output to those afi/safi @@ -8112,22 +8152,28 @@ static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, if (use_json && is_wildcard) vty_out(vty, "}\n"); - else if (use_json && !json_output) - vty_out(vty, "{}\n"); + else if (!nbr_output) { + if (use_json) + vty_out(vty, "{}\n"); + else + vty_out(vty, "%% No BGP neighbors found\n"); + } } static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, - safi_t safi, uint8_t use_json) + safi_t safi, bool use_json) { struct listnode *node, *nnode; struct bgp *bgp; json_object *json = NULL; int is_first = 1; + bool nbr_output = false; if (use_json) vty_out(vty, "{\n"); for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { + nbr_output = true; if (use_json) { json = json_object_new_object(); @@ -8151,10 +8197,12 @@ static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, if (use_json) vty_out(vty, "}\n"); + else if (!nbr_output) + vty_out(vty, "%% BGP instance not found\n"); } int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, - safi_t safi, uint8_t use_json) + safi_t safi, bool use_json) { struct bgp *bgp; @@ -8171,7 +8219,7 @@ int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, vty_out(vty, "{}\n"); else vty_out(vty, - "%% No such BGP instance exist\n"); + "%% BGP instance not found\n"); return CMD_WARNING; } @@ -8185,6 +8233,13 @@ int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, if (bgp) bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, NULL); + else { + if (use_json) + vty_out(vty, "{}\n"); + else + vty_out(vty, "%% BGP instance not found\n"); + return CMD_WARNING; + } return CMD_SUCCESS; } @@ -8211,16 +8266,20 @@ DEFUN (show_ip_bgp_summary, /* show [ip] bgp */ if (argv_find(argv, argc, "ip", &idx)) afi = AFI_IP; - /* [<view|vrf> VIEWVRFNAME] */ - if (argv_find(argv, argc, "view", &idx) - || argv_find(argv, argc, "vrf", &idx)) - vrf = argv[++idx]->arg; + /* [<vrf> VIEWVRFNAME] */ + if (argv_find(argv, argc, "vrf", &idx)) { + vrf = argv[idx + 1]->arg; + if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) + vrf = NULL; + } else if (argv_find(argv, argc, "view", &idx)) + /* [<view> VIEWVRFNAME] */ + vrf = argv[idx + 1]->arg; /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { argv_find_and_parse_safi(argv, argc, &idx, &safi); } - int uj = use_json(argc, argv); + bool uj = use_json(argc, argv); return bgp_show_summary_vty(vty, vrf, afi, safi, uj); } @@ -8302,7 +8361,7 @@ static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, afi_t afi, safi_t safi, uint16_t adv_smcap, uint16_t adv_rmcap, uint16_t rcv_smcap, uint16_t rcv_rmcap, - uint8_t use_json, json_object *json_pref) + bool use_json, json_object *json_pref) { /* Send-Mode */ if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) @@ -8362,7 +8421,7 @@ static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, } static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, - safi_t safi, uint8_t use_json, + safi_t safi, bool use_json, json_object *json_neigh) { struct bgp_filter *filter; @@ -8937,7 +8996,7 @@ static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, } } -static void bgp_show_peer(struct vty *vty, struct peer *p, uint8_t use_json, +static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, json_object *json) { struct bgp *bgp; @@ -10684,12 +10743,13 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, uint8_t use_json, static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, enum show_type type, union sockunion *su, - const char *conf_if, uint8_t use_json, + const char *conf_if, bool use_json, json_object *json) { struct listnode *node, *nnode; struct peer *peer; int find = 0; + bool nbr_output = false; for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) @@ -10698,6 +10758,7 @@ static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, switch (type) { case show_all: bgp_show_peer(vty, peer, use_json, json); + nbr_output = true; break; case show_peer: if (conf_if) { @@ -10727,6 +10788,9 @@ static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, vty_out(vty, "%% No such neighbor in this view/vrf\n"); } + if (type != show_peer && !nbr_output && !use_json) + vty_out(vty, "%% No BGP neighbors found\n"); + if (use_json) { vty_out(vty, "%s\n", json_object_to_json_string_ext( json, JSON_C_TO_STRING_PRETTY)); @@ -10741,18 +10805,20 @@ static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, static void bgp_show_all_instances_neighbors_vty(struct vty *vty, enum show_type type, const char *ip_str, - uint8_t use_json) + bool use_json) { struct listnode *node, *nnode; struct bgp *bgp; union sockunion su; json_object *json = NULL; int ret, is_first = 1; + bool nbr_output = false; if (use_json) vty_out(vty, "{\n"); for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { + nbr_output = true; if (use_json) { if (!(json = json_object_new_object())) { flog_err( @@ -10805,11 +10871,13 @@ static void bgp_show_all_instances_neighbors_vty(struct vty *vty, if (use_json) vty_out(vty, "}\n"); + else if (!nbr_output) + vty_out(vty, "%% BGP instance not found\n"); } static int bgp_show_neighbor_vty(struct vty *vty, const char *name, enum show_type type, const char *ip_str, - uint8_t use_json) + bool use_json) { int ret; struct bgp *bgp; @@ -10826,8 +10894,6 @@ static int bgp_show_neighbor_vty(struct vty *vty, const char *name, if (!bgp) { if (use_json) { json = json_object_new_object(); - json_object_boolean_true_add( - json, "bgpNoSuchInstance"); vty_out(vty, "%s\n", json_object_to_json_string_ext( json, @@ -10835,7 +10901,7 @@ static int bgp_show_neighbor_vty(struct vty *vty, const char *name, json_object_free(json); } else vty_out(vty, - "%% No such BGP instance exist\n"); + "%% BGP instance not found\n"); return CMD_WARNING; } @@ -10859,6 +10925,11 @@ static int bgp_show_neighbor_vty(struct vty *vty, const char *name, json); } json_object_free(json); + } else { + if (use_json) + vty_out(vty, "{}\n"); + else + vty_out(vty, "%% BGP instance not found\n"); } return CMD_SUCCESS; @@ -10884,12 +10955,17 @@ DEFUN (show_ip_bgp_neighbors, char *sh_arg = NULL; enum show_type sh_type; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); int idx = 0; - if (argv_find(argv, argc, "view", &idx) - || argv_find(argv, argc, "vrf", &idx)) + /* [<vrf> VIEWVRFNAME] */ + if (argv_find(argv, argc, "vrf", &idx)) { + vrf = argv[idx + 1]->arg; + if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) + vrf = NULL; + } else if (argv_find(argv, argc, "view", &idx)) + /* [<view> VIEWVRFNAME] */ vrf = argv[idx + 1]->arg; idx++; @@ -10994,8 +11070,8 @@ DEFUN (show_ip_bgp_attr_info, return CMD_SUCCESS; } -static int bgp_show_route_leak_vty(struct vty *vty, const char *name, - afi_t afi, safi_t safi, uint8_t use_json) +static int bgp_show_route_leak_vty(struct vty *vty, const char *name, afi_t afi, + safi_t safi, bool use_json) { struct bgp *bgp; struct listnode *node; @@ -11011,16 +11087,9 @@ static int bgp_show_route_leak_vty(struct vty *vty, const char *name, json = json_object_new_object(); - /* Provide context for the block */ - json_object_string_add(json, "vrf", name ? name : "default"); - json_object_string_add(json, "afiSafi", - afi_safi_print(afi, safi)); - bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); if (!bgp) { - json_object_boolean_true_add(json, - "bgpNoSuchInstance"); vty_out(vty, "%s\n", json_object_to_json_string_ext( json, @@ -11030,6 +11099,11 @@ static int bgp_show_route_leak_vty(struct vty *vty, const char *name, return CMD_WARNING; } + /* Provide context for the block */ + json_object_string_add(json, "vrf", name ? name : "default"); + json_object_string_add(json, "afiSafi", + afi_safi_print(afi, safi)); + if (!CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_VRF_TO_VRF_IMPORT)) { json_object_string_add(json, "importFromVrfs", "none"); @@ -11168,7 +11242,7 @@ DEFUN (show_ip_bgp_route_leak, afi_t afi = AFI_MAX; safi_t safi = SAFI_MAX; - uint8_t uj = use_json(argc, argv); + bool uj = use_json(argc, argv); int idx = 0; /* show [ip] bgp */ @@ -11183,8 +11257,11 @@ DEFUN (show_ip_bgp_route_leak, return CMD_WARNING; } - if (argv_find(argv, argc, "vrf", &idx)) - vrf = argv[++idx]->arg; + if (argv_find(argv, argc, "vrf", &idx)) { + vrf = argv[idx + 1]->arg; + if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) + vrf = NULL; + } /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { argv_find_and_parse_safi(argv, argc, &idx, &safi); @@ -11257,10 +11334,14 @@ DEFUN (show_ip_bgp_updgrps, /* show [ip] bgp */ if (argv_find(argv, argc, "ip", &idx)) afi = AFI_IP; - /* [<view|vrf> VIEWVRFNAME] */ - if (argv_find(argv, argc, "view", &idx) - || argv_find(argv, argc, "vrf", &idx)) - vrf = argv[++idx]->arg; + /* [<vrf> VIEWVRFNAME] */ + if (argv_find(argv, argc, "vrf", &idx)) { + vrf = argv[idx + 1]->arg; + if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) + vrf = NULL; + } else if (argv_find(argv, argc, "view", &idx)) + /* [<view> VIEWVRFNAME] */ + vrf = argv[idx + 1]->arg; /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { argv_find_and_parse_safi(argv, argc, &idx, &safi); @@ -11486,7 +11567,7 @@ static int bgp_show_peer_group_vty(struct vty *vty, const char *name, bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); if (!bgp) { - vty_out(vty, "%% No such BGP instance exists\n"); + vty_out(vty, "%% BGP instance not found\n"); return CMD_WARNING; } diff --git a/bgpd/bgp_vty.h b/bgpd/bgp_vty.h index afb85f112b..d9df2b4cfe 100644 --- a/bgpd/bgp_vty.h +++ b/bgpd/bgp_vty.h @@ -69,9 +69,10 @@ extern int argv_find_and_parse_safi(struct cmd_token **argv, int argc, extern int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, struct cmd_token **argv, int argc, int *idx, afi_t *afi, - safi_t *safi, struct bgp **bgp); + safi_t *safi, struct bgp **bgp, + bool use_json); extern int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, - safi_t safi, uint8_t use_json); + safi_t safi, bool use_json); extern void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, afi_t afi); #endif /* _QUAGGA_BGP_VTY_H */ diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 7ff5053ce3..a9707a7fc7 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -6626,7 +6626,7 @@ int peer_clear_soft(struct peer *peer, afi_t afi, safi_t safi, } /* Display peer uptime.*/ -char *peer_uptime(time_t uptime2, char *buf, size_t len, uint8_t use_json, +char *peer_uptime(time_t uptime2, char *buf, size_t len, bool use_json, json_object *json) { time_t uptime1, epoch_tbuf; @@ -7735,10 +7735,8 @@ static void bgp_viewvrf_autocomplete(vector comps, struct cmd_token *token) struct listnode *next; struct bgp *bgp; - RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { - if (vrf->vrf_id != VRF_DEFAULT) - vector_set(comps, XSTRDUP(MTYPE_COMPLETION, vrf->name)); - } + RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) + vector_set(comps, XSTRDUP(MTYPE_COMPLETION, vrf->name)); for (ALL_LIST_ELEMENTS_RO(bm->bgp, next, bgp)) { if (bgp->inst_type != BGP_INSTANCE_TYPE_VIEW) @@ -7767,8 +7765,8 @@ static void bgp_pthreads_init() .start = bgp_keepalives_start, .stop = bgp_keepalives_stop, }; - frr_pthread_new(&io, "BGP I/O thread"); - frr_pthread_new(&ka, "BGP Keepalives thread"); + frr_pthread_new(&io, "BGP I/O thread", "bgpd_io"); + frr_pthread_new(&ka, "BGP Keepalives thread", "bgpd_ka"); } void bgp_pthreads_run() diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index 06eb86da95..8a99741390 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -1513,7 +1513,8 @@ extern struct peer *peer_create(union sockunion *, const char *, struct bgp *, struct peer_group *); extern struct peer *peer_create_accept(struct bgp *); extern void peer_xfer_config(struct peer *dst, struct peer *src); -extern char *peer_uptime(time_t, char *, size_t, uint8_t, json_object *); +extern char *peer_uptime(time_t uptime2, char *buf, size_t len, bool use_json, + json_object *json); extern int bgp_config_write(struct vty *); diff --git a/bgpd/rfapi/bgp_rfapi_cfg.c b/bgpd/rfapi/bgp_rfapi_cfg.c index 8553846c90..f1dd08fda0 100644 --- a/bgpd/rfapi/bgp_rfapi_cfg.c +++ b/bgpd/rfapi/bgp_rfapi_cfg.c @@ -23,7 +23,7 @@ #include "lib/prefix.h" #include "lib/memory.h" #include "lib/linklist.h" -#include "lib/table.h" +#include "lib/agg_table.h" #include "lib/plist.h" #include "lib/routemap.h" @@ -126,10 +126,10 @@ struct rfapi_nve_group_cfg *bgp_rfapi_cfg_match_group(struct rfapi_cfg *hc, struct rfapi_nve_group_cfg *rfg_vn = NULL; struct rfapi_nve_group_cfg *rfg_un = NULL; - struct route_table *rt_vn; - struct route_table *rt_un; - struct route_node *rn_vn; - struct route_node *rn_un; + struct agg_table *rt_vn; + struct agg_table *rt_un; + struct agg_node *rn_vn; + struct agg_node *rn_un; struct rfapi_nve_group_cfg *rfg; struct listnode *node, *nnode; @@ -156,16 +156,16 @@ struct rfapi_nve_group_cfg *bgp_rfapi_cfg_match_group(struct rfapi_cfg *hc, return NULL; } - rn_vn = route_node_match(rt_vn, vn); /* NB locks node */ + rn_vn = agg_node_match(rt_vn, vn); /* NB locks node */ if (rn_vn) { rfg_vn = rn_vn->info; - route_unlock_node(rn_vn); + agg_unlock_node(rn_vn); } - rn_un = route_node_match(rt_un, un); /* NB locks node */ + rn_un = agg_node_match(rt_un, un); /* NB locks node */ if (rn_un) { rfg_un = rn_un->info; - route_unlock_node(rn_un); + agg_unlock_node(rn_un); } #if BGP_VNC_DEBUG_MATCH_GROUP @@ -2304,11 +2304,11 @@ static void bgp_rfapi_delete_nve_group(struct vty *vty, /* NULL = no output */ if (rfg->vn_node) { rfg->vn_node->info = NULL; - route_unlock_node(rfg->vn_node); /* frees */ + agg_unlock_node(rfg->vn_node); /* frees */ } if (rfg->un_node) { rfg->un_node->info = NULL; - route_unlock_node(rfg->un_node); /* frees */ + agg_unlock_node(rfg->un_node); /* frees */ } if (rfg->rfp_cfg) XFREE(MTYPE_RFAPI_RFP_GROUP_CFG, rfg->rfp_cfg); @@ -2468,8 +2468,8 @@ DEFUN (vnc_nve_group_prefix, VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg, rfg); struct prefix p; afi_t afi; - struct route_table *rt; - struct route_node *rn; + struct agg_table *rt; + struct agg_node *rn; int is_un_prefix = 0; /* make sure it's still in list */ @@ -2497,12 +2497,12 @@ DEFUN (vnc_nve_group_prefix, rt = bgp->rfapi_cfg->nve_groups_vn[afi]; } - rn = route_node_get(rt, &p); /* NB locks node */ + rn = agg_node_get(rt, &p); /* NB locks node */ if (rn->info) { /* * There is already a group with this prefix */ - route_unlock_node(rn); + agg_unlock_node(rn); if (rn->info != rfg) { /* * different group name: fail @@ -2535,7 +2535,7 @@ DEFUN (vnc_nve_group_prefix, /* detach rfg from previous route table location */ if (rfg->un_node) { rfg->un_node->info = NULL; - route_unlock_node(rfg->un_node); /* frees */ + agg_unlock_node(rfg->un_node); /* frees */ } rfg->un_node = rn; /* back ref */ rfg->un_prefix = p; @@ -2545,7 +2545,7 @@ DEFUN (vnc_nve_group_prefix, /* detach rfg from previous route table location */ if (rfg->vn_node) { rfg->vn_node->info = NULL; - route_unlock_node(rfg->vn_node); /* frees */ + agg_unlock_node(rfg->vn_node); /* frees */ } rfg->vn_node = rn; /* back ref */ rfg->vn_prefix = p; @@ -3761,8 +3761,8 @@ struct rfapi_cfg *bgp_rfapi_cfg_new(struct rfapi_rfp_cfg *cfg) h->nve_groups_sequential = list_new(); assert(h->nve_groups_sequential); for (afi = AFI_IP; afi < AFI_MAX; afi++) { - h->nve_groups_vn[afi] = route_table_init(); - h->nve_groups_un[afi] = route_table_init(); + h->nve_groups_vn[afi] = agg_table_init(); + h->nve_groups_un[afi] = agg_table_init(); } h->default_response_lifetime = BGP_VNC_DEFAULT_RESPONSE_LIFETIME_DEFAULT; @@ -3820,8 +3820,8 @@ void bgp_rfapi_cfg_destroy(struct bgp *bgp, struct rfapi_cfg *h) if (h->default_rfp_cfg) XFREE(MTYPE_RFAPI_RFP_GROUP_CFG, h->default_rfp_cfg); for (afi = AFI_IP; afi < AFI_MAX; afi++) { - route_table_finish(h->nve_groups_vn[afi]); - route_table_finish(h->nve_groups_un[afi]); + agg_table_finish(h->nve_groups_vn[afi]); + agg_table_finish(h->nve_groups_un[afi]); } XFREE(MTYPE_RFAPI_CFG, h); } diff --git a/bgpd/rfapi/bgp_rfapi_cfg.h b/bgpd/rfapi/bgp_rfapi_cfg.h index a11b0992fa..b72d38220b 100644 --- a/bgpd/rfapi/bgp_rfapi_cfg.h +++ b/bgpd/rfapi/bgp_rfapi_cfg.h @@ -47,8 +47,8 @@ typedef enum { } rfapi_group_cfg_type_t; struct rfapi_nve_group_cfg { - struct route_node *vn_node; /* backref */ - struct route_node *un_node; /* backref */ + struct agg_node *vn_node; /* backref */ + struct agg_node *un_node; /* backref */ rfapi_group_cfg_type_t type; /* NVE|VPN */ char *name; /* unique by type! */ @@ -135,8 +135,8 @@ struct rfapi_cfg { struct list *l2_groups; /* rfapi_l2_group_cfg list */ /* three views into the same collection of rfapi_nve_group_cfg */ struct list *nve_groups_sequential; - struct route_table *nve_groups_vn[AFI_MAX]; - struct route_table *nve_groups_un[AFI_MAX]; + struct agg_table *nve_groups_vn[AFI_MAX]; + struct agg_table *nve_groups_un[AFI_MAX]; /* * For Single VRF export to ordinary routing protocols. This is diff --git a/bgpd/rfapi/rfapi.c b/bgpd/rfapi/rfapi.c index 84a5b9c70f..a427608f67 100644 --- a/bgpd/rfapi/rfapi.c +++ b/bgpd/rfapi/rfapi.c @@ -23,7 +23,7 @@ #include "lib/zebra.h" #include "lib/prefix.h" -#include "lib/table.h" +#include "lib/agg_table.h" #include "lib/vty.h" #include "lib/memory.h" #include "lib/routemap.h" @@ -203,11 +203,11 @@ int rfapi_ip_addr_cmp(struct rfapi_ip_addr *a1, struct rfapi_ip_addr *a2) static int rfapi_find_node(struct bgp *bgp, struct rfapi_ip_addr *vn_addr, struct rfapi_ip_addr *un_addr, - struct route_node **node) + struct agg_node **node) { struct rfapi *h; struct prefix p; - struct route_node *rn; + struct agg_node *rn; int rc; afi_t afi; @@ -228,12 +228,12 @@ static int rfapi_find_node(struct bgp *bgp, struct rfapi_ip_addr *vn_addr, if ((rc = rfapiRaddr2Qprefix(un_addr, &p))) return rc; - rn = route_node_lookup(h->un[afi], &p); + rn = agg_node_lookup(h->un[afi], &p); if (!rn) return ENOENT; - route_unlock_node(rn); + agg_unlock_node(rn); *node = rn; @@ -244,7 +244,7 @@ static int rfapi_find_node(struct bgp *bgp, struct rfapi_ip_addr *vn_addr, int rfapi_find_rfd(struct bgp *bgp, struct rfapi_ip_addr *vn_addr, struct rfapi_ip_addr *un_addr, struct rfapi_descriptor **rfd) { - struct route_node *rn; + struct agg_node *rn; int rc; rc = rfapi_find_node(bgp, vn_addr, un_addr, &rn); @@ -1347,8 +1347,8 @@ static int rfapi_open_inner(struct rfapi_descriptor *rfd, struct bgp *bgp, #define RFD_RTINIT_AFI(rh, ary, afi) \ do { \ if (!ary[afi]) { \ - ary[afi] = route_table_init(); \ - ary[afi]->info = rh; \ + ary[afi] = agg_table_init(); \ + agg_set_table_info(ary[afi], rh); \ } \ } while (0) @@ -1394,7 +1394,7 @@ int rfapi_init_and_open(struct bgp *bgp, struct rfapi_descriptor *rfd, char buf_un[BUFSIZ]; afi_t afi_vn, afi_un; struct prefix pfx_un; - struct route_node *rn; + struct agg_node *rn; rfapi_time(&rfd->open_time); @@ -1423,7 +1423,7 @@ int rfapi_init_and_open(struct bgp *bgp, struct rfapi_descriptor *rfd, assert(afi_vn && afi_un); assert(!rfapiRaddr2Qprefix(&rfd->un_addr, &pfx_un)); - rn = route_node_get(h->un[afi_un], &pfx_un); + rn = agg_node_get(h->un[afi_un], &pfx_un); assert(rn); rfd->next = rn->info; rn->info = rfd; @@ -1535,7 +1535,7 @@ rfapi_query_inner(void *handle, struct rfapi_ip_addr *target, afi_t afi; struct prefix p; struct prefix p_original; - struct route_node *rn; + struct agg_node *rn; struct rfapi_descriptor *rfd = (struct rfapi_descriptor *)handle; struct bgp *bgp = rfd->bgp; struct rfapi_next_hop_entry *pNHE = NULL; @@ -1704,7 +1704,7 @@ rfapi_query_inner(void *handle, struct rfapi_ip_addr *target, } if (rn) { - route_lock_node(rn); /* so we can unlock below */ + agg_lock_node(rn); /* so we can unlock below */ } else { /* * returns locked node. Don't unlock yet because the @@ -1721,7 +1721,7 @@ rfapi_query_inner(void *handle, struct rfapi_ip_addr *target, assert(rn); if (!rn->info) { - route_unlock_node(rn); + agg_unlock_node(rn); vnc_zlog_debug_verbose( "%s: VPN route not found, returning ENOENT", __func__); return ENOENT; @@ -1758,7 +1758,7 @@ rfapi_query_inner(void *handle, struct rfapi_ip_addr *target, &p_original); } - route_unlock_node(rn); + agg_unlock_node(rn); done: if (ppNextHopEntry) { @@ -2170,7 +2170,7 @@ int rfapi_close(void *handle) { struct rfapi_descriptor *rfd = (struct rfapi_descriptor *)handle; int rc; - struct route_node *node; + struct agg_node *node; struct bgp *bgp; struct rfapi *h; @@ -2276,7 +2276,7 @@ int rfapi_close(void *handle) } } } - route_unlock_node(node); + agg_unlock_node(node); } /* diff --git a/bgpd/rfapi/rfapi_ap.c b/bgpd/rfapi/rfapi_ap.c index 3112505d4b..691e1e4ec8 100644 --- a/bgpd/rfapi/rfapi_ap.c +++ b/bgpd/rfapi/rfapi_ap.c @@ -22,7 +22,7 @@ #include "lib/zebra.h" #include "lib/prefix.h" -#include "lib/table.h" +#include "lib/agg_table.h" #include "lib/vty.h" #include "lib/memory.h" #include "lib/routemap.h" diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c index ac3b6da230..4c506da686 100644 --- a/bgpd/rfapi/rfapi_import.c +++ b/bgpd/rfapi/rfapi_import.c @@ -27,7 +27,7 @@ #include "lib/zebra.h" #include "lib/prefix.h" -#include "lib/table.h" +#include "lib/agg_table.h" #include "lib/vty.h" #include "lib/memory.h" #include "lib/log.h" @@ -80,7 +80,7 @@ */ struct rfapi_withdraw { struct rfapi_import_table *import_table; - struct route_node *node; + struct agg_node *node; struct bgp_info *info; safi_t safi; /* used only for bulk operations */ /* @@ -88,8 +88,8 @@ struct rfapi_withdraw { * Normally when a timer expires, lockoffset should be 0. However, if * the timer expiration function is called directly (e.g., * rfapiExpireVpnNow), the node could be locked by a preceding - * route_top() or route_next() in a loop, so we need to pass this - * value in. + * agg_route_top() or agg_route_next() in a loop, so we need to pass + * this value in. */ int lockoffset; }; @@ -140,8 +140,8 @@ void rfapiCheckRouteCount() for (it = h->imports; it; it = it->next) { for (afi = AFI_IP; afi < AFI_MAX; ++afi) { - struct route_table *rt; - struct route_node *rn; + struct agg_table *rt; + struct agg_node *rn; int holddown_count = 0; int local_count = 0; @@ -150,7 +150,8 @@ void rfapiCheckRouteCount() rt = it->imported_vpn[afi]; - for (rn = route_top(rt); rn; rn = route_next(rn)) { + for (rn = agg_route_top(rt); rn; + rn = agg_route_next(rn)) { struct bgp_info *bi; struct bgp_info *next; @@ -211,11 +212,11 @@ void rfapiCheckRouteCount() * Validate reference count for a node in an import table * * Normally lockoffset is 0 for nodes in quiescent state. However, - * route_unlock_node will delete the node if it is called when + * agg_unlock_node will delete the node if it is called when * node->lock == 1, and we have to validate the refcount before * the node is deleted. In this case, we specify lockoffset 1. */ -void rfapiCheckRefcount(struct route_node *rn, safi_t safi, int lockoffset) +void rfapiCheckRefcount(struct agg_node *rn, safi_t safi, int lockoffset) { unsigned int count_bi = 0; unsigned int count_monitor = 0; @@ -613,8 +614,8 @@ struct rfapi_import_table *rfapiMacImportTableGet(struct bgp *bgp, uint32_t lni) it->rt_import_list = enew; for (afi = AFI_IP; afi < AFI_MAX; ++afi) { - it->imported_vpn[afi] = route_table_init(); - it->imported_encap[afi] = route_table_init(); + it->imported_vpn[afi] = agg_table_init(); + it->imported_encap[afi] = agg_table_init(); } it->l2_logical_net_id = lni; @@ -633,10 +634,10 @@ struct rfapi_import_table *rfapiMacImportTableGet(struct bgp *bgp, uint32_t lni) * Returns pointer to the list of moved monitors */ static struct rfapi_monitor_vpn * -rfapiMonitorMoveShorter(struct route_node *original_vpn_node, int lockoffset) +rfapiMonitorMoveShorter(struct agg_node *original_vpn_node, int lockoffset) { struct bgp_info *bi; - struct route_node *par; + struct agg_node *par; struct rfapi_monitor_vpn *m; struct rfapi_monitor_vpn *mlast; struct rfapi_monitor_vpn *moved; @@ -679,7 +680,8 @@ rfapiMonitorMoveShorter(struct route_node *original_vpn_node, int lockoffset) * one route (even if it is only a withdrawn route) with a * valid UN address. Call this node "Node P." */ - for (par = original_vpn_node->parent; par; par = par->parent) { + for (par = agg_node_parent(original_vpn_node); par; + par = agg_node_parent(par)) { for (bi = par->info; bi; bi = bi->next) { struct prefix pfx; if (!rfapiGetUnAddrOfVpnBi(bi, &pfx)) { @@ -699,14 +701,14 @@ rfapiMonitorMoveShorter(struct route_node *original_vpn_node, int lockoffset) */ if (!par) { /* this isn't necessarily 0/0 */ - par = route_top(original_vpn_node->table); + par = agg_route_table_top(original_vpn_node); /* * If we got the top node but it wasn't 0/0, * ignore it */ if (par && par->p.prefixlen) { - route_unlock_node(par); /* maybe free */ + agg_unlock_node(par); /* maybe free */ par = NULL; } @@ -725,7 +727,8 @@ rfapiMonitorMoveShorter(struct route_node *original_vpn_node, int lockoffset) pfx_default.family = original_vpn_node->p.family; /* creates default node if none exists */ - par = route_node_get(original_vpn_node->table, &pfx_default); + par = agg_node_get(agg_get_table(original_vpn_node), + &pfx_default); ++parent_already_refcounted; } @@ -764,18 +767,18 @@ rfapiMonitorMoveShorter(struct route_node *original_vpn_node, int lockoffset) RFAPI_CHECK_REFCOUNT(par, SAFI_MPLS_VPN, parent_already_refcounted - movecount); while (movecount > parent_already_refcounted) { - route_lock_node(par); + agg_lock_node(par); ++parent_already_refcounted; } while (movecount < parent_already_refcounted) { /* unlikely, but code defensively */ - route_unlock_node(par); + agg_unlock_node(par); --parent_already_refcounted; } RFAPI_CHECK_REFCOUNT(original_vpn_node, SAFI_MPLS_VPN, movecount + lockoffset); while (movecount--) { - route_unlock_node(original_vpn_node); + agg_unlock_node(original_vpn_node); } #if DEBUG_MONITOR_MOVE_SHORTER @@ -796,12 +799,12 @@ rfapiMonitorMoveShorter(struct route_node *original_vpn_node, int lockoffset) * Implement MONITOR_MOVE_LONGER(new_node) from * RFAPI-Import-Event-Handling.txt */ -static void rfapiMonitorMoveLonger(struct route_node *new_vpn_node) +static void rfapiMonitorMoveLonger(struct agg_node *new_vpn_node) { struct rfapi_monitor_vpn *monitor; struct rfapi_monitor_vpn *mlast; struct bgp_info *bi; - struct route_node *par; + struct agg_node *par; RFAPI_CHECK_REFCOUNT(new_vpn_node, SAFI_MPLS_VPN, 0); @@ -824,7 +827,8 @@ static void rfapiMonitorMoveLonger(struct route_node *new_vpn_node) /* * Find first parent node that has monitors */ - for (par = new_vpn_node->parent; par; par = par->parent) { + for (par = agg_node_parent(new_vpn_node); par; + par = agg_node_parent(par)) { if (RFAPI_MONITOR_VPN(par)) break; } @@ -860,14 +864,14 @@ static void rfapiMonitorMoveLonger(struct route_node *new_vpn_node) RFAPI_MONITOR_VPN_W_ALLOC(new_vpn_node) = monitor; monitor->node = new_vpn_node; - route_lock_node(new_vpn_node); /* incr refcount */ + agg_lock_node(new_vpn_node); /* incr refcount */ monitor = mlast ? mlast->next : RFAPI_MONITOR_VPN(par); RFAPI_CHECK_REFCOUNT(par, SAFI_MPLS_VPN, 1); /* decr refcount after we're done with par as this might * free it */ - route_unlock_node(par); + agg_unlock_node(par); continue; } @@ -919,10 +923,10 @@ static void rfapiImportTableFlush(struct rfapi_import_table *it) for (afi = AFI_IP; afi < AFI_MAX; ++afi) { - struct route_node *rn; + struct agg_node *rn; - for (rn = route_top(it->imported_vpn[afi]); rn; - rn = route_next(rn)) { + for (rn = agg_route_top(it->imported_vpn[afi]); rn; + rn = agg_route_next(rn)) { /* * Each route_node has: * aggregate: points to rfapi_it_extra with monitor @@ -936,8 +940,8 @@ static void rfapiImportTableFlush(struct rfapi_import_table *it) rfapiMonitorExtraFlush(SAFI_MPLS_VPN, rn); } - for (rn = route_top(it->imported_encap[afi]); rn; - rn = route_next(rn)) { + for (rn = agg_route_top(it->imported_encap[afi]); rn; + rn = agg_route_next(rn)) { /* free bgp_info and its children */ rfapiBgpInfoChainFree(rn->info); rn->info = NULL; @@ -945,8 +949,8 @@ static void rfapiImportTableFlush(struct rfapi_import_table *it) rfapiMonitorExtraFlush(SAFI_ENCAP, rn); } - route_table_finish(it->imported_vpn[afi]); - route_table_finish(it->imported_encap[afi]); + agg_table_finish(it->imported_vpn[afi]); + agg_table_finish(it->imported_encap[afi]); } if (it->monitor_exterior_orphans) { skiplist_free(it->monitor_exterior_orphans); @@ -1293,9 +1297,9 @@ int rfapi_extract_l2o( static struct rfapi_next_hop_entry * rfapiRouteInfo2NextHopEntry(struct rfapi_ip_prefix *rprefix, - struct bgp_info *bi, /* route to encode */ - uint32_t lifetime, /* use this in nhe */ - struct route_node *rn) /* req for L2 eth addr */ + struct bgp_info *bi, /* route to encode */ + uint32_t lifetime, /* use this in nhe */ + struct agg_node *rn) /* req for L2 eth addr */ { struct rfapi_next_hop_entry *new; int have_vnc_tunnel_un = 0; @@ -1481,7 +1485,7 @@ rfapiRouteInfo2NextHopEntry(struct rfapi_ip_prefix *rprefix, return new; } -int rfapiHasNonRemovedRoutes(struct route_node *rn) +int rfapiHasNonRemovedRoutes(struct agg_node *rn) { struct bgp_info *bi; @@ -1501,7 +1505,7 @@ int rfapiHasNonRemovedRoutes(struct route_node *rn) /* * DEBUG FUNCTION */ -void rfapiDumpNode(struct route_node *rn) +void rfapiDumpNode(struct agg_node *rn) { struct bgp_info *bi; @@ -1527,14 +1531,14 @@ void rfapiDumpNode(struct route_node *rn) #endif static int rfapiNhlAddNodeRoutes( - struct route_node *rn, /* in */ + struct agg_node *rn, /* in */ struct rfapi_ip_prefix *rprefix, /* in */ uint32_t lifetime, /* in */ int removed, /* in */ struct rfapi_next_hop_entry **head, /* in/out */ struct rfapi_next_hop_entry **tail, /* in/out */ struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */ - struct route_node *rfd_rib_node, /* preload this NVE rib node */ + struct agg_node *rfd_rib_node, /* preload this NVE rib node */ struct prefix *pfx_target_original) /* query target */ { struct bgp_info *bi; @@ -1544,15 +1548,17 @@ static int rfapiNhlAddNodeRoutes( int count = 0; int is_l2 = (rn->p.family == AF_ETHERNET); - if (rfd_rib_node && rfd_rib_node->table && rfd_rib_node->table->info) { + if (rfd_rib_node) { + struct agg_table *atable = agg_get_table(rfd_rib_node); struct rfapi_descriptor *rfd; - rfd = (struct rfapi_descriptor *)(rfd_rib_node->table->info); + if (atable) { + rfd = agg_get_table_info(atable); - if (rfapiRibFTDFilterRecentPrefix( - rfd, rn, pfx_target_original)) - - return 0; + if (rfapiRibFTDFilterRecentPrefix(rfd, rn, + pfx_target_original)) + return 0; + } } seen_nexthops = @@ -1657,13 +1663,13 @@ static int rfapiNhlAddNodeRoutes( * matches (of course, we still travel down its child subtrees). */ static int rfapiNhlAddSubtree( - struct route_node *rn, /* in */ + struct agg_node *rn, /* in */ uint32_t lifetime, /* in */ struct rfapi_next_hop_entry **head, /* in/out */ struct rfapi_next_hop_entry **tail, /* in/out */ - struct route_node *omit_node, /* in */ + struct agg_node *omit_node, /* in */ struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */ - struct route_table *rfd_rib_table, /* preload here */ + struct agg_table *rfd_rib_table, /* preload here */ struct prefix *pfx_target_original) /* query target */ { struct rfapi_ip_prefix rprefix; @@ -1671,65 +1677,67 @@ static int rfapiNhlAddSubtree( /* FIXME: need to find a better way here to work without sticking our * hands in node->link */ - if (rn->l_left && rn->l_left != omit_node) { - if (rn->l_left->info) { + if (agg_node_left(rn) && agg_node_left(rn) != omit_node) { + if (agg_node_left(rn)->info) { int count = 0; - struct route_node *rib_rn = NULL; + struct agg_node *rib_rn = NULL; - rfapiQprefix2Rprefix(&rn->l_left->p, &rprefix); + rfapiQprefix2Rprefix(&agg_node_left(rn)->p, &rprefix); if (rfd_rib_table) { - rib_rn = route_node_get(rfd_rib_table, - &rn->l_left->p); + rib_rn = agg_node_get(rfd_rib_table, + &agg_node_left(rn)->p); } count = rfapiNhlAddNodeRoutes( - rn->l_left, &rprefix, lifetime, 0, head, tail, - exclude_vnaddr, rib_rn, pfx_target_original); + agg_node_left(rn), &rprefix, lifetime, 0, head, + tail, exclude_vnaddr, rib_rn, + pfx_target_original); if (!count) { count = rfapiNhlAddNodeRoutes( - rn->l_left, &rprefix, lifetime, 1, head, - tail, exclude_vnaddr, rib_rn, + agg_node_left(rn), &rprefix, lifetime, + 1, head, tail, exclude_vnaddr, rib_rn, pfx_target_original); } rcount += count; if (rib_rn) - route_unlock_node(rib_rn); + agg_unlock_node(rib_rn); } } - if (rn->l_right && rn->l_right != omit_node) { - if (rn->l_right->info) { + if (agg_node_right(rn) && agg_node_right(rn) != omit_node) { + if (agg_node_right(rn)->info) { int count = 0; - struct route_node *rib_rn = NULL; + struct agg_node *rib_rn = NULL; - rfapiQprefix2Rprefix(&rn->l_right->p, &rprefix); + rfapiQprefix2Rprefix(&agg_node_right(rn)->p, &rprefix); if (rfd_rib_table) { - rib_rn = route_node_get(rfd_rib_table, - &rn->l_right->p); + rib_rn = agg_node_get(rfd_rib_table, + &agg_node_right(rn)->p); } count = rfapiNhlAddNodeRoutes( - rn->l_right, &rprefix, lifetime, 0, head, tail, - exclude_vnaddr, rib_rn, pfx_target_original); + agg_node_right(rn), &rprefix, lifetime, 0, head, + tail, exclude_vnaddr, rib_rn, + pfx_target_original); if (!count) { count = rfapiNhlAddNodeRoutes( - rn->l_right, &rprefix, lifetime, 1, - head, tail, exclude_vnaddr, rib_rn, + agg_node_right(rn), &rprefix, lifetime, + 1, head, tail, exclude_vnaddr, rib_rn, pfx_target_original); } rcount += count; if (rib_rn) - route_unlock_node(rib_rn); + agg_unlock_node(rib_rn); } } - if (rn->l_left) { + if (agg_node_left(rn)) { rcount += rfapiNhlAddSubtree( - rn->l_left, lifetime, head, tail, omit_node, + agg_node_left(rn), lifetime, head, tail, omit_node, exclude_vnaddr, rfd_rib_table, pfx_target_original); } - if (rn->l_right) { + if (agg_node_right(rn)) { rcount += rfapiNhlAddSubtree( - rn->l_right, lifetime, head, tail, omit_node, + agg_node_right(rn), lifetime, head, tail, omit_node, exclude_vnaddr, rfd_rib_table, pfx_target_original); } @@ -1748,17 +1756,17 @@ static int rfapiNhlAddSubtree( * next less-specific node (i.e., this node's parent) at the end. */ struct rfapi_next_hop_entry *rfapiRouteNode2NextHopList( - struct route_node *rn, uint32_t lifetime, /* put into nexthop entries */ - struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */ - struct route_table *rfd_rib_table, /* preload here */ - struct prefix *pfx_target_original) /* query target */ + struct agg_node *rn, uint32_t lifetime, /* put into nexthop entries */ + struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */ + struct agg_table *rfd_rib_table, /* preload here */ + struct prefix *pfx_target_original) /* query target */ { struct rfapi_ip_prefix rprefix; struct rfapi_next_hop_entry *answer = NULL; struct rfapi_next_hop_entry *last = NULL; - struct route_node *parent; + struct agg_node *parent; int count = 0; - struct route_node *rib_rn; + struct agg_node *rib_rn; #if DEBUG_RETURNED_NHL { @@ -1773,7 +1781,7 @@ struct rfapi_next_hop_entry *rfapiRouteNode2NextHopList( rfapiQprefix2Rprefix(&rn->p, &rprefix); - rib_rn = rfd_rib_table ? route_node_get(rfd_rib_table, &rn->p) : NULL; + rib_rn = rfd_rib_table ? agg_node_get(rfd_rib_table, &rn->p) : NULL; /* * Add non-withdrawn routes at this node @@ -1795,7 +1803,7 @@ struct rfapi_next_hop_entry *rfapiRouteNode2NextHopList( rfapiPrintNhl(NULL, answer); #endif if (rib_rn) - route_unlock_node(rib_rn); + agg_unlock_node(rib_rn); return answer; } @@ -1806,7 +1814,7 @@ struct rfapi_next_hop_entry *rfapiRouteNode2NextHopList( exclude_vnaddr, rib_rn, pfx_target_original); if (rib_rn) - route_unlock_node(rib_rn); + agg_unlock_node(rib_rn); // rfapiPrintNhl(NULL, answer); @@ -1814,7 +1822,8 @@ struct rfapi_next_hop_entry *rfapiRouteNode2NextHopList( * walk up the tree until we find a node with non-deleted * routes, then add them */ - for (parent = rn->parent; parent; parent = parent->parent) { + for (parent = agg_node_parent(rn); parent; + parent = agg_node_parent(parent)) { if (rfapiHasNonRemovedRoutes(parent)) { break; } @@ -1824,9 +1833,8 @@ struct rfapi_next_hop_entry *rfapiRouteNode2NextHopList( * Add non-withdrawn routes from less-specific prefix */ if (parent) { - rib_rn = rfd_rib_table - ? route_node_get(rfd_rib_table, &parent->p) - : NULL; + rib_rn = rfd_rib_table ? agg_node_get(rfd_rib_table, &parent->p) + : NULL; rfapiQprefix2Rprefix(&parent->p, &rprefix); count += rfapiNhlAddNodeRoutes(parent, &rprefix, lifetime, 0, &answer, &last, exclude_vnaddr, @@ -1835,7 +1843,7 @@ struct rfapi_next_hop_entry *rfapiRouteNode2NextHopList( rn, exclude_vnaddr, rfd_rib_table, pfx_target_original); if (rib_rn) - route_unlock_node(rib_rn); + agg_unlock_node(rib_rn); } else { /* * There is no parent with non-removed routes. Still need to @@ -1861,19 +1869,18 @@ struct rfapi_next_hop_entry *rfapiRouteNode2NextHopList( * Construct nexthop list of all routes in table */ struct rfapi_next_hop_entry *rfapiRouteTable2NextHopList( - struct route_table *rt, - uint32_t lifetime, /* put into nexthop entries */ - struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */ - struct route_table *rfd_rib_table, /* preload this NVE rib table */ - struct prefix *pfx_target_original) /* query target */ + struct agg_table *rt, uint32_t lifetime, /* put into nexthop entries */ + struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */ + struct agg_table *rfd_rib_table, /* preload this NVE rib table */ + struct prefix *pfx_target_original) /* query target */ { - struct route_node *rn; + struct agg_node *rn; struct rfapi_next_hop_entry *biglist = NULL; struct rfapi_next_hop_entry *nhl; struct rfapi_next_hop_entry *tail = NULL; int count = 0; - for (rn = route_top(rt); rn; rn = route_next(rn)) { + for (rn = agg_route_top(rt); rn; rn = agg_route_next(rn)) { nhl = rfapiRouteNode2NextHopList(rn, lifetime, exclude_vnaddr, rfd_rib_table, @@ -1898,18 +1905,18 @@ struct rfapi_next_hop_entry *rfapiRouteTable2NextHopList( } struct rfapi_next_hop_entry *rfapiEthRouteNode2NextHopList( - struct route_node *rn, struct rfapi_ip_prefix *rprefix, + struct agg_node *rn, struct rfapi_ip_prefix *rprefix, uint32_t lifetime, /* put into nexthop entries */ struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */ - struct route_table *rfd_rib_table, /* preload NVE rib table */ + struct agg_table *rfd_rib_table, /* preload NVE rib table */ struct prefix *pfx_target_original) /* query target */ { int count = 0; struct rfapi_next_hop_entry *answer = NULL; struct rfapi_next_hop_entry *last = NULL; - struct route_node *rib_rn; + struct agg_node *rib_rn; - rib_rn = rfd_rib_table ? route_node_get(rfd_rib_table, &rn->p) : NULL; + rib_rn = rfd_rib_table ? agg_node_get(rfd_rib_table, &rn->p) : NULL; count = rfapiNhlAddNodeRoutes(rn, rprefix, lifetime, 0, &answer, &last, NULL, rib_rn, pfx_target_original); @@ -1928,7 +1935,7 @@ struct rfapi_next_hop_entry *rfapiEthRouteNode2NextHopList( } if (rib_rn) - route_unlock_node(rib_rn); + agg_unlock_node(rib_rn); #if DEBUG_RETURNED_NHL rfapiPrintNhl(NULL, answer); @@ -1945,13 +1952,13 @@ struct rfapi_next_hop_entry *rfapiEthRouteTable2NextHopList( uint32_t logical_net_id, struct rfapi_ip_prefix *rprefix, uint32_t lifetime, /* put into nexthop entries */ struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */ - struct route_table *rfd_rib_table, /* preload NVE rib node */ + struct agg_table *rfd_rib_table, /* preload NVE rib node */ struct prefix *pfx_target_original) /* query target */ { struct rfapi_import_table *it; struct bgp *bgp = bgp_get_default(); - struct route_table *rt; - struct route_node *rn; + struct agg_table *rt; + struct agg_node *rn; struct rfapi_next_hop_entry *biglist = NULL; struct rfapi_next_hop_entry *nhl; struct rfapi_next_hop_entry *tail = NULL; @@ -1961,7 +1968,7 @@ struct rfapi_next_hop_entry *rfapiEthRouteTable2NextHopList( it = rfapiMacImportTableGet(bgp, logical_net_id); rt = it->imported_vpn[AFI_L2VPN]; - for (rn = route_top(rt); rn; rn = route_next(rn)) { + for (rn = agg_route_top(rt); rn; rn = agg_route_next(rn)) { nhl = rfapiEthRouteNode2NextHopList( rn, rprefix, lifetime, exclude_vnaddr, rfd_rib_table, @@ -1989,7 +1996,7 @@ struct rfapi_next_hop_entry *rfapiEthRouteTable2NextHopList( * Insert a new bi to the imported route table node, * keeping the list of BIs sorted best route first */ -static void rfapiBgpInfoAttachSorted(struct route_node *rn, +static void rfapiBgpInfoAttachSorted(struct agg_node *rn, struct bgp_info *info_new, afi_t afi, safi_t safi) { @@ -2031,7 +2038,7 @@ static void rfapiBgpInfoAttachSorted(struct route_node *rn, bgp_attr_intern(info_new->attr); } -static void rfapiBgpInfoDetach(struct route_node *rn, struct bgp_info *bi) +static void rfapiBgpInfoDetach(struct agg_node *rn, struct bgp_info *bi) { /* * Remove the route (doubly-linked) @@ -2127,8 +2134,8 @@ static int rfapi_bi_peer_rd_aux_cmp(void *b1, void *b2) /* * Index on RD and Peer */ -static void rfapiItBiIndexAdd(struct route_node *rn, /* Import table VPN node */ - struct bgp_info *bi) /* new BI */ +static void rfapiItBiIndexAdd(struct agg_node *rn, /* Import table VPN node */ + struct bgp_info *bi) /* new BI */ { struct skiplist *sl; @@ -2153,15 +2160,15 @@ static void rfapiItBiIndexAdd(struct route_node *rn, /* Import table VPN node */ sl = skiplist_new(0, rfapi_bi_peer_rd_cmp, NULL); } RFAPI_IT_EXTRA_GET(rn)->u.vpn.idx_rd = sl; - route_lock_node(rn); /* for skiplist */ + agg_lock_node(rn); /* for skiplist */ } assert(!skiplist_insert(sl, (void *)bi, (void *)bi)); - route_lock_node(rn); /* for skiplist entry */ + agg_lock_node(rn); /* for skiplist entry */ /* NB: BIs in import tables are not refcounted */ } -static void rfapiItBiIndexDump(struct route_node *rn) +static void rfapiItBiIndexDump(struct agg_node *rn) { struct skiplist *sl; void *cursor = NULL; @@ -2192,7 +2199,7 @@ static void rfapiItBiIndexDump(struct route_node *rn) } static struct bgp_info *rfapiItBiIndexSearch( - struct route_node *rn, /* Import table VPN node */ + struct agg_node *rn, /* Import table VPN node */ struct prefix_rd *prd, struct peer *peer, struct prefix *aux_prefix) /* optional L3 addr for L2 ITs */ { @@ -2298,8 +2305,8 @@ static struct bgp_info *rfapiItBiIndexSearch( return bi_result; } -static void rfapiItBiIndexDel(struct route_node *rn, /* Import table VPN node */ - struct bgp_info *bi) /* old BI */ +static void rfapiItBiIndexDel(struct agg_node *rn, /* Import table VPN node */ + struct bgp_info *bi) /* old BI */ { struct skiplist *sl; int rc; @@ -2322,7 +2329,7 @@ static void rfapiItBiIndexDel(struct route_node *rn, /* Import table VPN node */ } assert(!rc); - route_unlock_node(rn); /* for skiplist entry */ + agg_unlock_node(rn); /* for skiplist entry */ /* NB: BIs in import tables are not refcounted */ } @@ -2332,17 +2339,16 @@ static void rfapiItBiIndexDel(struct route_node *rn, /* Import table VPN node */ * refers to it */ static void rfapiMonitorEncapAdd(struct rfapi_import_table *import_table, - struct prefix *p, /* VN address */ - struct route_node *vpn_rn, /* VPN node */ - struct bgp_info *vpn_bi) /* VPN bi/route */ + struct prefix *p, /* VN address */ + struct agg_node *vpn_rn, /* VPN node */ + struct bgp_info *vpn_bi) /* VPN bi/route */ { afi_t afi = family2afi(p->family); - struct route_node *rn; + struct agg_node *rn; struct rfapi_monitor_encap *m; assert(afi); - rn = route_node_get(import_table->imported_encap[afi], - p); /* locks rn */ + rn = agg_node_get(import_table->imported_encap[afi], p); /* locks rn */ assert(rn); m = XCALLOC(MTYPE_RFAPI_MONITOR_ENCAP, @@ -2399,7 +2405,7 @@ static void rfapiMonitorEncapDelete(struct bgp_info *vpn_bi) * freed */ rfapiMonitorExtraPrune(SAFI_ENCAP, hme->rn); - route_unlock_node(hme->rn); /* decr ref count */ + agg_unlock_node(hme->rn); /* decr ref count */ XFREE(MTYPE_RFAPI_MONITOR_ENCAP, hme); vpn_bi->extra->vnc.import.hme = NULL; } @@ -2533,7 +2539,7 @@ done: } RFAPI_CHECK_REFCOUNT(wcb->node, SAFI_MPLS_VPN, 1 + wcb->lockoffset); - route_unlock_node(wcb->node); /* decr ref count */ + agg_unlock_node(wcb->node); /* decr ref count */ XFREE(MTYPE_RFAPI_WITHDRAW, wcb); return 0; } @@ -2660,7 +2666,7 @@ static void rfapiCopyUnEncap2VPN(struct bgp_info *encap_bi, */ static int rfapiWithdrawEncapUpdateCachedUn( struct rfapi_import_table *import_table, struct bgp_info *encap_bi, - struct route_node *vpn_rn, struct bgp_info *vpn_bi) + struct agg_node *vpn_rn, struct bgp_info *vpn_bi) { if (!encap_bi) { @@ -2762,7 +2768,7 @@ static int rfapiWithdrawTimerEncap(struct thread *t) /* * for each VPN node referenced in the ENCAP monitors: */ - struct route_node *rn; + struct agg_node *rn; while (!skiplist_first(vpn_node_sl, (void **)&rn, NULL)) { if (!wcb->node->info) { struct rfapi_monitor_vpn *moved; @@ -2783,7 +2789,7 @@ static int rfapiWithdrawTimerEncap(struct thread *t) done: RFAPI_CHECK_REFCOUNT(wcb->node, SAFI_ENCAP, 1); - route_unlock_node(wcb->node); /* decr ref count */ + agg_unlock_node(wcb->node); /* decr ref count */ XFREE(MTYPE_RFAPI_WITHDRAW, wcb); skiplist_free(vpn_node_sl); return 0; @@ -2796,7 +2802,7 @@ done: */ static void rfapiBiStartWithdrawTimer(struct rfapi_import_table *import_table, - struct route_node *rn, struct bgp_info *bi, afi_t afi, + struct agg_node *rn, struct bgp_info *bi, afi_t afi, safi_t safi, int (*timer_service_func)(struct thread *)) { @@ -2886,7 +2892,7 @@ typedef void(rfapi_bi_filtered_import_f)(struct rfapi_import_table *, int, static void rfapiExpireEncapNow(struct rfapi_import_table *it, - struct route_node *rn, struct bgp_info *bi) + struct agg_node *rn, struct bgp_info *bi) { struct rfapi_withdraw *wcb; struct thread t; @@ -2939,8 +2945,8 @@ static void rfapiBgpInfoFilteredImportEncap( uint8_t sub_type, /* part of bgp_info */ uint32_t *label) /* part of bgp_info */ { - struct route_table *rt = NULL; - struct route_node *rn; + struct agg_table *rt = NULL; + struct agg_node *rn; struct bgp_info *info_new; struct bgp_info *bi; struct bgp_info *next; @@ -3034,10 +3040,10 @@ static void rfapiBgpInfoFilteredImportEncap( } /* - * route_node_lookup returns a node only if there is at least + * agg_node_lookup returns a node only if there is at least * one route attached. */ - rn = route_node_lookup(rt, p); + rn = agg_node_lookup(rt, p); #if DEBUG_ENCAP_MONITOR vnc_zlog_debug_verbose("%s: initial encap lookup(it=%p) rn=%p", @@ -3047,7 +3053,7 @@ static void rfapiBgpInfoFilteredImportEncap( if (rn) { RFAPI_CHECK_REFCOUNT(rn, SAFI_ENCAP, 1); - route_unlock_node(rn); /* undo lock in route_node_lookup */ + agg_unlock_node(rn); /* undo lock in agg_node_lookup */ /* @@ -3187,9 +3193,9 @@ static void rfapiBgpInfoFilteredImportEncap( if (rn) { if (!replacing) - route_lock_node(rn); /* incr ref count for new BI */ + agg_lock_node(rn); /* incr ref count for new BI */ } else { - rn = route_node_get(rt, p); + rn = agg_node_get(rt, p); } vnc_zlog_debug_verbose( @@ -3254,7 +3260,7 @@ static void rfapiBgpInfoFilteredImportEncap( struct rfapi_monitor_encap *m; struct rfapi_monitor_encap *mnext; - struct route_node *referenced_vpn_prefix; + struct agg_node *referenced_vpn_prefix; /* * Optimized approach: build radix tree on the fly to @@ -3265,9 +3271,9 @@ static void rfapiBgpInfoFilteredImportEncap( * struct rfapi_monitor_encap, each of which refers to a * specific VPN node. */ - struct route_table *referenced_vpn_table; + struct agg_table *referenced_vpn_table; - referenced_vpn_table = route_table_init(); + referenced_vpn_table = agg_table_init(); assert(referenced_vpn_table); /* @@ -3306,8 +3312,8 @@ static void rfapiBgpInfoFilteredImportEncap( * per prefix. */ - referenced_vpn_prefix = route_node_get( - referenced_vpn_table, &m->node->p); + referenced_vpn_prefix = + agg_node_get(referenced_vpn_table, &m->node->p); assert(referenced_vpn_prefix); for (mnext = referenced_vpn_prefix->info; mnext; mnext = mnext->next) { @@ -3320,7 +3326,7 @@ static void rfapiBgpInfoFilteredImportEncap( /* * already have an entry for this VPN node */ - route_unlock_node(referenced_vpn_prefix); + agg_unlock_node(referenced_vpn_prefix); } else { mnext = XCALLOC( MTYPE_RFAPI_MONITOR_ENCAP, @@ -3335,16 +3341,18 @@ static void rfapiBgpInfoFilteredImportEncap( /* * for each VPN node referenced in the ENCAP monitors: */ - for (referenced_vpn_prefix = route_top(referenced_vpn_table); - referenced_vpn_prefix; referenced_vpn_prefix = route_next( - referenced_vpn_prefix)) { + for (referenced_vpn_prefix = + agg_route_top(referenced_vpn_table); + referenced_vpn_prefix; + referenced_vpn_prefix = + agg_route_next(referenced_vpn_prefix)) { while ((m = referenced_vpn_prefix->info)) { - struct route_node *n; + struct agg_node *n; rfapiMonitorMoveLonger(m->node); - for (n = m->node; n; n = n->parent) { + for (n = m->node; n; n = agg_node_parent(n)) { // rfapiDoRouteCallback(import_table, n, // NULL); } @@ -3352,18 +3360,18 @@ static void rfapiBgpInfoFilteredImportEncap( NULL); referenced_vpn_prefix->info = m->next; - route_unlock_node(referenced_vpn_prefix); + agg_unlock_node(referenced_vpn_prefix); XFREE(MTYPE_RFAPI_MONITOR_ENCAP, m); } } - route_table_finish(referenced_vpn_table); + agg_table_finish(referenced_vpn_table); } RFAPI_CHECK_REFCOUNT(rn, SAFI_ENCAP, 0); } static void rfapiExpireVpnNow(struct rfapi_import_table *it, - struct route_node *rn, struct bgp_info *bi, + struct agg_node *rn, struct bgp_info *bi, int lockoffset) { struct rfapi_withdraw *wcb; @@ -3398,9 +3406,9 @@ void rfapiBgpInfoFilteredImportVPN( uint8_t sub_type, /* part of bgp_info */ uint32_t *label) /* part of bgp_info */ { - struct route_table *rt = NULL; - struct route_node *rn; - struct route_node *n; + struct agg_table *rt = NULL; + struct agg_node *rn; + struct agg_node *n; struct bgp_info *info_new; struct bgp_info *bi; struct bgp_info *next; @@ -3408,7 +3416,7 @@ void rfapiBgpInfoFilteredImportVPN( struct prefix vn_prefix; struct prefix un_prefix; int un_prefix_valid = 0; - struct route_node *ern; + struct agg_node *ern; int replacing = 0; int original_had_routes = 0; struct prefix original_nexthop; @@ -3494,17 +3502,17 @@ void rfapiBgpInfoFilteredImportVPN( memset(&original_nexthop, 0, sizeof(original_nexthop)); /* - * route_node_lookup returns a node only if there is at least + * agg_node_lookup returns a node only if there is at least * one route attached. */ - rn = route_node_lookup(rt, p); + rn = agg_node_lookup(rt, p); vnc_zlog_debug_verbose("%s: rn=%p", __func__, rn); if (rn) { RFAPI_CHECK_REFCOUNT(rn, SAFI_MPLS_VPN, 1); - route_unlock_node(rn); /* undo lock in route_node_lookup */ + agg_unlock_node(rn); /* undo lock in agg_node_lookup */ if (rn->info) original_had_routes = 1; @@ -3667,10 +3675,10 @@ void rfapiBgpInfoFilteredImportVPN( /* * lookup un address in encap table */ - ern = route_node_match(import_table->imported_encap[afi], &vn_prefix); + ern = agg_node_match(import_table->imported_encap[afi], &vn_prefix); if (ern) { rfapiCopyUnEncap2VPN(ern->info, info_new); - route_unlock_node(ern); /* undo lock in route_note_match */ + agg_unlock_node(ern); /* undo lock in route_note_match */ } else { char buf[PREFIX_STRLEN]; @@ -3683,13 +3691,13 @@ void rfapiBgpInfoFilteredImportVPN( if (rn) { if (!replacing) - route_lock_node(rn); + agg_lock_node(rn); } else { /* * No need to increment reference count, so only "get" * if the node is not there already */ - rn = route_node_get(rt, p); + rn = agg_node_get(rt, p); } /* @@ -3856,7 +3864,7 @@ void rfapiBgpInfoFilteredImportVPN( } if (!(bgp->rfapi_cfg->flags & BGP_VNC_CONFIG_CALLBACK_DISABLE)) { - for (n = rn; n; n = n->parent) { + for (n = rn; n; n = agg_node_parent(n)) { // rfapiDoRouteCallback(import_table, n, NULL); } rfapiMonitorItNodeChanged(import_table, rn, NULL); @@ -4108,9 +4116,9 @@ static void rfapiProcessPeerDownRt(struct peer *peer, struct rfapi_import_table *import_table, afi_t afi, safi_t safi) { - struct route_node *rn; + struct agg_node *rn; struct bgp_info *bi; - struct route_table *rt; + struct agg_table *rt; int (*timer_service_func)(struct thread *); assert(afi == AFI_IP || afi == AFI_IP6); @@ -4131,7 +4139,7 @@ static void rfapiProcessPeerDownRt(struct peer *peer, } - for (rn = route_top(rt); rn; rn = route_next(rn)) { + for (rn = agg_route_top(rt); rn; rn = agg_route_next(rn)) { for (bi = rn->info; bi; bi = bi->next) { if (bi->peer == peer) { @@ -4274,7 +4282,7 @@ struct rfapi *bgp_rfapi_new(struct bgp *bgp) h = (struct rfapi *)XCALLOC(MTYPE_RFAPI, sizeof(struct rfapi)); for (afi = AFI_IP; afi < AFI_MAX; afi++) { - h->un[afi] = route_table_init(); + h->un[afi] = agg_table_init(); } /* @@ -4282,10 +4290,10 @@ struct rfapi *bgp_rfapi_new(struct bgp *bgp) */ h->it_ce = XCALLOC(MTYPE_RFAPI_IMPORTTABLE, sizeof(struct rfapi_import_table)); - h->it_ce->imported_vpn[AFI_IP] = route_table_init(); - h->it_ce->imported_vpn[AFI_IP6] = route_table_init(); - h->it_ce->imported_encap[AFI_IP] = route_table_init(); - h->it_ce->imported_encap[AFI_IP6] = route_table_init(); + h->it_ce->imported_vpn[AFI_IP] = agg_table_init(); + h->it_ce->imported_vpn[AFI_IP6] = agg_table_init(); + h->it_ce->imported_encap[AFI_IP] = agg_table_init(); + h->it_ce->imported_encap[AFI_IP6] = agg_table_init(); rfapiBgpTableFilteredImport(bgp, h->it_ce, AFI_IP, SAFI_MPLS_VPN); rfapiBgpTableFilteredImport(bgp, h->it_ce, AFI_IP6, SAFI_MPLS_VPN); @@ -4317,10 +4325,10 @@ void bgp_rfapi_destroy(struct bgp *bgp, struct rfapi *h) h->resolve_nve_nexthop = NULL; } - route_table_finish(h->it_ce->imported_vpn[AFI_IP]); - route_table_finish(h->it_ce->imported_vpn[AFI_IP6]); - route_table_finish(h->it_ce->imported_encap[AFI_IP]); - route_table_finish(h->it_ce->imported_encap[AFI_IP6]); + agg_table_finish(h->it_ce->imported_vpn[AFI_IP]); + agg_table_finish(h->it_ce->imported_vpn[AFI_IP6]); + agg_table_finish(h->it_ce->imported_encap[AFI_IP]); + agg_table_finish(h->it_ce->imported_encap[AFI_IP6]); if (h->import_mac) { struct rfapi_import_table *it; @@ -4346,7 +4354,7 @@ void bgp_rfapi_destroy(struct bgp *bgp, struct rfapi *h) rfp_stop(h->rfp); for (afi = AFI_IP; afi < AFI_MAX; afi++) { - route_table_finish(h->un[afi]); + agg_table_finish(h->un[afi]); } XFREE(MTYPE_RFAPI_IMPORTTABLE, h->it_ce); @@ -4394,8 +4402,8 @@ rfapiImportTableRefAdd(struct bgp *bgp, struct ecommunity *rt_import_list, */ for (afi = AFI_IP; afi < AFI_MAX; ++afi) { - it->imported_vpn[afi] = route_table_init(); - it->imported_encap[afi] = route_table_init(); + it->imported_vpn[afi] = agg_table_init(); + it->imported_encap[afi] = agg_table_init(); rfapiBgpTableFilteredImport(bgp, it, afi, SAFI_MPLS_VPN); @@ -4452,8 +4460,8 @@ static void rfapiDeleteRemotePrefixesIt( for (afi = AFI_IP; afi < AFI_MAX; ++afi) { - struct route_table *rt; - struct route_node *rn; + struct agg_table *rt; + struct agg_node *rn; if (p && (family2afi(p->family) != afi)) { continue; @@ -4466,7 +4474,7 @@ static void rfapiDeleteRemotePrefixesIt( vnc_zlog_debug_verbose("%s: scanning rt for afi=%d", __func__, afi); - for (rn = route_top(rt); rn; rn = route_next(rn)) { + for (rn = agg_route_top(rt); rn; rn = agg_route_next(rn)) { struct bgp_info *bi; struct bgp_info *next; diff --git a/bgpd/rfapi/rfapi_import.h b/bgpd/rfapi/rfapi_import.h index 84b7ca3a76..ae3d248367 100644 --- a/bgpd/rfapi/rfapi_import.h +++ b/bgpd/rfapi/rfapi_import.h @@ -40,10 +40,10 @@ struct rfapi_import_table { struct ecommunity *rt_import_list; /* copied from nve grp */ int refcount; /* nve grps and nves */ uint32_t l2_logical_net_id; /* L2 only: EVPN Eth Seg Id */ - struct route_table *imported_vpn[AFI_MAX]; + struct agg_table *imported_vpn[AFI_MAX]; struct rfapi_monitor_vpn *vpn0_queries[AFI_MAX]; struct rfapi_monitor_eth *eth0_queries; - struct route_table *imported_encap[AFI_MAX]; + struct agg_table *imported_encap[AFI_MAX]; struct skiplist *monitor_exterior_orphans; int local_count[AFI_MAX]; int remote_count[AFI_MAX]; @@ -80,7 +80,7 @@ extern void rfapiCheckRouteCount(void); extern void rfapiPrintBi(void *stream, struct bgp_info *bi); extern void rfapiShowImportTable(void *stream, const char *label, - struct route_table *rt, int isvpn); + struct agg_table *rt, int isvpn); extern struct rfapi_import_table * rfapiImportTableRefAdd(struct bgp *bgp, struct ecommunity *rt_import_list, @@ -100,32 +100,31 @@ extern void rfapiImportTableRefDelByIt(struct bgp *bgp, * next less-specific node (i.e., this node's parent) at the end. */ extern struct rfapi_next_hop_entry *rfapiRouteNode2NextHopList( - struct route_node *rn, uint32_t lifetime, /* put into nexthop entries */ - struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */ - struct route_table *rfd_rib_table, /* preload this NVE rib table */ - struct prefix *pfx_target_original); /* query target */ + struct agg_node *rn, uint32_t lifetime, /* put into nexthop entries */ + struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */ + struct agg_table *rfd_rib_table, /* preload this NVE rib table */ + struct prefix *pfx_target_original); /* query target */ extern struct rfapi_next_hop_entry *rfapiRouteTable2NextHopList( - struct route_table *rt, - uint32_t lifetime, /* put into nexthop entries */ - struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */ - struct route_table *rfd_rib_table, /* preload this NVE rib table */ - struct prefix *pfx_target_original); /* query target */ + struct agg_table *rt, uint32_t lifetime, /* put into nexthop entries */ + struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */ + struct agg_table *rfd_rib_table, /* preload this NVE rib table */ + struct prefix *pfx_target_original); /* query target */ extern struct rfapi_next_hop_entry *rfapiEthRouteTable2NextHopList( uint32_t logical_net_id, struct rfapi_ip_prefix *rprefix, uint32_t lifetime, /* put into nexthop entries */ struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */ - struct route_table *rib_route_table, /* preload NVE rib node */ + struct agg_table *rib_route_table, /* preload NVE rib node */ struct prefix *pfx_target_original); /* query target */ extern int rfapiEcommunitiesIntersect(struct ecommunity *e1, struct ecommunity *e2); -extern void rfapiCheckRefcount(struct route_node *rn, safi_t safi, +extern void rfapiCheckRefcount(struct agg_node *rn, safi_t safi, int lockoffset); -extern int rfapiHasNonRemovedRoutes(struct route_node *rn); +extern int rfapiHasNonRemovedRoutes(struct agg_node *rn); extern int rfapiProcessDeferredClose(struct thread *t); @@ -153,10 +152,10 @@ extern void rfapiBgpInfoFilteredImportVPN( uint32_t *label); /* part of bgp_info */ extern struct rfapi_next_hop_entry *rfapiEthRouteNode2NextHopList( - struct route_node *rn, struct rfapi_ip_prefix *rprefix, + struct agg_node *rn, struct rfapi_ip_prefix *rprefix, uint32_t lifetime, /* put into nexthop entries */ struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */ - struct route_table *rib_route_table, /* preload NVE rib table */ + struct agg_table *rib_route_table, /* preload NVE rib table */ struct prefix *pfx_target_original); /* query target */ extern struct rfapi_import_table *rfapiMacImportTableGetNoAlloc(struct bgp *bgp, diff --git a/bgpd/rfapi/rfapi_monitor.c b/bgpd/rfapi/rfapi_monitor.c index 30182ba7a6..59387240fa 100644 --- a/bgpd/rfapi/rfapi_monitor.c +++ b/bgpd/rfapi/rfapi_monitor.c @@ -28,7 +28,7 @@ #include "lib/zebra.h" #include "lib/prefix.h" -#include "lib/table.h" +#include "lib/agg_table.h" #include "lib/vty.h" #include "lib/memory.h" #include "lib/log.h" @@ -68,10 +68,10 @@ static void rfapiMonitorEthDetachImport(struct bgp *bgp, /* * Debug function, special case */ -void rfapiMonitorEthSlCheck(struct route_node *rn, const char *tag1, +void rfapiMonitorEthSlCheck(struct agg_node *rn, const char *tag1, const char *tag2) { - struct route_node *rn_saved = NULL; + struct agg_node *rn_saved = NULL; static struct skiplist *sl_saved = NULL; struct skiplist *sl; @@ -118,12 +118,13 @@ void rfapiMonitorDupCheck(struct bgp *bgp) struct rfapi_descriptor *rfd; for (ALL_LIST_ELEMENTS_RO(&bgp->rfapi->descriptors, hnode, rfd)) { - struct route_node *mrn; + struct agg_node *mrn; if (!rfd->mon) continue; - for (mrn = route_top(rfd->mon); mrn; mrn = route_next(mrn)) { + for (mrn = agg_route_top(rfd->mon); mrn; + mrn = agg_route_next(mrn)) { struct rfapi_monitor_vpn *m; for (m = (struct rfapi_monitor_vpn *)(mrn->info); m; m = m->next) @@ -132,12 +133,13 @@ void rfapiMonitorDupCheck(struct bgp *bgp) } for (ALL_LIST_ELEMENTS_RO(&bgp->rfapi->descriptors, hnode, rfd)) { - struct route_node *mrn; + struct agg_node *mrn; if (!rfd->mon) continue; - for (mrn = route_top(rfd->mon); mrn; mrn = route_next(mrn)) { + for (mrn = agg_route_top(rfd->mon); mrn; + mrn = agg_route_next(mrn)) { struct rfapi_monitor_vpn *m; for (m = (struct rfapi_monitor_vpn *)(mrn->info); m; @@ -158,15 +160,17 @@ void rfapiMonitorCleanCheck(struct bgp *bgp) assert(!rfd->import_table->vpn0_queries[AFI_IP]); assert(!rfd->import_table->vpn0_queries[AFI_IP6]); - struct route_node *rn; + struct agg_node *rn; - for (rn = route_top(rfd->import_table->imported_vpn[AFI_IP]); - rn; rn = route_next(rn)) { + for (rn = agg_route_top( + rfd->import_table->imported_vpn[AFI_IP]); + rn; rn = agg_route_next(rn)) { assert(!RFAPI_MONITOR_VPN(rn)); } - for (rn = route_top(rfd->import_table->imported_vpn[AFI_IP6]); - rn; rn = route_next(rn)) { + for (rn = agg_route_top( + rfd->import_table->imported_vpn[AFI_IP6]); + rn; rn = agg_route_next(rn)) { assert(!RFAPI_MONITOR_VPN(rn)); } @@ -180,7 +184,7 @@ void rfapiMonitorCheckAttachAllowed(void) assert(!(bgp->rfapi_cfg->flags & BGP_VNC_CONFIG_CALLBACK_DISABLE)); } -void rfapiMonitorExtraFlush(safi_t safi, struct route_node *rn) +void rfapiMonitorExtraFlush(safi_t safi, struct agg_node *rn) { struct rfapi_it_extra *hie; struct rfapi_monitor_vpn *v; @@ -202,7 +206,7 @@ void rfapiMonitorExtraFlush(safi_t safi, struct route_node *rn) e_next = e->next; e->next = NULL; XFREE(MTYPE_RFAPI_MONITOR_ENCAP, e); - route_unlock_node(rn); + agg_unlock_node(rn); } hie->u.encap.e = NULL; break; @@ -212,33 +216,33 @@ void rfapiMonitorExtraFlush(safi_t safi, struct route_node *rn) v_next = v->next; v->next = NULL; XFREE(MTYPE_RFAPI_MONITOR, e); - route_unlock_node(rn); + agg_unlock_node(rn); } hie->u.vpn.v = NULL; if (hie->u.vpn.e.source) { while (!skiplist_delete_first(hie->u.vpn.e.source)) { - route_unlock_node(rn); + agg_unlock_node(rn); } skiplist_free(hie->u.vpn.e.source); hie->u.vpn.e.source = NULL; - route_unlock_node(rn); + agg_unlock_node(rn); } if (hie->u.vpn.idx_rd) { /* looping through bi->extra->vnc.import.rd is tbd */ while (!skiplist_delete_first(hie->u.vpn.idx_rd)) { - route_unlock_node(rn); + agg_unlock_node(rn); } skiplist_free(hie->u.vpn.idx_rd); hie->u.vpn.idx_rd = NULL; - route_unlock_node(rn); + agg_unlock_node(rn); } if (hie->u.vpn.mon_eth) { while (!skiplist_delete_first(hie->u.vpn.mon_eth)) { - route_unlock_node(rn); + agg_unlock_node(rn); } skiplist_free(hie->u.vpn.mon_eth); hie->u.vpn.mon_eth = NULL; - route_unlock_node(rn); + agg_unlock_node(rn); } break; @@ -247,13 +251,13 @@ void rfapiMonitorExtraFlush(safi_t safi, struct route_node *rn) } XFREE(MTYPE_RFAPI_IT_EXTRA, hie); rn->aggregate = NULL; - route_unlock_node(rn); + agg_unlock_node(rn); } /* * If the child lists are empty, release the rfapi_it_extra struct */ -void rfapiMonitorExtraPrune(safi_t safi, struct route_node *rn) +void rfapiMonitorExtraPrune(safi_t safi, struct agg_node *rn) { struct rfapi_it_extra *hie; @@ -279,28 +283,28 @@ void rfapiMonitorExtraPrune(safi_t safi, struct route_node *rn) return; skiplist_free(hie->u.vpn.mon_eth); hie->u.vpn.mon_eth = NULL; - route_unlock_node(rn); /* uncount skiplist */ + agg_unlock_node(rn); /* uncount skiplist */ } if (hie->u.vpn.e.source) { if (skiplist_count(hie->u.vpn.e.source)) return; skiplist_free(hie->u.vpn.e.source); hie->u.vpn.e.source = NULL; - route_unlock_node(rn); + agg_unlock_node(rn); } if (hie->u.vpn.idx_rd) { if (skiplist_count(hie->u.vpn.idx_rd)) return; skiplist_free(hie->u.vpn.idx_rd); hie->u.vpn.idx_rd = NULL; - route_unlock_node(rn); + agg_unlock_node(rn); } if (hie->u.vpn.mon_eth) { if (skiplist_count(hie->u.vpn.mon_eth)) return; skiplist_free(hie->u.vpn.mon_eth); hie->u.vpn.mon_eth = NULL; - route_unlock_node(rn); + agg_unlock_node(rn); } break; @@ -309,17 +313,17 @@ void rfapiMonitorExtraPrune(safi_t safi, struct route_node *rn) } XFREE(MTYPE_RFAPI_IT_EXTRA, hie); rn->aggregate = NULL; - route_unlock_node(rn); + agg_unlock_node(rn); } /* * returns locked node */ -struct route_node *rfapiMonitorGetAttachNode(struct rfapi_descriptor *rfd, - struct prefix *p) +struct agg_node *rfapiMonitorGetAttachNode(struct rfapi_descriptor *rfd, + struct prefix *p) { afi_t afi; - struct route_node *rn; + struct agg_node *rn; if (RFAPI_0_PREFIX(p)) { assert(1); @@ -341,7 +345,7 @@ struct route_node *rfapiMonitorGetAttachNode(struct rfapi_descriptor *rfd, * if a monitor is moved to another node, there must be * corresponding unlock/locks */ - for (rn = route_node_match(rfd->import_table->imported_vpn[afi], p); + for (rn = agg_node_match(rfd->import_table->imported_vpn[afi], p); rn;) { struct bgp_info *bi; @@ -369,9 +373,9 @@ struct route_node *rfapiMonitorGetAttachNode(struct rfapi_descriptor *rfd, if (bi) break; - route_unlock_node(rn); - if ((rn = rn->parent)) { - route_lock_node(rn); + agg_unlock_node(rn); + if ((rn = agg_node_parent(rn))) { + agg_lock_node(rn); } } @@ -383,8 +387,8 @@ struct route_node *rfapiMonitorGetAttachNode(struct rfapi_descriptor *rfd, /* creates default node if none exists, and increments ref count */ - rn = route_node_get(rfd->import_table->imported_vpn[afi], - &pfx_default); + rn = agg_node_get(rfd->import_table->imported_vpn[afi], + &pfx_default); } return rn; @@ -396,10 +400,10 @@ struct route_node *rfapiMonitorGetAttachNode(struct rfapi_descriptor *rfd, * returned (for the benefit of caller which might like to use it * to generate an immediate query response). */ -static struct route_node *rfapiMonitorAttachImport(struct rfapi_descriptor *rfd, - struct rfapi_monitor_vpn *m) +static struct agg_node *rfapiMonitorAttachImport(struct rfapi_descriptor *rfd, + struct rfapi_monitor_vpn *m) { - struct route_node *rn; + struct agg_node *rn; rfapiMonitorCheckAttachAllowed(); @@ -438,7 +442,7 @@ static struct route_node *rfapiMonitorAttachImport(struct rfapi_descriptor *rfd, */ void rfapiMonitorAttachImportHd(struct rfapi_descriptor *rfd) { - struct route_node *mrn; + struct agg_node *mrn; if (!rfd->mon) { /* @@ -447,7 +451,7 @@ void rfapiMonitorAttachImportHd(struct rfapi_descriptor *rfd) return; } - for (mrn = route_top(rfd->mon); mrn; mrn = route_next(mrn)) { + for (mrn = agg_route_top(rfd->mon); mrn; mrn = agg_route_next(mrn)) { if (!mrn->info) continue; @@ -467,11 +471,11 @@ void rfapiMonitorAttachImportHd(struct rfapi_descriptor *rfd) * are disabled, this function will not perform a lookup, and the * caller will have to do its own lookup. */ -struct route_node * -rfapiMonitorAdd(struct bgp *bgp, struct rfapi_descriptor *rfd, struct prefix *p) +struct agg_node *rfapiMonitorAdd(struct bgp *bgp, struct rfapi_descriptor *rfd, + struct prefix *p) { struct rfapi_monitor_vpn *m; - struct route_node *rn; + struct agg_node *rn; /* * Initialize nve's monitor list if needed @@ -480,15 +484,15 @@ rfapiMonitorAdd(struct bgp *bgp, struct rfapi_descriptor *rfd, struct prefix *p) * or be 0/0 so they won't get mixed up. */ if (!rfd->mon) { - rfd->mon = route_table_init(); + rfd->mon = agg_table_init(); } - rn = route_node_get(rfd->mon, p); + rn = agg_node_get(rfd->mon, p); if (rn->info) { /* * received this query before, no further action needed */ rfapiMonitorTimerRestart((struct rfapi_monitor_vpn *)rn->info); - route_unlock_node(rn); + agg_unlock_node(rn); return NULL; } @@ -575,7 +579,7 @@ rfapiMonitorDetachImport(struct rfapi_monitor_vpn *m) this->next; } RFAPI_CHECK_REFCOUNT(m->node, SAFI_MPLS_VPN, 1); - route_unlock_node(m->node); + agg_unlock_node(m->node); } m->node = NULL; } @@ -586,12 +590,12 @@ rfapiMonitorDetachImport(struct rfapi_monitor_vpn *m) void rfapiMonitorDetachImportHd(struct rfapi_descriptor *rfd) { - struct route_node *rn; + struct agg_node *rn; if (!rfd->mon) return; - for (rn = route_top(rfd->mon); rn; rn = route_next(rn)) { + for (rn = agg_route_top(rfd->mon); rn; rn = agg_route_next(rn)) { if (rn->info) { rfapiMonitorDetachImport( (struct rfapi_monitor_vpn *)(rn->info)); @@ -602,11 +606,11 @@ void rfapiMonitorDetachImportHd(struct rfapi_descriptor *rfd) void rfapiMonitorDel(struct bgp *bgp, struct rfapi_descriptor *rfd, struct prefix *p) { - struct route_node *rn; + struct agg_node *rn; struct rfapi_monitor_vpn *m; assert(rfd->mon); - rn = route_node_get(rfd->mon, p); /* locks node */ + rn = agg_node_get(rfd->mon, p); /* locks node */ m = rn->info; assert(m); @@ -628,8 +632,8 @@ void rfapiMonitorDel(struct bgp *bgp, struct rfapi_descriptor *rfd, */ XFREE(MTYPE_RFAPI_MONITOR, m); rn->info = NULL; - route_unlock_node(rn); /* undo original lock when created */ - route_unlock_node(rn); /* undo lock in route_node_get */ + agg_unlock_node(rn); /* undo original lock when created */ + agg_unlock_node(rn); /* undo lock in agg_node_get */ --rfd->monitor_count; --bgp->rfapi->monitor_count; @@ -640,7 +644,7 @@ void rfapiMonitorDel(struct bgp *bgp, struct rfapi_descriptor *rfd, */ int rfapiMonitorDelHd(struct rfapi_descriptor *rfd) { - struct route_node *rn; + struct agg_node *rn; struct bgp *bgp; int count = 0; @@ -649,7 +653,8 @@ int rfapiMonitorDelHd(struct rfapi_descriptor *rfd) bgp = bgp_get_default(); if (rfd->mon) { - for (rn = route_top(rfd->mon); rn; rn = route_next(rn)) { + for (rn = agg_route_top(rfd->mon); rn; + rn = agg_route_next(rn)) { struct rfapi_monitor_vpn *m; if ((m = rn->info)) { if (!(bgp->rfapi_cfg->flags @@ -664,14 +669,14 @@ int rfapiMonitorDelHd(struct rfapi_descriptor *rfd) XFREE(MTYPE_RFAPI_MONITOR, m); rn->info = NULL; - route_unlock_node(rn); /* undo original lock + agg_unlock_node(rn); /* undo original lock when created */ ++count; --rfd->monitor_count; --bgp->rfapi->monitor_count; } } - route_table_finish(rfd->mon); + agg_table_finish(rfd->mon); rfd->mon = NULL; } @@ -788,7 +793,7 @@ static void rfapiMonitorTimerRestart(struct rfapi_monitor_vpn *m) */ void rfapiMonitorTimersRestart(struct rfapi_descriptor *rfd, struct prefix *p) { - struct route_node *rn; + struct agg_node *rn; if (AF_ETHERNET == p->family) { struct rfapi_monitor_eth *mon_eth; @@ -812,7 +817,8 @@ void rfapiMonitorTimersRestart(struct rfapi_descriptor *rfd, struct prefix *p) } } else { - for (rn = route_top(rfd->mon); rn; rn = route_next(rn)) { + for (rn = agg_route_top(rfd->mon); rn; + rn = agg_route_next(rn)) { struct rfapi_monitor_vpn *m; if (!((m = rn->info))) @@ -831,11 +837,11 @@ void rfapiMonitorTimersRestart(struct rfapi_descriptor *rfd, struct prefix *p) * rfapiRibUpdatePendingNode with this node and all corresponding NVEs. */ void rfapiMonitorItNodeChanged( - struct rfapi_import_table *import_table, struct route_node *it_node, + struct rfapi_import_table *import_table, struct agg_node *it_node, struct rfapi_monitor_vpn *monitor_list) /* for base it node, NULL=all */ { struct skiplist *nves_seen; - struct route_node *rn = it_node; + struct agg_node *rn = it_node; struct bgp *bgp = bgp_get_default(); afi_t afi = family2afi(rn->p.family); #if DEBUG_L2_EXTRA @@ -909,7 +915,8 @@ void rfapiMonitorItNodeChanged( * to them * because we haven't sent them an initial route. */ - if (!rn->parent && !rn->info && it_node->parent) + if (!agg_node_parent(rn) && !rn->info + && it_node->parent) break; for (; m; m = m->next) { @@ -947,7 +954,7 @@ void rfapiMonitorItNodeChanged( m->rfd->response_lifetime); } } - rn = rn->parent; + rn = agg_node_parent(rn); if (rn) m = RFAPI_MONITOR_VPN(rn); } while (rn); @@ -1023,8 +1030,7 @@ void rfapiMonitorItNodeChanged( * omit old node and its subtree */ void rfapiMonitorMovedUp(struct rfapi_import_table *import_table, - struct route_node *old_node, - struct route_node *new_node, + struct agg_node *old_node, struct agg_node *new_node, struct rfapi_monitor_vpn *monitor_list) { struct bgp *bgp = bgp_get_default(); @@ -1125,7 +1131,7 @@ static int mon_eth_cmp(void *a, void *b) static void rfapiMonitorEthAttachImport( struct rfapi_import_table *it, - struct route_node *rn, /* it node attach point if non-0 */ + struct agg_node *rn, /* it node attach point if non-0 */ struct rfapi_monitor_eth *mon) /* monitor struct to attach */ { struct skiplist *sl; @@ -1162,7 +1168,7 @@ static void rfapiMonitorEthAttachImport( if (!sl) { sl = RFAPI_MONITOR_ETH_W_ALLOC(rn) = skiplist_new(0, NULL, NULL); - route_lock_node(rn); /* count skiplist mon_eth */ + agg_lock_node(rn); /* count skiplist mon_eth */ } #if DEBUG_L2_EXTRA @@ -1175,7 +1181,7 @@ static void rfapiMonitorEthAttachImport( assert(!rc); /* count eth monitor */ - route_lock_node(rn); + agg_lock_node(rn); } /* @@ -1202,7 +1208,7 @@ static void rfapiMonitorEthAttachImportHd(struct bgp *bgp, struct rfapi_import_table *it; struct prefix pfx_mac_buf; - struct route_node *rn; + struct agg_node *rn; it = rfapiMacImportTableGet(bgp, mon->logical_net_id); assert(it); @@ -1212,7 +1218,7 @@ static void rfapiMonitorEthAttachImportHd(struct bgp *bgp, pfx_mac_buf.prefixlen = 48; pfx_mac_buf.u.prefix_eth = mon->macaddr; - rn = route_node_get(it->imported_vpn[AFI_L2VPN], &pfx_mac_buf); + rn = agg_node_get(it->imported_vpn[AFI_L2VPN], &pfx_mac_buf); assert(rn); (void)rfapiMonitorEthAttachImport(it, rn, mon); @@ -1226,7 +1232,7 @@ static void rfapiMonitorEthDetachImport( struct rfapi_import_table *it; struct prefix pfx_mac_buf; struct skiplist *sl; - struct route_node *rn; + struct agg_node *rn; int rc; it = rfapiMacImportTableGet(bgp, mon->logical_net_id); @@ -1262,7 +1268,7 @@ static void rfapiMonitorEthDetachImport( pfx_mac_buf.prefixlen = 48; pfx_mac_buf.u.prefix_eth = mon->macaddr; - rn = route_node_get(it->imported_vpn[AFI_L2VPN], &pfx_mac_buf); + rn = agg_node_get(it->imported_vpn[AFI_L2VPN], &pfx_mac_buf); assert(rn); #if DEBUG_L2_EXTRA @@ -1288,19 +1294,19 @@ static void rfapiMonitorEthDetachImport( assert(!rc); /* uncount eth monitor */ - route_unlock_node(rn); + agg_unlock_node(rn); } -struct route_node *rfapiMonitorEthAdd(struct bgp *bgp, - struct rfapi_descriptor *rfd, - struct ethaddr *macaddr, - uint32_t logical_net_id) +struct agg_node *rfapiMonitorEthAdd(struct bgp *bgp, + struct rfapi_descriptor *rfd, + struct ethaddr *macaddr, + uint32_t logical_net_id) { int rc; struct rfapi_monitor_eth mon_buf; struct rfapi_monitor_eth *val; struct rfapi_import_table *it; - struct route_node *rn = NULL; + struct agg_node *rn = NULL; struct prefix pfx_mac_buf; if (!rfd->mon_eth) { @@ -1323,7 +1329,7 @@ struct route_node *rfapiMonitorEthAdd(struct bgp *bgp, pfx_mac_buf.u.prefix_eth = *macaddr; if (!RFAPI_0_ETHERADDR(macaddr)) { - rn = route_node_get(it->imported_vpn[AFI_L2VPN], &pfx_mac_buf); + rn = agg_node_get(it->imported_vpn[AFI_L2VPN], &pfx_mac_buf); assert(rn); } @@ -1453,8 +1459,8 @@ void rfapiMonitorCallbacksOff(struct bgp *bgp) { struct rfapi_import_table *it; afi_t afi; - struct route_table *rt; - struct route_node *rn; + struct agg_table *rt; + struct agg_node *rn; void *cursor; int rc; struct rfapi *h = bgp->rfapi; @@ -1485,7 +1491,8 @@ void rfapiMonitorCallbacksOff(struct bgp *bgp) rt = it->imported_vpn[afi]; - for (rn = route_top(rt); rn; rn = route_next(rn)) { + for (rn = agg_route_top(rt); rn; + rn = agg_route_next(rn)) { m = RFAPI_MONITOR_VPN(rn); if (RFAPI_MONITOR_VPN(rn)) RFAPI_MONITOR_VPN_W_ALLOC(rn) = NULL; @@ -1494,7 +1501,7 @@ void rfapiMonitorCallbacksOff(struct bgp *bgp) m->next = NULL; /* gratuitous safeness */ m->node = NULL; - route_unlock_node(rn); /* uncount */ + agg_unlock_node(rn); /* uncount */ } } @@ -1531,12 +1538,12 @@ void rfapiMonitorCallbacksOff(struct bgp *bgp) * Find non-0 monitors (i.e., actual addresses, not FTD * monitors) */ - for (rn = route_top(rt); rn; rn = route_next(rn)) { + for (rn = agg_route_top(rt); rn; rn = agg_route_next(rn)) { struct skiplist *sl; sl = RFAPI_MONITOR_ETH(rn); while (!skiplist_delete_first(sl)) { - route_unlock_node(rn); /* uncount monitor */ + agg_unlock_node(rn); /* uncount monitor */ } } diff --git a/bgpd/rfapi/rfapi_monitor.h b/bgpd/rfapi/rfapi_monitor.h index edc9744cdb..9b85f6248e 100644 --- a/bgpd/rfapi/rfapi_monitor.h +++ b/bgpd/rfapi/rfapi_monitor.h @@ -30,10 +30,10 @@ * to indicate which nves are interested in a prefix/target */ struct rfapi_monitor_vpn { - struct rfapi_monitor_vpn *next; /* chain from struct route_node */ + struct rfapi_monitor_vpn *next; /* chain from struct agg_node */ struct rfapi_descriptor *rfd; /* which NVE requested the route */ struct prefix p; /* constant: pfx in original request */ - struct route_node *node; /* node we're currently attached to */ + struct agg_node *node; /* node we're currently attached to */ uint32_t flags; #define RFAPI_MON_FLAG_NEEDCALLBACK 0x00000001 /* deferred callback */ @@ -44,9 +44,9 @@ struct rfapi_monitor_vpn { struct rfapi_monitor_encap { struct rfapi_monitor_encap *next; struct rfapi_monitor_encap *prev; - struct route_node *node; /* VPN node */ + struct agg_node *node; /* VPN node */ struct bgp_info *bi; /* VPN bi */ - struct route_node *rn; /* parent node */ + struct agg_node *rn; /* parent node */ }; struct rfapi_monitor_eth { @@ -98,7 +98,7 @@ struct rfapi_it_extra { ((struct rfapi_it_extra \ *)((rn)->aggregate \ ? (rn)->aggregate \ - : (route_lock_node(rn), \ + : (agg_lock_node(rn), \ (rn)->aggregate = XCALLOC( \ MTYPE_RFAPI_IT_EXTRA, \ sizeof(struct rfapi_it_extra))))) @@ -138,16 +138,16 @@ extern void rfapiMonitorCleanCheck(struct bgp *bgp); extern void rfapiMonitorCheckAttachAllowed(void); -extern void rfapiMonitorExtraFlush(safi_t safi, struct route_node *rn); +extern void rfapiMonitorExtraFlush(safi_t safi, struct agg_node *rn); -extern struct route_node * -rfapiMonitorGetAttachNode(struct rfapi_descriptor *rfd, struct prefix *p); +extern struct agg_node *rfapiMonitorGetAttachNode(struct rfapi_descriptor *rfd, + struct prefix *p); extern void rfapiMonitorAttachImportHd(struct rfapi_descriptor *rfd); -extern struct route_node *rfapiMonitorAdd(struct bgp *bgp, - struct rfapi_descriptor *rfd, - struct prefix *p); +extern struct agg_node *rfapiMonitorAdd(struct bgp *bgp, + struct rfapi_descriptor *rfd, + struct prefix *p); extern void rfapiMonitorDetachImportHd(struct rfapi_descriptor *rfd); @@ -164,24 +164,24 @@ extern void rfapiMonitorResponseRemovalOff(struct bgp *bgp); extern void rfapiMonitorResponseRemovalOn(struct bgp *bgp); -extern void rfapiMonitorExtraPrune(safi_t safi, struct route_node *rn); +extern void rfapiMonitorExtraPrune(safi_t safi, struct agg_node *rn); extern void rfapiMonitorTimersRestart(struct rfapi_descriptor *rfd, struct prefix *p); extern void rfapiMonitorItNodeChanged(struct rfapi_import_table *import_table, - struct route_node *it_node, + struct agg_node *it_node, struct rfapi_monitor_vpn *monitor_list); extern void rfapiMonitorMovedUp(struct rfapi_import_table *import_table, - struct route_node *old_node, - struct route_node *new_node, + struct agg_node *old_node, + struct agg_node *new_node, struct rfapi_monitor_vpn *monitor_list); -extern struct route_node *rfapiMonitorEthAdd(struct bgp *bgp, - struct rfapi_descriptor *rfd, - struct ethaddr *macaddr, - uint32_t logical_net_id); +extern struct agg_node *rfapiMonitorEthAdd(struct bgp *bgp, + struct rfapi_descriptor *rfd, + struct ethaddr *macaddr, + uint32_t logical_net_id); extern void rfapiMonitorEthDel(struct bgp *bgp, struct rfapi_descriptor *rfd, struct ethaddr *macaddr, diff --git a/bgpd/rfapi/rfapi_nve_addr.c b/bgpd/rfapi/rfapi_nve_addr.c index 0fb887912c..ee54d88c3f 100644 --- a/bgpd/rfapi/rfapi_nve_addr.c +++ b/bgpd/rfapi/rfapi_nve_addr.c @@ -21,7 +21,7 @@ #include "lib/zebra.h" #include "lib/prefix.h" -#include "lib/table.h" +#include "lib/agg_table.h" #include "lib/vty.h" #include "lib/memory.h" #include "lib/skiplist.h" diff --git a/bgpd/rfapi/rfapi_private.h b/bgpd/rfapi/rfapi_private.h index 9c759fc47e..4d8072a49b 100644 --- a/bgpd/rfapi/rfapi_private.h +++ b/bgpd/rfapi/rfapi_private.h @@ -47,7 +47,7 @@ struct rfapi_advertised_prefixes { }; struct rfapi_descriptor { - struct route_node *un_node; /* backref to un table */ + struct agg_node *un_node; /* backref to un table */ struct rfapi_descriptor *next; /* next vn_addr */ @@ -76,7 +76,7 @@ struct rfapi_descriptor { struct rfapi_import_table *import_table; uint32_t monitor_count; - struct route_table *mon; /* rfapi_monitors */ + struct agg_table *mon; /* rfapi_monitors */ struct skiplist *mon_eth; /* ethernet monitors */ /* @@ -85,10 +85,10 @@ struct rfapi_descriptor { * rsp_times last time we sent response containing pfx */ uint32_t rib_prefix_count; /* pfxes with routes */ - struct route_table *rib[AFI_MAX]; - struct route_table *rib_pending[AFI_MAX]; + struct agg_table *rib[AFI_MAX]; + struct agg_table *rib_pending[AFI_MAX]; struct work_queue *updated_responses_queue; - struct route_table *rsp_times[AFI_MAX]; + struct agg_table *rsp_times[AFI_MAX]; uint32_t rsp_counter; /* dedup initial rsp */ time_t rsp_time; /* dedup initial rsp */ @@ -171,7 +171,7 @@ struct rfapi_global_stats { * check vn address to get exact match. */ struct rfapi { - struct route_table *un[AFI_MAX]; + struct agg_table *un[AFI_MAX]; struct rfapi_import_table *imports; /* IPv4, IPv6 */ struct list descriptors; /* debug & resolve-nve imports */ @@ -198,8 +198,8 @@ struct rfapi { * bgp unicast or zebra, we need to keep track of information * related to expiring the routes according to the VNC lifetime */ - struct route_table *rt_export_bgp[AFI_MAX]; - struct route_table *rt_export_zebra[AFI_MAX]; + struct agg_table *rt_export_bgp[AFI_MAX]; + struct agg_table *rt_export_zebra[AFI_MAX]; /* * For VNC->BGP unicast exports in CE mode, we need a diff --git a/bgpd/rfapi/rfapi_rib.c b/bgpd/rfapi/rfapi_rib.c index 60534fece0..3ac217ff89 100644 --- a/bgpd/rfapi/rfapi_rib.c +++ b/bgpd/rfapi/rfapi_rib.c @@ -27,7 +27,7 @@ #include "lib/zebra.h" #include "lib/prefix.h" -#include "lib/table.h" +#include "lib/agg_table.h" #include "lib/vty.h" #include "lib/memory.h" #include "lib/log.h" @@ -150,10 +150,10 @@ void rfapiRibCheckCounts( for (afi = AFI_IP; afi < AFI_MAX; ++afi) { - struct route_node *rn; + struct agg_node *rn; - for (rn = route_top(rfd->rib[afi]); rn; - rn = route_next(rn)) { + for (rn = agg_route_top(rfd->rib[afi]); rn; + rn = agg_route_next(rn)) { struct skiplist *sl = rn->info; struct skiplist *dsl = rn->aggregate; @@ -175,8 +175,8 @@ void rfapiRibCheckCounts( ++t_pfx_deleted; } } - for (rn = route_top(rfd->rib_pending[afi]); rn; - rn = route_next(rn)) { + for (rn = agg_route_top(rfd->rib_pending[afi]); rn; + rn = agg_route_next(rn)) { struct list *l = rn->info; /* sorted by cost */ struct skiplist *sl = rn->aggregate; @@ -286,7 +286,7 @@ struct rfapi_rib_tcb { struct rfapi_descriptor *rfd; struct skiplist *sl; struct rfapi_info *ri; - struct route_node *rn; + struct agg_node *rn; int flags; #define RFAPI_RIB_TCB_FLAG_DELETED 0x00000001 }; @@ -325,7 +325,7 @@ static int rfapiRibExpireTimer(struct thread *t) RFAPI_RIB_PREFIX_COUNT_DECR(tcb->rfd, bgp->rfapi); } skiplist_free(tcb->sl); - route_unlock_node(tcb->rn); + agg_unlock_node(tcb->rn); } XFREE(MTYPE_RFAPI_RECENT_DELETE, tcb); @@ -335,10 +335,10 @@ static int rfapiRibExpireTimer(struct thread *t) return 0; } -static void -rfapiRibStartTimer(struct rfapi_descriptor *rfd, struct rfapi_info *ri, - struct route_node *rn, /* route node attached to */ - int deleted) +static void rfapiRibStartTimer(struct rfapi_descriptor *rfd, + struct rfapi_info *ri, + struct agg_node *rn, /* route node attached to */ + int deleted) { struct thread *t = ri->timer; struct rfapi_rib_tcb *tcb = NULL; @@ -486,12 +486,12 @@ void rfapiRibClear(struct rfapi_descriptor *rfd) #endif for (afi = AFI_IP; afi < AFI_MAX; ++afi) { - struct route_node *pn; - struct route_node *rn; + struct agg_node *pn; + struct agg_node *rn; if (rfd->rib_pending[afi]) { - for (pn = route_top(rfd->rib_pending[afi]); pn; - pn = route_next(pn)) { + for (pn = agg_route_top(rfd->rib_pending[afi]); pn; + pn = agg_route_next(pn)) { if (pn->aggregate) { /* * free references into the rfapi_info @@ -502,7 +502,7 @@ void rfapiRibClear(struct rfapi_descriptor *rfd) (struct skiplist *)(pn->aggregate)); pn->aggregate = NULL; - route_unlock_node( + agg_unlock_node( pn); /* skiplist deleted */ } /* @@ -516,13 +516,13 @@ void rfapiRibClear(struct rfapi_descriptor *rfd) } pn->info = NULL; /* linklist or 1 deleted */ - route_unlock_node(pn); + agg_unlock_node(pn); } } } if (rfd->rib[afi]) { - for (rn = route_top(rfd->rib[afi]); rn; - rn = route_next(rn)) { + for (rn = agg_route_top(rfd->rib[afi]); rn; + rn = agg_route_next(rn)) { if (rn->info) { struct rfapi_info *ri; @@ -541,7 +541,7 @@ void rfapiRibClear(struct rfapi_descriptor *rfd) skiplist_free( (struct skiplist *)rn->info); rn->info = NULL; - route_unlock_node(rn); + agg_unlock_node(rn); RFAPI_RIB_PREFIX_COUNT_DECR(rfd, bgp->rfapi); } @@ -566,7 +566,7 @@ void rfapiRibClear(struct rfapi_descriptor *rfd) *)(rn->aggregate)); rn->aggregate = NULL; - route_unlock_node(rn); + agg_unlock_node(rn); } } } @@ -601,15 +601,18 @@ void rfapiRibFree(struct rfapi_descriptor *rfd) * Free radix trees */ for (afi = AFI_IP; afi < AFI_MAX; ++afi) { - route_table_finish(rfd->rib_pending[afi]); + if (rfd->rib_pending[afi]) + agg_table_finish(rfd->rib_pending[afi]); rfd->rib_pending[afi] = NULL; - route_table_finish(rfd->rib[afi]); + if (rfd->rib[afi]) + agg_table_finish(rfd->rib[afi]); rfd->rib[afi] = NULL; - /* NB route_table_finish frees only prefix nodes, not chained + /* NB agg_table_finish frees only prefix nodes, not chained * info */ - route_table_finish(rfd->rsp_times[afi]); + if (rfd->rsp_times[afi]) + agg_table_finish(rfd->rsp_times[afi]); rfd->rib[afi] = NULL; } } @@ -730,7 +733,7 @@ static void rfapiRibBi2Ri(struct bgp_info *bi, struct rfapi_info *ri, * !0 do not include route in response */ int rfapiRibPreloadBi( - struct route_node *rfd_rib_node, /* NULL = don't preload or filter */ + struct agg_node *rfd_rib_node, /* NULL = don't preload or filter */ struct prefix *pfx_vn, struct prefix *pfx_un, uint32_t lifetime, struct bgp_info *bi) { @@ -738,7 +741,7 @@ int rfapiRibPreloadBi( struct skiplist *slRibPt = NULL; struct rfapi_info *ori = NULL; struct rfapi_rib_key rk; - struct route_node *trn; + struct agg_node *trn; afi_t afi; if (!rfd_rib_node) @@ -746,7 +749,7 @@ int rfapiRibPreloadBi( afi = family2afi(rfd_rib_node->p.family); - rfd = (struct rfapi_descriptor *)(rfd_rib_node->table->info); + rfd = agg_get_table_info(agg_get_table(rfd_rib_node)); memset((void *)&rk, 0, sizeof(rk)); rk.vn = *pfx_vn; @@ -784,7 +787,7 @@ int rfapiRibPreloadBi( if (!slRibPt) { slRibPt = skiplist_new(0, rfapi_rib_key_cmp, NULL); rfd_rib_node->info = slRibPt; - route_lock_node(rfd_rib_node); + agg_lock_node(rfd_rib_node); RFAPI_RIB_PREFIX_COUNT_INCR(rfd, rfd->bgp->rfapi); } skiplist_insert(slRibPt, &ori->rk, ori); @@ -802,11 +805,11 @@ int rfapiRibPreloadBi( /* * Update last sent time for prefix */ - trn = route_node_get(rfd->rsp_times[afi], - &rfd_rib_node->p); /* locks trn */ + trn = agg_node_get(rfd->rsp_times[afi], + &rfd_rib_node->p); /* locks trn */ trn->info = (void *)(uintptr_t)bgp_clock(); if (trn->lock > 1) - route_unlock_node(trn); + agg_unlock_node(trn); return 0; } @@ -837,7 +840,7 @@ int rfapiRibPreloadBi( */ static void process_pending_node(struct bgp *bgp, struct rfapi_descriptor *rfd, afi_t afi, - struct route_node *pn, /* pending node */ + struct agg_node *pn, /* pending node */ struct rfapi_next_hop_entry **head, struct rfapi_next_hop_entry **tail) { @@ -845,7 +848,7 @@ static void process_pending_node(struct bgp *bgp, struct rfapi_descriptor *rfd, struct listnode *nnode = NULL; struct rfapi_info *ri = NULL; /* happy valgrind */ struct rfapi_ip_prefix hp = {0}; /* pfx to put in NHE */ - struct route_node *rn = NULL; + struct agg_node *rn = NULL; struct skiplist *slRibPt = NULL; /* rib list */ struct skiplist *slPendPt = NULL; struct list *lPendCost = NULL; @@ -875,7 +878,7 @@ static void process_pending_node(struct bgp *bgp, struct rfapi_descriptor *rfd, /* * Find corresponding RIB node */ - rn = route_node_get(rfd->rib[afi], &pn->p); /* locks rn */ + rn = agg_node_get(rfd->rib[afi], &pn->p); /* locks rn */ /* * RIB skiplist has key=rfapi_addr={vn,un}, val = rfapi_info, @@ -945,30 +948,30 @@ static void process_pending_node(struct bgp *bgp, struct rfapi_descriptor *rfd, skiplist_free(slRibPt); rn->info = slRibPt = NULL; - route_unlock_node(rn); + agg_unlock_node(rn); lPendCost = pn->info = NULL; - route_unlock_node(pn); + agg_unlock_node(pn); goto callback; } if (slRibPt) { skiplist_free(slRibPt); rn->info = NULL; - route_unlock_node(rn); + agg_unlock_node(rn); } assert(!slPendPt); if (slPendPt) { /* TBD I think we can toss this block */ skiplist_free(slPendPt); pn->aggregate = NULL; - route_unlock_node(pn); + agg_unlock_node(pn); } pn->info = NULL; - route_unlock_node(pn); + agg_unlock_node(pn); - route_unlock_node(rn); /* route_node_get() */ + agg_unlock_node(rn); /* agg_node_get() */ if (rib_node_started_nonempty) { RFAPI_RIB_PREFIX_COUNT_DECR(rfd, bgp->rfapi); @@ -1076,7 +1079,7 @@ static void process_pending_node(struct bgp *bgp, struct rfapi_descriptor *rfd, if (skiplist_empty(slRibPt)) { skiplist_free(slRibPt); slRibPt = rn->info = NULL; - route_unlock_node(rn); + agg_unlock_node(rn); } } } @@ -1142,7 +1145,7 @@ static void process_pending_node(struct bgp *bgp, struct rfapi_descriptor *rfd, slRibPt = skiplist_new( 0, rfapi_rib_key_cmp, NULL); rn->info = slRibPt; - route_lock_node(rn); + agg_lock_node(rn); } skiplist_insert(slRibPt, &ori->rk, ori); @@ -1192,7 +1195,7 @@ callback: for (ALL_LIST_ELEMENTS(lPendCost, node, nnode, ri)) { struct rfapi_next_hop_entry *new; - struct route_node *trn; + struct agg_node *trn; new = XCALLOC(MTYPE_RFAPI_NEXTHOP, sizeof(struct rfapi_next_hop_entry)); @@ -1244,11 +1247,11 @@ callback: /* * update this NVE's timestamp for this prefix */ - trn = route_node_get(rfd->rsp_times[afi], - &pn->p); /* locks trn */ + trn = agg_node_get(rfd->rsp_times[afi], + &pn->p); /* locks trn */ trn->info = (void *)(uintptr_t)bgp_clock(); if (trn->lock > 1) - route_unlock_node(trn); + agg_unlock_node(trn); rfapiRfapiIpAddr2Str(&new->vn_address, buf, BUFSIZ); rfapiRfapiIpAddr2Str(&new->un_address, buf2, BUFSIZ); @@ -1347,7 +1350,7 @@ callback: 0, rfapi_rib_key_cmp, (void (*)(void *)) rfapi_info_free); - route_lock_node(rn); + agg_lock_node(rn); } RFAPI_RIB_CHECK_COUNTS(0, delete_list->count); @@ -1438,18 +1441,18 @@ callback: RFAPI_RIB_CHECK_COUNTS(0, 0); /* - * Reset pending lists. The final route_unlock_node() will probably + * Reset pending lists. The final agg_unlock_node() will probably * cause the pending node to be released. */ if (slPendPt) { skiplist_free(slPendPt); pn->aggregate = NULL; - route_unlock_node(pn); + agg_unlock_node(pn); } if (lPendCost) { list_delete_and_null(&lPendCost); pn->info = NULL; - route_unlock_node(pn); + agg_unlock_node(pn); } RFAPI_RIB_CHECK_COUNTS(0, 0); @@ -1466,7 +1469,7 @@ callback: if (sendingsomeroutes) rfapiMonitorTimersRestart(rfd, &pn->p); - route_unlock_node(rn); /* route_node_get() */ + agg_unlock_node(rn); /* agg_node_get() */ RFAPI_RIB_CHECK_COUNTS(1, 0); } @@ -1484,7 +1487,7 @@ static void rib_do_callback_onepass(struct rfapi_descriptor *rfd, afi_t afi) struct bgp *bgp = bgp_get_default(); struct rfapi_next_hop_entry *head = NULL; struct rfapi_next_hop_entry *tail = NULL; - struct route_node *rn; + struct agg_node *rn; #if DEBUG_L2_EXTRA vnc_zlog_debug_verbose("%s: rfd=%p, afi=%d", __func__, rfd, afi); @@ -1495,7 +1498,8 @@ static void rib_do_callback_onepass(struct rfapi_descriptor *rfd, afi_t afi) assert(bgp->rfapi); - for (rn = route_top(rfd->rib_pending[afi]); rn; rn = route_next(rn)) { + for (rn = agg_route_top(rfd->rib_pending[afi]); rn; + rn = agg_route_next(rn)) { process_pending_node(bgp, rfd, afi, rn, &head, &tail); } @@ -1585,11 +1589,11 @@ static void updated_responses_queue_init(struct rfapi_descriptor *rfd) void rfapiRibUpdatePendingNode( struct bgp *bgp, struct rfapi_descriptor *rfd, struct rfapi_import_table *it, /* needed for L2 */ - struct route_node *it_node, uint32_t lifetime) + struct agg_node *it_node, uint32_t lifetime) { struct prefix *prefix; struct bgp_info *bi; - struct route_node *pn; + struct agg_node *pn; afi_t afi; uint32_t queued_flag; int count = 0; @@ -1609,7 +1613,7 @@ void rfapiRibUpdatePendingNode( prefix2str(prefix, buf, sizeof(buf)); vnc_zlog_debug_verbose("%s: prefix=%s", __func__, buf); - pn = route_node_get(rfd->rib_pending[afi], prefix); + pn = agg_node_get(rfd->rib_pending[afi], prefix); assert(pn); vnc_zlog_debug_verbose("%s: pn->info=%p, pn->aggregate=%p", __func__, @@ -1622,7 +1626,7 @@ void rfapiRibUpdatePendingNode( */ skiplist_free((struct skiplist *)(pn->aggregate)); pn->aggregate = NULL; - route_unlock_node(pn); /* skiplist deleted */ + agg_unlock_node(pn); /* skiplist deleted */ } @@ -1634,7 +1638,7 @@ void rfapiRibUpdatePendingNode( list_delete_and_null((struct list **)(&pn->info)); } pn->info = NULL; - route_unlock_node(pn); /* linklist or 1 deleted */ + agg_unlock_node(pn); /* linklist or 1 deleted */ } /* @@ -1689,7 +1693,7 @@ void rfapiRibUpdatePendingNode( if (!pn->aggregate) { pn->aggregate = skiplist_new(0, rfapi_rib_key_cmp, NULL); - route_lock_node(pn); + agg_lock_node(pn); } /* @@ -1715,7 +1719,7 @@ void rfapiRibUpdatePendingNode( pn->info = list_new(); ((struct list *)(pn->info))->del = (void (*)(void *))rfapi_info_free; - route_lock_node(pn); + agg_lock_node(pn); } listnode_add((struct list *)(pn->info), ri); @@ -1730,10 +1734,10 @@ void rfapiRibUpdatePendingNode( assert(!pn->aggregate); pn->info = (void *)1; /* magic value means this node has no routes */ - route_lock_node(pn); + agg_lock_node(pn); } - route_unlock_node(pn); /* route_node_get */ + agg_unlock_node(pn); /* agg_node_get */ queued_flag = RFAPI_QUEUED_FLAG(afi); @@ -1757,25 +1761,30 @@ void rfapiRibUpdatePendingNode( void rfapiRibUpdatePendingNodeSubtree( struct bgp *bgp, struct rfapi_descriptor *rfd, - struct rfapi_import_table *it, struct route_node *it_node, - struct route_node *omit_subtree, /* may be NULL */ + struct rfapi_import_table *it, struct agg_node *it_node, + struct agg_node *omit_subtree, /* may be NULL */ uint32_t lifetime) { /* FIXME: need to find a better way here to work without sticking our * hands in node->link */ - if (it_node->l_left && (it_node->l_left != omit_subtree)) { - if (it_node->l_left->info) - rfapiRibUpdatePendingNode(bgp, rfd, it, it_node->l_left, - lifetime); - rfapiRibUpdatePendingNodeSubtree(bgp, rfd, it, it_node->l_left, + if (agg_node_left(it_node) + && (agg_node_left(it_node) != omit_subtree)) { + if (agg_node_left(it_node)->info) + rfapiRibUpdatePendingNode( + bgp, rfd, it, agg_node_left(it_node), lifetime); + rfapiRibUpdatePendingNodeSubtree(bgp, rfd, it, + agg_node_left(it_node), omit_subtree, lifetime); } - if (it_node->l_right && (it_node->l_right != omit_subtree)) { - if (it_node->l_right->info) + if (agg_node_right(it_node) + && (agg_node_right(it_node) != omit_subtree)) { + if (agg_node_right(it_node)->info) rfapiRibUpdatePendingNode(bgp, rfd, it, - it_node->l_right, lifetime); - rfapiRibUpdatePendingNodeSubtree(bgp, rfd, it, it_node->l_right, + agg_node_right(it_node), + lifetime); + rfapiRibUpdatePendingNodeSubtree(bgp, rfd, it, + agg_node_right(it_node), omit_subtree, lifetime); } } @@ -1788,13 +1797,13 @@ void rfapiRibUpdatePendingNodeSubtree( */ int rfapiRibFTDFilterRecentPrefix( struct rfapi_descriptor *rfd, - struct route_node *it_rn, /* import table node */ + struct agg_node *it_rn, /* import table node */ struct prefix *pfx_target_original) /* query target */ { struct bgp *bgp = rfd->bgp; afi_t afi = family2afi(it_rn->p.family); time_t prefix_time; - struct route_node *trn; + struct agg_node *trn; /* * Not in FTD mode, so allow prefix @@ -1833,10 +1842,10 @@ int rfapiRibFTDFilterRecentPrefix( /* * check this NVE's timestamp for this prefix */ - trn = route_node_get(rfd->rsp_times[afi], &it_rn->p); /* locks trn */ + trn = agg_node_get(rfd->rsp_times[afi], &it_rn->p); /* locks trn */ prefix_time = (time_t)trn->info; if (trn->lock > 1) - route_unlock_node(trn); + agg_unlock_node(trn); #if DEBUG_FTD_FILTER_RECENT vnc_zlog_debug_verbose("%s: last sent time %lu, last allowed time %lu", @@ -1883,9 +1892,9 @@ rfapiRibPreload(struct bgp *bgp, struct rfapi_descriptor *rfd, afi_t afi; struct rfapi_info *ri; int need_insert; - struct route_node *rn; + struct agg_node *rn; int rib_node_started_nonempty = 0; - struct route_node *trn; + struct agg_node *trn; int allowed = 0; /* save in case we delete nhp */ @@ -1947,13 +1956,13 @@ rfapiRibPreload(struct bgp *bgp, struct rfapi_descriptor *rfd, /* * Look up prefix in RIB */ - rn = route_node_get(rfd->rib[afi], &pfx); /* locks rn */ + rn = agg_node_get(rfd->rib[afi], &pfx); /* locks rn */ if (rn->info) { rib_node_started_nonempty = 1; } else { rn->info = skiplist_new(0, rfapi_rib_key_cmp, NULL); - route_lock_node(rn); + agg_lock_node(rn); } /* @@ -2063,15 +2072,15 @@ rfapiRibPreload(struct bgp *bgp, struct rfapi_descriptor *rfd, rfapiRibStartTimer(rfd, ri, rn, 0); RFAPI_RIB_CHECK_COUNTS(0, 0); - route_unlock_node(rn); + agg_unlock_node(rn); /* * update this NVE's timestamp for this prefix */ - trn = route_node_get(rfd->rsp_times[afi], &pfx); /* locks trn */ + trn = agg_node_get(rfd->rsp_times[afi], &pfx); /* locks trn */ trn->info = (void *)(uintptr_t)bgp_clock(); if (trn->lock > 1) - route_unlock_node(trn); + agg_unlock_node(trn); { char str_pfx[PREFIX_STRLEN]; @@ -2108,7 +2117,7 @@ rfapiRibPreload(struct bgp *bgp, struct rfapi_descriptor *rfd, } void rfapiRibPendingDeleteRoute(struct bgp *bgp, struct rfapi_import_table *it, - afi_t afi, struct route_node *it_node) + afi_t afi, struct agg_node *it_node) { struct rfapi_descriptor *rfd; struct listnode *node; @@ -2124,7 +2133,7 @@ void rfapiRibPendingDeleteRoute(struct bgp *bgp, struct rfapi_import_table *it, * identifies the rfd that owns it. */ struct rfapi_monitor_eth *m; - struct route_node *rn; + struct agg_node *rn; struct skiplist *sl; void *cursor; int rc; @@ -2154,12 +2163,12 @@ void rfapiRibPendingDeleteRoute(struct bgp *bgp, struct rfapi_import_table *it, * NVE, it's OK to send an update with the * delete */ - if ((rn = route_node_lookup(m->rfd->rib[afi], - &it_node->p))) { + if ((rn = agg_node_lookup(m->rfd->rib[afi], + &it_node->p))) { rfapiRibUpdatePendingNode( bgp, m->rfd, it, it_node, m->rfd->response_lifetime); - route_unlock_node(rn); + agg_unlock_node(rn); } } } @@ -2177,8 +2186,8 @@ void rfapiRibPendingDeleteRoute(struct bgp *bgp, struct rfapi_import_table *it, * this * NVE, it's OK to send an update with the delete */ - if ((rn = route_node_lookup(m->rfd->rib[afi], - &it_node->p))) { + if ((rn = agg_node_lookup(m->rfd->rib[afi], + &it_node->p))) { rfapiRibUpdatePendingNode( bgp, m->rfd, it, it_node, m->rfd->response_lifetime); @@ -2192,7 +2201,7 @@ void rfapiRibPendingDeleteRoute(struct bgp *bgp, struct rfapi_import_table *it, for (ALL_LIST_ELEMENTS_RO(&bgp->rfapi->descriptors, node, rfd)) { - struct route_node *rn; + struct agg_node *rn; vnc_zlog_debug_verbose( "%s: comparing rfd(%p)->import_table=%p to it=%p", @@ -2209,12 +2218,12 @@ void rfapiRibPendingDeleteRoute(struct bgp *bgp, struct rfapi_import_table *it, * prefix * previously, we should send an updated response. */ - if ((rn = route_node_lookup(rfd->rib[afi], - &it_node->p))) { + if ((rn = agg_node_lookup(rfd->rib[afi], + &it_node->p))) { rfapiRibUpdatePendingNode( bgp, rfd, it, it_node, rfd->response_lifetime); - route_unlock_node(rn); + agg_unlock_node(rn); } } } @@ -2406,13 +2415,13 @@ void rfapiRibShowResponses(void *stream, struct prefix *pfx_match, for (afi = AFI_IP; afi < AFI_MAX; ++afi) { - struct route_node *rn; + struct agg_node *rn; if (!rfd->rib[afi]) continue; - for (rn = route_top(rfd->rib[afi]); rn; - rn = route_next(rn)) { + for (rn = agg_route_top(rfd->rib[afi]); rn; + rn = agg_route_next(rn)) { struct skiplist *sl; char str_pfx[PREFIX_STRLEN]; diff --git a/bgpd/rfapi/rfapi_rib.h b/bgpd/rfapi/rfapi_rib.h index 0542727c2e..a8872295cd 100644 --- a/bgpd/rfapi/rfapi_rib.h +++ b/bgpd/rfapi/rfapi_rib.h @@ -93,17 +93,17 @@ extern void rfapiRibFree(struct rfapi_descriptor *rfd); extern void rfapiRibUpdatePendingNode(struct bgp *bgp, struct rfapi_descriptor *rfd, struct rfapi_import_table *it, - struct route_node *it_node, + struct agg_node *it_node, uint32_t lifetime); extern void rfapiRibUpdatePendingNodeSubtree(struct bgp *bgp, struct rfapi_descriptor *rfd, struct rfapi_import_table *it, - struct route_node *it_node, - struct route_node *omit_subtree, + struct agg_node *it_node, + struct agg_node *omit_subtree, uint32_t lifetime); -extern int rfapiRibPreloadBi(struct route_node *rfd_rib_node, +extern int rfapiRibPreloadBi(struct agg_node *rfd_rib_node, struct prefix *pfx_vn, struct prefix *pfx_un, uint32_t lifetime, struct bgp_info *bi); @@ -113,7 +113,7 @@ rfapiRibPreload(struct bgp *bgp, struct rfapi_descriptor *rfd, extern void rfapiRibPendingDeleteRoute(struct bgp *bgp, struct rfapi_import_table *it, afi_t afi, - struct route_node *it_node); + struct agg_node *it_node); extern void rfapiRibShowResponsesSummary(void *stream); @@ -124,7 +124,7 @@ extern void rfapiRibShowResponses(void *stream, struct prefix *pfx_match, extern int rfapiRibFTDFilterRecentPrefix( struct rfapi_descriptor *rfd, - struct route_node *it_rn, /* import table node */ + struct agg_node *it_rn, /* import table node */ struct prefix *pfx_target_original); /* query target */ extern void rfapiFreeRfapiUnOptionChain(struct rfapi_un_option *p); diff --git a/bgpd/rfapi/rfapi_vty.c b/bgpd/rfapi/rfapi_vty.c index cd12edbccb..b2767da8b2 100644 --- a/bgpd/rfapi/rfapi_vty.c +++ b/bgpd/rfapi/rfapi_vty.c @@ -23,7 +23,7 @@ #include "lib/zebra.h" #include "lib/prefix.h" -#include "lib/table.h" +#include "lib/agg_table.h" #include "lib/vty.h" #include "lib/memory.h" #include "lib/routemap.h" @@ -742,7 +742,7 @@ static void rfapiDebugPrintMonitorEncap(void *stream, m->bi, HVTYNL); } -void rfapiShowItNode(void *stream, struct route_node *rn) +void rfapiShowItNode(void *stream, struct agg_node *rn) { struct bgp_info *bi; char buf[BUFSIZ]; @@ -766,10 +766,10 @@ void rfapiShowItNode(void *stream, struct route_node *rn) /* doesn't show montors */ } -void rfapiShowImportTable(void *stream, const char *label, - struct route_table *rt, int isvpn) +void rfapiShowImportTable(void *stream, const char *label, struct agg_table *rt, + int isvpn) { - struct route_node *rn; + struct agg_node *rn; char buf[BUFSIZ]; int (*fp)(void *, const char *, ...); @@ -782,7 +782,7 @@ void rfapiShowImportTable(void *stream, const char *label, fp(out, "Import Table [%s]%s", label, HVTYNL); - for (rn = route_top(rt); rn; rn = route_next(rn)) { + for (rn = agg_route_top(rt); rn; rn = agg_route_next(rn)) { struct bgp_info *bi; if (rn->p.family == AF_ETHERNET) { @@ -851,7 +851,7 @@ int rfapiShowVncQueries(void *stream, struct prefix *pfx_match) for (ALL_LIST_ELEMENTS_RO(&h->descriptors, node, rfd)) { - struct route_node *rn; + struct agg_node *rn; int printedquerier = 0; @@ -868,8 +868,8 @@ int rfapiShowVncQueries(void *stream, struct prefix *pfx_match) * IP Queries */ if (rfd->mon) { - for (rn = route_top(rfd->mon); rn; - rn = route_next(rn)) { + for (rn = agg_route_top(rfd->mon); rn; + rn = agg_route_next(rn)) { struct rfapi_monitor_vpn *m; char buf_remain[BUFSIZ]; char buf_pfx[BUFSIZ]; @@ -1012,7 +1012,7 @@ int rfapiShowVncQueries(void *stream, struct prefix *pfx_match) } static int rfapiPrintRemoteRegBi(struct bgp *bgp, void *stream, - struct route_node *rn, struct bgp_info *bi) + struct agg_node *rn, struct bgp_info *bi) { int (*fp)(void *, const char *, ...); struct vty *vty; @@ -1218,13 +1218,13 @@ static int rfapiShowRemoteRegistrationsIt(struct bgp *bgp, void *stream, for (afi = AFI_IP; afi < AFI_MAX; ++afi) { - struct route_node *rn; + struct agg_node *rn; if (!it->imported_vpn[afi]) continue; - for (rn = route_top(it->imported_vpn[afi]); rn; - rn = route_next(rn)) { + for (rn = agg_route_top(it->imported_vpn[afi]); rn; + rn = agg_route_next(rn)) { struct bgp_info *bi; int count_only; diff --git a/bgpd/rfapi/rfapi_vty.h b/bgpd/rfapi/rfapi_vty.h index a08183aa46..8b881292ac 100644 --- a/bgpd/rfapi/rfapi_vty.h +++ b/bgpd/rfapi/rfapi_vty.h @@ -124,7 +124,7 @@ extern char *rfapiMonitorVpn2Str(struct rfapi_monitor_vpn *m, char *buf, extern const char *rfapiRfapiIpPrefix2Str(struct rfapi_ip_prefix *p, char *buf, int bufsize); -extern void rfapiShowItNode(void *stream, struct route_node *rn); +extern void rfapiShowItNode(void *stream, struct agg_node *rn); extern char *rfapiEthAddr2Str(const struct ethaddr *ea, char *buf, int bufsize); diff --git a/bgpd/rfapi/vnc_export_bgp.c b/bgpd/rfapi/vnc_export_bgp.c index 69426670a1..6289175645 100644 --- a/bgpd/rfapi/vnc_export_bgp.c +++ b/bgpd/rfapi/vnc_export_bgp.c @@ -25,7 +25,7 @@ #include "lib/zebra.h" #include "lib/prefix.h" -#include "lib/table.h" +#include "lib/agg_table.h" #include "lib/vty.h" #include "lib/log.h" #include "lib/stream.h" @@ -54,7 +54,7 @@ static void vnc_direct_add_rn_group_rd(struct bgp *bgp, struct rfapi_nve_group_cfg *rfg, - struct route_node *rn, struct attr *attr, + struct agg_node *rn, struct attr *attr, afi_t afi, struct rfapi_descriptor *irfd); @@ -172,7 +172,7 @@ static int getce(struct bgp *bgp, struct attr *attr, struct prefix *pfx_ce) } -void vnc_direct_bgp_add_route_ce(struct bgp *bgp, struct route_node *rn, +void vnc_direct_bgp_add_route_ce(struct bgp *bgp, struct agg_node *rn, struct bgp_info *bi) { struct attr *attr = bi->attr; @@ -327,7 +327,7 @@ void vnc_direct_bgp_add_route_ce(struct bgp *bgp, struct route_node *rn, /* * "Withdrawing a Route" export process */ -void vnc_direct_bgp_del_route_ce(struct bgp *bgp, struct route_node *rn, +void vnc_direct_bgp_del_route_ce(struct bgp *bgp, struct agg_node *rn, struct bgp_info *bi) { afi_t afi = family2afi(rn->p.family); @@ -404,7 +404,7 @@ void vnc_direct_bgp_del_route_ce(struct bgp *bgp, struct route_node *rn, static void vnc_direct_bgp_vpn_enable_ce(struct bgp *bgp, afi_t afi) { - struct route_node *rn; + struct agg_node *rn; struct bgp_info *ri; vnc_zlog_debug_verbose("%s: entry, afi=%d", __func__, afi); @@ -430,8 +430,8 @@ static void vnc_direct_bgp_vpn_enable_ce(struct bgp *bgp, afi_t afi) /* * Go through entire ce import table and export to BGP unicast. */ - for (rn = route_top(bgp->rfapi->it_ce->imported_vpn[afi]); rn; - rn = route_next(rn)) { + for (rn = agg_route_top(bgp->rfapi->it_ce->imported_vpn[afi]); rn; + rn = agg_route_next(rn)) { if (!rn->info) continue; @@ -513,7 +513,7 @@ static void vnc_direct_bgp_vpn_disable_ce(struct bgp *bgp, afi_t afi) * Export methods that proxy nexthop BEGIN ***********************************************************************/ -static struct ecommunity *vnc_route_origin_ecom(struct route_node *rn) +static struct ecommunity *vnc_route_origin_ecom(struct agg_node *rn) { struct ecommunity *new; struct bgp_info *bi; @@ -586,8 +586,8 @@ static struct ecommunity *vnc_route_origin_ecom_single(struct in_addr *origin) static int encap_attr_export(struct attr *new, struct attr *orig, struct prefix *new_nexthop, - struct route_node *rn) /* for VN addrs for ecom list */ - /* if rn is 0, use route's nexthop */ + struct agg_node *rn) /* for VN addrs for ecom list */ + /* if rn is 0, use route's nexthop */ { struct prefix orig_nexthop; struct prefix *use_nexthop; @@ -692,7 +692,7 @@ encap_attr_export(struct attr *new, struct attr *orig, */ void vnc_direct_bgp_add_prefix(struct bgp *bgp, struct rfapi_import_table *import_table, - struct route_node *rn) + struct agg_node *rn) { struct attr attr = {0}; struct listnode *node, *nnode; @@ -803,7 +803,7 @@ void vnc_direct_bgp_add_prefix(struct bgp *bgp, */ void vnc_direct_bgp_del_prefix(struct bgp *bgp, struct rfapi_import_table *import_table, - struct route_node *rn) + struct agg_node *rn) { struct listnode *node, *nnode; struct rfapi_rfg_name *rfgn; @@ -965,8 +965,8 @@ void vnc_direct_bgp_add_nve(struct bgp *bgp, struct rfapi_descriptor *rfd) */ if (rfgn->rfg == rfg) { - struct route_table *rt = NULL; - struct route_node *rn; + struct agg_table *rt = NULL; + struct agg_node *rn; struct attr attr = {0}; struct rfapi_import_table *import_table; @@ -987,7 +987,8 @@ void vnc_direct_bgp_add_nve(struct bgp *bgp, struct rfapi_descriptor *rfd) /* * Walk the NVE-Group's VNC Import table */ - for (rn = route_top(rt); rn; rn = route_next(rn)) { + for (rn = agg_route_top(rt); rn; + rn = agg_route_next(rn)) { if (rn->info) { @@ -1111,8 +1112,8 @@ void vnc_direct_bgp_del_nve(struct bgp *bgp, struct rfapi_descriptor *rfd) */ if (rfg && rfgn->rfg == rfg) { - struct route_table *rt = NULL; - struct route_node *rn; + struct agg_table *rt = NULL; + struct agg_node *rn; struct rfapi_import_table *import_table; import_table = rfg->rfapi_import_table; @@ -1128,7 +1129,8 @@ void vnc_direct_bgp_del_nve(struct bgp *bgp, struct rfapi_descriptor *rfd) /* * Walk the NVE-Group's VNC Import table */ - for (rn = route_top(rt); rn; rn = route_next(rn)) { + for (rn = agg_route_top(rt); rn; + rn = agg_route_next(rn)) { if (rn->info) { @@ -1159,7 +1161,7 @@ void vnc_direct_bgp_del_nve(struct bgp *bgp, struct rfapi_descriptor *rfd) static void vnc_direct_add_rn_group_rd(struct bgp *bgp, struct rfapi_nve_group_cfg *rfg, - struct route_node *rn, struct attr *attr, + struct agg_node *rn, struct attr *attr, afi_t afi, struct rfapi_descriptor *irfd) { struct prefix nhp; @@ -1279,8 +1281,8 @@ static void vnc_direct_bgp_add_group_afi(struct bgp *bgp, struct rfapi_nve_group_cfg *rfg, afi_t afi) { - struct route_table *rt = NULL; - struct route_node *rn; + struct agg_table *rt = NULL; + struct agg_node *rn; struct attr attr = {0}; struct rfapi_import_table *import_table; @@ -1311,7 +1313,7 @@ static void vnc_direct_bgp_add_group_afi(struct bgp *bgp, /* * Walk the NVE-Group's VNC Import table */ - for (rn = route_top(rt); rn; rn = route_next(rn)) { + for (rn = agg_route_top(rt); rn; rn = agg_route_next(rn)) { if (rn->info) { @@ -1366,7 +1368,7 @@ void vnc_direct_bgp_add_group(struct bgp *bgp, struct rfapi_nve_group_cfg *rfg) static void vnc_direct_del_rn_group_rd(struct bgp *bgp, struct rfapi_nve_group_cfg *rfg, - struct route_node *rn, afi_t afi, + struct agg_node *rn, afi_t afi, struct rfapi_descriptor *irfd) { if (irfd == NULL) @@ -1388,8 +1390,8 @@ static void vnc_direct_bgp_del_group_afi(struct bgp *bgp, struct rfapi_nve_group_cfg *rfg, afi_t afi) { - struct route_table *rt = NULL; - struct route_node *rn; + struct agg_table *rt = NULL; + struct agg_node *rn; struct rfapi_import_table *import_table; vnc_zlog_debug_verbose("%s: entry", __func__); @@ -1412,7 +1414,7 @@ static void vnc_direct_bgp_del_group_afi(struct bgp *bgp, /* * Walk the NVE-Group's VNC Import table */ - for (rn = route_top(rt); rn; rn = route_next(rn)) + for (rn = agg_route_top(rt); rn; rn = agg_route_next(rn)) if (rn->info) { if (rfg->type == RFAPI_GROUP_CFG_VRF) vnc_direct_del_rn_group_rd(bgp, rfg, rn, afi, @@ -1473,14 +1475,14 @@ void vnc_direct_bgp_reexport_group_afi(struct bgp *bgp, } -static void vnc_direct_bgp_unexport_table(afi_t afi, struct route_table *rt, +static void vnc_direct_bgp_unexport_table(afi_t afi, struct agg_table *rt, struct list *nve_list) { if (nve_list) { - struct route_node *rn; + struct agg_node *rn; - for (rn = route_top(rt); rn; rn = route_next(rn)) { + for (rn = agg_route_top(rt); rn; rn = agg_route_next(rn)) { if (rn->info) { diff --git a/bgpd/rfapi/vnc_export_bgp_p.h b/bgpd/rfapi/vnc_export_bgp_p.h index c164a35432..e074c3eaad 100644 --- a/bgpd/rfapi/vnc_export_bgp_p.h +++ b/bgpd/rfapi/vnc_export_bgp_p.h @@ -29,19 +29,19 @@ #include "rfapi_private.h" -extern void vnc_direct_bgp_add_route_ce(struct bgp *bgp, struct route_node *rn, +extern void vnc_direct_bgp_add_route_ce(struct bgp *bgp, struct agg_node *rn, struct bgp_info *bi); -extern void vnc_direct_bgp_del_route_ce(struct bgp *bgp, struct route_node *rn, +extern void vnc_direct_bgp_del_route_ce(struct bgp *bgp, struct agg_node *rn, struct bgp_info *bi); extern void vnc_direct_bgp_add_prefix(struct bgp *bgp, struct rfapi_import_table *import_table, - struct route_node *rn); + struct agg_node *rn); extern void vnc_direct_bgp_del_prefix(struct bgp *bgp, struct rfapi_import_table *import_table, - struct route_node *rn); + struct agg_node *rn); extern void vnc_direct_bgp_add_nve(struct bgp *bgp, struct rfapi_descriptor *rfd); diff --git a/bgpd/rfapi/vnc_export_table.c b/bgpd/rfapi/vnc_export_table.c index bbdb59c125..5e00a1017b 100644 --- a/bgpd/rfapi/vnc_export_table.c +++ b/bgpd/rfapi/vnc_export_table.c @@ -21,7 +21,7 @@ #include "lib/zebra.h" #include "lib/prefix.h" -#include "lib/table.h" +#include "lib/agg_table.h" #include "lib/memory.h" #include "lib/vty.h" @@ -33,11 +33,11 @@ #include "bgpd/rfapi/rfapi_import.h" #include "bgpd/rfapi/vnc_debug.h" -struct route_node *vnc_etn_get(struct bgp *bgp, vnc_export_type_t type, - struct prefix *p) +struct agg_node *vnc_etn_get(struct bgp *bgp, vnc_export_type_t type, + struct prefix *p) { - struct route_table *t = NULL; - struct route_node *rn = NULL; + struct agg_table *t = NULL; + struct agg_node *rn = NULL; afi_t afi; if (!bgp || !bgp->rfapi) @@ -49,27 +49,27 @@ struct route_node *vnc_etn_get(struct bgp *bgp, vnc_export_type_t type, switch (type) { case EXPORT_TYPE_BGP: if (!bgp->rfapi->rt_export_bgp[afi]) - bgp->rfapi->rt_export_bgp[afi] = route_table_init(); + bgp->rfapi->rt_export_bgp[afi] = agg_table_init(); t = bgp->rfapi->rt_export_bgp[afi]; break; case EXPORT_TYPE_ZEBRA: if (!bgp->rfapi->rt_export_zebra[afi]) - bgp->rfapi->rt_export_zebra[afi] = route_table_init(); + bgp->rfapi->rt_export_zebra[afi] = agg_table_init(); t = bgp->rfapi->rt_export_zebra[afi]; break; } if (t) - rn = route_node_get(t, p); + rn = agg_node_get(t, p); return rn; } -struct route_node *vnc_etn_lookup(struct bgp *bgp, vnc_export_type_t type, - struct prefix *p) +struct agg_node *vnc_etn_lookup(struct bgp *bgp, vnc_export_type_t type, + struct prefix *p) { - struct route_table *t = NULL; - struct route_node *rn = NULL; + struct agg_table *t = NULL; + struct agg_node *rn = NULL; afi_t afi; if (!bgp || !bgp->rfapi) @@ -81,19 +81,19 @@ struct route_node *vnc_etn_lookup(struct bgp *bgp, vnc_export_type_t type, switch (type) { case EXPORT_TYPE_BGP: if (!bgp->rfapi->rt_export_bgp[afi]) - bgp->rfapi->rt_export_bgp[afi] = route_table_init(); + bgp->rfapi->rt_export_bgp[afi] = agg_table_init(); t = bgp->rfapi->rt_export_bgp[afi]; break; case EXPORT_TYPE_ZEBRA: if (!bgp->rfapi->rt_export_zebra[afi]) - bgp->rfapi->rt_export_zebra[afi] = route_table_init(); + bgp->rfapi->rt_export_zebra[afi] = agg_table_init(); t = bgp->rfapi->rt_export_zebra[afi]; break; } if (t) - rn = route_node_lookup(t, p); + rn = agg_node_lookup(t, p); return rn; } @@ -101,7 +101,7 @@ struct vnc_export_info *vnc_eti_get(struct bgp *bgp, vnc_export_type_t etype, struct prefix *p, struct peer *peer, uint8_t type, uint8_t subtype) { - struct route_node *etn; + struct agg_node *etn; struct vnc_export_info *eti; etn = vnc_etn_get(bgp, etype, p); @@ -116,7 +116,7 @@ struct vnc_export_info *vnc_eti_get(struct bgp *bgp, vnc_export_type_t etype, } if (eti) { - route_unlock_node(etn); + agg_unlock_node(etn); } else { eti = XCALLOC(MTYPE_RFAPI_ETI, sizeof(struct vnc_export_info)); assert(eti); @@ -134,7 +134,7 @@ struct vnc_export_info *vnc_eti_get(struct bgp *bgp, vnc_export_type_t etype, void vnc_eti_delete(struct vnc_export_info *goner) { - struct route_node *etn; + struct agg_node *etn; struct vnc_export_info *eti; struct vnc_export_info *eti_prev = NULL; @@ -160,7 +160,7 @@ void vnc_eti_delete(struct vnc_export_info *goner) goner->node = NULL; XFREE(MTYPE_RFAPI_ETI, goner); - route_unlock_node(etn); + agg_unlock_node(etn); } struct vnc_export_info *vnc_eti_checktimer(struct bgp *bgp, @@ -168,7 +168,7 @@ struct vnc_export_info *vnc_eti_checktimer(struct bgp *bgp, struct prefix *p, struct peer *peer, uint8_t type, uint8_t subtype) { - struct route_node *etn; + struct agg_node *etn; struct vnc_export_info *eti; etn = vnc_etn_lookup(bgp, etype, p); @@ -183,7 +183,7 @@ struct vnc_export_info *vnc_eti_checktimer(struct bgp *bgp, } } - route_unlock_node(etn); + agg_unlock_node(etn); if (eti && eti->timer) return eti; diff --git a/bgpd/rfapi/vnc_export_table.h b/bgpd/rfapi/vnc_export_table.h index 3ccf8661e7..fdb35e81e1 100644 --- a/bgpd/rfapi/vnc_export_table.h +++ b/bgpd/rfapi/vnc_export_table.h @@ -37,7 +37,7 @@ typedef enum vnc_export_type { struct vnc_export_info { struct vnc_export_info *next; - struct route_node *node; + struct agg_node *node; struct peer *peer; uint8_t type; uint8_t subtype; @@ -45,11 +45,11 @@ struct vnc_export_info { struct thread *timer; }; -extern struct route_node *vnc_etn_get(struct bgp *bgp, vnc_export_type_t type, - struct prefix *p); +extern struct agg_node *vnc_etn_get(struct bgp *bgp, vnc_export_type_t type, + struct prefix *p); -extern struct route_node * -vnc_etn_lookup(struct bgp *bgp, vnc_export_type_t type, struct prefix *p); +extern struct agg_node *vnc_etn_lookup(struct bgp *bgp, vnc_export_type_t type, + struct prefix *p); extern struct vnc_export_info *vnc_eti_get(struct bgp *bgp, vnc_export_type_t etype, diff --git a/bgpd/rfapi/vnc_import_bgp.c b/bgpd/rfapi/vnc_import_bgp.c index 72363f7cfe..6022e4cc24 100644 --- a/bgpd/rfapi/vnc_import_bgp.c +++ b/bgpd/rfapi/vnc_import_bgp.c @@ -25,7 +25,7 @@ #include "lib/zebra.h" #include "lib/prefix.h" -#include "lib/table.h" +#include "lib/agg_table.h" #include "lib/vty.h" #include "lib/log.h" #include "lib/memory.h" @@ -1737,9 +1737,9 @@ static void vnc_import_bgp_exterior_add_route_it( rfapiUnicastNexthop2Prefix(afi, info->attr, &pfx_orig_nexthop); for (it = h->imports; it; it = it->next) { - struct route_table *table; - struct route_node *rn; - struct route_node *par; + struct agg_table *table; + struct agg_node *rn; + struct agg_node *par; struct bgp_info *bi_interior; int have_usable_route; @@ -1753,7 +1753,7 @@ static void vnc_import_bgp_exterior_add_route_it( table = it->imported_vpn[afi]; - for (rn = route_node_match(table, &pfx_orig_nexthop), + for (rn = agg_node_match(table, &pfx_orig_nexthop), have_usable_route = 0; (!have_usable_route) && rn;) { @@ -1821,9 +1821,9 @@ static void vnc_import_bgp_exterior_add_route_it( 0, NULL, (void (*)(void *)) prefix_free); - route_lock_node(rn); /* for skiplist */ + agg_lock_node(rn); /* for skiplist */ } - route_lock_node(rn); /* for skiplist entry */ + agg_lock_node(rn); /* for skiplist entry */ prefix_copy(pfx_mon, prefix); if (!skiplist_insert( RFAPI_MONITOR_EXTERIOR(rn)->source, @@ -1832,14 +1832,14 @@ static void vnc_import_bgp_exterior_add_route_it( bgp_info_lock(info); } } - par = rn->parent; + par = agg_node_parent(rn); if (par) - route_lock_node(par); - route_unlock_node(rn); + agg_lock_node(par); + agg_unlock_node(rn); rn = par; } if (rn) - route_unlock_node(rn); + agg_unlock_node(rn); if (!have_usable_route) { struct prefix *pfx_mon = prefix_new(); @@ -1928,15 +1928,15 @@ void vnc_import_bgp_exterior_del_route( rfapiUnicastNexthop2Prefix(afi, info->attr, &pfx_orig_nexthop); for (it = h->imports; it; it = it->next) { - struct route_table *table; - struct route_node *rn; - struct route_node *par; + struct agg_table *table; + struct agg_node *rn; + struct agg_node *par; struct bgp_info *bi_interior; int have_usable_route; table = it->imported_vpn[afi]; - for (rn = route_node_match(table, &pfx_orig_nexthop), + for (rn = agg_node_match(table, &pfx_orig_nexthop), have_usable_route = 0; (!have_usable_route) && rn;) { @@ -1987,9 +1987,9 @@ void vnc_import_bgp_exterior_del_route( info, NULL)) { bgp_info_unlock(info); - route_unlock_node( + agg_unlock_node( rn); /* sl entry - */ + */ } if (skiplist_empty( RFAPI_MONITOR_EXTERIOR( @@ -2002,7 +2002,7 @@ void vnc_import_bgp_exterior_del_route( RFAPI_MONITOR_EXTERIOR( rn) ->source = NULL; - route_unlock_node( + agg_unlock_node( rn); /* skiplist itself */ @@ -2010,14 +2010,14 @@ void vnc_import_bgp_exterior_del_route( } } } - par = rn->parent; + par = agg_node_parent(rn); if (par) - route_lock_node(par); - route_unlock_node(rn); + agg_lock_node(par); + agg_unlock_node(rn); rn = par; } if (rn) - route_unlock_node(rn); + agg_unlock_node(rn); if (!have_usable_route) { if (!skiplist_delete(it->monitor_exterior_orphans, info, @@ -2038,11 +2038,11 @@ void vnc_import_bgp_exterior_del_route( */ void vnc_import_bgp_exterior_add_route_interior( struct bgp *bgp, struct rfapi_import_table *it, - struct route_node *rn_interior, /* VPN IT node */ - struct bgp_info *bi_interior) /* VPN IT route */ + struct agg_node *rn_interior, /* VPN IT node */ + struct bgp_info *bi_interior) /* VPN IT route */ { afi_t afi = family2afi(rn_interior->p.family); - struct route_node *par; + struct agg_node *par; struct bgp_info *bi_exterior; struct prefix *pfx_exterior; /* exterior pfx */ void *cursor; @@ -2161,7 +2161,8 @@ void vnc_import_bgp_exterior_add_route_interior( * Look up the tree for possible pulldown candidates. * Find nearest parent with an exterior route monitor */ - for (par = rn_interior->parent; par; par = par->parent) { + for (par = agg_node_parent(rn_interior); par; + par = agg_node_parent(par)) { if (RFAPI_HAS_MONITOR_EXTERIOR(par)) break; } @@ -2211,13 +2212,13 @@ void vnc_import_bgp_exterior_add_route_interior( ->source = skiplist_new( 0, NULL, (void (*)(void *))prefix_free); - route_lock_node(rn_interior); + agg_lock_node(rn_interior); } skiplist_insert( RFAPI_MONITOR_EXTERIOR(rn_interior) ->source, bi_exterior, pfx_mon); - route_lock_node(rn_interior); + agg_lock_node(rn_interior); /* * Delete constructed exterior routes based on @@ -2291,12 +2292,12 @@ void vnc_import_bgp_exterior_add_route_interior( skiplist_delete(RFAPI_MONITOR_EXTERIOR(par)->source, bi_exterior, NULL); - route_unlock_node(par); /* sl entry */ + agg_unlock_node(par); /* sl entry */ } if (skiplist_empty(RFAPI_MONITOR_EXTERIOR(par)->source)) { skiplist_free(RFAPI_MONITOR_EXTERIOR(par)->source); RFAPI_MONITOR_EXTERIOR(par)->source = NULL; - route_unlock_node(par); /* sl itself */ + agg_unlock_node(par); /* sl itself */ } } @@ -2353,12 +2354,12 @@ void vnc_import_bgp_exterior_add_route_interior( skiplist_new( 0, NULL, (void (*)(void *))prefix_free); - route_lock_node(rn_interior); /* sl */ + agg_lock_node(rn_interior); /* sl */ } skiplist_insert( RFAPI_MONITOR_EXTERIOR(rn_interior)->source, bi_exterior, pfx_mon); - route_lock_node(rn_interior); /* sl entry */ + agg_lock_node(rn_interior); /* sl entry */ if (!list_adopted) { list_adopted = list_new(); } @@ -2397,7 +2398,7 @@ void vnc_import_bgp_exterior_add_route_interior( } if (list_adopted) { struct listnode *node; - struct route_node *bi_exterior; + struct agg_node *bi_exterior; for (ALL_LIST_ELEMENTS_RO(list_adopted, node, bi_exterior)) { skiplist_delete(it->monitor_exterior_orphans, @@ -2419,11 +2420,11 @@ void vnc_import_bgp_exterior_add_route_interior( */ void vnc_import_bgp_exterior_del_route_interior( struct bgp *bgp, struct rfapi_import_table *it, - struct route_node *rn_interior, /* VPN IT node */ - struct bgp_info *bi_interior) /* VPN IT route */ + struct agg_node *rn_interior, /* VPN IT node */ + struct bgp_info *bi_interior) /* VPN IT route */ { afi_t afi = family2afi(rn_interior->p.family); - struct route_node *par; + struct agg_node *par; struct bgp_info *bi_exterior; struct prefix *pfx_exterior; /* exterior pfx */ void *cursor; @@ -2509,7 +2510,8 @@ void vnc_import_bgp_exterior_del_route_interior( * If none is found, par will end up NULL, and we will move * the monitors to the orphan list for this import table */ - for (par = rn_interior->parent; par; par = par->parent) { + for (par = agg_node_parent(rn_interior); par; + par = agg_node_parent(par)) { if (RFAPI_MONITOR_EXTERIOR(par)->valid_interior_count) break; } @@ -2540,11 +2542,11 @@ void vnc_import_bgp_exterior_del_route_interior( skiplist_new( 0, NULL, (void (*)(void *))prefix_free); - route_lock_node(par); /* sl */ + agg_lock_node(par); /* sl */ } skiplist_insert(RFAPI_MONITOR_EXTERIOR(par)->source, bi_exterior, pfx_mon); - route_lock_node(par); /* sl entry */ + agg_lock_node(par); /* sl entry */ /* Add constructed exterior routes based on parent */ for (bi = par->info; bi; bi = bi->next) { @@ -2596,12 +2598,12 @@ void vnc_import_bgp_exterior_del_route_interior( skiplist_delete_first( RFAPI_MONITOR_EXTERIOR(rn_interior)->source); - route_unlock_node(rn_interior); /* sl entry */ + agg_unlock_node(rn_interior); /* sl entry */ } if (skiplist_empty(RFAPI_MONITOR_EXTERIOR(rn_interior)->source)) { skiplist_free(RFAPI_MONITOR_EXTERIOR(rn_interior)->source); RFAPI_MONITOR_EXTERIOR(rn_interior)->source = NULL; - route_unlock_node(rn_interior); /* sl itself */ + agg_unlock_node(rn_interior); /* sl itself */ } } diff --git a/bgpd/rfapi/vnc_import_bgp_p.h b/bgpd/rfapi/vnc_import_bgp_p.h index b38fa2276a..a6fcae926d 100644 --- a/bgpd/rfapi/vnc_import_bgp_p.h +++ b/bgpd/rfapi/vnc_import_bgp_p.h @@ -29,13 +29,13 @@ extern void vnc_import_bgp_exterior_add_route_interior( struct bgp *bgp, struct rfapi_import_table *it, - struct route_node *rn_interior, /* VPN IT node */ - struct bgp_info *bi_interior); /* VPN IT route */ + struct agg_node *rn_interior, /* VPN IT node */ + struct bgp_info *bi_interior); /* VPN IT route */ extern void vnc_import_bgp_exterior_del_route_interior( struct bgp *bgp, struct rfapi_import_table *it, - struct route_node *rn_interior, /* VPN IT node */ - struct bgp_info *bi_interior); /* VPN IT route */ + struct agg_node *rn_interior, /* VPN IT node */ + struct bgp_info *bi_interior); /* VPN IT route */ extern void vnc_import_bgp_exterior_redist_enable_it(struct bgp *bgp, afi_t afi, diff --git a/bgpd/rfapi/vnc_zebra.c b/bgpd/rfapi/vnc_zebra.c index a2871188e6..a93fb60735 100644 --- a/bgpd/rfapi/vnc_zebra.c +++ b/bgpd/rfapi/vnc_zebra.c @@ -25,7 +25,7 @@ #include "lib/zebra.h" #include "lib/prefix.h" -#include "lib/table.h" +#include "lib/agg_table.h" #include "lib/log.h" #include "lib/command.h" #include "lib/zclient.h" @@ -556,7 +556,7 @@ static void import_table_to_nve_list_zebra(struct bgp *bgp, static void vnc_zebra_add_del_prefix(struct bgp *bgp, struct rfapi_import_table *import_table, - struct route_node *rn, + struct agg_node *rn, int add) /* !0 = add, 0 = del */ { struct list *nves; @@ -611,14 +611,14 @@ static void vnc_zebra_add_del_prefix(struct bgp *bgp, void vnc_zebra_add_prefix(struct bgp *bgp, struct rfapi_import_table *import_table, - struct route_node *rn) + struct agg_node *rn) { vnc_zebra_add_del_prefix(bgp, import_table, rn, 1); } void vnc_zebra_del_prefix(struct bgp *bgp, struct rfapi_import_table *import_table, - struct route_node *rn) + struct agg_node *rn) { vnc_zebra_add_del_prefix(bgp, import_table, rn, 0); } @@ -678,8 +678,8 @@ static void vnc_zebra_add_del_nve(struct bgp *bgp, struct rfapi_descriptor *rfd, */ if (rfgn->rfg == rfg) { - struct route_table *rt = NULL; - struct route_node *rn; + struct agg_table *rt = NULL; + struct agg_node *rn; struct rfapi_import_table *import_table; import_table = rfg->rfapi_import_table; @@ -692,7 +692,8 @@ static void vnc_zebra_add_del_nve(struct bgp *bgp, struct rfapi_descriptor *rfd, /* * Walk the NVE-Group's VNC Import table */ - for (rn = route_top(rt); rn; rn = route_next(rn)) { + for (rn = agg_route_top(rt); rn; + rn = agg_route_next(rn)) { if (rn->info) { @@ -721,8 +722,8 @@ static void vnc_zebra_add_del_group_afi(struct bgp *bgp, struct rfapi_nve_group_cfg *rfg, afi_t afi, int add) { - struct route_table *rt = NULL; - struct route_node *rn; + struct agg_table *rt = NULL; + struct agg_node *rn; struct rfapi_import_table *import_table; uint8_t family = afi2family(afi); @@ -773,7 +774,8 @@ static void vnc_zebra_add_del_group_afi(struct bgp *bgp, /* * Walk the NVE-Group's VNC Import table */ - for (rn = route_top(rt); rn; rn = route_next(rn)) { + for (rn = agg_route_top(rt); rn; + rn = agg_route_next(rn)) { if (rn->info) { vnc_zebra_route_msg(&rn->p, nexthop_count, diff --git a/bgpd/rfapi/vnc_zebra.h b/bgpd/rfapi/vnc_zebra.h index 708aaeef50..b8c1cb15c4 100644 --- a/bgpd/rfapi/vnc_zebra.h +++ b/bgpd/rfapi/vnc_zebra.h @@ -29,11 +29,11 @@ extern void vnc_zebra_add_prefix(struct bgp *bgp, struct rfapi_import_table *import_table, - struct route_node *rn); + struct agg_node *rn); extern void vnc_zebra_del_prefix(struct bgp *bgp, struct rfapi_import_table *import_table, - struct route_node *rn); + struct agg_node *rn); extern void vnc_zebra_add_nve(struct bgp *bgp, struct rfapi_descriptor *rfd); diff --git a/bgpd/rfp-example/librfp/rfp_example.c b/bgpd/rfp-example/librfp/rfp_example.c index fe74be682d..75e57a029e 100644 --- a/bgpd/rfp-example/librfp/rfp_example.c +++ b/bgpd/rfp-example/librfp/rfp_example.c @@ -288,7 +288,7 @@ void *rfp_start(struct thread_master *master, struct rfapi_rfp_cfg **cfgp, /* initilize struct rfapi_rfp_cfg, see rfapi.h */ global_rfi.rfapi_config.download_type = - RFAPI_RFP_DOWNLOAD_FULL; /* default=partial */ + RFAPI_RFP_DOWNLOAD_PARTIAL; /* default=partial */ global_rfi.rfapi_config.ftd_advertisement_interval = RFAPI_RFP_CFG_DEFAULT_FTD_ADVERTISEMENT_INTERVAL; global_rfi.rfapi_config.holddown_factor = |
