diff options
author | Donald Sharp <sharpd@cumulusnetworks.com> | 2018-07-30 17:40:02 +0200 |
---|---|---|
committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2018-11-16 15:43:35 +0100 |
commit | 6f94b685d0480f7ea427ddfd1c603399dd047aa3 (patch) | |
tree | 0bd62ffb42a51cf9c27efbf5e686a703748e1b2a /bgpd/rfapi | |
parent | bgpd: Reduce size of 'struct bgp_node' by 8 bytes (diff) | |
download | frr-6f94b685d0480f7ea427ddfd1c603399dd047aa3.tar.xz frr-6f94b685d0480f7ea427ddfd1c603399dd047aa3.zip |
bgpd: Abstract bgp_info retrieving/setting from info pointer
The bgp_info data is stored as a void pointer in `struct bgp_node`.
Abstract retrieval of this data and setting of this data
into functions so that in the future we can move around
what is stored in bgp_node.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'bgpd/rfapi')
-rw-r--r-- | bgpd/rfapi/rfapi.c | 20 | ||||
-rw-r--r-- | bgpd/rfapi/rfapi_import.c | 6 | ||||
-rw-r--r-- | bgpd/rfapi/rfapi_vty.c | 2 | ||||
-rw-r--r-- | bgpd/rfapi/vnc_export_bgp.c | 12 | ||||
-rw-r--r-- | bgpd/rfapi/vnc_import_bgp.c | 26 | ||||
-rw-r--r-- | bgpd/rfapi/vnc_zebra.c | 3 |
6 files changed, 42 insertions, 27 deletions
diff --git a/bgpd/rfapi/rfapi.c b/bgpd/rfapi/rfapi.c index 6978dd145..4fffe94a8 100644 --- a/bgpd/rfapi/rfapi.c +++ b/bgpd/rfapi/rfapi.c @@ -382,9 +382,10 @@ void del_vnc_route(struct rfapi_descriptor *rfd, vnc_zlog_debug_verbose( "%s: peer=%p, prefix=%s, prd=%s afi=%d, safi=%d bn=%p, bn->info=%p", __func__, peer, buf, prefix_rd2str(prd, buf2, sizeof(buf2)), - afi, safi, bn, (bn ? bn->info : NULL)); + afi, safi, bn, (bn ? bgp_node_get_bgp_path_info(bn) : NULL)); - for (bpi = (bn ? bn->info : NULL); bpi; bpi = bpi->next) { + for (bpi = (bn ? bgp_node_get_bgp_path_info(bn) : NULL); bpi; + bpi = bpi->next) { vnc_zlog_debug_verbose( "%s: trying bpi=%p, bpi->peer=%p, bpi->type=%d, bpi->sub_type=%d, bpi->extra->vnc.export.rfapi_handle=%p, local_pref=%u", @@ -945,7 +946,7 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */ * ecommunity: POINTS TO interned/refcounted dynamic 2-part AS attr * aspath: POINTS TO interned/refcounted hashed block */ - for (bpi = bn->info; bpi; bpi = bpi->next) { + for (bpi = bgp_node_get_bgp_path_info(bn); bpi; bpi = bpi->next) { /* probably only need to check * bpi->extra->vnc.export.rfapi_handle */ if (bpi->peer == rfd->peer && bpi->type == type @@ -1081,7 +1082,7 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */ /* debug */ if (VNC_DEBUG(VERBOSE)) { - vnc_zlog_debug_verbose("%s: printing BI", __func__); + vnc_zlog_debug_verbose("%s: printing BPI", __func__); rfapiPrintBi(NULL, new); } @@ -3701,10 +3702,12 @@ static void rfapi_print_exported(struct bgp *bgp) fprintf(stderr, "%s: vpn rdn=%p\n", __func__, rdn); for (rn = bgp_table_top(rdn->info); rn; rn = bgp_route_next(rn)) { - if (!rn->info) + bpi = bgp_node_get_bgp_path_info(rn); + + if (!bpi) continue; fprintf(stderr, "%s: rn=%p\n", __func__, rn); - for (bpi = rn->info; bpi; bpi = bpi->next) { + for (; bpi; bpi = bpi->next) { rfapiPrintBi((void *)2, bpi); /* 2 => stderr */ } } @@ -3716,10 +3719,11 @@ static void rfapi_print_exported(struct bgp *bgp) fprintf(stderr, "%s: encap rdn=%p\n", __func__, rdn); for (rn = bgp_table_top(rdn->info); rn; rn = bgp_route_next(rn)) { - if (!rn->info) + bpi = bgp_node_get_bgp_path_info(rn); + if (!bpi) continue; fprintf(stderr, "%s: rn=%p\n", __func__, rn); - for (bpi = rn->info; bpi; bpi = bpi->next) { + for (; bpi; bpi = bpi->next) { rfapiPrintBi((void *)2, bpi); /* 2 => stderr */ } } diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c index 6f5af5182..aa20a9d36 100644 --- a/bgpd/rfapi/rfapi_import.c +++ b/bgpd/rfapi/rfapi_import.c @@ -4244,13 +4244,15 @@ static void rfapiBgpTableFilteredImport(struct bgp *bgp, for (rn1 = bgp_table_top(bgp->rib[afi][safi]); rn1; rn1 = bgp_route_next(rn1)) { - if (rn1->info) { + if (bgp_node_has_bgp_path_info_data(rn1)) { + for (rn2 = bgp_table_top(rn1->info); rn2; rn2 = bgp_route_next(rn2)) { struct bgp_path_info *bpi; - for (bpi = rn2->info; bpi; bpi = bpi->next) { + for (bpi = bgp_node_get_bgp_path_info(rn2); + bpi; bpi = bpi->next) { uint32_t label = 0; if (CHECK_FLAG(bpi->flags, diff --git a/bgpd/rfapi/rfapi_vty.c b/bgpd/rfapi/rfapi_vty.c index 1844839f2..04ddff934 100644 --- a/bgpd/rfapi/rfapi_vty.c +++ b/bgpd/rfapi/rfapi_vty.c @@ -1570,7 +1570,7 @@ void rfapiPrintAdvertisedInfo(struct vty *vty, struct rfapi_descriptor *rfd, vty_out(vty, " bn=%p%s", bn, HVTYNL); - for (bpi = bn->info; bpi; bpi = bpi->next) { + for (bpi = bgp_node_get_bgp_path_info(bn); bpi; bpi = bpi->next) { if (bpi->peer == rfd->peer && bpi->type == type && bpi->sub_type == BGP_ROUTE_RFP && bpi->extra && bpi->extra->vnc.export.rfapi_handle == (void *)rfd) { diff --git a/bgpd/rfapi/vnc_export_bgp.c b/bgpd/rfapi/vnc_export_bgp.c index 212d394fd..9f55634aa 100644 --- a/bgpd/rfapi/vnc_export_bgp.c +++ b/bgpd/rfapi/vnc_export_bgp.c @@ -256,7 +256,7 @@ void vnc_direct_bgp_add_route_ce(struct bgp *bgp, struct agg_node *rn, */ urn = bgp_afi_node_get(bgp->rib[afi][SAFI_UNICAST], afi, SAFI_UNICAST, prefix, NULL); - for (ubpi = urn->info; ubpi; ubpi = ubpi->next) { + for (ubpi = bgp_node_get_bgp_path_info(urn); ubpi; ubpi = ubpi->next) { struct prefix unicast_nexthop; if (CHECK_FLAG(ubpi->flags, BGP_PATH_REMOVED)) @@ -483,7 +483,8 @@ static void vnc_direct_bgp_vpn_disable_ce(struct bgp *bgp, afi_t afi) struct bgp_path_info *ri; struct bgp_path_info *next; - for (ri = rn->info, next = NULL; ri; ri = next) { + for (ri = bgp_node_get_bgp_path_info(rn), next = NULL; + ri; ri = next) { next = ri->next; @@ -1856,7 +1857,7 @@ void vnc_direct_bgp_rh_vpn_enable(struct bgp *bgp, afi_t afi) /* * skip prefix list check if no routes here */ - if (!rn->info) + if (!bgp_node_has_bgp_path_info_data(rn)) continue; { @@ -1883,7 +1884,8 @@ void vnc_direct_bgp_rh_vpn_enable(struct bgp *bgp, afi_t afi) } } - for (ri = rn->info; ri; ri = ri->next) { + for (ri = bgp_node_get_bgp_path_info(rn); + ri; ri = ri->next) { vnc_zlog_debug_verbose("%s: ri->sub_type: %d", __func__, ri->sub_type); @@ -2003,7 +2005,7 @@ void vnc_direct_bgp_rh_vpn_disable(struct bgp *bgp, afi_t afi) struct bgp_path_info *ri; struct bgp_path_info *next; - for (ri = rn->info, next = NULL; ri; ri = next) { + for (ri = bgp_node_get_bgp_path_info(rn), next = NULL; ri; ri = next) { next = ri->next; diff --git a/bgpd/rfapi/vnc_import_bgp.c b/bgpd/rfapi/vnc_import_bgp.c index 2f634f6f4..e54e3b615 100644 --- a/bgpd/rfapi/vnc_import_bgp.c +++ b/bgpd/rfapi/vnc_import_bgp.c @@ -545,8 +545,8 @@ static void vnc_import_bgp_add_route_mode_resolve_nve_one_rd( return; } - /* Iterate over bgp_path_info items at this node */ - for (bpi = bn->info; bpi; bpi = bpi->next) { + /* Iterate over bgp_info items at this node */ + for (bpi = bgp_node_get_bgp_path_info(bn); bpi; bpi = bpi->next) { vnc_import_bgp_add_route_mode_resolve_nve_one_bi( bgp, afi, bpi, /* VPN bpi */ @@ -1305,8 +1305,8 @@ static void vnc_import_bgp_del_route_mode_resolve_nve_one_rd( return; } - /* Iterate over bgp_path_info items at this node */ - for (bpi = bn->info; bpi; bpi = bpi->next) { + /* Iterate over bgp_info items at this node */ + for (bpi = bgp_node_get_bgp_path_info(bn); bpi; bpi = bpi->next) { vnc_import_bgp_del_route_mode_resolve_nve_one_bi( bgp, afi, bpi, /* VPN bpi */ @@ -2780,7 +2780,8 @@ void vnc_import_bgp_redist_enable(struct bgp *bgp, afi_t afi) struct bgp_path_info *bpi; - for (bpi = rn->info; bpi; bpi = bpi->next) { + for (bpi = bgp_node_get_bgp_path_info(rn); bpi; + bpi = bpi->next) { if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) continue; @@ -2820,7 +2821,8 @@ void vnc_import_bgp_exterior_redist_enable(struct bgp *bgp, afi_t afi) struct bgp_path_info *bpi; - for (bpi = rn->info; bpi; bpi = bpi->next) { + for (bpi = bgp_node_get_bgp_path_info(rn); bpi; + bpi = bpi->next) { if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) continue; @@ -2865,7 +2867,8 @@ void vnc_import_bgp_exterior_redist_enable_it( struct bgp_path_info *bpi; - for (bpi = rn->info; bpi; bpi = bpi->next) { + for (bpi = bgp_node_get_bgp_path_info(rn); bpi; + bpi = bpi->next) { if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) continue; @@ -2902,14 +2905,16 @@ void vnc_import_bgp_redist_disable(struct bgp *bgp, afi_t afi) for (rn1 = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); rn1; rn1 = bgp_route_next(rn1)) { - if (rn1->info) { + if (bgp_node_has_bgp_path_info_data(rn1)) { + for (rn2 = bgp_table_top(rn1->info); rn2; rn2 = bgp_route_next(rn2)) { struct bgp_path_info *bpi; struct bgp_path_info *nextbpi; - for (bpi = rn2->info; bpi; bpi = nextbpi) { + for (bpi = bgp_node_get_bgp_path_info(rn2); bpi; + bpi = nextbpi) { nextbpi = bpi->next; @@ -2999,7 +3004,8 @@ void vnc_import_bgp_exterior_redist_disable(struct bgp *bgp, afi_t afi) struct bgp_path_info *bpi; - for (bpi = rn->info; bpi; bpi = bpi->next) { + for (bpi = bgp_node_get_bgp_path_info(rn); bpi; + bpi = bpi->next) { if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) continue; diff --git a/bgpd/rfapi/vnc_zebra.c b/bgpd/rfapi/vnc_zebra.c index a43cf1f6a..77bec4842 100644 --- a/bgpd/rfapi/vnc_zebra.c +++ b/bgpd/rfapi/vnc_zebra.c @@ -320,7 +320,8 @@ static void vnc_redistribute_withdraw(struct bgp *bgp, afi_t afi, uint8_t type) struct bgp_path_info *ri; - for (ri = rn->info; ri; ri = ri->next) { + for (ri = bgp_node_get_bgp_path_info(rn); ri; + ri = ri->next) { if (ri->type == type) { /* has matching redist type */ break; |