diff options
author | Mark Stapp <mjs@voltanet.io> | 2020-07-17 14:54:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-17 14:54:54 +0200 |
commit | 7d4b857955864f6fd8aa40ebf61f9c3a9dc90041 (patch) | |
tree | 59b8a34967f4e0c923958715bba1d3afe971e8f2 | |
parent | Merge pull request #6759 from donaldsharp/rules_family (diff) | |
parent | pbrd: nhgc state improvements when installed/removed (diff) | |
download | frr-7d4b857955864f6fd8aa40ebf61f9c3a9dc90041.tar.xz frr-7d4b857955864f6fd8aa40ebf61f9c3a9dc90041.zip |
Merge pull request #6705 from sworleys/PBR-Fixes-More
pbrd: A couple pbr fixes
-rw-r--r-- | pbrd/pbr_map.c | 6 | ||||
-rw-r--r-- | pbrd/pbr_map.h | 3 | ||||
-rw-r--r-- | pbrd/pbr_nht.c | 51 |
3 files changed, 35 insertions, 25 deletions
diff --git a/pbrd/pbr_map.c b/pbrd/pbr_map.c index edc3f1d8d..0ef8432e5 100644 --- a/pbrd/pbr_map.c +++ b/pbrd/pbr_map.c @@ -603,7 +603,7 @@ bool pbr_map_check_valid(const char *name) return pbrm->valid; } -void pbr_map_schedule_policy_from_nhg(const char *nh_group) +void pbr_map_schedule_policy_from_nhg(const char *nh_group, bool installed) { struct pbr_map_sequence *pbrms; struct pbr_map *pbrm; @@ -618,7 +618,7 @@ void pbr_map_schedule_policy_from_nhg(const char *nh_group) if (pbrms->nhgrp_name && (strcmp(nh_group, pbrms->nhgrp_name) == 0)) { - pbrms->nhs_installed = true; + pbrms->nhs_installed = installed; pbr_map_check(pbrms, false); } @@ -626,7 +626,7 @@ void pbr_map_schedule_policy_from_nhg(const char *nh_group) if (pbrms->nhg && (strcmp(nh_group, pbrms->internal_nhg_name) == 0)) { - pbrms->nhs_installed = true; + pbrms->nhs_installed = installed; pbr_map_check(pbrms, false); } diff --git a/pbrd/pbr_map.h b/pbrd/pbr_map.h index 41f170395..704f1a036 100644 --- a/pbrd/pbr_map.h +++ b/pbrd/pbr_map.h @@ -194,7 +194,8 @@ extern void pbr_map_check(struct pbr_map_sequence *pbrms, bool changed); extern void pbr_map_check_nh_group_change(const char *nh_group); extern void pbr_map_reason_string(unsigned int reason, char *buf, int size); -extern void pbr_map_schedule_policy_from_nhg(const char *nh_group); +extern void pbr_map_schedule_policy_from_nhg(const char *nh_group, + bool installed); extern void pbr_map_install(struct pbr_map *pbrm); diff --git a/pbrd/pbr_nht.c b/pbrd/pbr_nht.c index 98be958fc..31da65679 100644 --- a/pbrd/pbr_nht.c +++ b/pbrd/pbr_nht.c @@ -328,27 +328,29 @@ static struct pbr_nexthop_cache *pbr_nht_lookup_nexthop(struct nexthop *nexthop) } #endif +static void +pbr_nht_find_nhg_from_table_update(struct pbr_nexthop_group_cache *pnhgc, + uint32_t table_id, bool installed) +{ + if (pnhgc->table_id == table_id) { + DEBUGD(&pbr_dbg_nht, "%s: %s: Table ID (%u) matches %s", + __func__, (installed ? "install" : "remove"), table_id, + pnhgc->name); + + pnhgc->installed = installed; + pnhgc->valid = installed; + pbr_map_schedule_policy_from_nhg(pnhgc->name, pnhgc->installed); + } +} + static void pbr_nht_find_nhg_from_table_install(struct hash_bucket *b, void *data) { struct pbr_nexthop_group_cache *pnhgc = (struct pbr_nexthop_group_cache *)b->data; - uint32_t *table_id = (uint32_t *)data; - - if (pnhgc->table_id == *table_id) { - DEBUGD(&pbr_dbg_nht, "%s: Table ID (%u) matches %s", __func__, - *table_id, pnhgc->name); + uint32_t table_id = *(uint32_t *)data; - /* - * If the table has been re-handled by zebra - * and we are already installed no need to do - * anything here. - */ - if (!pnhgc->installed) { - pnhgc->installed = true; - pbr_map_schedule_policy_from_nhg(pnhgc->name); - } - } + pbr_nht_find_nhg_from_table_update(pnhgc, table_id, true); } void pbr_nht_route_installed_for_table(uint32_t table_id) @@ -360,7 +362,11 @@ void pbr_nht_route_installed_for_table(uint32_t table_id) static void pbr_nht_find_nhg_from_table_remove(struct hash_bucket *b, void *data) { - ; + struct pbr_nexthop_group_cache *pnhgc = + (struct pbr_nexthop_group_cache *)b->data; + uint32_t table_id = *(uint32_t *)data; + + pbr_nht_find_nhg_from_table_update(pnhgc, table_id, false); } void pbr_nht_route_removed_for_table(uint32_t table_id) @@ -852,12 +858,15 @@ static void pbr_nht_nexthop_update_lookup(struct hash_bucket *b, void *data) */ pnhgc->valid = !!pnhi.valid; - if (pnhgc->valid) { - pbr_nexthop_group_cache_to_nexthop_group(&nhg, pnhgc); + pbr_nexthop_group_cache_to_nexthop_group(&nhg, pnhgc); + + if (pnhgc->valid) pbr_nht_install_nexthop_group(pnhgc, nhg); - /* Don't need copied nexthops anymore */ - nexthops_free(nhg.nexthop); - } + else + pbr_nht_uninstall_nexthop_group(pnhgc, nhg, 0); + + /* Don't need copied nexthops anymore */ + nexthops_free(nhg.nexthop); if (old_valid != pnhgc->valid) pbr_map_check_nh_group_change(pnhgc->name); |