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

pbrd: be more selective about route updates #7010

Merged
merged 2 commits into from
Sep 1, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
pbrd: be more selective about route updates
Given a received nexthop update, only send down an update to the
relevant nexthop group. Avoid sending down superfluous updates

Signed-off-by: Wesley Coakley <wcoakley@nvidia.com>
  • Loading branch information
Wesley Coakley committed Sep 1, 2020
commit c59f754dd4ca63364107c4de4763beb46f1f6a0a
18 changes: 12 additions & 6 deletions pbrd/pbr_nht.c
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ struct pbr_nht_individual {

static bool
pbr_nht_individual_nexthop_gw_update(struct pbr_nexthop_cache *pnhc,
const struct pbr_nht_individual *pnhi)
struct pbr_nht_individual *pnhi)
{
bool is_valid = pnhc->valid;

Expand All @@ -736,6 +736,7 @@ pbr_nht_individual_nexthop_gw_update(struct pbr_nexthop_cache *pnhc,
break;
}

pnhi->nhr_matched = true;
if (!pnhi->nhr->nexthop_num) {
is_valid = false;
goto done;
Expand Down Expand Up @@ -767,8 +768,9 @@ pbr_nht_individual_nexthop_gw_update(struct pbr_nexthop_cache *pnhc,
return pnhc->valid;
}

static bool pbr_nht_individual_nexthop_interface_update(
struct pbr_nexthop_cache *pnhc, const struct pbr_nht_individual *pnhi)
static bool
pbr_nht_individual_nexthop_interface_update(struct pbr_nexthop_cache *pnhc,
struct pbr_nht_individual *pnhi)
{
bool is_valid = pnhc->valid;

Expand All @@ -779,6 +781,7 @@ static bool pbr_nht_individual_nexthop_interface_update(
!= pnhi->ifp->ifindex) /* Un-related interface */
goto done;

pnhi->nhr_matched = true;
is_valid = !!if_is_up(pnhi->ifp);

done:
Expand All @@ -793,9 +796,8 @@ static bool pbr_nht_individual_nexthop_interface_update(
* If the update is un-related, the subroutines shoud just return their cached
* valid state.
*/
static void
pbr_nht_individual_nexthop_update(struct pbr_nexthop_cache *pnhc,
const struct pbr_nht_individual *pnhi)
static void pbr_nht_individual_nexthop_update(struct pbr_nexthop_cache *pnhc,
struct pbr_nht_individual *pnhi)
{
assert(pnhi->nhr || pnhi->ifp); /* Either nexthop or interface update */

Expand Down Expand Up @@ -870,9 +872,13 @@ static void pbr_nht_nexthop_update_lookup(struct hash_bucket *b, void *data)

pnhi.nhr = (struct zapi_route *)data;
pnhi.valid = 0;
pnhi.nhr_matched = false;
hash_iterate(pnhgc->nhh, pbr_nht_individual_nexthop_update_lookup,
&pnhi);

if (!pnhi.nhr_matched)
return;

/*
* If any of the specified nexthops are valid we are valid
*/
Expand Down
1 change: 1 addition & 0 deletions pbrd/pbr_nht.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ struct pbr_nexthop_cache {

bool looked_at;
bool valid;
bool nhr_matched;
};

extern void pbr_nht_write_table_range(struct vty *vty);
Expand Down