1 /*
2  * Copyright (C) 2018        Vmware
3  *                           Vishal Dhingra
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the Free
7  * Software Foundation; either version 2 of the License, or (at your option)
8  * any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; see the file COPYING; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 #include "northbound.h"
20 #include "libfrr.h"
21 #include "log.h"
22 #include "lib_errors.h"
23 #include "prefix.h"
24 #include "table.h"
25 #include "vrf.h"
26 #include "nexthop.h"
27 #include "srcdest_table.h"
28 
29 #include "static_vrf.h"
30 #include "static_routes.h"
31 #include "static_nb.h"
32 
33 
static_path_list_create(struct nb_cb_create_args * args)34 static int static_path_list_create(struct nb_cb_create_args *args)
35 {
36 	struct route_node *rn;
37 	struct static_path *pn;
38 	const struct lyd_node *vrf_dnode;
39 	const char *vrf;
40 	uint8_t distance;
41 	uint32_t table_id;
42 
43 	switch (args->event) {
44 	case NB_EV_VALIDATE:
45 		vrf_dnode = yang_dnode_get_parent(args->dnode,
46 						  "control-plane-protocol");
47 		vrf = yang_dnode_get_string(vrf_dnode, "./vrf");
48 		table_id = yang_dnode_get_uint32(args->dnode, "./table-id");
49 
50 		/*
51 		 * TableId is not applicable for VRF. Consider the case of
52 		 * l3mdev, there is one uint32_t space to work with.
53 		 * A l3mdev device points at a specific table that it
54 		 * relates to and a set of interfaces it belongs to.
55 		 */
56 		if (table_id && (strcmp(vrf, vrf_get_default_name()) != 0)
57 		    && !vrf_is_backend_netns()) {
58 			snprintf(
59 				args->errmsg, args->errmsg_len,
60 				"%% table param only available when running on netns-based vrfs");
61 			return NB_ERR_VALIDATION;
62 		}
63 		break;
64 	case NB_EV_ABORT:
65 	case NB_EV_PREPARE:
66 		break;
67 	case NB_EV_APPLY:
68 		rn = nb_running_get_entry(args->dnode, NULL, true);
69 		distance = yang_dnode_get_uint8(args->dnode, "./distance");
70 		table_id = yang_dnode_get_uint32(args->dnode, "./table-id");
71 		pn = static_add_path(rn, table_id, distance);
72 		nb_running_set_entry(args->dnode, pn);
73 	}
74 
75 	return NB_OK;
76 }
77 
static_path_list_destroy(struct nb_cb_destroy_args * args,const struct lyd_node * rn_dnode,struct stable_info * info)78 static void static_path_list_destroy(struct nb_cb_destroy_args *args,
79 				     const struct lyd_node *rn_dnode,
80 				     struct stable_info *info)
81 {
82 	struct route_node *rn;
83 	struct static_path *pn;
84 
85 	pn = nb_running_unset_entry(args->dnode);
86 	rn = nb_running_get_entry(rn_dnode, NULL, true);
87 	static_del_path(rn, pn, info->safi, info->svrf);
88 }
89 
static_path_list_tag_modify(struct nb_cb_modify_args * args,const struct lyd_node * rn_dnode,struct stable_info * info)90 static void static_path_list_tag_modify(struct nb_cb_modify_args *args,
91 					const struct lyd_node *rn_dnode,
92 					struct stable_info *info)
93 {
94 	struct static_path *pn;
95 	struct route_node *rn;
96 	route_tag_t tag;
97 
98 	tag = yang_dnode_get_uint32(args->dnode, NULL);
99 	pn = nb_running_get_entry(args->dnode, NULL, true);
100 	pn->tag = tag;
101 	rn = nb_running_get_entry(rn_dnode, NULL, true);
102 
103 	static_install_path(rn, pn, info->safi, info->svrf);
104 }
105 
static_nexthop_create(struct nb_cb_create_args * args,const struct lyd_node * rn_dnode,struct stable_info * info)106 static bool static_nexthop_create(struct nb_cb_create_args *args,
107 				  const struct lyd_node *rn_dnode,
108 				  struct stable_info *info)
109 {
110 	struct route_node *rn;
111 	struct static_path *pn;
112 	struct ipaddr ipaddr;
113 	struct static_nexthop *nh;
114 	int nh_type;
115 	const char *ifname;
116 	const char *nh_vrf;
117 
118 	switch (args->event) {
119 	case NB_EV_VALIDATE:
120 		ifname = yang_dnode_get_string(args->dnode, "./interface");
121 		if (ifname != NULL) {
122 			if (strcasecmp(ifname, "Null0") == 0
123 			    || strcasecmp(ifname, "reject") == 0
124 			    || strcasecmp(ifname, "blackhole") == 0) {
125 				snprintf(args->errmsg, args->errmsg_len,
126 					"%s: Nexthop interface name can not be from reserved keywords(Null0, reject, blackhole)",
127 					ifname);
128 				return NB_ERR_VALIDATION;
129 			}
130 		}
131 		break;
132 	case NB_EV_PREPARE:
133 	case NB_EV_ABORT:
134 		break;
135 	case NB_EV_APPLY:
136 		yang_dnode_get_ip(&ipaddr, args->dnode, "./gateway");
137 		nh_type = yang_dnode_get_enum(args->dnode, "./nh-type");
138 		ifname = yang_dnode_get_string(args->dnode, "./interface");
139 		nh_vrf = yang_dnode_get_string(args->dnode, "./vrf");
140 		pn = nb_running_get_entry(args->dnode, NULL, true);
141 		rn = nb_running_get_entry(rn_dnode, NULL, true);
142 
143 		if (!static_add_nexthop_validate(nh_vrf, nh_type, &ipaddr))
144 			flog_warn(
145 				EC_LIB_NB_CB_CONFIG_VALIDATE,
146 				"Warning!! Local connected address is configured as Gateway IP((%s))",
147 				yang_dnode_get_string(args->dnode,
148 						      "./gateway"));
149 		nh = static_add_nexthop(rn, pn, info->safi, info->svrf, nh_type,
150 					&ipaddr, ifname, nh_vrf, 0);
151 		nb_running_set_entry(args->dnode, nh);
152 		break;
153 	}
154 
155 	return NB_OK;
156 }
157 
static_nexthop_destroy(struct nb_cb_destroy_args * args,const struct lyd_node * rn_dnode,struct stable_info * info)158 static bool static_nexthop_destroy(struct nb_cb_destroy_args *args,
159 				   const struct lyd_node *rn_dnode,
160 				   struct stable_info *info)
161 {
162 	struct route_node *rn;
163 	struct static_path *pn;
164 	const struct lyd_node *pn_dnode;
165 	struct static_nexthop *nh;
166 	int ret;
167 
168 	nh = nb_running_unset_entry(args->dnode);
169 	pn_dnode = yang_dnode_get_parent(args->dnode, "path-list");
170 	pn = nb_running_get_entry(pn_dnode, NULL, true);
171 	rn = nb_running_get_entry(rn_dnode, NULL, true);
172 
173 	ret = static_delete_nexthop(rn, pn, info->safi, info->svrf, nh);
174 	if (!ret) {
175 		char buf[SRCDEST2STR_BUFFER];
176 
177 		flog_warn(EC_LIB_NB_CB_CONFIG_APPLY,
178 			  "%s : nh [%d:%s:%s:%s] nexthop destroy failed",
179 			  srcdest_rnode2str(rn, buf, sizeof(buf)),
180 			  yang_dnode_get_enum(args->dnode, "./nh-type"),
181 			  yang_dnode_get_string(args->dnode, "./interface"),
182 			  yang_dnode_get_string(args->dnode, "./gateway"),
183 			  yang_dnode_get_string(args->dnode, "./vrf"));
184 		return NB_ERR;
185 	}
186 
187 	return NB_OK;
188 }
189 
nexthop_mpls_label_stack_entry_create(struct nb_cb_create_args * args)190 static int nexthop_mpls_label_stack_entry_create(struct nb_cb_create_args *args)
191 {
192 	struct static_nexthop *nh;
193 	uint32_t pos;
194 	uint8_t index;
195 
196 	switch (args->event) {
197 	case NB_EV_VALIDATE:
198 	case NB_EV_PREPARE:
199 	case NB_EV_ABORT:
200 		break;
201 	case NB_EV_APPLY:
202 		nh = nb_running_get_entry(args->dnode, NULL, true);
203 		pos = yang_get_list_pos(args->dnode);
204 		if (!pos) {
205 			flog_warn(EC_LIB_NB_CB_CONFIG_APPLY,
206 				  "libyang returns invalid label position");
207 			return NB_ERR;
208 		}
209 		/* Mapping to array = list-index -1 */
210 		index = pos - 1;
211 		nh->snh_label.label[index] = 0;
212 		nh->snh_label.num_labels++;
213 		break;
214 	}
215 
216 	return NB_OK;
217 }
218 
219 static int
nexthop_mpls_label_stack_entry_destroy(struct nb_cb_destroy_args * args)220 nexthop_mpls_label_stack_entry_destroy(struct nb_cb_destroy_args *args)
221 {
222 	struct static_nexthop *nh;
223 	uint32_t pos;
224 	uint8_t index;
225 
226 	switch (args->event) {
227 	case NB_EV_VALIDATE:
228 	case NB_EV_PREPARE:
229 	case NB_EV_ABORT:
230 		break;
231 	case NB_EV_APPLY:
232 		nh = nb_running_get_entry(args->dnode, NULL, true);
233 		pos = yang_get_list_pos(args->dnode);
234 		if (!pos) {
235 			flog_warn(EC_LIB_NB_CB_CONFIG_APPLY,
236 				  "libyang returns invalid label position");
237 			return NB_ERR;
238 		}
239 		index = pos - 1;
240 		nh->snh_label.label[index] = 0;
241 		nh->snh_label.num_labels--;
242 		break;
243 	}
244 
245 	return NB_OK;
246 }
247 
static_nexthop_mpls_label_modify(struct nb_cb_modify_args * args)248 static int static_nexthop_mpls_label_modify(struct nb_cb_modify_args *args)
249 {
250 	struct static_nexthop *nh;
251 	uint32_t pos;
252 	uint8_t index;
253 
254 	nh = nb_running_get_entry(args->dnode, NULL, true);
255 	pos = yang_get_list_pos(args->dnode->parent);
256 	if (!pos) {
257 		flog_warn(EC_LIB_NB_CB_CONFIG_APPLY,
258 			  "libyang returns invalid label position");
259 		return NB_ERR;
260 	}
261 	/* Mapping to array = list-index -1 */
262 	index = pos - 1;
263 	nh->snh_label.label[index] = yang_dnode_get_uint32(args->dnode, NULL);
264 
265 	return NB_OK;
266 }
267 
static_nexthop_onlink_modify(struct nb_cb_modify_args * args)268 static int static_nexthop_onlink_modify(struct nb_cb_modify_args *args)
269 {
270 	struct static_nexthop *nh;
271 
272 	nh = nb_running_get_entry(args->dnode, NULL, true);
273 	nh->onlink = yang_dnode_get_bool(args->dnode, NULL);
274 
275 	return NB_OK;
276 }
277 
static_nexthop_color_modify(struct nb_cb_modify_args * args)278 static int static_nexthop_color_modify(struct nb_cb_modify_args *args)
279 {
280 	struct static_nexthop *nh;
281 
282 	nh = nb_running_get_entry(args->dnode, NULL, true);
283 	nh->color = yang_dnode_get_uint32(args->dnode, NULL);
284 
285 	return NB_OK;
286 }
287 
static_nexthop_color_destroy(struct nb_cb_destroy_args * args)288 static int static_nexthop_color_destroy(struct nb_cb_destroy_args *args)
289 {
290 	struct static_nexthop *nh;
291 
292 	nh = nb_running_unset_entry(args->dnode);
293 	nh->color = 0;
294 
295 	return NB_OK;
296 }
297 
static_nexthop_bh_type_modify(struct nb_cb_modify_args * args)298 static int static_nexthop_bh_type_modify(struct nb_cb_modify_args *args)
299 {
300 	struct static_nexthop *nh;
301 
302 	nh = nb_running_get_entry(args->dnode, NULL, true);
303 	nh->bh_type = yang_dnode_get_enum(args->dnode, NULL);
304 
305 	return NB_OK;
306 }
307 
308 
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_apply_finish(struct nb_cb_apply_finish_args * args)309 void routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_apply_finish(
310 	struct nb_cb_apply_finish_args *args)
311 {
312 	struct static_nexthop *nh;
313 	struct static_path *pn;
314 	struct route_node *rn;
315 	const struct lyd_node *pn_dnode;
316 	const struct lyd_node *rn_dnode;
317 	const char *ifname;
318 	const char *nh_vrf;
319 	struct stable_info *info;
320 	int nh_type;
321 
322 	nh_type = yang_dnode_get_enum(args->dnode, "./nh-type");
323 	ifname = yang_dnode_get_string(args->dnode, "./interface");
324 	nh_vrf = yang_dnode_get_string(args->dnode, "./vrf");
325 
326 	nh = nb_running_get_entry(args->dnode, NULL, true);
327 
328 	pn_dnode = yang_dnode_get_parent(args->dnode, "path-list");
329 	pn = nb_running_get_entry(pn_dnode, NULL, true);
330 
331 	rn_dnode = yang_dnode_get_parent(pn_dnode, "route-list");
332 	rn = nb_running_get_entry(rn_dnode, NULL, true);
333 	info = route_table_get_info(rn->table);
334 
335 	static_install_nexthop(rn, pn, nh, info->safi, info->svrf, ifname,
336 			       nh_type, nh_vrf);
337 }
338 
339 
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_apply_finish(struct nb_cb_apply_finish_args * args)340 void routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_apply_finish(
341 	struct nb_cb_apply_finish_args *args)
342 {
343 	struct static_nexthop *nh;
344 	struct static_path *pn;
345 	struct route_node *rn;
346 	struct route_node *src_rn;
347 	const struct lyd_node *pn_dnode;
348 	const struct lyd_node *rn_dnode;
349 	const struct lyd_node *src_dnode;
350 	const char *ifname;
351 	const char *nh_vrf;
352 	struct stable_info *info;
353 	int nh_type;
354 
355 	nh_type = yang_dnode_get_enum(args->dnode, "./nh-type");
356 	ifname = yang_dnode_get_string(args->dnode, "./interface");
357 	nh_vrf = yang_dnode_get_string(args->dnode, "./vrf");
358 
359 	nh = nb_running_get_entry(args->dnode, NULL, true);
360 
361 	pn_dnode = yang_dnode_get_parent(args->dnode, "path-list");
362 	pn = nb_running_get_entry(pn_dnode, NULL, true);
363 
364 	src_dnode = yang_dnode_get_parent(pn_dnode, "src-list");
365 	src_rn = nb_running_get_entry(src_dnode, NULL, true);
366 
367 	rn_dnode = yang_dnode_get_parent(src_dnode, "route-list");
368 	rn = nb_running_get_entry(rn_dnode, NULL, true);
369 	info = route_table_get_info(rn->table);
370 
371 	static_install_nexthop(src_rn, pn, nh, info->safi, info->svrf, ifname,
372 			       nh_type, nh_vrf);
373 }
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_pre_validate(struct nb_cb_pre_validate_args * args)374 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_pre_validate(
375 	struct nb_cb_pre_validate_args *args)
376 {
377 	const struct lyd_node *mls_dnode;
378 	uint32_t count;
379 
380 	mls_dnode = yang_dnode_get(args->dnode, "./mpls-label-stack");
381 	count = yang_get_list_elements_count(yang_dnode_get_child(mls_dnode));
382 
383 	if (count > MPLS_MAX_LABELS) {
384 		snprintf(args->errmsg, args->errmsg_len,
385 			"Too many labels, Enter %d or fewer",
386 			MPLS_MAX_LABELS);
387 		return NB_ERR_VALIDATION;
388 	}
389 	return NB_OK;
390 }
391 
routing_control_plane_protocols_name_validate(struct nb_cb_create_args * args)392 int routing_control_plane_protocols_name_validate(
393 	struct nb_cb_create_args *args)
394 {
395 	const char *name;
396 
397 	name = yang_dnode_get_string(args->dnode, "./name");
398 	if (!strmatch(name, "staticd")) {
399 		snprintf(args->errmsg, args->errmsg_len,
400 			"static routing supports only one instance with name staticd");
401 		return NB_ERR_VALIDATION;
402 	}
403 	return NB_OK;
404 }
405 /*
406  * XPath:
407  * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list
408  */
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_create(struct nb_cb_create_args * args)409 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_create(
410 	struct nb_cb_create_args *args)
411 {
412 	struct vrf *vrf;
413 	struct static_vrf *s_vrf;
414 	struct route_node *rn;
415 	const struct lyd_node *vrf_dnode;
416 	struct prefix prefix;
417 	const char *afi_safi;
418 	afi_t prefix_afi;
419 	afi_t afi;
420 	safi_t safi;
421 
422 	switch (args->event) {
423 	case NB_EV_VALIDATE:
424 		yang_dnode_get_prefix(&prefix, args->dnode, "./prefix");
425 		afi_safi = yang_dnode_get_string(args->dnode, "./afi-safi");
426 		yang_afi_safi_identity2value(afi_safi, &afi, &safi);
427 		prefix_afi = family2afi(prefix.family);
428 		if (afi != prefix_afi) {
429 			flog_warn(
430 				EC_LIB_NB_CB_CONFIG_VALIDATE,
431 				"route node %s creation failed",
432 				yang_dnode_get_string(args->dnode, "./prefix"));
433 			return NB_ERR_VALIDATION;
434 		}
435 		break;
436 	case NB_EV_PREPARE:
437 	case NB_EV_ABORT:
438 		break;
439 	case NB_EV_APPLY:
440 		vrf_dnode = yang_dnode_get_parent(args->dnode,
441 						  "control-plane-protocol");
442 		vrf = nb_running_get_entry(vrf_dnode, NULL, true);
443 		s_vrf = vrf->info;
444 
445 		yang_dnode_get_prefix(&prefix, args->dnode, "./prefix");
446 		afi_safi = yang_dnode_get_string(args->dnode, "./afi-safi");
447 		yang_afi_safi_identity2value(afi_safi, &afi, &safi);
448 
449 		rn = static_add_route(afi, safi, &prefix, NULL, s_vrf);
450 		if (!rn) {
451 			flog_warn(
452 				EC_LIB_NB_CB_CONFIG_APPLY,
453 				"route node %s creation failed",
454 				yang_dnode_get_string(args->dnode, "./prefix"));
455 			return NB_ERR;
456 		}
457 		nb_running_set_entry(args->dnode, rn);
458 		break;
459 	}
460 	return NB_OK;
461 }
462 
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_destroy(struct nb_cb_destroy_args * args)463 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_destroy(
464 	struct nb_cb_destroy_args *args)
465 {
466 	struct route_node *rn;
467 	struct stable_info *info;
468 
469 	switch (args->event) {
470 	case NB_EV_VALIDATE:
471 	case NB_EV_PREPARE:
472 	case NB_EV_ABORT:
473 		break;
474 	case NB_EV_APPLY:
475 		rn = nb_running_unset_entry(args->dnode);
476 		info = route_table_get_info(rn->table);
477 		static_del_route(rn, info->safi, info->svrf);
478 		break;
479 	}
480 	return NB_OK;
481 }
482 
483 /*
484  * XPath:
485  * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list
486  */
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_create(struct nb_cb_create_args * args)487 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_create(
488 	struct nb_cb_create_args *args)
489 {
490 	return static_path_list_create(args);
491 }
492 
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_destroy(struct nb_cb_destroy_args * args)493 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_destroy(
494 	struct nb_cb_destroy_args *args)
495 {
496 	const struct lyd_node *rn_dnode;
497 	struct route_node *rn;
498 	struct stable_info *info;
499 
500 	switch (args->event) {
501 	case NB_EV_VALIDATE:
502 	case NB_EV_PREPARE:
503 	case NB_EV_ABORT:
504 		break;
505 	case NB_EV_APPLY:
506 		rn_dnode = yang_dnode_get_parent(args->dnode, "route-list");
507 		rn = nb_running_get_entry(rn_dnode, NULL, true);
508 		info = route_table_get_info(rn->table);
509 		static_path_list_destroy(args, rn_dnode, info);
510 		break;
511 	}
512 	return NB_OK;
513 }
514 
515 /*
516  * XPath:
517  * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/tag
518  */
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_tag_modify(struct nb_cb_modify_args * args)519 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_tag_modify(
520 	struct nb_cb_modify_args *args)
521 {
522 	struct stable_info *info;
523 	struct route_node *rn;
524 	const struct lyd_node *rn_dnode;
525 
526 	switch (args->event) {
527 	case NB_EV_VALIDATE:
528 	case NB_EV_ABORT:
529 	case NB_EV_PREPARE:
530 		break;
531 	case NB_EV_APPLY:
532 		rn_dnode = yang_dnode_get_parent(args->dnode, "route-list");
533 		rn = nb_running_get_entry(rn_dnode, NULL, true);
534 		info = route_table_get_info(rn->table);
535 		static_path_list_tag_modify(args, rn_dnode, info);
536 		break;
537 	}
538 
539 	return NB_OK;
540 }
541 
542 /*
543  * XPath:
544  * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop
545  */
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_create(struct nb_cb_create_args * args)546 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_create(
547 	struct nb_cb_create_args *args)
548 {
549 	struct route_node *rn;
550 	const struct lyd_node *rn_dnode;
551 	struct stable_info *info;
552 
553 	switch (args->event) {
554 	case NB_EV_VALIDATE:
555 		rn_dnode = yang_dnode_get_parent(args->dnode, "route-list");
556 		if (static_nexthop_create(args, rn_dnode, NULL) != NB_OK)
557 			return NB_ERR_VALIDATION;
558 		break;
559 	case NB_EV_PREPARE:
560 	case NB_EV_ABORT:
561 		break;
562 	case NB_EV_APPLY:
563 		rn_dnode = yang_dnode_get_parent(args->dnode, "route-list");
564 		rn = nb_running_get_entry(rn_dnode, NULL, true);
565 		info = route_table_get_info(rn->table);
566 
567 		if (static_nexthop_create(args, rn_dnode, info) != NB_OK)
568 			return NB_ERR_VALIDATION;
569 		break;
570 	}
571 	return NB_OK;
572 }
573 
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_destroy(struct nb_cb_destroy_args * args)574 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_destroy(
575 	struct nb_cb_destroy_args *args)
576 {
577 	struct route_node *rn;
578 	const struct lyd_node *rn_dnode;
579 	struct stable_info *info;
580 
581 	switch (args->event) {
582 	case NB_EV_VALIDATE:
583 	case NB_EV_PREPARE:
584 	case NB_EV_ABORT:
585 		break;
586 	case NB_EV_APPLY:
587 		rn_dnode = yang_dnode_get_parent(args->dnode, "route-list");
588 		rn = nb_running_get_entry(rn_dnode, NULL, true);
589 		info = route_table_get_info(rn->table);
590 
591 		if (static_nexthop_destroy(args, rn_dnode, info) != NB_OK)
592 			return NB_ERR;
593 		break;
594 	}
595 	return NB_OK;
596 }
597 
598 /*
599  * XPath:
600  * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/bh-type
601  */
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_bh_type_modify(struct nb_cb_modify_args * args)602 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_bh_type_modify(
603 	struct nb_cb_modify_args *args)
604 {
605 	switch (args->event) {
606 	case NB_EV_VALIDATE:
607 	case NB_EV_PREPARE:
608 	case NB_EV_ABORT:
609 		break;
610 	case NB_EV_APPLY:
611 		if (static_nexthop_bh_type_modify(args) != NB_OK)
612 			return NB_ERR;
613 		break;
614 	}
615 	return NB_OK;
616 }
617 
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_bh_type_destroy(struct nb_cb_destroy_args * args)618 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_bh_type_destroy(
619 	struct nb_cb_destroy_args *args)
620 {
621 	/* blackhole type has a boolean type with default value,
622 	 * so no need to do any operations in destroy callback
623 	 */
624 	switch (args->event) {
625 	case NB_EV_VALIDATE:
626 	case NB_EV_PREPARE:
627 	case NB_EV_ABORT:
628 	case NB_EV_APPLY:
629 		break;
630 	}
631 	return NB_OK;
632 }
633 
634 /*
635  * XPath:
636  * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/onlink
637  */
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_onlink_modify(struct nb_cb_modify_args * args)638 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_onlink_modify(
639 	struct nb_cb_modify_args *args)
640 {
641 	switch (args->event) {
642 	case NB_EV_VALIDATE:
643 	case NB_EV_PREPARE:
644 	case NB_EV_ABORT:
645 		break;
646 	case NB_EV_APPLY:
647 		if (static_nexthop_onlink_modify(args) != NB_OK)
648 			return NB_ERR;
649 
650 		break;
651 	}
652 	return NB_OK;
653 }
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_onlink_destroy(struct nb_cb_destroy_args * args)654 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_onlink_destroy(
655 	struct nb_cb_destroy_args *args)
656 {
657 	/* onlink has a boolean type with default value,
658 	 * so no need to do any operations in destroy callback
659 	 */
660 	switch (args->event) {
661 	case NB_EV_VALIDATE:
662 	case NB_EV_PREPARE:
663 	case NB_EV_ABORT:
664 	case NB_EV_APPLY:
665 		break;
666 	}
667 	return NB_OK;
668 }
669 
670 /*
671  * XPath:
672  * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/srte-color
673  */
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_color_modify(struct nb_cb_modify_args * args)674 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_color_modify(
675 	struct nb_cb_modify_args *args)
676 {
677 	switch (args->event) {
678 	case NB_EV_VALIDATE:
679 	case NB_EV_PREPARE:
680 	case NB_EV_ABORT:
681 		break;
682 	case NB_EV_APPLY:
683 		if (static_nexthop_color_modify(args) != NB_OK)
684 			return NB_ERR;
685 
686 		break;
687 	}
688 	return NB_OK;
689 }
690 
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_color_destroy(struct nb_cb_destroy_args * args)691 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_color_destroy(
692 	struct nb_cb_destroy_args *args)
693 {
694 	switch (args->event) {
695 	case NB_EV_VALIDATE:
696 	case NB_EV_PREPARE:
697 	case NB_EV_ABORT:
698 		break;
699 	case NB_EV_APPLY:
700 		if (static_nexthop_color_destroy(args) != NB_OK)
701 			return NB_ERR;
702 		break;
703 	}
704 	return NB_OK;
705 }
706 
707 /*
708  * XPath:
709  * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry
710  */
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_create(struct nb_cb_create_args * args)711 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_create(
712 	struct nb_cb_create_args *args)
713 {
714 	return nexthop_mpls_label_stack_entry_create(args);
715 }
716 
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_destroy(struct nb_cb_destroy_args * args)717 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_destroy(
718 	struct nb_cb_destroy_args *args)
719 {
720 	return nexthop_mpls_label_stack_entry_destroy(args);
721 }
722 
723 /*
724  * XPath:
725  * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry/label
726  */
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_modify(struct nb_cb_modify_args * args)727 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_modify(
728 	struct nb_cb_modify_args *args)
729 {
730 	switch (args->event) {
731 	case NB_EV_VALIDATE:
732 	case NB_EV_PREPARE:
733 	case NB_EV_ABORT:
734 		break;
735 	case NB_EV_APPLY:
736 		if (static_nexthop_mpls_label_modify(args) != NB_OK)
737 			return NB_ERR;
738 		break;
739 	}
740 	return NB_OK;
741 }
742 
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_destroy(struct nb_cb_destroy_args * args)743 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_destroy(
744 	struct nb_cb_destroy_args *args)
745 {
746 	/*
747 	 * No operation is required in this call back.
748 	 * nexthop_mpls_label_stack_entry_destroy() will take care
749 	 * to reset the label vaue.
750 	 */
751 	switch (args->event) {
752 	case NB_EV_VALIDATE:
753 	case NB_EV_PREPARE:
754 	case NB_EV_ABORT:
755 	case NB_EV_APPLY:
756 		break;
757 	}
758 	return NB_OK;
759 }
760 
761 /*
762  * XPath:
763  * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry/ttl
764  */
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_modify(struct nb_cb_modify_args * args)765 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_modify(
766 	struct nb_cb_modify_args *args)
767 {
768 	switch (args->event) {
769 	case NB_EV_VALIDATE:
770 	case NB_EV_PREPARE:
771 	case NB_EV_ABORT:
772 	case NB_EV_APPLY:
773 		break;
774 	}
775 
776 	return NB_OK;
777 }
778 
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_destroy(struct nb_cb_destroy_args * args)779 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_destroy(
780 	struct nb_cb_destroy_args *args)
781 {
782 	switch (args->event) {
783 	case NB_EV_VALIDATE:
784 	case NB_EV_PREPARE:
785 	case NB_EV_ABORT:
786 	case NB_EV_APPLY:
787 		break;
788 	}
789 
790 	return NB_OK;
791 }
792 
793 /*
794  * XPath:
795  * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry/traffic-class
796  */
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_traffic_class_modify(struct nb_cb_modify_args * args)797 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_traffic_class_modify(
798 	struct nb_cb_modify_args *args)
799 {
800 	switch (args->event) {
801 	case NB_EV_VALIDATE:
802 	case NB_EV_PREPARE:
803 	case NB_EV_ABORT:
804 	case NB_EV_APPLY:
805 		break;
806 	}
807 
808 	return NB_OK;
809 }
810 
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_traffic_class_destroy(struct nb_cb_destroy_args * args)811 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_traffic_class_destroy(
812 	struct nb_cb_destroy_args *args)
813 {
814 	switch (args->event) {
815 	case NB_EV_VALIDATE:
816 	case NB_EV_PREPARE:
817 	case NB_EV_ABORT:
818 	case NB_EV_APPLY:
819 		break;
820 	}
821 
822 	return NB_OK;
823 }
824 
825 /*
826  * XPath:
827  * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list
828  */
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_create(struct nb_cb_create_args * args)829 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_create(
830 	struct nb_cb_create_args *args)
831 {
832 	struct static_vrf *s_vrf;
833 	struct route_node *rn;
834 	struct route_node *src_rn;
835 	struct prefix_ipv6 src_prefix = {};
836 	struct stable_info *info;
837 	afi_t afi;
838 	safi_t safi = SAFI_UNICAST;
839 
840 	switch (args->event) {
841 	case NB_EV_VALIDATE:
842 	case NB_EV_PREPARE:
843 	case NB_EV_ABORT:
844 		break;
845 	case NB_EV_APPLY:
846 		rn = nb_running_get_entry(args->dnode, NULL, true);
847 		info = route_table_get_info(rn->table);
848 		s_vrf = info->svrf;
849 		yang_dnode_get_ipv6p(&src_prefix, args->dnode, "./src-prefix");
850 		afi = family2afi(src_prefix.family);
851 		src_rn =
852 			static_add_route(afi, safi, &rn->p, &src_prefix, s_vrf);
853 		if (!src_rn) {
854 			flog_warn(EC_LIB_NB_CB_CONFIG_APPLY,
855 				  "src rn %s creation failed",
856 				  yang_dnode_get_string(args->dnode,
857 							"./src-prefix"));
858 			return NB_ERR;
859 		}
860 		nb_running_set_entry(args->dnode, src_rn);
861 		break;
862 	}
863 	return NB_OK;
864 }
865 
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_destroy(struct nb_cb_destroy_args * args)866 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_destroy(
867 	struct nb_cb_destroy_args *args)
868 {
869 	struct route_node *src_rn;
870 	struct route_node *rn;
871 	struct stable_info *info;
872 	const struct lyd_node *rn_dnode;
873 
874 	switch (args->event) {
875 	case NB_EV_VALIDATE:
876 	case NB_EV_PREPARE:
877 	case NB_EV_ABORT:
878 		break;
879 	case NB_EV_APPLY:
880 		src_rn = nb_running_unset_entry(args->dnode);
881 		rn_dnode = yang_dnode_get_parent(args->dnode, "route-list");
882 		rn = nb_running_get_entry(rn_dnode, NULL, true);
883 		info = route_table_get_info(rn->table);
884 		static_del_route(src_rn, info->safi, info->svrf);
885 		break;
886 	}
887 
888 	return NB_OK;
889 }
890 
891 /*
892  * XPath:
893  * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list
894  */
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_create(struct nb_cb_create_args * args)895 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_create(
896 	struct nb_cb_create_args *args)
897 {
898 	return static_path_list_create(args);
899 }
900 
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_destroy(struct nb_cb_destroy_args * args)901 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_destroy(
902 	struct nb_cb_destroy_args *args)
903 {
904 	struct route_node *rn;
905 	const struct lyd_node *rn_dnode;
906 	const struct lyd_node *srn_dnode;
907 	struct stable_info *info;
908 
909 	switch (args->event) {
910 	case NB_EV_VALIDATE:
911 	case NB_EV_PREPARE:
912 	case NB_EV_ABORT:
913 		break;
914 	case NB_EV_APPLY:
915 		srn_dnode = yang_dnode_get_parent(args->dnode, "src-list");
916 		rn_dnode = yang_dnode_get_parent(srn_dnode, "route-list");
917 		rn = nb_running_get_entry(rn_dnode, NULL, true);
918 		info = route_table_get_info(rn->table);
919 		static_path_list_destroy(args, srn_dnode, info);
920 		break;
921 	}
922 	return NB_OK;
923 }
924 
925 /*
926  * XPath:
927  * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/tag
928  */
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_tag_modify(struct nb_cb_modify_args * args)929 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_tag_modify(
930 	struct nb_cb_modify_args *args)
931 {
932 	struct stable_info *info;
933 	struct route_node *rn;
934 	const struct lyd_node *srn_dnode;
935 	const struct lyd_node *rn_dnode;
936 
937 	switch (args->event) {
938 	case NB_EV_VALIDATE:
939 	case NB_EV_ABORT:
940 	case NB_EV_PREPARE:
941 		break;
942 	case NB_EV_APPLY:
943 		srn_dnode = yang_dnode_get_parent(args->dnode, "src-list");
944 		rn_dnode = yang_dnode_get_parent(srn_dnode, "route-list");
945 		rn = nb_running_get_entry(rn_dnode, NULL, true);
946 		info = route_table_get_info(rn->table);
947 		static_path_list_tag_modify(args, srn_dnode, info);
948 		break;
949 	}
950 	return NB_OK;
951 }
952 
953 /*
954  * XPath:
955  * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop
956  */
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_create(struct nb_cb_create_args * args)957 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_create(
958 	struct nb_cb_create_args *args)
959 {
960 	struct route_node *rn;
961 	const struct lyd_node *rn_dnode;
962 	const struct lyd_node *src_dnode;
963 	struct stable_info *info;
964 
965 	switch (args->event) {
966 	case NB_EV_VALIDATE:
967 		rn_dnode = yang_dnode_get_parent(args->dnode, "route-list");
968 		if (static_nexthop_create(args, rn_dnode, NULL) != NB_OK)
969 			return NB_ERR_VALIDATION;
970 		break;
971 	case NB_EV_PREPARE:
972 	case NB_EV_ABORT:
973 		break;
974 	case NB_EV_APPLY:
975 		src_dnode = yang_dnode_get_parent(args->dnode, "src-list");
976 		rn_dnode = yang_dnode_get_parent(src_dnode, "route-list");
977 		rn = nb_running_get_entry(rn_dnode, NULL, true);
978 		info = route_table_get_info(rn->table);
979 
980 		if (static_nexthop_create(args, src_dnode, info) != NB_OK)
981 			return NB_ERR_VALIDATION;
982 
983 		break;
984 	}
985 	return NB_OK;
986 }
987 
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_destroy(struct nb_cb_destroy_args * args)988 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_destroy(
989 	struct nb_cb_destroy_args *args)
990 {
991 	struct route_node *rn;
992 	const struct lyd_node *rn_dnode;
993 	const struct lyd_node *src_dnode;
994 	struct stable_info *info;
995 
996 	switch (args->event) {
997 	case NB_EV_VALIDATE:
998 	case NB_EV_PREPARE:
999 	case NB_EV_ABORT:
1000 		break;
1001 	case NB_EV_APPLY:
1002 		src_dnode = yang_dnode_get_parent(args->dnode, "src-list");
1003 		rn_dnode = yang_dnode_get_parent(src_dnode, "route-list");
1004 		rn = nb_running_get_entry(rn_dnode, NULL, true);
1005 		info = route_table_get_info(rn->table);
1006 
1007 		if (static_nexthop_destroy(args, rn_dnode, info) != NB_OK)
1008 			return NB_ERR;
1009 		break;
1010 	}
1011 	return NB_OK;
1012 }
1013 
1014 /*
1015  * XPath:
1016  * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/bh-type
1017  */
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_bh_type_modify(struct nb_cb_modify_args * args)1018 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_bh_type_modify(
1019 	struct nb_cb_modify_args *args)
1020 {
1021 	switch (args->event) {
1022 	case NB_EV_VALIDATE:
1023 	case NB_EV_PREPARE:
1024 	case NB_EV_ABORT:
1025 		break;
1026 	case NB_EV_APPLY:
1027 		if (static_nexthop_bh_type_modify(args) != NB_OK)
1028 			return NB_ERR;
1029 		break;
1030 	}
1031 	return NB_OK;
1032 }
1033 
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_bh_type_destroy(struct nb_cb_destroy_args * args)1034 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_bh_type_destroy(
1035 	struct nb_cb_destroy_args *args)
1036 {
1037 	/* blackhole type has a boolean type with default value,
1038 	 * so no need to do any operations in destroy callback
1039 	 */
1040 	switch (args->event) {
1041 	case NB_EV_VALIDATE:
1042 	case NB_EV_PREPARE:
1043 	case NB_EV_ABORT:
1044 	case NB_EV_APPLY:
1045 		break;
1046 	}
1047 
1048 	return NB_OK;
1049 }
1050 
1051 /*
1052  * XPath:
1053  * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/onlink
1054  */
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_onlink_modify(struct nb_cb_modify_args * args)1055 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_onlink_modify(
1056 	struct nb_cb_modify_args *args)
1057 {
1058 	switch (args->event) {
1059 	case NB_EV_VALIDATE:
1060 	case NB_EV_PREPARE:
1061 	case NB_EV_ABORT:
1062 		break;
1063 	case NB_EV_APPLY:
1064 		if (static_nexthop_onlink_modify(args) != NB_OK)
1065 			return NB_ERR;
1066 
1067 		break;
1068 	}
1069 	return NB_OK;
1070 }
1071 
1072 
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_onlink_destroy(struct nb_cb_destroy_args * args)1073 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_onlink_destroy(
1074 	struct nb_cb_destroy_args *args)
1075 {
1076 	/* onlink has a boolean type with default value,
1077 	 * so no need to do any operations in destroy callback
1078 	 */
1079 	switch (args->event) {
1080 	case NB_EV_VALIDATE:
1081 	case NB_EV_PREPARE:
1082 	case NB_EV_ABORT:
1083 	case NB_EV_APPLY:
1084 		break;
1085 	}
1086 	return NB_OK;
1087 }
1088 
1089 /*
1090  * XPath:
1091  * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/srte-color
1092  */
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_color_modify(struct nb_cb_modify_args * args)1093 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_color_modify(
1094 	struct nb_cb_modify_args *args)
1095 {
1096 	switch (args->event) {
1097 	case NB_EV_VALIDATE:
1098 	case NB_EV_PREPARE:
1099 	case NB_EV_ABORT:
1100 		break;
1101 	case NB_EV_APPLY:
1102 		if (static_nexthop_color_modify(args) != NB_OK)
1103 			return NB_ERR;
1104 
1105 		break;
1106 	}
1107 	return NB_OK;
1108 }
1109 
1110 
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_color_destroy(struct nb_cb_destroy_args * args)1111 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_color_destroy(
1112 	struct nb_cb_destroy_args *args)
1113 {
1114 	switch (args->event) {
1115 	case NB_EV_VALIDATE:
1116 	case NB_EV_PREPARE:
1117 	case NB_EV_ABORT:
1118 		break;
1119 	case NB_EV_APPLY:
1120 		if (static_nexthop_color_destroy(args) != NB_OK)
1121 			return NB_ERR;
1122 		break;
1123 	}
1124 	return NB_OK;
1125 }
1126 
1127 /*
1128  * XPath:
1129  * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry
1130  */
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_create(struct nb_cb_create_args * args)1131 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_create(
1132 	struct nb_cb_create_args *args)
1133 {
1134 	return nexthop_mpls_label_stack_entry_create(args);
1135 }
1136 
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_destroy(struct nb_cb_destroy_args * args)1137 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_destroy(
1138 	struct nb_cb_destroy_args *args)
1139 {
1140 	return nexthop_mpls_label_stack_entry_destroy(args);
1141 }
1142 
1143 /*
1144  * XPath:
1145  * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry/label
1146  */
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_modify(struct nb_cb_modify_args * args)1147 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_modify(
1148 	struct nb_cb_modify_args *args)
1149 {
1150 	switch (args->event) {
1151 	case NB_EV_VALIDATE:
1152 	case NB_EV_PREPARE:
1153 	case NB_EV_ABORT:
1154 		break;
1155 	case NB_EV_APPLY:
1156 		if (static_nexthop_mpls_label_modify(args) != NB_OK)
1157 			return NB_ERR;
1158 		break;
1159 	}
1160 	return NB_OK;
1161 }
1162 
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_destroy(struct nb_cb_destroy_args * args)1163 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_label_destroy(
1164 	struct nb_cb_destroy_args *args)
1165 {
1166 	/*
1167 	 * No operation is required in this call back.
1168 	 * nexthop_mpls_label_stack_entry_destroy() will take care
1169 	 * to reset the label vaue.
1170 	 */
1171 	switch (args->event) {
1172 	case NB_EV_VALIDATE:
1173 	case NB_EV_PREPARE:
1174 	case NB_EV_ABORT:
1175 	case NB_EV_APPLY:
1176 		break;
1177 	}
1178 	return NB_OK;
1179 }
1180 
1181 /*
1182  * XPath:
1183  * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry/ttl
1184  */
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_modify(struct nb_cb_modify_args * args)1185 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_modify(
1186 	struct nb_cb_modify_args *args)
1187 {
1188 	switch (args->event) {
1189 	case NB_EV_VALIDATE:
1190 	case NB_EV_PREPARE:
1191 	case NB_EV_ABORT:
1192 	case NB_EV_APPLY:
1193 		break;
1194 	}
1195 
1196 	return NB_OK;
1197 }
1198 
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_destroy(struct nb_cb_destroy_args * args)1199 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_ttl_destroy(
1200 	struct nb_cb_destroy_args *args)
1201 {
1202 	switch (args->event) {
1203 	case NB_EV_VALIDATE:
1204 	case NB_EV_PREPARE:
1205 	case NB_EV_ABORT:
1206 	case NB_EV_APPLY:
1207 		break;
1208 	}
1209 
1210 	return NB_OK;
1211 }
1212 
1213 /*
1214  * XPath:
1215  * /frr-routing:routing/control-plane-protocols/control-plane-protocol/frr-staticd:staticd/route-list/src-list/path-list/frr-nexthops/nexthop/mpls-label-stack/entry/traffic-class
1216  */
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_traffic_class_modify(struct nb_cb_modify_args * args)1217 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_traffic_class_modify(
1218 	struct nb_cb_modify_args *args)
1219 {
1220 	switch (args->event) {
1221 	case NB_EV_VALIDATE:
1222 	case NB_EV_PREPARE:
1223 	case NB_EV_ABORT:
1224 	case NB_EV_APPLY:
1225 		break;
1226 	}
1227 
1228 	return NB_OK;
1229 }
1230 
routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_traffic_class_destroy(struct nb_cb_destroy_args * args)1231 int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_src_list_path_list_frr_nexthops_nexthop_mpls_label_stack_entry_traffic_class_destroy(
1232 	struct nb_cb_destroy_args *args)
1233 {
1234 	switch (args->event) {
1235 	case NB_EV_VALIDATE:
1236 	case NB_EV_PREPARE:
1237 	case NB_EV_ABORT:
1238 	case NB_EV_APPLY:
1239 		break;
1240 	}
1241 
1242 	return NB_OK;
1243 }
1244