]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: import table match against interface name could fail
authorDonald Sharp <sharpd@nvidia.com>
Fri, 11 Aug 2023 14:18:41 +0000 (10:18 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Fri, 11 Aug 2023 14:33:16 +0000 (10:33 -0400)
If an import table route-map is trying to match against
a particular interface, The code is matching against
the actual vrf the route entry is in -vs- the vrf
the nexthop entry is in.  Let's modify the code
to actually allow the import table entry to match
against the nexthops vrf.

Not working:

ip import-table 91
ip import-table 93 route-map FOO
no service integrated-vtysh-config
!
debug zebra events
!
interface green
 ip address 192.168.4.3/24
exit
!
route-map FOO permit 10
 match interface green
exit

eva# show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

K>* 0.0.0.0/0 [0/100] via 192.168.119.1, enp13s0, 1d10h07m
T[91]>* 1.2.3.5/32 [15/0] via 192.168.119.1, enp13s0, 00:00:05
K>* 169.254.0.0/16 [0/1000] is directly connected, virbr0 linkdown, 1d16h34m
C>* 192.168.44.0/24 is directly connected, virbr1, 01:30:51
C>* 192.168.45.0/24 is directly connected, virbr2, 01:30:51
C>* 192.168.119.0/24 is directly connected, enp13s0, 1d16h34m
C>* 192.168.122.0/24 is directly connected, virbr0 linkdown, 01:30:51
eva# show ip route table 91
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

VRF default table 91:
K>* 1.2.3.5/32 [0/0] via 192.168.119.1, enp13s0, 00:00:15
eva# show ip route table 93
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

VRF default table 93:
K * 1.2.3.4/32 [0/0] via 192.168.4.5, green (vrf green), 00:03:05

Working:

eva# show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

K>* 0.0.0.0/0 [0/100] via 192.168.119.1, enp13s0, 00:03:09
T[93]>* 1.2.3.4/32 [15/0] via 192.168.4.5, green (vrf green), 00:02:21
T[91]>* 1.2.3.5/32 [15/0] via 192.168.119.1, enp13s0, 00:02:26
K>* 169.254.0.0/16 [0/1000] is directly connected, virbr0, 00:03:09
C>* 192.168.44.0/24 is directly connected, virbr1, 00:03:09
C>* 192.168.45.0/24 is directly connected, virbr2, 00:03:09
C>* 192.168.119.0/24 is directly connected, enp13s0, 00:03:09
C>* 192.168.122.0/24 is directly connected, virbr0, 00:03:09
eva# show ip route table 91
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

VRF default table 91:
K * 1.2.3.5/32 [0/0] via 192.168.119.1, enp13s0, 00:03:12
eva# show ip route table 93
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

VRF default table 93:
K * 1.2.3.4/32 [0/0] via 192.168.4.5, green (vrf green), 00:03:14

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

index 9ca9c7a55aa52a38efc919f6f420e7afbffa7bfb..89394d5b2200bbbb6baea2c46a2a4c52da31e417 100644 (file)
@@ -647,10 +647,10 @@ 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,
-                       re->nhe->nhg.nexthop,
-                       zvrf->vrf->vrf_id, re->tag, rmap_name);
+               ret = zebra_import_table_route_map_check(afi, re->type,
+                                                        re->instance, &rn->p,
+                                                        re->nhe->nhg.nexthop,
+                                                        re->tag, rmap_name);
 
        if (ret != RMAP_PERMITMATCH) {
                UNSET_FLAG(re->flags, ZEBRA_FLAG_SELECTED);
index 91c8af9c6c7c9497230a399977d6877de7e8a566..e0aff191fd15ad0a6212d3cb6b4721c4fe70496e 100644 (file)
@@ -1816,19 +1816,16 @@ 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,
-                                  vrf_id_t vrf_id, route_tag_t tag,
-                                  const char *rmap_name)
+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)
 {
        struct route_map *rmap = NULL;
        route_map_result_t ret = RMAP_DENYMATCH;
        struct zebra_rmap_obj rm_obj;
 
        rm_obj.nexthop = nexthop;
-       rm_obj.vrf_id = vrf_id;
+       rm_obj.vrf_id = nexthop->vrf_id;
        rm_obj.source_protocol = re_type;
        rm_obj.instance = instance;
        rm_obj.metric = 0;
index f77735edc21b6c66ead8b7c02b5152cf2b57d27a..0921933ef7f43c7e3eb6ec9590a0568f79326ed1 100644 (file)
@@ -21,11 +21,9 @@ 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, vrf_id_t vrf_id,
-                                  route_tag_t tag, const char *rmap_name);
+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,
                      const struct prefix *p, struct nexthop *nexthop,