]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: let the route-map rule "match interface" work for VRFs
authorFeng Lu <lu.feng@6wind.com>
Fri, 22 May 2015 09:40:04 +0000 (11:40 +0200)
committerVipin Kumar <vipin@cumulusnetworks.com>
Fri, 30 Oct 2015 06:52:37 +0000 (23:52 -0700)
Introduce a new "struct nexthop_vrfid" to specify a nexthop together
with the VRF ID it belongs to.

Thus in route_match_interface(), we can lookup the interface from
the correct VRF.

Signed-off-by: Feng Lu <lu.feng@6wind.com>
Reviewed-by: Alain Ritoux <alain.ritoux@6wind.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Acked-by: Vincent JARDIN <vincent.jardin@6wind.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Conflicts:
zebra/zebra_rib.c
zebra/zebra_routemap.c

zebra/zebra_rib.c
zebra/zebra_routemap.c
zebra/zserv.h

index 79aa989814b33320eecee4d9f9a8f29db6233002..0f25c768583a8a21c2ad8107dc0a5fade4f20b5b 100644 (file)
@@ -1213,7 +1213,8 @@ nexthop_active_check (struct route_node *rn, struct rib *rib,
   memset(&nexthop->rmap_src.ipv6, 0, sizeof(union g_addr));
 
   /* It'll get set if required inside */
-  ret = zebra_route_map_check(family, rib->type, &rn->p, nexthop, rib->tag);
+  ret = zebra_route_map_check(family, rib->type, &rn->p, nexthop, rib->vrf_id,
+                              rib->tag);
   if (ret == RMAP_DENYMATCH)
     {
       if (IS_ZEBRA_DEBUG_RIB)
index 1c7b63e7579697a07de4bab0e70f31f5b3557c1f..a8e87dd09c4c5f88f6ec0c4fa273940f9df85b98 100644 (file)
@@ -29,6 +29,7 @@
 #include "filter.h"
 #include "plist.h"
 #include "nexthop.h"
+#include "vrf.h"
 
 #include "zebra/zserv.h"
 #include "zebra/debug.h"
@@ -45,6 +46,7 @@ extern struct zebra_t zebrad;
 struct nh_rmap_obj
 {
   struct nexthop *nexthop;
+  vrf_id_t vrf_id;
   u_int32_t source_protocol;
   int metric;
   u_short tag;
@@ -255,12 +257,12 @@ route_match_interface (void *rule, struct prefix *prefix,
     {
       if (strcasecmp(ifname, "any") == 0)
        return RMAP_MATCH;
-      ifindex = ifname2ifindex(ifname);
-      if (ifindex == 0)
-       return RMAP_NOMATCH;
       nh_data = object;
       if (!nh_data || !nh_data->nexthop)
        return RMAP_NOMATCH;
+      ifindex = ifname2ifindex_vrf (ifname, nh_data->vrf_id);
+      if (ifindex == 0)
+       return RMAP_NOMATCH;
       if (nh_data->nexthop->ifindex == ifindex)
        return RMAP_MATCH;
     }
@@ -767,7 +769,7 @@ DEFUN (ip_protocol,
   if (IS_ZEBRA_DEBUG_RIB)
     zlog_debug ("%s: calling rib_update", __func__);
 
-  rib_update();
+  rib_update(VRF_DEFAULT);
   return CMD_SUCCESS;
 }
 
@@ -804,7 +806,7 @@ DEFUN (no_ip_protocol,
       if (IS_ZEBRA_DEBUG_RIB)
         zlog_debug ("%s: calling rib_update", __func__);
 
-      rib_update();
+      rib_update(VRF_DEFAULT);
     }
   return CMD_SUCCESS;
 }
@@ -879,7 +881,7 @@ DEFUN (ipv6_protocol,
   if (IS_ZEBRA_DEBUG_RIB)
     zlog_debug ("%s: calling rib_update", __func__);
 
-  rib_update();
+  rib_update(VRF_DEFAULT);
   return CMD_SUCCESS;
 }
 
@@ -916,7 +918,7 @@ DEFUN (no_ipv6_protocol,
       if (IS_ZEBRA_DEBUG_RIB)
         zlog_debug ("%s: calling rib_update", __func__);
 
-      rib_update();
+      rib_update(VRF_DEFAULT);
     }
   return CMD_SUCCESS;
 }
@@ -1590,7 +1592,7 @@ zebra_route_map_update_timer (struct thread *thread)
   if (IS_ZEBRA_DEBUG_RIB)
     zlog_debug ("%s: calling rib_update", __func__);
 
-  rib_update();
+  rib_update(VRF_DEFAULT);
   zebra_evaluate_rnh(0, AF_INET, 1, RNH_NEXTHOP_TYPE, NULL);
   zebra_evaluate_rnh(0, AF_INET6, 1, RNH_NEXTHOP_TYPE, NULL);
 
@@ -1621,13 +1623,14 @@ zebra_route_map_write_delay_timer (struct vty *vty)
 
 route_map_result_t
 zebra_route_map_check (int family, int rib_type, struct prefix *p,
-                      struct nexthop *nexthop, u_short tag)
+                      struct nexthop *nexthop, vrf_id_t vrf_id, u_short tag)
 {
   struct route_map *rmap = NULL;
   route_map_result_t ret = RMAP_MATCH;
   struct nh_rmap_obj nh_obj;
 
   nh_obj.nexthop = nexthop;
+  nh_obj.vrf_id = vrf_id;
   nh_obj.source_protocol = rib_type;
   nh_obj.metric = 0;
   nh_obj.tag = tag;
@@ -1652,6 +1655,7 @@ zebra_nht_route_map_check (int family, int client_proto, struct prefix *p,
   struct nh_rmap_obj nh_obj;
 
   nh_obj.nexthop = nexthop;
+  nh_obj.vrf_id = rib->vrf_id;
   nh_obj.source_protocol = rib->type;
   nh_obj.metric = rib->metric;
   nh_obj.tag = rib->tag;
index 41a4b9ea9f5acce3d3e831e5b38640e6fdecd921..ace37152477545ac3e91232abda0f2a04a4461c7 100644 (file)
@@ -162,6 +162,7 @@ extern void zebra_route_map_write_delay_timer(struct vty *);
 extern route_map_result_t zebra_route_map_check (int family, int rib_type,
                                                 struct prefix *p,
                                                 struct nexthop *nexthop,
+                                                 vrf_id_t vrf_id,
                                                  u_short tag);
 extern route_map_result_t zebra_nht_route_map_check (int family,
                                                     int client_proto,