Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bgpd: add the bgp_zebra_announce_dest() function #16393

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions bgpd/bgp_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -1678,13 +1678,25 @@ bgp_zebra_announce_actual(struct bgp_dest *dest, struct bgp_path_info *info,
return zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api);
}

void bgp_zebra_announce_dest(struct bgp *bgp, struct bgp_dest *dest,
bool imported)
{
struct bgp_path_info *pi;

for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next)
if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED) &&
(pi->type == ZEBRA_ROUTE_BGP &&
(pi->sub_type == BGP_ROUTE_NORMAL ||
(imported && pi->sub_type == BGP_ROUTE_IMPORTED))))
bgp_zebra_route_install(dest, pi, bgp, true, NULL,
false);
}

/* Announce all routes of a table to zebra */
void bgp_zebra_announce_table(struct bgp *bgp, afi_t afi, safi_t safi)
{
struct bgp_dest *dest;
struct bgp_table *table;
struct bgp_path_info *pi;

/* Don't try to install if we're not connected to Zebra or Zebra doesn't
* know of this instance.
Expand All @@ -1697,13 +1709,7 @@ void bgp_zebra_announce_table(struct bgp *bgp, afi_t afi, safi_t safi)
return;

for (dest = bgp_table_top(table); dest; dest = bgp_route_next(dest))
for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next)
if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED) &&
(pi->type == ZEBRA_ROUTE_BGP
&& (pi->sub_type == BGP_ROUTE_NORMAL
|| pi->sub_type == BGP_ROUTE_IMPORTED)))
bgp_zebra_route_install(dest, pi, bgp, true,
NULL, false);
bgp_zebra_announce_dest(bgp, dest, true);
}

/* Announce routes of any bgp subtype of a table to zebra */
Expand All @@ -1712,7 +1718,6 @@ void bgp_zebra_announce_table_all_subtypes(struct bgp *bgp, afi_t afi,
{
struct bgp_dest *dest;
struct bgp_table *table;
struct bgp_path_info *pi;

if (!bgp_install_info_to_zebra(bgp))
return;
Expand All @@ -1722,11 +1727,7 @@ void bgp_zebra_announce_table_all_subtypes(struct bgp *bgp, afi_t afi,
return;

for (dest = bgp_table_top(table); dest; dest = bgp_route_next(dest))
for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next)
if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED) &&
pi->type == ZEBRA_ROUTE_BGP)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the tests in the new function doesn't look the same - that seems ... questionable?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a parameter to handle this case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about pi->subtype and BGP_ROUTE_NORMAL, the new code tests for this as well, when before it doesn't. This looks like it would break STATIC/AGGREGATES/REDISTRIBUTION here right?

bgp_zebra_route_install(dest, pi, bgp, true,
NULL, false);
bgp_zebra_announce_dest(bgp, dest, false);
}

enum zclient_send_status bgp_zebra_withdraw_actual(struct bgp_dest *dest,
Expand Down
2 changes: 2 additions & 0 deletions bgpd/bgp_zebra.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ extern void bgp_zebra_route_install(struct bgp_dest *dest,
bool install, struct bgpevpn *vpn,
bool is_sync);
extern void bgp_zebra_announce_table(struct bgp *bgp, afi_t afi, safi_t safi);
extern void bgp_zebra_announce_dest(struct bgp *bgp, struct bgp_dest *dest,
bool imported);

/* Announce routes of any bgp subtype of a table to zebra */
extern void bgp_zebra_announce_table_all_subtypes(struct bgp *bgp, afi_t afi,
Expand Down
Loading