]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: Replace source_protocol with just using re in route map object
authorDonald Sharp <sharpd@nvidia.com>
Fri, 11 Aug 2023 15:11:40 +0000 (11:11 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Fri, 11 Aug 2023 15:11:40 +0000 (11:11 -0400)
Replace the source_protocol with just saving a pointer to the re
in the `struct zebra_rmap_obj` data structure.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
zebra/redistribute.c
zebra/zebra_nhg.c
zebra/zebra_routemap.c
zebra/zebra_routemap.h

index 89394d5b2200bbbb6baea2c46a2a4c52da31e417..c87da5ed6c55a948589d0697a262432145a3879a 100644 (file)
@@ -647,8 +647,8 @@ 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->type,
-                                                        re->instance, &rn->p,
+               ret = zebra_import_table_route_map_check(afi, re, re->instance,
+                                                        &rn->p,
                                                         re->nhe->nhg.nexthop,
                                                         re->tag, rmap_name);
 
index a701b582cef5c3eb2d87cb51a2dacc91eefef536..8c640f4e32bc25c7230d3f57dae8ca90b6b4fd05 100644 (file)
@@ -2703,8 +2703,8 @@ skip_check:
        }
 
        /* It'll get set if required inside */
-       ret = zebra_route_map_check(family, re->type, re->instance, p, nexthop,
-                                   zvrf, re->tag);
+       ret = zebra_route_map_check(family, re, re->instance, p, nexthop, zvrf,
+                                   re->tag);
        if (ret == RMAP_DENYMATCH) {
                if (IS_ZEBRA_DEBUG_RIB) {
                        zlog_debug(
index ec76222b3eaec719f901768728f5fc38fcfa119c..e0069912f9bacf3fd6358136207a3e58b5ebcd48 100644 (file)
@@ -33,7 +33,7 @@ char *zebra_import_table_routemap[AFI_MAX][ZEBRA_KERNEL_TABLE_MAX];
 
 struct zebra_rmap_obj {
        struct nexthop *nexthop;
-       uint32_t source_protocol;
+       struct route_entry *re;
        uint8_t instance;
        int metric;
        route_tag_t tag;
@@ -1431,15 +1431,14 @@ static const struct route_map_rule_cmd
 static enum route_map_cmd_result_t
 route_match_source_protocol(void *rule, const struct prefix *p, void *object)
 {
-       uint32_t *rib_type = (uint32_t *)rule;
+       int32_t *rib_type = (int32_t *)rule;
        struct zebra_rmap_obj *rm_data;
 
        rm_data = (struct zebra_rmap_obj *)object;
        if (!rm_data)
                return RMAP_NOMATCH;
 
-       return ((rm_data->source_protocol == *rib_type) ? RMAP_MATCH
-                                                       : RMAP_NOMATCH);
+       return ((rm_data->re->type == *rib_type) ? RMAP_MATCH : RMAP_NOMATCH);
 }
 
 static void *route_match_source_protocol_compile(const char *arg)
@@ -1761,7 +1760,7 @@ void zebra_routemap_finish(void)
 }
 
 route_map_result_t
-zebra_route_map_check(afi_t family, int rib_type, uint8_t instance,
+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)
 {
@@ -1771,14 +1770,14 @@ zebra_route_map_check(afi_t family, int rib_type, uint8_t instance,
        struct zebra_rmap_obj rm_obj;
 
        rm_obj.nexthop = nexthop;
-       rm_obj.source_protocol = rib_type;
+       rm_obj.re = re;
        rm_obj.instance = instance;
        rm_obj.metric = 0;
        rm_obj.tag = tag;
 
-       if (rib_type >= 0 && rib_type < ZEBRA_ROUTE_MAX) {
-               rm_name = PROTO_RM_NAME(zvrf, family, rib_type);
-               rmap = PROTO_RM_MAP(zvrf, family, rib_type);
+       if (re->type >= 0 && re->type < ZEBRA_ROUTE_MAX) {
+               rm_name = PROTO_RM_NAME(zvrf, family, re->type);
+               rmap = PROTO_RM_MAP(zvrf, family, re->type);
 
                if (rm_name && !rmap)
                        return RMAP_DENYMATCH;
@@ -1814,21 +1813,23 @@ 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, int re_type, 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,
+                                  uint8_t instance, 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;
        struct zebra_rmap_obj rm_obj;
 
        rm_obj.nexthop = nexthop;
-       rm_obj.source_protocol = re_type;
+       rm_obj.re = re;
        rm_obj.instance = instance;
        rm_obj.metric = 0;
        rm_obj.tag = tag;
 
-       if (re_type >= 0 && re_type < ZEBRA_ROUTE_MAX)
+       if (re->type >= 0 && re->type < ZEBRA_ROUTE_MAX)
                rmap = route_map_lookup_by_name(rmap_name);
        if (rmap) {
                ret = route_map_apply(rmap, p, &rm_obj);
@@ -1848,7 +1849,7 @@ route_map_result_t zebra_nht_route_map_check(afi_t afi, int client_proto,
        struct zebra_rmap_obj rm_obj;
 
        rm_obj.nexthop = nexthop;
-       rm_obj.source_protocol = re->type;
+       rm_obj.re = re;
        rm_obj.instance = re->instance;
        rm_obj.metric = re->metric;
        rm_obj.tag = re->tag;
index 0921933ef7f43c7e3eb6ec9590a0568f79326ed1..81a34ef28cf67d5e738bf6b2a3d7fc07525c03b3 100644 (file)
@@ -21,17 +21,20 @@ 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, int rib_type, 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, int rib_type, uint8_t instance,
+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,
                      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, const struct prefix *p,
-                         struct zebra_vrf *zvrf, struct route_entry *,
-                         struct nexthop *nexthop);
+extern route_map_result_t zebra_nht_route_map_check(afi_t afi, int client_proto,
+                                                   const struct prefix *p,
+                                                   struct zebra_vrf *zvrf,
+                                                   struct route_entry *re,
+                                                   struct nexthop *nexthop);
 
 extern void zebra_routemap_vrf_delete(struct zebra_vrf *zvrf);