@@ -1524,9 +1524,8 @@ static void bgp_debug_zebra_nh(struct zapi_route *api)
15241524 }
15251525}
15261526
1527- void bgp_zebra_announce (struct bgp_dest * dest , const struct prefix * p ,
1528- struct bgp_path_info * info , struct bgp * bgp , afi_t afi ,
1529- safi_t safi )
1527+ void bgp_zebra_announce (struct bgp_dest * dest , struct bgp_path_info * info ,
1528+ struct bgp * bgp )
15301529{
15311530 struct bgp_path_info * bpi_ultimate ;
15321531 struct zapi_route api = { 0 };
@@ -1539,6 +1538,8 @@ void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p,
15391538 bool is_add ;
15401539 uint32_t nhg_id = 0 ;
15411540 uint32_t recursion_flag = 0 ;
1541+ struct bgp_table * table = bgp_dest_table (dest );
1542+ const struct prefix * p = bgp_dest_get_prefix (dest );
15421543
15431544 /*
15441545 * BGP is installing this route and bgp has been configured
@@ -1557,16 +1558,16 @@ void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p,
15571558 if (bgp -> main_zebra_update_hold )
15581559 return ;
15591560
1560- if (safi == SAFI_FLOWSPEC ) {
1561- bgp_pbr_update_entry (bgp , bgp_dest_get_prefix ( dest ) , info , afi ,
1562- safi , true);
1561+ if (table -> safi == SAFI_FLOWSPEC ) {
1562+ bgp_pbr_update_entry (bgp , p , info , table -> afi , table -> safi ,
1563+ true);
15631564 return ;
15641565 }
15651566
15661567 /* Make Zebra API structure. */
15671568 api .vrf_id = bgp -> vrf_id ;
15681569 api .type = ZEBRA_ROUTE_BGP ;
1569- api .safi = safi ;
1570+ api .safi = table -> safi ;
15701571 api .prefix = * p ;
15711572 SET_FLAG (api .message , ZAPI_MESSAGE_NEXTHOP );
15721573
@@ -1603,8 +1604,8 @@ void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p,
16031604 metric = info -> attr -> med ;
16041605
16051606 bgp_zebra_announce_parse_nexthop (info , p , bgp , & api , & valid_nh_count ,
1606- afi , safi , & nhg_id , & metric , & tag ,
1607- & allow_recursion );
1607+ table -> afi , table -> safi , & nhg_id ,
1608+ & metric , & tag , & allow_recursion );
16081609
16091610 is_add = (valid_nh_count || nhg_id ) ? true : false;
16101611
@@ -1657,7 +1658,7 @@ void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p,
16571658 api .tag = tag ;
16581659 }
16591660
1660- distance = bgp_distance_apply (p , info , afi , safi , bgp );
1661+ distance = bgp_distance_apply (p , info , table -> afi , table -> safi , bgp );
16611662 if (distance ) {
16621663 SET_FLAG (api .message , ZAPI_MESSAGE_DISTANCE );
16631664 api .distance = distance ;
@@ -1706,9 +1707,7 @@ void bgp_zebra_announce_table(struct bgp *bgp, afi_t afi, safi_t safi)
17061707 && (pi -> sub_type == BGP_ROUTE_NORMAL
17071708 || pi -> sub_type == BGP_ROUTE_IMPORTED )))
17081709
1709- bgp_zebra_announce (dest ,
1710- bgp_dest_get_prefix (dest ),
1711- pi , bgp , afi , safi );
1710+ bgp_zebra_announce (dest , pi , bgp );
17121711}
17131712
17141713/* Announce routes of any bgp subtype of a table to zebra */
@@ -1730,16 +1729,16 @@ void bgp_zebra_announce_table_all_subtypes(struct bgp *bgp, afi_t afi,
17301729 for (pi = bgp_dest_get_bgp_path_info (dest ); pi ; pi = pi -> next )
17311730 if (CHECK_FLAG (pi -> flags , BGP_PATH_SELECTED ) &&
17321731 pi -> type == ZEBRA_ROUTE_BGP )
1733- bgp_zebra_announce (dest ,
1734- bgp_dest_get_prefix (dest ),
1735- pi , bgp , afi , safi );
1732+ bgp_zebra_announce (dest , pi , bgp );
17361733}
17371734
1738- void bgp_zebra_withdraw (const struct prefix * p , struct bgp_path_info * info ,
1739- struct bgp * bgp , afi_t afi , safi_t safi )
1735+ void bgp_zebra_withdraw (struct bgp_dest * dest , struct bgp_path_info * info ,
1736+ struct bgp * bgp )
17401737{
17411738 struct zapi_route api ;
17421739 struct peer * peer ;
1740+ struct bgp_table * table = bgp_dest_table (dest );
1741+ const struct prefix * p = bgp_dest_get_prefix (dest );
17431742
17441743 /*
17451744 * If we are withdrawing the route, we don't need to have this
@@ -1753,16 +1752,17 @@ void bgp_zebra_withdraw(const struct prefix *p, struct bgp_path_info *info,
17531752 if (!bgp_install_info_to_zebra (bgp ))
17541753 return ;
17551754
1756- if (safi == SAFI_FLOWSPEC ) {
1755+ if (table -> safi == SAFI_FLOWSPEC ) {
17571756 peer = info -> peer ;
1758- bgp_pbr_update_entry (peer -> bgp , p , info , afi , safi , false);
1757+ bgp_pbr_update_entry (peer -> bgp , p , info , table -> afi ,
1758+ table -> safi , false);
17591759 return ;
17601760 }
17611761
17621762 memset (& api , 0 , sizeof (api ));
17631763 api .vrf_id = bgp -> vrf_id ;
17641764 api .type = ZEBRA_ROUTE_BGP ;
1765- api .safi = safi ;
1765+ api .safi = table -> safi ;
17661766 api .prefix = * p ;
17671767
17681768 if (info -> attr -> rmap_table_id ) {
@@ -1795,8 +1795,7 @@ void bgp_zebra_withdraw_table_all_subtypes(struct bgp *bgp, afi_t afi, safi_t sa
17951795 for (pi = bgp_dest_get_bgp_path_info (dest ); pi ; pi = pi -> next ) {
17961796 if (CHECK_FLAG (pi -> flags , BGP_PATH_SELECTED )
17971797 && (pi -> type == ZEBRA_ROUTE_BGP ))
1798- bgp_zebra_withdraw (bgp_dest_get_prefix (dest ),
1799- pi , bgp , afi , safi );
1798+ bgp_zebra_withdraw (dest , pi , bgp );
18001799 }
18011800 }
18021801}
0 commit comments