summaryrefslogtreecommitdiffstats
path: root/sharpd
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2019-01-10 00:58:36 +0100
committerDonald Sharp <sharpd@cumulusnetworks.com>2019-01-11 01:26:31 +0100
commitdbc1bf462b5ca972b26e6e12a665f3a4625b3557 (patch)
treec1f1860a1e400e9595594d26316489848ca5b644 /sharpd
parentlib: Add another 32 bit accessor to the prefix data structure (diff)
downloadfrr-dbc1bf462b5ca972b26e6e12a665f3a4625b3557.tar.xz
frr-dbc1bf462b5ca972b26e6e12a665f3a4625b3557.zip
sharpd: Allow route install/removal of v6 routes.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'sharpd')
-rw-r--r--sharpd/sharp_vty.c31
-rw-r--r--sharpd/sharp_zebra.c26
2 files changed, 44 insertions, 13 deletions
diff --git a/sharpd/sharp_vty.c b/sharpd/sharp_vty.c
index d0a34c0f9..ea878323f 100644
--- a/sharpd/sharp_vty.c
+++ b/sharpd/sharp_vty.c
@@ -90,11 +90,12 @@ 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>|nexthop-group NAME$nexthop_group> (1-1000000)$routes [instance (0-255)$instance] [repeat (2-1000)$rpt]",
+ "sharp install routes <A.B.C.D$start4|X:X::X:X$start6> <nexthop <A.B.C.D$nexthop4|X:X::X:X$nexthop6>|nexthop-group NAME$nexthop_group> (1-1000000)$routes [instance (0-255)$instance] [repeat (2-1000)$rpt]",
"Sharp routing Protocol\n"
"install some routes\n"
"Routes to install\n"
- "Address to start /32 generation at\n"
+ "v4 Address to start /32 generation at\n"
+ "v6 Address to start /32 generation at\n"
"Nexthop to use(Can be an IPv4 or IPv6 address)\n"
"V4 Nexthop address to use\n"
"V6 Nexthop address to use\n"
@@ -119,9 +120,15 @@ DEFPY (install_routes,
memset(&nhop, 0, sizeof(nhop));
memset(&nhop_group, 0, sizeof(nhop_group));
- prefix.family = AF_INET;
- prefix.prefixlen = 32;
- prefix.u.prefix4 = start;
+ if (start4.s_addr != 0) {
+ prefix.family = AF_INET;
+ prefix.prefixlen = 32;
+ prefix.u.prefix4 = start4;
+ } else {
+ prefix.family = AF_INET6;
+ prefix.prefixlen = 128;
+ prefix.u.prefix6 = start6;
+ }
orig_prefix = prefix;
if (nexthop_group) {
@@ -185,7 +192,7 @@ DEFPY(vrf_label, vrf_label_cmd,
DEFPY (remove_routes,
remove_routes_cmd,
- "sharp remove routes A.B.C.D$start (1-1000000)$routes [instance (0-255)$instance]",
+ "sharp remove routes <A.B.C.D$start4|X:X::X:X$start6> (1-1000000)$routes [instance (0-255)$instance]",
"Sharp Routing Protocol\n"
"Remove some routes\n"
"Routes to remove\n"
@@ -199,9 +206,15 @@ DEFPY (remove_routes,
memset(&prefix, 0, sizeof(prefix));
- prefix.family = AF_INET;
- prefix.prefixlen = 32;
- prefix.u.prefix4 = start;
+ if (start4.s_addr != 0) {
+ prefix.family = AF_INET;
+ prefix.prefixlen = 32;
+ prefix.u.prefix4 = start4;
+ } else {
+ prefix.family = AF_INET6;
+ prefix.prefixlen = 128;
+ prefix.u.prefix6 = start6;
+ }
inst = instance;
rts = routes;
diff --git a/sharpd/sharp_zebra.c b/sharpd/sharp_zebra.c
index 37591fa41..8d6260494 100644
--- a/sharpd/sharp_zebra.c
+++ b/sharpd/sharp_zebra.c
@@ -142,13 +142,22 @@ void sharp_install_routes_helper(struct prefix *p, uint8_t instance,
uint32_t routes)
{
uint32_t temp, i;
+ bool v4 = false;
zlog_debug("Inserting %u routes", routes);
- temp = ntohl(p->u.prefix4.s_addr);
+ if (p->family == AF_INET) {
+ v4 = true;
+ temp = ntohl(p->u.prefix4.s_addr);
+ } else
+ temp = ntohl(p->u.val32[3]);
+
for (i = 0; i < routes; i++) {
route_add(p, (uint8_t)instance, nhg);
- p->u.prefix4.s_addr = htonl(++temp);
+ if (v4)
+ p->u.prefix4.s_addr = htonl(++temp);
+ else
+ p->u.val32[3] = htonl(++temp);
}
}
@@ -156,13 +165,22 @@ void sharp_remove_routes_helper(struct prefix *p, uint8_t instance,
uint32_t routes)
{
uint32_t temp, i;
+ bool v4 = false;
zlog_debug("Removing %u routes", routes);
- temp = ntohl(p->u.prefix4.s_addr);
+ if (p->family == AF_INET) {
+ v4 = true;
+ temp = ntohl(p->u.prefix4.s_addr);
+ } else
+ temp = ntohl(p->u.val32[3]);
+
for (i = 0; i < routes; i++) {
route_delete(p, (uint8_t)instance);
- p->u.prefix4.s_addr = htonl(++temp);
+ if (v4)
+ p->u.prefix4.s_addr = htonl(++temp);
+ else
+ p->u.val32[3] = htonl(++temp);
}
}