Skip to content

Commit 2b7160c

Browse files
authored
Merge pull request FRRouting#20634 from donaldsharp/sharp_send_tableid_for_route
2 parents c140bbc + 43c4fee commit 2b7160c

File tree

5 files changed

+144
-63
lines changed

5 files changed

+144
-63
lines changed

doc/user/sharp.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Using SHARP
2828
All sharp commands are under the enable node and preceded by the ``sharp``
2929
keyword. At present, no sharp commands will be preserved in the config.
3030

31-
.. clicmd:: sharp install routes A.B.C.D <nexthop <E.F.G.H|X:X::X:X>|nexthop-group NAME> (1-1000000) [instance (0-255)] [repeat (2-1000)] [opaque WORD]
31+
.. clicmd:: sharp install routes A.B.C.D <nexthop <E.F.G.H|X:X::X:X>|nexthop-group NAME> (1-1000000) [table (0-4294967295)] [instance (0-255)] [repeat (2-1000)] [opaque WORD]
3232

3333
Install up to 1,000,000 (one million) /32 routes starting at ``A.B.C.D``
3434
with specified nexthop ``E.F.G.H`` or ``X:X::X:X``. The nexthop is
@@ -51,6 +51,11 @@ keyword. At present, no sharp commands will be preserved in the config.
5151
log and when all routes have been successfully deleted the debug log will be
5252
updated with this information as well.
5353

54+
.. clicmd:: sharp install stop
55+
56+
If sharpd is operating in a repeat loop, stop the repeat and remove
57+
any installed routes.
58+
5459
.. clicmd:: sharp data route
5560

5661
Allow end user doing route install and deletion to get timing information

