Skip to content

Commit 8df93dd

Browse files
committed
T8046: FRR: support no version of max-bw etc
Add FRR patch with '[no]' versions for commands: * max-bw * max-rsv-bw * unrsv-bw Without these frr-reload failes after deletion of link-params with these commands.
1 parent 70369b4 commit 8df93dd

1 file changed

Lines changed: 222 additions & 0 deletions

File tree

Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
From 31a0930f89c6de17e8dcc83543f75dab96cd99cf Mon Sep 17 00:00:00 2001
2+
From: Kyrylo Yatsenko <hedrok@gmail.com>
3+
Date: Fri, 19 Dec 2025 10:40:46 +0200
4+
Subject: [PATCH] zebra: add CLI 'no' versions for max-bw and others
5+
6+
Add '[no]' versions for commands:
7+
8+
* max-bw
9+
* max-rsv-bw
10+
* unrsv-bw
11+
12+
Without these frr-reload failed after deletion of link-params with these commands.
13+
14+
For them to work update:
15+
16+
* lib_interface_zebra_link_params_max_bandwidth_destroy
17+
* lib_interface_zebra_link_params_max_reservable_bandwidth_destroy
18+
* lib_interface_zebra_link_params_unreserved_bandwidths_unreserved_bandwidth_destroy
19+
20+
All three forbid to destroy these parameters. New code allows it and
21+
sets value of these parameters to default_bw on removal.
22+
23+
Fixes: #20310
24+
Signed-off-by: Kyrylo Yatsenko <hedrok@gmail.com>
25+
---
26+
zebra/zebra_cli.c | 66 +++++++++++++++++++++++++----------------
27+
zebra/zebra_nb_config.c | 49 ++++++++++++++++++++----------
28+
2 files changed, 75 insertions(+), 40 deletions(-)
29+
30+
diff --git a/zebra/zebra_cli.c b/zebra/zebra_cli.c
31+
index befb3ec6be..3d04c1513d 100644
32+
--- a/zebra/zebra_cli.c
33+
+++ b/zebra/zebra_cli.c
34+
@@ -379,21 +379,25 @@ static void lib_interface_zebra_link_params_metric_cli_write(
35+
36+
DEFPY_YANG (link_params_maxbw,
37+
link_params_maxbw_cmd,
38+
- "max-bw BANDWIDTH",
39+
+ "[no] max-bw BANDWIDTH",
40+
+ NO_STR
41+
"Maximum bandwidth that can be used\n"
42+
"Bytes/second (IEEE floating point format)\n")
43+
{
44+
char value[YANG_VALUE_MAXLEN];
45+
float bw;
46+
47+
- if (sscanf(bandwidth, "%g", &bw) != 1) {
48+
- vty_out(vty, "Invalid bandwidth value\n");
49+
- return CMD_WARNING_CONFIG_FAILED;
50+
- }
51+
+ if (!no) {
52+
+ if (sscanf(bandwidth, "%g", &bw) != 1) {
53+
+ vty_out(vty, "Invalid bandwidth value\n");
54+
+ return CMD_WARNING_CONFIG_FAILED;
55+
+ }
56+
57+
- snprintf(value, sizeof(value), "%a", bw);
58+
+ snprintf(value, sizeof(value), "%a", bw);
59+
60+
- nb_cli_enqueue_change(vty, "./max-bandwidth", NB_OP_MODIFY, value);
61+
+ nb_cli_enqueue_change(vty, "./max-bandwidth", NB_OP_MODIFY, value);
62+
+ } else
63+
+ nb_cli_enqueue_change(vty, "./max-bandwidth", NB_OP_DESTROY, NULL);
64+
65+
return nb_cli_apply_changes(vty, NULL);
66+
}
67+
@@ -408,22 +412,25 @@ static void lib_interface_zebra_link_params_max_bandwidth_cli_write(
68+
69+
DEFPY_YANG (link_params_max_rsv_bw,
70+
link_params_max_rsv_bw_cmd,
71+
- "max-rsv-bw BANDWIDTH",
72+
+ "[no] max-rsv-bw BANDWIDTH",
73+
+ NO_STR
74+
"Maximum bandwidth that may be reserved\n"
75+
"Bytes/second (IEEE floating point format)\n")
76+
{
77+
char value[YANG_VALUE_MAXLEN];
78+
float bw;
79+
80+
- if (sscanf(bandwidth, "%g", &bw) != 1) {
81+
- vty_out(vty, "Invalid bandwidth value\n");
82+
- return CMD_WARNING_CONFIG_FAILED;
83+
- }
84+
+ if (!no) {
85+
+ if (sscanf(bandwidth, "%g", &bw) != 1) {
86+
+ vty_out(vty, "Invalid bandwidth value\n");
87+
+ return CMD_WARNING_CONFIG_FAILED;
88+
+ }
89+
90+
- snprintf(value, sizeof(value), "%a", bw);
91+
+ snprintf(value, sizeof(value), "%a", bw);
92+
93+
- nb_cli_enqueue_change(vty, "./max-reservable-bandwidth", NB_OP_MODIFY,
94+
- value);
95+
+ nb_cli_enqueue_change(vty, "./max-reservable-bandwidth", NB_OP_MODIFY, value);
96+
+ } else
97+
+ nb_cli_enqueue_change(vty, "./max-reservable-bandwidth", NB_OP_DESTROY, NULL);
98+
99+
return nb_cli_apply_changes(vty, NULL);
100+
}
101+
@@ -439,7 +446,8 @@ static void lib_interface_zebra_link_params_max_reservable_bandwidth_cli_write(
102+
103+
DEFPY_YANG (link_params_unrsv_bw,
104+
link_params_unrsv_bw_cmd,
105+
- "unrsv-bw (0-7)$priority BANDWIDTH",
106+
+ "[no] unrsv-bw (0-7)$priority BANDWIDTH",
107+
+ NO_STR
108+
"Unreserved bandwidth at each priority level\n"
109+
"Priority\n"
110+
"Bytes/second (IEEE floating point format)\n")
111+
@@ -448,17 +456,25 @@ DEFPY_YANG (link_params_unrsv_bw,
112+
char value[YANG_VALUE_MAXLEN];
113+
float bw;
114+
115+
- if (sscanf(bandwidth, "%g", &bw) != 1) {
116+
- vty_out(vty, "Invalid bandwidth value\n");
117+
- return CMD_WARNING_CONFIG_FAILED;
118+
- }
119+
+ if (!no) {
120+
+ if (sscanf(bandwidth, "%g", &bw) != 1) {
121+
+ vty_out(vty, "Invalid bandwidth value\n");
122+
+ return CMD_WARNING_CONFIG_FAILED;
123+
+ }
124+
125+
- snprintf(xpath, sizeof(xpath),
126+
- "./unreserved-bandwidths/unreserved-bandwidth[priority='%s']/unreserved-bandwidth",
127+
- priority_str);
128+
- snprintf(value, sizeof(value), "%a", bw);
129+
+ snprintf(xpath, sizeof(xpath),
130+
+ "./unreserved-bandwidths/unreserved-bandwidth[priority='%s']/unreserved-bandwidth",
131+
+ priority_str);
132+
+ snprintf(value, sizeof(value), "%a", bw);
133+
134+
- nb_cli_enqueue_change(vty, xpath, NB_OP_MODIFY, value);
135+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_MODIFY, value);
136+
+ } else {
137+
+ snprintf(xpath, sizeof(xpath),
138+
+ "./unreserved-bandwidths/unreserved-bandwidth[priority='%s']",
139+
+ priority_str);
140+
+
141+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
142+
+ }
143+
144+
return nb_cli_apply_changes(vty, NULL);
145+
}
146+
diff --git a/zebra/zebra_nb_config.c b/zebra/zebra_nb_config.c
147+
index 38533eb24b..5a2e8fe0e7 100644
148+
--- a/zebra/zebra_nb_config.c
149+
+++ b/zebra/zebra_nb_config.c
150+
@@ -1459,11 +1459,16 @@ int lib_interface_zebra_link_params_max_bandwidth_modify(
151+
int lib_interface_zebra_link_params_max_bandwidth_destroy(
152+
struct nb_cb_destroy_args *args)
153+
{
154+
- if (args->event == NB_EV_VALIDATE) {
155+
- snprintfrr(args->errmsg, args->errmsg_len,
156+
- "Removing max-bandwidth is not allowed");
157+
- return NB_ERR_VALIDATION;
158+
- }
159+
+ struct interface *ifp;
160+
+ struct if_link_params *iflp;
161+
+
162+
+ if (args->event != NB_EV_APPLY)
163+
+ return NB_OK;
164+
+
165+
+ ifp = nb_running_get_entry(args->dnode, NULL, true);
166+
+ iflp = if_link_params_get(ifp);
167+
+ if (iflp)
168+
+ link_param_cmd_set_float(ifp, &iflp->max_bw, LP_MAX_BW, iflp->default_bw);
169+
170+
return NB_OK;
171+
}
172+
@@ -1494,11 +1499,16 @@ int lib_interface_zebra_link_params_max_reservable_bandwidth_modify(
173+
int lib_interface_zebra_link_params_max_reservable_bandwidth_destroy(
174+
struct nb_cb_destroy_args *args)
175+
{
176+
- if (args->event == NB_EV_VALIDATE) {
177+
- snprintfrr(args->errmsg, args->errmsg_len,
178+
- "Removing max-reservable-bandwidth is not allowed");
179+
- return NB_ERR_VALIDATION;
180+
- }
181+
+ struct interface *ifp;
182+
+ struct if_link_params *iflp;
183+
+
184+
+ if (args->event != NB_EV_APPLY)
185+
+ return NB_OK;
186+
+
187+
+ ifp = nb_running_get_entry(args->dnode, NULL, true);
188+
+ iflp = if_link_params_get(ifp);
189+
+ if (iflp)
190+
+ link_param_cmd_set_float(ifp, &iflp->max_rsv_bw, LP_MAX_RSV_BW, iflp->default_bw);
191+
192+
return NB_OK;
193+
}
194+
@@ -1532,11 +1542,20 @@ int lib_interface_zebra_link_params_unreserved_bandwidths_unreserved_bandwidth_c
195+
int lib_interface_zebra_link_params_unreserved_bandwidths_unreserved_bandwidth_destroy(
196+
struct nb_cb_destroy_args *args)
197+
{
198+
- if (args->event == NB_EV_VALIDATE) {
199+
- snprintfrr(args->errmsg, args->errmsg_len,
200+
- "Removing unreserved-bandwidth is not allowed");
201+
- return NB_ERR_VALIDATION;
202+
- }
203+
+ struct interface *ifp;
204+
+ struct if_link_params *iflp;
205+
+ uint8_t priority;
206+
+
207+
+ if (args->event != NB_EV_APPLY)
208+
+ return NB_OK;
209+
+
210+
+ priority = yang_dnode_get_uint8(args->dnode, "priority");
211+
+
212+
+ ifp = nb_running_get_entry(args->dnode, NULL, true);
213+
+ iflp = if_link_params_get(ifp);
214+
+ if (iflp)
215+
+ link_param_cmd_set_float(ifp, &iflp->unrsv_bw[priority], LP_UNRSV_BW,
216+
+ iflp->default_bw);
217+
218+
return NB_OK;
219+
}
220+
--
221+
2.50.1
222+

0 commit comments

Comments
 (0)