]> git.puffer.fish Git - matthieu/frr.git/commitdiff
Zebra: Fix setting source for 5549-learnt routes via ip protocol
authorvivek <vivek@cumulusnetworks.com>
Tue, 20 Oct 2015 21:32:12 +0000 (14:32 -0700)
committervivek <vivek@cumulusnetworks.com>
Tue, 20 Oct 2015 21:32:12 +0000 (14:32 -0700)
Ticket: CM-6854
Reviewed By: CCR-3297
Testing Done: bgpsmoke, bgpclos to verify setting source (in 2.5-br)

Two pieces prevented the user from specifying a route-map with set src on
IPv4 routes learnt via BGP's RFC 5549 model (v4 prefix with v6 nexthop):
   - There was code missing in the section specific to 5549 in setting
     the src in the netlink message
   - During RIB processing, route-map processing was ignored when the NH
     was v6 and the route itself was v4.

As per the code, all route-map processing that uses nexthop validates the
NH type before applying the route-map and so there should be no errors
as a consequence of relaxing bullet 2 above.

Signed-off-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
zebra/rt_netlink.c
zebra/zebra_rib.c

index dfff7869aad4cf7392dfc285ff3a9d13f40bcf10..4c16df61a1bff1f6e67f66bfede73bb8792898c5 100644 (file)
@@ -1500,6 +1500,13 @@ _netlink_route_build_singlepath(
       addattr_l (nlmsg, req_size, RTA_GATEWAY, &ipv4_ll, 4);
       addattr32 (nlmsg, req_size, RTA_OIF, nexthop->ifindex);
 
+      if (nexthop->rmap_src.ipv4.s_addr && (cmd == RTM_NEWROUTE))
+        addattr_l (nlmsg, req_size, RTA_PREFSRC,
+                   &nexthop->rmap_src.ipv4, bytelen);
+      else if (nexthop->src.ipv4.s_addr && (cmd == RTM_NEWROUTE))
+        addattr_l (nlmsg, req_size, RTA_PREFSRC,
+                   &nexthop->src.ipv4, bytelen);
+
       if (IS_ZEBRA_DEBUG_KERNEL)
         zlog_debug(" 5549: _netlink_route_build_singlepath() (%s): "
                    "nexthop via %s if %u",
@@ -1648,6 +1655,11 @@ _netlink_route_build_multipath(
       rtnh->rtnh_len += sizeof (struct rtattr) + bytelen;
       rtnh->rtnh_ifindex = nexthop->ifindex;
 
+      if (nexthop->rmap_src.ipv4.s_addr)
+        *src = &nexthop->rmap_src;
+      else if (nexthop->src.ipv4.s_addr)
+         *src = &nexthop->src;
+
       if (IS_ZEBRA_DEBUG_KERNEL)
         zlog_debug(" 5549: netlink_route_build_multipath() (%s): "
                    "nexthop via %s if %u",
index 261aed156f4c26a32a4af0aa5fbb9b9d54b5cb30..8e873211a0ddea5629246dc8c6e881881ce49ef7 100644 (file)
@@ -1268,7 +1268,9 @@ nexthop_active_check (struct route_node *rn, struct rib *rib,
        UNSET_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE);
       break;
     case NEXTHOP_TYPE_IPV6_IFINDEX:
-      family = AFI_IP6;
+      /* RFC 5549, v4 prefix with v6 NH */
+      if (rn->p.family != AF_INET)
+       family = AFI_IP6;
       if (IN6_IS_ADDR_LINKLOCAL (&nexthop->gate.ipv6))
        {
          ifp = if_lookup_by_index (nexthop->ifindex);