sharpd/sharp_globals.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ struct sharp_routes {
3030
/* ZAPI_ROUTE's flag */
3131
uint32_t flags;
3232

33+
bool tableid_set;
34+
uint32_t tableid;
35+
bool stop_loop;
36+
3337
uint8_t inst;
3438
vrf_id_t vrf_id;
3539

sharpd/sharp_vty.c

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,24 @@ DEFPY (install_routes_data_dump,
200200
return CMD_SUCCESS;
201201
}
202202

203+
DEFPY(sharp_install_stop_vty, sharp_install_stop_cmd, "sharp install stop",
204+
"Sharp routing Protocol\n"
205+
"install some routes\n"
206+
"Stop any repeating install/remove loops\n")
207+
{
208+
sharp_install_stop();
209+
210+
return CMD_SUCCESS;
211+
}
212+
203213
DEFPY (install_routes,
204214
install_routes_cmd,
205215
"sharp install routes [vrf NAME$vrf_name]\
206216
<A.B.C.D$start4|X:X::X:X$start6>\
207217
<nexthop <A.B.C.D$nexthop4|X:X::X:X$nexthop6>|\
208218
nexthop-group NHGNAME$nexthop_group>\
209219
[backup$backup <A.B.C.D$backup_nexthop4|X:X::X:X$backup_nexthop6>] \
210-
(1-1000000)$routes [instance (0-255)$instance] [repeat (2-1000)$rpt] [opaque WORD] [no-recurse$norecurse]",
220+
(1-1000000)$routes [instance (0-255)$instance] [table (0-4294967295)$table_id] [repeat (2-1000)$rpt] [opaque WORD] [no-recurse$norecurse]",
211221
"Sharp routing Protocol\n"
212222
"install some routes\n"
213223
"Routes to install\n"
@@ -226,6 +236,8 @@ DEFPY (install_routes,
226236
"How many to create\n"
227237
"Instance to use\n"
228238
"Instance\n"
239+
"Table to install into\n"
240+
"Table id\n"
229241
"Should we repeat this command\n"
230242
"How many times to repeat this command\n"
231243
"What opaque data to send down\n"
@@ -240,6 +252,9 @@ DEFPY (install_routes,
240252
sg.r.total_routes = routes;
241253
sg.r.installed_routes = 0;
242254
sg.r.flags = 0;
255+
sg.r.tableid = 0;
256+
sg.r.tableid_set = false;
257+
sg.r.stop_loop = false;
243258

244259
if (rpt >= 2)
245260
sg.r.repeat = rpt * 2;
@@ -347,16 +362,21 @@ DEFPY (install_routes,
347362
else
348363
sg.r.opaque[0] = '\0';
349364

365+
if (table_id_str) {
366+
sg.r.tableid = (uint32_t)table_id;
367+
sg.r.tableid_set = true;
368+
}
369+
350370
/* Default is to ask for recursive nexthop resolution */
351371
if (norecurse == NULL)
352372
SET_FLAG(sg.r.flags, ZEBRA_FLAG_ALLOW_RECURSION);
353373

354374
sg.r.inst = instance;
355375
sg.r.vrf_id = vrf->vrf_id;
356376
rts = routes;
357-
sharp_install_routes_helper(&prefix, sg.r.vrf_id, sg.r.inst, nhgid,
358-
&sg.r.nhop_group, &sg.r.backup_nhop_group,
359-
rts, sg.r.flags, sg.r.opaque);
377+
sharp_install_routes_helper(&prefix, sg.r.vrf_id, sg.r.inst, nhgid, &sg.r.nhop_group,
378+
&sg.r.backup_nhop_group, rts, sg.r.flags, sg.r.opaque,
379+
sg.r.tableid, sg.r.tableid_set);
360380

361381
return CMD_SUCCESS;
362382
}
@@ -388,6 +408,7 @@ DEFPY (install_seg6_routes,
388408

389409
sg.r.total_routes = routes;
390410
sg.r.installed_routes = 0;
411+
sg.r.stop_loop = false;
391412

392413
if (rpt >= 2)
393414
sg.r.repeat = rpt * 2;
@@ -433,9 +454,9 @@ DEFPY (install_seg6_routes,
433454
nexthop_add_srv6_seg6(&sg.r.nhop, &seg6_seg, 1, SRV6_HEADEND_BEHAVIOR_H_ENCAPS);
434455

435456
sg.r.vrf_id = vrf->vrf_id;
436-
sharp_install_routes_helper(&prefix, sg.r.vrf_id, sg.r.inst, 0,
437-
&sg.r.nhop_group, &sg.r.backup_nhop_group,
438-
routes, route_flags, sg.r.opaque);
457+
sharp_install_routes_helper(&prefix, sg.r.vrf_id, sg.r.inst, 0, &sg.r.nhop_group,
458+
&sg.r.backup_nhop_group, routes, route_flags, sg.r.opaque, 0,
459+
false);
439460

440461
return CMD_SUCCESS;
441462
}
@@ -481,6 +502,7 @@ DEFPY(install_seg6local_segs_routes, install_seg6local_segs_routes_cmd,
481502

482503
sg.r.total_routes = routes;
483504
sg.r.installed_routes = 0;
505+
sg.r.stop_loop = false;
484506

485507
if (rpt >= 2)
486508
sg.r.repeat = rpt * 2;
@@ -532,7 +554,8 @@ DEFPY(install_seg6local_segs_routes, install_seg6local_segs_routes_cmd,
532554

533555
sg.r.vrf_id = vrf->vrf_id;
534556
sharp_install_routes_helper(&sg.r.orig_prefix, sg.r.vrf_id, sg.r.inst, 0, &sg.r.nhop_group,
535-
&sg.r.backup_nhop_group, routes, route_flags, sg.r.opaque);
557+
&sg.r.backup_nhop_group, routes, route_flags, sg.r.opaque, 0,
558+
false);
536559

537560
return CMD_SUCCESS;
538561
}
@@ -615,6 +638,7 @@ DEFPY (install_seg6local_routes,
615638

616639
sg.r.total_routes = routes;
617640
sg.r.installed_routes = 0;
641+
sg.r.stop_loop = false;
618642

619643
if (rpt >= 2)
620644
sg.r.repeat = rpt * 2;
@@ -717,10 +741,9 @@ DEFPY (install_seg6local_routes,
717741
nexthop_add_srv6_seg6local(&sg.r.nhop, action, &ctx);
718742

719743
sg.r.vrf_id = vrf->vrf_id;
720-
sharp_install_routes_helper(&sg.r.orig_prefix, sg.r.vrf_id, sg.r.inst,
721-
0, &sg.r.nhop_group,
722-
&sg.r.backup_nhop_group, routes,
723-
route_flags, sg.r.opaque);
744+
sharp_install_routes_helper(&sg.r.orig_prefix, sg.r.vrf_id, sg.r.inst, 0, &sg.r.nhop_group,
745+
&sg.r.backup_nhop_group, routes, route_flags, sg.r.opaque, 0,
746+
false);
724747

725748
return CMD_SUCCESS;
726749
}
@@ -757,7 +780,7 @@ DEFPY(vrf_label, vrf_label_cmd,
757780

758781
DEFPY (remove_routes,
759782
remove_routes_cmd,
760-
"sharp remove routes [vrf NAME$vrf_name] <A.B.C.D$start4|X:X::X:X$start6> (1-1000000)$routes [instance (0-255)$instance]",
783+
"sharp remove routes [vrf NAME$vrf_name] <A.B.C.D$start4|X:X::X:X$start6> (1-1000000)$routes [instance (0-255)$instance] [table (0-4294967295)$table_id]",
761784
"Sharp Routing Protocol\n"
762785
"Remove some routes\n"
763786
"Routes to remove\n"
@@ -767,13 +790,16 @@ DEFPY (remove_routes,
767790
"v6 Starting spot\n"
768791
"Routes to uninstall\n"
769792
"instance to use\n"
770-
"Value of instance\n")
793+
"Value of instance\n"
794+
"Table to remove from\n"
795+
"Table id\n")
771796
{
772797
struct vrf *vrf;
773798
struct prefix prefix;
774799

775800
sg.r.total_routes = routes;
776801
sg.r.removed_routes = 0;
802+
sg.r.stop_loop = false;
777803
uint32_t rts;
778804

779805
memset(&prefix, 0, sizeof(prefix));
@@ -797,9 +823,15 @@ DEFPY (remove_routes,
797823

798824
sg.r.inst = instance;
799825
sg.r.vrf_id = vrf->vrf_id;
826+
sg.r.tableid = 0;
827+
sg.r.tableid_set = false;
828+
if (table_id_str) {
829+
sg.r.tableid = (uint32_t)table_id;
830+
sg.r.tableid_set = true;
831+
}
800832
rts = routes;
801-
sharp_remove_routes_helper(&prefix, sg.r.vrf_id,
802-
sg.r.inst, rts);
833+
sharp_remove_routes_helper(&prefix, sg.r.vrf_id, sg.r.inst, rts, sg.r.tableid,
834+
sg.r.tableid_set);
803835

804836
return CMD_SUCCESS;
805837
}
@@ -1671,6 +1703,7 @@ DEFPY(sharp_use_resolved_nexthop_weight,
16711703
void sharp_vty_init(void)
16721704
{
16731705
install_element(ENABLE_NODE, &install_routes_data_dump_cmd);
1706+
install_element(ENABLE_NODE, &sharp_install_stop_cmd);
16741707
install_element(ENABLE_NODE, &install_routes_cmd);
16751708
install_element(ENABLE_NODE, &install_seg6_routes_cmd);
16761709
install_element(ENABLE_NODE, &install_seg6local_routes_cmd);

0 commit comments

Comments
 (0)