Skip to content

Commit 446b399

Browse files
committed
ospf: route retransmit-interval and transmit-delay CLI through ietf-ospf YANG
Extends the per-interface CLI-through-YANG conversion already done for cost / hello-interval / dead-interval / priority / mtu-ignore / passive to the two remaining per-interface scalars that have RFC 9129 callbacks: retransmit-interval and transmit-delay. Commands converted on each daemon: v2: ip ospf retransmit-interval / no ip ospf retransmit-interval + the hidden `ospf retransmit-interval` / `no ospf retransmit-interval` backwards-compat aliases ip ospf transmit-delay / no ip ospf transmit-delay + the matching hidden `ospf transmit-delay` / `no ospf transmit-delay` aliases v3: ipv6 ospf6 retransmit-interval / no ipv6 ospf6 retransmit-interval ipv6 ospf6 transmit-delay / no ipv6 ospf6 transmit-delay Conversion pattern (matches the cost / hello / dead / priority / mtu-ignore / passive slice): * v2 commands take an optional `[A.B.C.D]` per-address override that has no RFC 9129 representation. Each DEFPY_YANG body checks `if (!ifaddr_str && per_iface_xpath returns 0)` and dispatches through nb_cli_enqueue_change / nb_cli_apply_changes; on the negative path it falls back to the legacy direct-mutation logic, preserving the per-address-override capability for operators that need it. * The YANG path also requires the interface to be in an area (if_area on IF_DEF_PARAMS). Operators setting per-interface attrs on an unattached interface continue to use the legacy path -- the YANG model can't express "interface params before area assignment" because the leaves live under areas/area[id]/interfaces. * Per-leaf bodies factor into small `_set_apply` / `_unset_apply` helpers shared by the main `ip ospf X` form and the hidden backwards-compat `ospf X` alias (v2 only). * v3 collapses the legacy DEFUN+ALIAS pair into two DEFPY_YANG forms (one for set, one for `no`), each guarded by `ospf6_per_iface_xpath` before falling back to direct ospf6_interface mutation. Topotest: extends `test_ospf_per_iface_cli_routes_through_yang` to drive `ip ospf retransmit-interval 23` + `ip ospf transmit-delay 31` (and v3 equivalents) on r1-eth1 alongside the previously-covered six leaves, verifies each lands in `show running-config <daemon>`, then unwinds via `no` and verifies absence. The `b3b` and `transmit-delay` focused mgmtd-write tests continue to cover the YANG-side of the round-trip. Doc: no change. The converted-leaves paragraph already lists retransmit-interval and transmit-delay; the "Existing CLI commands for those leaves set the same YANG nodes as mgmtd writes" sentence now becomes accurate for these two. Signed-off-by: Eric Parsonage <eric@eparsonage.com>
1 parent f150c86 commit 446b399

3 files changed

Lines changed: 223 additions & 117 deletions

File tree

ospf6d/ospf6_interface.c

Lines changed: 60 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2494,72 +2494,116 @@ DEFPY(no_ipv6_ospf6_gr_hdelay,
24942494
}
24952495

