diff options
author | Mark Stapp <mjs@voltanet.io> | 2019-01-11 13:54:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-11 13:54:18 +0100 |
commit | e8aa58a5b92133477a37fbc011411ea5d9850611 (patch) | |
tree | d59813bd88cbd3b9c9f32887cbb38cadbf09802e | |
parent | Merge pull request #3511 from pguibert6WIND/handle_multiple_netns_delete_event (diff) | |
parent | sharpd: Do addition/subtraction for me (diff) | |
download | frr-e8aa58a5b92133477a37fbc011411ea5d9850611.tar.xz frr-e8aa58a5b92133477a37fbc011411ea5d9850611.zip |
Merge pull request #3591 from donaldsharp/sharp_v6
Sharp v6 and stuff
Diffstat (limited to '')
-rw-r--r-- | lib/prefix.h | 1 | ||||
-rw-r--r-- | sharpd/sharp_vty.c | 31 | ||||
-rw-r--r-- | sharpd/sharp_zebra.c | 41 |
3 files changed, 58 insertions, 15 deletions
diff --git a/lib/prefix.h b/lib/prefix.h index 424756913..04c62b19e 100644 --- a/lib/prefix.h +++ b/lib/prefix.h @@ -162,6 +162,7 @@ struct prefix { } lp; struct ethaddr prefix_eth; /* AF_ETHERNET */ uint8_t val[16]; + uint32_t val32[4]; uintptr_t ptr; struct evpn_addr prefix_evpn; /* AF_EVPN */ struct flowspec_prefix prefix_flowspec; /* AF_FLOWSPEC */ 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..c9f333e34 100644 --- a/sharpd/sharp_zebra.c +++ b/sharpd/sharp_zebra.c @@ -129,6 +129,8 @@ static int interface_state_down(int command, struct zclient *zclient, return 0; } +static struct timeval t_start; +static struct timeval t_end; extern uint32_t total_routes; extern uint32_t installed_routes; extern uint32_t removed_routes; @@ -142,13 +144,23 @@ 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]); + + monotime(&t_start); 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 +168,23 @@ 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]); + + monotime(&t_start); 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); } } @@ -189,6 +211,7 @@ static void handle_repeated(bool installed) static int route_notify_owner(int command, struct zclient *zclient, zebra_size_t length, vrf_id_t vrf_id) { + struct timeval r; struct prefix p; enum zapi_route_notify_owner note; uint32_t table; @@ -200,7 +223,10 @@ static int route_notify_owner(int command, struct zclient *zclient, case ZAPI_ROUTE_INSTALLED: installed_routes++; if (total_routes == installed_routes) { - zlog_debug("Installed All Items"); + monotime(&t_end); + timersub(&t_end, &t_start, &r); + zlog_debug("Installed All Items %ld.%ld", r.tv_sec, + r.tv_usec); handle_repeated(true); } break; @@ -213,7 +239,10 @@ static int route_notify_owner(int command, struct zclient *zclient, case ZAPI_ROUTE_REMOVED: removed_routes++; if (total_routes == removed_routes) { - zlog_debug("Removed all Items"); + monotime(&t_end); + timersub(&t_end, &t_start, &r); + zlog_debug("Removed all Items %ld.%ld", r.tv_sec, + r.tv_usec); handle_repeated(false); } break; |