From b7542d5af889e039ef19e1fd00d0116396659688 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 11 Aug 2023 11:15:06 -0400 Subject: [PATCH] zebra: Remove instance from zebra_rmap_obj data structure In all cases the instance is derived from the re pointer and since the re pointer is already stored, let's just remove it from the game and cut to the chase. Signed-off-by: Donald Sharp --- zebra/redistribute.c | 3 +-- zebra/zebra_nhg.c | 3 +-- zebra/zebra_routemap.c | 22 ++++++++-------------- zebra/zebra_routemap.h | 10 ++++------ 4 files changed, 14 insertions(+), 24 deletions(-) diff --git a/zebra/redistribute.c b/zebra/redistribute.c index c87da5ed6c..9e73e6a2fd 100644 --- a/zebra/redistribute.c +++ b/zebra/redistribute.c @@ -647,8 +647,7 @@ int zebra_add_import_table_entry(struct zebra_vrf *zvrf, struct route_node *rn, afi = family2afi(rn->p.family); if (rmap_name) - ret = zebra_import_table_route_map_check(afi, re, re->instance, - &rn->p, + ret = zebra_import_table_route_map_check(afi, re, &rn->p, re->nhe->nhg.nexthop, re->tag, rmap_name); diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c index 8c640f4e32..b94475fc08 100644 --- a/zebra/zebra_nhg.c +++ b/zebra/zebra_nhg.c @@ -2703,8 +2703,7 @@ skip_check: } /* It'll get set if required inside */ - ret = zebra_route_map_check(family, re, re->instance, p, nexthop, zvrf, - re->tag); + ret = zebra_route_map_check(family, re, p, nexthop, zvrf, re->tag); if (ret == RMAP_DENYMATCH) { if (IS_ZEBRA_DEBUG_RIB) { zlog_debug( diff --git a/zebra/zebra_routemap.c b/zebra/zebra_routemap.c index e0069912f9..f5c194fe3f 100644 --- a/zebra/zebra_routemap.c +++ b/zebra/zebra_routemap.c @@ -34,7 +34,6 @@ char *zebra_import_table_routemap[AFI_MAX][ZEBRA_KERNEL_TABLE_MAX]; struct zebra_rmap_obj { struct nexthop *nexthop; struct route_entry *re; - uint8_t instance; int metric; route_tag_t tag; }; @@ -1477,7 +1476,7 @@ route_match_source_instance(void *rule, const struct prefix *p, void *object) if (!rm_data) return RMAP_NOMATCH; - return (rm_data->instance == *instance) ? RMAP_MATCH : RMAP_NOMATCH; + return (rm_data->re->instance == *instance) ? RMAP_MATCH : RMAP_NOMATCH; } static void *route_match_source_instance_compile(const char *arg) @@ -1759,10 +1758,10 @@ void zebra_routemap_finish(void) route_map_finish(); } -route_map_result_t -zebra_route_map_check(afi_t family, struct route_entry *re, uint8_t instance, - const struct prefix *p, struct nexthop *nexthop, - struct zebra_vrf *zvrf, route_tag_t tag) +route_map_result_t zebra_route_map_check(afi_t family, struct route_entry *re, + const struct prefix *p, + struct nexthop *nexthop, + struct zebra_vrf *zvrf, route_tag_t tag) { struct route_map *rmap = NULL; char *rm_name; @@ -1771,7 +1770,6 @@ zebra_route_map_check(afi_t family, struct route_entry *re, uint8_t instance, rm_obj.nexthop = nexthop; rm_obj.re = re; - rm_obj.instance = instance; rm_obj.metric = 0; rm_obj.tag = tag; @@ -1813,11 +1811,9 @@ void zebra_del_import_table_route_map(afi_t afi, uint32_t table) XFREE(MTYPE_ROUTE_MAP_NAME, zebra_import_table_routemap[afi][table]); } -route_map_result_t -zebra_import_table_route_map_check(int family, struct route_entry *re, - uint8_t instance, const struct prefix *p, - struct nexthop *nexthop, route_tag_t tag, - const char *rmap_name) +route_map_result_t zebra_import_table_route_map_check( + int family, struct route_entry *re, const struct prefix *p, + struct nexthop *nexthop, route_tag_t tag, const char *rmap_name) { struct route_map *rmap = NULL; route_map_result_t ret = RMAP_DENYMATCH; @@ -1825,7 +1821,6 @@ zebra_import_table_route_map_check(int family, struct route_entry *re, rm_obj.nexthop = nexthop; rm_obj.re = re; - rm_obj.instance = instance; rm_obj.metric = 0; rm_obj.tag = tag; @@ -1850,7 +1845,6 @@ route_map_result_t zebra_nht_route_map_check(afi_t afi, int client_proto, rm_obj.nexthop = nexthop; rm_obj.re = re; - rm_obj.instance = re->instance; rm_obj.metric = re->metric; rm_obj.tag = re->tag; diff --git a/zebra/zebra_routemap.h b/zebra/zebra_routemap.h index 81a34ef28c..3fa1476896 100644 --- a/zebra/zebra_routemap.h +++ b/zebra/zebra_routemap.h @@ -21,13 +21,11 @@ extern void zebra_add_import_table_route_map(afi_t afi, const char *rmap_name, uint32_t table); extern void zebra_del_import_table_route_map(afi_t afi, uint32_t table); +extern route_map_result_t zebra_import_table_route_map_check( + int family, struct route_entry *re, const struct prefix *p, + struct nexthop *nexthop, route_tag_t tag, const char *rmap_name); extern route_map_result_t -zebra_import_table_route_map_check(int family, struct route_entry *re, - uint8_t instance, const struct prefix *p, - struct nexthop *nexthop, route_tag_t tag, - const char *rmap_name); -extern route_map_result_t -zebra_route_map_check(afi_t family, struct route_entry *re, uint8_t instance, +zebra_route_map_check(afi_t family, struct route_entry *re, const struct prefix *p, struct nexthop *nexthop, struct zebra_vrf *zvrf, route_tag_t tag); extern route_map_result_t zebra_nht_route_map_check(afi_t afi, int client_proto, -- 2.39.5