24962496
/* interface variable set command */
2497-
DEFUN (ipv6_ospf6_transmitdelay,
2497+
DEFPY_YANG (ipv6_ospf6_transmitdelay,
24982498
ipv6_ospf6_transmitdelay_cmd,
2499-
"ipv6 ospf6 transmit-delay (1-3600)",
2499+
"ipv6 ospf6 transmit-delay (1-3600)$interval",
25002500
IP6_STR
25012501
OSPF6_STR
25022502
"Link state transmit delay\n"
25032503
SECONDS_STR)
25042504
{
25052505
VTY_DECLVAR_CONTEXT(interface, ifp);
2506-
int idx_number = 3;
25072506
struct ospf6_interface *oi;
2507+
char xpath[XPATH_MAXLEN];
2508+
25082509
assert(ifp);
2510+
if (ospf6_per_iface_xpath(xpath, sizeof(xpath), ifp,
2511+
"/transmit-delay") == 0) {
2512+
nb_cli_enqueue_change(vty, xpath, NB_OP_MODIFY, interval_str);
2513+
return nb_cli_apply_changes(vty, NULL);
2514+
}
25092515

25102516
oi = (struct ospf6_interface *)ifp->info;
25112517
if (oi == NULL)
25122518
oi = ospf6_interface_create(ifp);
25132519
assert(oi);
2514-
2515-
oi->transdelay = strmatch(argv[0]->text, "no")
2516-
? OSPF6_INTERFACE_TRANSDELAY
2517-
: strtoul(argv[idx_number]->arg, NULL, 10);
2520+
oi->transdelay = interval;
25182521
return CMD_SUCCESS;
25192522
}
25202523

2521-
ALIAS (ipv6_ospf6_transmitdelay,
2524+
DEFPY_YANG (no_ipv6_ospf6_transmitdelay,
25222525
no_ipv6_ospf6_transmitdelay_cmd,
25232526
"no ipv6 ospf6 transmit-delay [(1-3600)]",
25242527
NO_STR
25252528
IP6_STR
25262529
OSPF6_STR
25272530
"Link state transmit delay\n"
25282531
SECONDS_STR)
2532+
{
2533+
VTY_DECLVAR_CONTEXT(interface, ifp);
2534+
struct ospf6_interface *oi;
2535+
char xpath[XPATH_MAXLEN];
2536+
2537+
assert(ifp);
2538+
if (ospf6_per_iface_xpath(xpath, sizeof(xpath), ifp,
2539+
"/transmit-delay") == 0) {
2540+
nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
2541+
return nb_cli_apply_changes(vty, NULL);
2542+
}
2543+
2544+
oi = (struct ospf6_interface *)ifp->info;
2545+
if (oi == NULL)
2546+
oi = ospf6_interface_create(ifp);
2547+
assert(oi);
2548+
oi->transdelay = OSPF6_INTERFACE_TRANSDELAY;
2549+
return CMD_SUCCESS;
2550+
}
25292551

25302552
/* interface variable set command */
2531-
DEFUN (ipv6_ospf6_retransmitinterval,
2553+
DEFPY_YANG (ipv6_ospf6_retransmitinterval,
25322554
ipv6_ospf6_retransmitinterval_cmd,
2533-
"ipv6 ospf6 retransmit-interval (1-65535)",
2555+
"ipv6 ospf6 retransmit-interval (1-65535)$interval",
25342556
IP6_STR
25352557
OSPF6_STR
25362558
"Time between retransmitting lost link state advertisements\n"
25372559
SECONDS_STR)
25382560
{
25392561
VTY_DECLVAR_CONTEXT(interface, ifp);
2540-
int idx_number = 3;
25412562
struct ospf6_interface *oi;
2563+
char xpath[XPATH_MAXLEN];
2564+
25422565
assert(ifp);
2566+
if (ospf6_per_iface_xpath(xpath, sizeof(xpath), ifp,
2567+
"/retransmit-interval") == 0) {
2568+
nb_cli_enqueue_change(vty, xpath, NB_OP_MODIFY, interval_str);
2569+
return nb_cli_apply_changes(vty, NULL);
2570+
}
25432571

25442572
oi = (struct ospf6_interface *)ifp->info;
25452573
if (oi == NULL)
25462574
oi = ospf6_interface_create(ifp);
25472575
assert(oi);
2548-
2549-
oi->rxmt_interval = strmatch(argv[0]->text, "no")
2550-
? OSPF_RETRANSMIT_INTERVAL_DEFAULT
2551-
: strtoul(argv[idx_number]->arg, NULL, 10);
2576+
oi->rxmt_interval = interval;
25522577
return CMD_SUCCESS;
25532578
}
25542579

2555-
ALIAS (ipv6_ospf6_retransmitinterval,
2580+
DEFPY_YANG (no_ipv6_ospf6_retransmitinterval,
25562581
no_ipv6_ospf6_retransmitinterval_cmd,
25572582
"no ipv6 ospf6 retransmit-interval [(1-65535)]",
25582583
NO_STR
25592584
IP6_STR
25602585
OSPF6_STR
25612586
"Time between retransmitting lost link state advertisements\n"
25622587
SECONDS_STR)
2588+
{
2589+
VTY_DECLVAR_CONTEXT(interface, ifp);
2590+
struct ospf6_interface *oi;
2591+
char xpath[XPATH_MAXLEN];
2592+
2593+
assert(ifp);
2594+
if (ospf6_per_iface_xpath(xpath, sizeof(xpath), ifp,
2595+
"/retransmit-interval") == 0) {
2596+
nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
2597+
return nb_cli_apply_changes(vty, NULL);
2598+
}
2599+
2600+
oi = (struct ospf6_interface *)ifp->info;
2601+
if (oi == NULL)
2602+
oi = ospf6_interface_create(ifp);
2603+
assert(oi);
2604+
oi->rxmt_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
2605+
return CMD_SUCCESS;
2606+
}
25632607

25642608
void ospf6_priority_recompute(struct ospf6_interface *oi)
25652609
{

0 commit comments

Comments
 (0)