]> git.puffer.fish Git - matthieu/frr.git/commitdiff
sharpd: Allow sharpd to accept nexthop group as part of route install
authorDonald Sharp <sharpd@cumulusnetworks.com>
Mon, 31 Dec 2018 22:49:47 +0000 (17:49 -0500)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 2 Jan 2019 14:55:51 +0000 (09:55 -0500)
When installing routes via sharpd 'sharp install route... ' command
add the ability to specify a nexthop-group to use.  This will
allow sharpd to create ECMP routes into zebra.

Nexthop-group:
!
nexthop-group JANELLE
  nexthop 192.168.209.1
  nexthop 192.168.210.1
!

The install:

donna.cumulusnetworks.com# sharp install routes 10.0.50.0 nexthop-group JANELLE 10
donna.cumulusnetworks.com# end
donna.cumulusnetworks.com# 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

K>* 0.0.0.0/0 [0/106] via 10.0.2.2, enp0s3, 00:20:38
C>* 10.0.2.0/24 is directly connected, enp0s3, 00:20:38
D>* 10.0.50.0/32 [150/0] via 192.168.209.1, enp0s8, 00:00:02
  *                      via 192.168.210.1, enp0s9, 00:00:02
D>* 10.0.50.1/32 [150/0] via 192.168.209.1, enp0s8, 00:00:02
  *                      via 192.168.210.1, enp0s9, 00:00:02
D>* 10.0.50.2/32 [150/0] via 192.168.209.1, enp0s8, 00:00:02
  *                      via 192.168.210.1, enp0s9, 00:00:02
D>* 10.0.50.3/32 [150/0] via 192.168.209.1, enp0s8, 00:00:02
  *                      via 192.168.210.1, enp0s9, 00:00:02
D>* 10.0.50.4/32 [150/0] via 192.168.209.1, enp0s8, 00:00:02
  *                      via 192.168.210.1, enp0s9, 00:00:02
D>* 10.0.50.5/32 [150/0] via 192.168.209.1, enp0s8, 00:00:02
  *                      via 192.168.210.1, enp0s9, 00:00:02
D>* 10.0.50.6/32 [150/0] via 192.168.209.1, enp0s8, 00:00:02
  *                      via 192.168.210.1, enp0s9, 00:00:02
D>* 10.0.50.7/32 [150/0] via 192.168.209.1, enp0s8, 00:00:02
  *                      via 192.168.210.1, enp0s9, 00:00:02
D>* 10.0.50.8/32 [150/0] via 192.168.209.1, enp0s8, 00:00:02
  *                      via 192.168.210.1, enp0s9, 00:00:02
D>* 10.0.50.9/32 [150/0] via 192.168.209.1, enp0s8, 00:00:02
  *                      via 192.168.210.1, enp0s9, 00:00:02
C>* 192.168.209.0/24 is directly connected, enp0s8, 00:20:38
C>* 192.168.210.0/24 is directly connected, enp0s9, 00:20:38
donna.cumulusnetworks.com#

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
sharpd/sharp_vty.c

index 700b5a911c43c0d78f0ee266b1fad4b0667e6b4f..3aed8eb1231623cc40eafc22f44f0dc5ef5eb99e 100644 (file)
@@ -82,7 +82,7 @@ DEFPY(watch_nexthop_v4, watch_nexthop_v4_cmd,
 
 DEFPY (install_routes,
        install_routes_cmd,
-       "sharp install routes A.B.C.D$start nexthop <A.B.C.D$nexthop4|X:X::X:X$nexthop6> (1-1000000)$routes [instance (0-255)$instance]",
+       "sharp install routes A.B.C.D$start <nexthop <A.B.C.D$nexthop4|X:X::X:X$nexthop6>|nexthop-group NAME$nexthop_group> (1-1000000)$routes [instance (0-255)$instance]",
        "Sharp routing Protocol\n"
        "install some routes\n"
        "Routes to install\n"
@@ -90,6 +90,8 @@ DEFPY (install_routes,
        "Nexthop to use(Can be an IPv4 or IPv6 address)\n"
        "V4 Nexthop address to use\n"
        "V6 Nexthop address to use\n"
+       "Nexthop-Group to use\n"
+       "The Name of the nexthop-group\n"
        "How many to create\n"
        "Instance to use\n"
        "Instance\n")
@@ -111,15 +113,27 @@ DEFPY (install_routes,
        p.prefixlen = 32;
        p.u.prefix4 = start;
 
-       if (nexthop4.s_addr != INADDR_ANY) {
-               nhop.gate.ipv4 = nexthop4;
-               nhop.type = NEXTHOP_TYPE_IPV4;
+       if (nexthop_group) {
+               struct nexthop_group_cmd *nhgc = nhgc_find(nexthop_group);
+               if (!nhgc) {
+                       vty_out(vty,
+                               "Specified Nexthop Group: %s does not exist\n",
+                               nexthop_group);
+                       return CMD_WARNING;
+               }
+
+               nhg.nexthop = nhgc->nhg.nexthop;
        } else {
-               memcpy(&nhop.gate.ipv6, &nexthop6, IPV6_MAX_BYTELEN);
-               nhop.type = NEXTHOP_TYPE_IPV6;
+               if (nexthop4.s_addr != INADDR_ANY) {
+                       nhop.gate.ipv4 = nexthop4;
+                       nhop.type = NEXTHOP_TYPE_IPV4;
+               } else {
+                       nhop.gate.ipv6 = nexthop6;
+                       nhop.type = NEXTHOP_TYPE_IPV6;
+               }
+
+               nhg.nexthop = &nhop;
        }
-
-       nhg.nexthop = &nhop;
        zlog_debug("Inserting %ld routes", routes);
 
        temp = ntohl(p.u.prefix4.s_addr);