summaryrefslogtreecommitdiffstats
path: root/sharpd
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2019-01-03 15:49:15 +0100
committerDonald Sharp <sharpd@cumulusnetworks.com>2019-01-03 15:49:15 +0100
commitb939f6ff513808aba46f4797a4349d85989ae01b (patch)
tree8e3d73e412eb92e05026d1094f610dd72e6a1344 /sharpd
parentsharpd: Abstract the route install/delete functions a bit (diff)
downloadfrr-b939f6ff513808aba46f4797a4349d85989ae01b.tar.xz
frr-b939f6ff513808aba46f4797a4349d85989ae01b.zip
sharpd: Add code to allow install/uninstall repeatedly
Add a bit of test code to allow the tester to install/uninstall the routes via: sharp install routes A.B.C.D nexthop Y.Z.M.D 1000000 repeat 100 This will install 1000000 routes wait for them to be finished then uninstall them then start installation over 100 times. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com.
Diffstat (limited to 'sharpd')
-rw-r--r--sharpd/sharp_vty.c58
-rw-r--r--sharpd/sharp_zebra.c12
2 files changed, 45 insertions, 25 deletions
diff --git a/sharpd/sharp_vty.c b/sharpd/sharp_vty.c
index abc2c720c..d0a34c0f9 100644
--- a/sharpd/sharp_vty.c
+++ b/sharpd/sharp_vty.c
@@ -40,6 +40,14 @@ extern uint32_t total_routes;
extern uint32_t installed_routes;
extern uint32_t removed_routes;
+uint8_t inst;
+struct prefix prefix;
+struct prefix orig_prefix;
+struct nexthop nhop;
+struct nexthop_group nhop_group;
+uint32_t rts;
+int32_t repeat;
+
DEFPY(watch_nexthop_v6, watch_nexthop_v6_cmd,
"sharp watch nexthop X:X::X:X$nhop",
"Sharp routing Protocol\n"
@@ -80,11 +88,9 @@ DEFPY(watch_nexthop_v4, watch_nexthop_v4_cmd,
return CMD_SUCCESS;
}
-
-
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]",
+ "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 routing Protocol\n"
"install some routes\n"
"Routes to install\n"
@@ -96,22 +102,27 @@ DEFPY (install_routes,
"The Name of the nexthop-group\n"
"How many to create\n"
"Instance to use\n"
- "Instance\n")
+ "Instance\n"
+ "Should we repeat this command\n"
+ "How many times to repeat this command\n")
{
- struct prefix p;
- struct nexthop nhop;
- struct nexthop_group nhg;
-
total_routes = routes;
installed_routes = 0;
- memset(&p, 0, sizeof(p));
+ if (rpt >= 2)
+ repeat = rpt * 2;
+ else
+ repeat = 0;
+
+ memset(&prefix, 0, sizeof(prefix));
+ memset(&orig_prefix, 0, sizeof(orig_prefix));
memset(&nhop, 0, sizeof(nhop));
- memset(&nhg, 0, sizeof(nhg));
+ memset(&nhop_group, 0, sizeof(nhop_group));
- p.family = AF_INET;
- p.prefixlen = 32;
- p.u.prefix4 = start;
+ prefix.family = AF_INET;
+ prefix.prefixlen = 32;
+ prefix.u.prefix4 = start;
+ orig_prefix = prefix;
if (nexthop_group) {
struct nexthop_group_cmd *nhgc = nhgc_find(nexthop_group);
@@ -122,7 +133,7 @@ DEFPY (install_routes,
return CMD_WARNING;
}
- nhg.nexthop = nhgc->nhg.nexthop;
+ nhop_group.nexthop = nhgc->nhg.nexthop;
} else {
if (nexthop4.s_addr != INADDR_ANY) {
nhop.gate.ipv4 = nexthop4;
@@ -132,10 +143,12 @@ DEFPY (install_routes,
nhop.type = NEXTHOP_TYPE_IPV6;
}
- nhg.nexthop = &nhop;
+ nhop_group.nexthop = &nhop;
}
- sharp_install_routes_helper(&p, instance, &nhg, routes);
+ inst = instance;
+ rts = routes;
+ sharp_install_routes_helper(&prefix, inst, &nhop_group, rts);
return CMD_SUCCESS;
}
@@ -181,17 +194,18 @@ DEFPY (remove_routes,
"instance to use\n"
"Value of instance\n")
{
- struct prefix p;
total_routes = routes;
removed_routes = 0;
- memset(&p, 0, sizeof(p));
+ memset(&prefix, 0, sizeof(prefix));
- p.family = AF_INET;
- p.prefixlen = 32;
- p.u.prefix4 = start;
+ prefix.family = AF_INET;
+ prefix.prefixlen = 32;
+ prefix.u.prefix4 = start;
- sharp_remove_routes_helper(&p, instance, routes);
+ inst = instance;
+ rts = routes;
+ sharp_remove_routes_helper(&prefix, inst, rts);
return CMD_SUCCESS;
}
diff --git a/sharpd/sharp_zebra.c b/sharpd/sharp_zebra.c
index 72e1eb2b2..37591fa41 100644
--- a/sharpd/sharp_zebra.c
+++ b/sharpd/sharp_zebra.c
@@ -132,6 +132,10 @@ static int interface_state_down(int command, struct zclient *zclient,
extern uint32_t total_routes;
extern uint32_t installed_routes;
extern uint32_t removed_routes;
+extern int32_t repeat;
+extern struct prefix orig_prefix;
+extern struct nexthop_group nhop_group;
+extern uint8_t inst;
void sharp_install_routes_helper(struct prefix *p, uint8_t instance,
struct nexthop_group *nhg,
@@ -162,8 +166,9 @@ void sharp_remove_routes_helper(struct prefix *p, uint8_t instance,
}
}
-static int handle_repeated(bool installed)
+static void handle_repeated(bool installed)
{
+ struct prefix p = orig_prefix;
repeat--;
if (repeat <= 0)
@@ -171,12 +176,13 @@ static int handle_repeated(bool installed)
if (installed) {
removed_routes = 0;
- sharp_remove_routes_helper(&prefix, inst, total_routes);
+ sharp_remove_routes_helper(&p, inst, total_routes);
}
if (!installed) {
installed_routes = 0;
- sharp_remove_routes
+ sharp_install_routes_helper(&p, inst, &nhop_group,
+ total_routes);
}
}