After commit 1885d0a5274cd78e46ad6c22171a5240a2f27f64 (zebra:
let the route-map rule "match interface" work for VRFs) type of *object was
changed.

But three functions continued to work with the old type.
This leads to a crash and malfunction in the case of using route maps like

ip prefix-list NH permit y.y.y.y/24 le 32
route-map RM_SET_SRC permit 10
 match ip next-hop prefix-list NH
 set src x.x.x.x
ip protocol bgp route-map RM_SET_SRC

Patch restores correct work of "match ip next-hop"
and fix crash in case of "set src".

Signed-off-by: Stas Nichiporovich <[email protected]>
---
 zebra/zebra_routemap.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/zebra/zebra_routemap.c b/zebra/zebra_routemap.c
index da9cb13..49feccd 100644
--- a/zebra/zebra_routemap.c
+++ b/zebra/zebra_routemap.c
@@ -424,11 +424,13 @@ route_match_ip_next_hop (void *rule, struct prefix
*prefix,
 {
   struct access_list *alist;
   struct nexthop *nexthop;
+  struct nexthop_vrfid *nh_vrf;
   struct prefix_ipv4 p;

   if (type == RMAP_ZEBRA)
     {
-      nexthop = object;
+      nh_vrf = object;
+      nexthop = nh_vrf->nexthop;
       switch (nexthop->type) {
       case NEXTHOP_TYPE_IFINDEX:
       case NEXTHOP_TYPE_IFNAME:
@@ -486,11 +488,13 @@ route_match_ip_next_hop_prefix_list (void *rule,
struct prefix *prefix,
 {
   struct prefix_list *plist;
   struct nexthop *nexthop;
+  struct nexthop_vrfid *nh_vrf;
   struct prefix_ipv4 p;

   if (type == RMAP_ZEBRA)
     {
-      nexthop = object;
+      nh_vrf = object;
+      nexthop = nh_vrf->nexthop;
       switch (nexthop->type) {
       case NEXTHOP_TYPE_IFINDEX:
       case NEXTHOP_TYPE_IFNAME:
@@ -632,10 +636,10 @@ route_set_src (void *rule, struct prefix *prefix,
 {
   if (type == RMAP_ZEBRA)
     {
-      struct nexthop *nexthop;
+      struct nexthop_vrfid *nh_vrf;

-      nexthop = object;
-      nexthop->src = *(union g_addr *)rule;
+      nh_vrf = object;
+      nh_vrf->nexthop->src = *(union g_addr *)rule;
     }
   return RMAP_OKAY;
 }
--
2.8.1
_______________________________________________
Quagga-dev mailing list
[email protected]
https://lists.quagga.net/mailman/listinfo/quagga-dev

Reply via email to