1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 1997, 1998, 1999 Kunihiro Ishiguro <kunihiro@zebra.org>
4 * Copyright (C) 2018 NetDEF, Inc.
6 * Copyright (C) 2023 LabN Consulting, L.L.C.
19 #include "northbound.h"
22 #include "ripd/ripd.h"
23 #include "ripd/rip_nb.h"
24 #include "ripd/rip_debug.h"
25 #include "ripd/rip_interface.h"
26 #include "ripd/rip_bfd.h"
29 * XPath: /frr-ripd:ripd/instance
31 int ripd_instance_create(struct nb_cb_create_args
*args
)
38 vrf_name
= yang_dnode_get_string(args
->dnode
, "./vrf");
39 vrf
= vrf_lookup_by_name(vrf_name
);
42 * Try to create a RIP socket only if the VRF is enabled, otherwise
43 * create a disabled RIP instance and wait for the VRF to be enabled.
45 switch (args
->event
) {
49 if (!vrf
|| !vrf_is_enabled(vrf
))
52 socket
= rip_create_socket(vrf
);
54 return NB_ERR_RESOURCE
;
55 args
->resource
->fd
= socket
;
58 if (!vrf
|| !vrf_is_enabled(vrf
))
61 socket
= args
->resource
->fd
;
65 if (vrf
&& vrf_is_enabled(vrf
))
66 socket
= args
->resource
->fd
;
70 rip
= rip_create(vrf_name
, vrf
, socket
);
71 nb_running_set_entry(args
->dnode
, rip
);
78 int ripd_instance_destroy(struct nb_cb_destroy_args
*args
)
82 if (args
->event
!= NB_EV_APPLY
)
85 rip
= nb_running_unset_entry(args
->dnode
);
92 * XPath: /frr-ripd:ripd/instance/allow-ecmp
94 int ripd_instance_allow_ecmp_modify(struct nb_cb_modify_args
*args
)
98 if (args
->event
!= NB_EV_APPLY
)
101 rip
= nb_running_get_entry(args
->dnode
, NULL
, true);
102 rip
->ecmp
= yang_dnode_get_bool(args
->dnode
, NULL
);
104 rip_ecmp_disable(rip
);
110 * XPath: /frr-ripd:ripd/instance/default-information-originate
112 int ripd_instance_default_information_originate_modify(
113 struct nb_cb_modify_args
*args
)
116 bool default_information
;
117 struct prefix_ipv4 p
;
119 if (args
->event
!= NB_EV_APPLY
)
122 rip
= nb_running_get_entry(args
->dnode
, NULL
, true);
123 default_information
= yang_dnode_get_bool(args
->dnode
, NULL
);
125 memset(&p
, 0, sizeof(p
));
127 if (default_information
) {
130 memset(&nh
, 0, sizeof(nh
));
131 nh
.type
= NEXTHOP_TYPE_IPV4
;
132 rip_redistribute_add(rip
, ZEBRA_ROUTE_RIP
, RIP_ROUTE_DEFAULT
,
135 rip_redistribute_delete(rip
, ZEBRA_ROUTE_RIP
, RIP_ROUTE_DEFAULT
,
143 * XPath: /frr-ripd:ripd/instance/default-metric
145 int ripd_instance_default_metric_modify(struct nb_cb_modify_args
*args
)
149 if (args
->event
!= NB_EV_APPLY
)
152 rip
= nb_running_get_entry(args
->dnode
, NULL
, true);
153 rip
->default_metric
= yang_dnode_get_uint8(args
->dnode
, NULL
);
154 /* rip_update_default_metric (); */
160 * XPath: /frr-ripd:ripd/instance/distance/default
162 int ripd_instance_distance_default_modify(struct nb_cb_modify_args
*args
)
166 if (args
->event
!= NB_EV_APPLY
)
169 rip
= nb_running_get_entry(args
->dnode
, NULL
, true);
170 rip
->distance
= yang_dnode_get_uint8(args
->dnode
, NULL
);
176 * XPath: /frr-ripd:ripd/instance/distance/source
178 int ripd_instance_distance_source_create(struct nb_cb_create_args
*args
)
181 struct prefix_ipv4 prefix
;
182 struct route_node
*rn
;
184 if (args
->event
!= NB_EV_APPLY
)
187 yang_dnode_get_ipv4p(&prefix
, args
->dnode
, "./prefix");
188 apply_mask_ipv4(&prefix
);
190 /* Get RIP distance node. */
191 rip
= nb_running_get_entry(args
->dnode
, NULL
, true);
192 rn
= route_node_get(rip
->distance_table
, (struct prefix
*)&prefix
);
193 rn
->info
= rip_distance_new();
194 nb_running_set_entry(args
->dnode
, rn
);
199 int ripd_instance_distance_source_destroy(struct nb_cb_destroy_args
*args
)
201 struct route_node
*rn
;
202 struct rip_distance
*rdistance
;
204 if (args
->event
!= NB_EV_APPLY
)
207 rn
= nb_running_unset_entry(args
->dnode
);
208 rdistance
= rn
->info
;
209 rip_distance_free(rdistance
);
211 route_unlock_node(rn
);
217 * XPath: /frr-ripd:ripd/instance/distance/source/distance
219 int ripd_instance_distance_source_distance_modify(
220 struct nb_cb_modify_args
*args
)
222 struct route_node
*rn
;
224 struct rip_distance
*rdistance
;
226 if (args
->event
!= NB_EV_APPLY
)
229 /* Set distance value. */
230 rn
= nb_running_get_entry(args
->dnode
, NULL
, true);
231 distance
= yang_dnode_get_uint8(args
->dnode
, NULL
);
232 rdistance
= rn
->info
;
233 rdistance
->distance
= distance
;
239 * XPath: /frr-ripd:ripd/instance/distance/source/access-list
241 int ripd_instance_distance_source_access_list_modify(
242 struct nb_cb_modify_args
*args
)
244 const char *acl_name
;
245 struct route_node
*rn
;
246 struct rip_distance
*rdistance
;
248 if (args
->event
!= NB_EV_APPLY
)
251 acl_name
= yang_dnode_get_string(args
->dnode
, NULL
);
253 /* Set access-list */
254 rn
= nb_running_get_entry(args
->dnode
, NULL
, true);
255 rdistance
= rn
->info
;
256 if (rdistance
->access_list
)
257 free(rdistance
->access_list
);
258 rdistance
->access_list
= strdup(acl_name
);
263 int ripd_instance_distance_source_access_list_destroy(
264 struct nb_cb_destroy_args
*args
)
266 struct route_node
*rn
;
267 struct rip_distance
*rdistance
;
269 if (args
->event
!= NB_EV_APPLY
)
272 /* Reset access-list configuration. */
273 rn
= nb_running_get_entry(args
->dnode
, NULL
, true);
274 rdistance
= rn
->info
;
275 free(rdistance
->access_list
);
276 rdistance
->access_list
= NULL
;
282 * XPath: /frr-ripd:ripd/instance/explicit-neighbor
284 int ripd_instance_explicit_neighbor_create(struct nb_cb_create_args
*args
)
287 struct prefix_ipv4 p
;
289 if (args
->event
!= NB_EV_APPLY
)
292 rip
= nb_running_get_entry(args
->dnode
, NULL
, true);
294 p
.prefixlen
= IPV4_MAX_BITLEN
;
295 yang_dnode_get_ipv4(&p
.prefix
, args
->dnode
, NULL
);
297 return rip_neighbor_add(rip
, &p
);
300 int ripd_instance_explicit_neighbor_destroy(struct nb_cb_destroy_args
*args
)
303 struct prefix_ipv4 p
;
305 if (args
->event
!= NB_EV_APPLY
)
308 rip
= nb_running_get_entry(args
->dnode
, NULL
, true);
310 p
.prefixlen
= IPV4_MAX_BITLEN
;
311 yang_dnode_get_ipv4(&p
.prefix
, args
->dnode
, NULL
);
313 return rip_neighbor_delete(rip
, &p
);
317 * XPath: /frr-ripd:ripd/instance/network
319 int ripd_instance_network_create(struct nb_cb_create_args
*args
)
324 if (args
->event
!= NB_EV_APPLY
)
327 rip
= nb_running_get_entry(args
->dnode
, NULL
, true);
328 yang_dnode_get_ipv4p(&p
, args
->dnode
, NULL
);
329 apply_mask_ipv4((struct prefix_ipv4
*)&p
);
331 return rip_enable_network_add(rip
, &p
);
334 int ripd_instance_network_destroy(struct nb_cb_destroy_args
*args
)
339 if (args
->event
!= NB_EV_APPLY
)
342 rip
= nb_running_get_entry(args
->dnode
, NULL
, true);
343 yang_dnode_get_ipv4p(&p
, args
->dnode
, NULL
);
344 apply_mask_ipv4((struct prefix_ipv4
*)&p
);
346 return rip_enable_network_delete(rip
, &p
);
350 * XPath: /frr-ripd:ripd/instance/interface
352 int ripd_instance_interface_create(struct nb_cb_create_args
*args
)
357 if (args
->event
!= NB_EV_APPLY
)
360 rip
= nb_running_get_entry(args
->dnode
, NULL
, true);
361 ifname
= yang_dnode_get_string(args
->dnode
, NULL
);
363 return rip_enable_if_add(rip
, ifname
);
366 int ripd_instance_interface_destroy(struct nb_cb_destroy_args
*args
)
371 if (args
->event
!= NB_EV_APPLY
)
374 rip
= nb_running_get_entry(args
->dnode
, NULL
, true);
375 ifname
= yang_dnode_get_string(args
->dnode
, NULL
);
377 return rip_enable_if_delete(rip
, ifname
);
381 * XPath: /frr-ripd:ripd/instance/offset-list
383 int ripd_instance_offset_list_create(struct nb_cb_create_args
*args
)
387 struct rip_offset_list
*offset
;
389 if (args
->event
!= NB_EV_APPLY
)
392 rip
= nb_running_get_entry(args
->dnode
, NULL
, true);
393 ifname
= yang_dnode_get_string(args
->dnode
, "./interface");
395 offset
= rip_offset_list_new(rip
, ifname
);
396 nb_running_set_entry(args
->dnode
, offset
);
401 int ripd_instance_offset_list_destroy(struct nb_cb_destroy_args
*args
)
404 struct rip_offset_list
*offset
;
406 if (args
->event
!= NB_EV_APPLY
)
409 direct
= yang_dnode_get_enum(args
->dnode
, "./direction");
411 offset
= nb_running_unset_entry(args
->dnode
);
412 if (offset
->direct
[direct
].alist_name
) {
413 free(offset
->direct
[direct
].alist_name
);
414 offset
->direct
[direct
].alist_name
= NULL
;
416 if (offset
->direct
[RIP_OFFSET_LIST_IN
].alist_name
== NULL
417 && offset
->direct
[RIP_OFFSET_LIST_OUT
].alist_name
== NULL
)
418 offset_list_del(offset
);
424 * XPath: /frr-ripd:ripd/instance/offset-list/access-list
426 int ripd_instance_offset_list_access_list_modify(struct nb_cb_modify_args
*args
)
429 struct rip_offset_list
*offset
;
430 const char *alist_name
;
432 if (args
->event
!= NB_EV_APPLY
)
435 direct
= yang_dnode_get_enum(args
->dnode
, "../direction");
436 alist_name
= yang_dnode_get_string(args
->dnode
, NULL
);
438 offset
= nb_running_get_entry(args
->dnode
, NULL
, true);
439 if (offset
->direct
[direct
].alist_name
)
440 free(offset
->direct
[direct
].alist_name
);
441 offset
->direct
[direct
].alist_name
= strdup(alist_name
);
447 * XPath: /frr-ripd:ripd/instance/offset-list/metric
449 int ripd_instance_offset_list_metric_modify(struct nb_cb_modify_args
*args
)
453 struct rip_offset_list
*offset
;
455 if (args
->event
!= NB_EV_APPLY
)
458 direct
= yang_dnode_get_enum(args
->dnode
, "../direction");
459 metric
= yang_dnode_get_uint8(args
->dnode
, NULL
);
461 offset
= nb_running_get_entry(args
->dnode
, NULL
, true);
462 offset
->direct
[direct
].metric
= metric
;
468 * XPath: /frr-ripd:ripd/instance/passive-default
470 int ripd_instance_passive_default_modify(struct nb_cb_modify_args
*args
)
474 if (args
->event
!= NB_EV_APPLY
)
477 rip
= nb_running_get_entry(args
->dnode
, NULL
, true);
478 rip
->passive_default
= yang_dnode_get_bool(args
->dnode
, NULL
);
479 rip_passive_nondefault_clean(rip
);
485 * XPath: /frr-ripd:ripd/instance/passive-interface
487 int ripd_instance_passive_interface_create(struct nb_cb_create_args
*args
)
492 if (args
->event
!= NB_EV_APPLY
)
495 rip
= nb_running_get_entry(args
->dnode
, NULL
, true);
496 ifname
= yang_dnode_get_string(args
->dnode
, NULL
);
498 return rip_passive_nondefault_set(rip
, ifname
);
501 int ripd_instance_passive_interface_destroy(struct nb_cb_destroy_args
*args
)
506 if (args
->event
!= NB_EV_APPLY
)
509 rip
= nb_running_get_entry(args
->dnode
, NULL
, true);
510 ifname
= yang_dnode_get_string(args
->dnode
, NULL
);
512 return rip_passive_nondefault_unset(rip
, ifname
);
516 * XPath: /frr-ripd:ripd/instance/non-passive-interface
518 int ripd_instance_non_passive_interface_create(struct nb_cb_create_args
*args
)
523 if (args
->event
!= NB_EV_APPLY
)
526 rip
= nb_running_get_entry(args
->dnode
, NULL
, true);
527 ifname
= yang_dnode_get_string(args
->dnode
, NULL
);
529 return rip_passive_nondefault_set(rip
, ifname
);
532 int ripd_instance_non_passive_interface_destroy(struct nb_cb_destroy_args
*args
)
537 if (args
->event
!= NB_EV_APPLY
)
540 rip
= nb_running_get_entry(args
->dnode
, NULL
, true);
541 ifname
= yang_dnode_get_string(args
->dnode
, NULL
);
543 return rip_passive_nondefault_unset(rip
, ifname
);
547 * XPath: /frr-ripd:ripd/instance/redistribute
549 int ripd_instance_redistribute_create(struct nb_cb_create_args
*args
)
554 if (args
->event
!= NB_EV_APPLY
)
557 rip
= nb_running_get_entry(args
->dnode
, NULL
, true);
558 type
= yang_dnode_get_enum(args
->dnode
, "./protocol");
560 rip
->redist
[type
].enabled
= true;
565 int ripd_instance_redistribute_destroy(struct nb_cb_destroy_args
*args
)
570 if (args
->event
!= NB_EV_APPLY
)
573 rip
= nb_running_get_entry(args
->dnode
, NULL
, true);
574 type
= yang_dnode_get_enum(args
->dnode
, "./protocol");
576 rip
->redist
[type
].enabled
= false;
577 if (rip
->redist
[type
].route_map
.name
) {
578 free(rip
->redist
[type
].route_map
.name
);
579 rip
->redist
[type
].route_map
.name
= NULL
;
580 rip
->redist
[type
].route_map
.map
= NULL
;
582 rip
->redist
[type
].metric_config
= false;
583 rip
->redist
[type
].metric
= 0;
586 rip_redistribute_conf_delete(rip
, type
);
591 void ripd_instance_redistribute_apply_finish(
592 struct nb_cb_apply_finish_args
*args
)
597 rip
= nb_running_get_entry(args
->dnode
, NULL
, true);
598 type
= yang_dnode_get_enum(args
->dnode
, "./protocol");
601 rip_redistribute_conf_update(rip
, type
);
605 * XPath: /frr-ripd:ripd/instance/redistribute/route-map
607 int ripd_instance_redistribute_route_map_modify(struct nb_cb_modify_args
*args
)
611 const char *rmap_name
;
613 if (args
->event
!= NB_EV_APPLY
)
616 rip
= nb_running_get_entry(args
->dnode
, NULL
, true);
617 type
= yang_dnode_get_enum(args
->dnode
, "../protocol");
618 rmap_name
= yang_dnode_get_string(args
->dnode
, NULL
);
620 if (rip
->redist
[type
].route_map
.name
)
621 free(rip
->redist
[type
].route_map
.name
);
622 rip
->redist
[type
].route_map
.name
= strdup(rmap_name
);
623 rip
->redist
[type
].route_map
.map
= route_map_lookup_by_name(rmap_name
);
628 int ripd_instance_redistribute_route_map_destroy(
629 struct nb_cb_destroy_args
*args
)
634 if (args
->event
!= NB_EV_APPLY
)
637 rip
= nb_running_get_entry(args
->dnode
, NULL
, true);
638 type
= yang_dnode_get_enum(args
->dnode
, "../protocol");
640 free(rip
->redist
[type
].route_map
.name
);
641 rip
->redist
[type
].route_map
.name
= NULL
;
642 rip
->redist
[type
].route_map
.map
= NULL
;
648 * XPath: /frr-ripd:ripd/instance/redistribute/metric
650 int ripd_instance_redistribute_metric_modify(struct nb_cb_modify_args
*args
)
656 if (args
->event
!= NB_EV_APPLY
)
659 rip
= nb_running_get_entry(args
->dnode
, NULL
, true);
660 type
= yang_dnode_get_enum(args
->dnode
, "../protocol");
661 metric
= yang_dnode_get_uint8(args
->dnode
, NULL
);
663 rip
->redist
[type
].metric_config
= true;
664 rip
->redist
[type
].metric
= metric
;
669 int ripd_instance_redistribute_metric_destroy(struct nb_cb_destroy_args
*args
)
674 if (args
->event
!= NB_EV_APPLY
)
677 rip
= nb_running_get_entry(args
->dnode
, NULL
, true);
678 type
= yang_dnode_get_enum(args
->dnode
, "../protocol");
680 rip
->redist
[type
].metric_config
= false;
681 rip
->redist
[type
].metric
= 0;
687 * XPath: /frr-ripd:ripd/instance/if-route-maps/if-route-map
689 int ripd_instance_if_route_maps_if_route_map_create(
690 struct nb_cb_create_args
*args
)
692 /* if_rmap is created when first routemap is added */
696 int ripd_instance_if_route_maps_if_route_map_destroy(
697 struct nb_cb_destroy_args
*args
)
701 if (args
->event
!= NB_EV_APPLY
)
705 * YANG will prune edit deletes up to the most general deleted node so
706 * we need to handle deleting any existing state underneath and not
707 * count on those more specific callbacks being called individually.
710 rip
= nb_running_get_entry(args
->dnode
, NULL
, true);
711 if_rmap_yang_destroy_cb(rip
->if_rmap_ctx
, args
->dnode
);
716 static void if_route_map_modify(const struct lyd_node
*dnode
,
717 enum if_rmap_type type
, bool delete)
719 struct rip
*rip
= nb_running_get_entry(dnode
, NULL
, true);
721 if_rmap_yang_modify_cb(rip
->if_rmap_ctx
, dnode
, type
, delete);
725 * XPath: /frr-ripd:ripd/instance/if-route-maps/if-route-map/in-route-map
727 int ripd_instance_if_route_maps_if_route_map_in_route_map_modify(
728 struct nb_cb_modify_args
*args
)
730 if (args
->event
!= NB_EV_APPLY
)
733 if_route_map_modify(args
->dnode
, IF_RMAP_IN
, false);
738 int ripd_instance_if_route_maps_if_route_map_in_route_map_destroy(
739 struct nb_cb_destroy_args
*args
)
741 if (args
->event
!= NB_EV_APPLY
)
744 if_route_map_modify(args
->dnode
, IF_RMAP_IN
, true);
750 * XPath: /frr-ripd:ripd/instance/if-route-maps/if-route-map/out-route-map
752 int ripd_instance_if_route_maps_if_route_map_out_route_map_modify(
753 struct nb_cb_modify_args
*args
)
755 if (args
->event
!= NB_EV_APPLY
)
758 if_route_map_modify(args
->dnode
, IF_RMAP_OUT
, false);
763 int ripd_instance_if_route_maps_if_route_map_out_route_map_destroy(
764 struct nb_cb_destroy_args
*args
)
766 if (args
->event
!= NB_EV_APPLY
)
769 if_route_map_modify(args
->dnode
, IF_RMAP_OUT
, true);
775 * XPath: /frr-ripd:ripd/instance/static-route
777 int ripd_instance_static_route_create(struct nb_cb_create_args
*args
)
781 struct prefix_ipv4 p
;
783 if (args
->event
!= NB_EV_APPLY
)
786 rip
= nb_running_get_entry(args
->dnode
, NULL
, true);
787 yang_dnode_get_ipv4p(&p
, args
->dnode
, NULL
);
790 memset(&nh
, 0, sizeof(nh
));
791 nh
.type
= NEXTHOP_TYPE_IPV4
;
792 rip_redistribute_add(rip
, ZEBRA_ROUTE_RIP
, RIP_ROUTE_STATIC
, &p
, &nh
, 0,
798 int ripd_instance_static_route_destroy(struct nb_cb_destroy_args
*args
)
801 struct prefix_ipv4 p
;
803 if (args
->event
!= NB_EV_APPLY
)
806 rip
= nb_running_get_entry(args
->dnode
, NULL
, true);
807 yang_dnode_get_ipv4p(&p
, args
->dnode
, NULL
);
810 rip_redistribute_delete(rip
, ZEBRA_ROUTE_RIP
, RIP_ROUTE_STATIC
, &p
, 0);
816 * XPath: /frr-ripd:ripd/instance/timers/
818 void ripd_instance_timers_apply_finish(struct nb_cb_apply_finish_args
*args
)
822 rip
= nb_running_get_entry(args
->dnode
, NULL
, true);
824 /* Reset update timer thread. */
825 rip_event(rip
, RIP_UPDATE_EVENT
, 0);
829 * XPath: /frr-ripd:ripd/instance/timers/flush-interval
831 int ripd_instance_timers_flush_interval_modify(struct nb_cb_modify_args
*args
)
835 if (args
->event
!= NB_EV_APPLY
)
838 rip
= nb_running_get_entry(args
->dnode
, NULL
, true);
839 rip
->garbage_time
= yang_dnode_get_uint32(args
->dnode
, NULL
);
845 * XPath: /frr-ripd:ripd/instance/timers/holddown-interval
847 int ripd_instance_timers_holddown_interval_modify(
848 struct nb_cb_modify_args
*args
)
852 if (args
->event
!= NB_EV_APPLY
)
855 rip
= nb_running_get_entry(args
->dnode
, NULL
, true);
856 rip
->timeout_time
= yang_dnode_get_uint32(args
->dnode
, NULL
);
862 * XPath: /frr-ripd:ripd/instance/timers/update-interval
864 int ripd_instance_timers_update_interval_modify(struct nb_cb_modify_args
*args
)
868 if (args
->event
!= NB_EV_APPLY
)
871 rip
= nb_running_get_entry(args
->dnode
, NULL
, true);
872 rip
->update_time
= yang_dnode_get_uint32(args
->dnode
, NULL
);
878 * XPath: /frr-ripd:ripd/instance/version/receive
880 int ripd_instance_version_receive_modify(struct nb_cb_modify_args
*args
)
884 if (args
->event
!= NB_EV_APPLY
)
887 rip
= nb_running_get_entry(args
->dnode
, NULL
, true);
888 rip
->version_recv
= yang_dnode_get_enum(args
->dnode
, NULL
);
894 * XPath: /frr-ripd:ripd/instance/version/send
896 int ripd_instance_version_send_modify(struct nb_cb_modify_args
*args
)
900 if (args
->event
!= NB_EV_APPLY
)
903 rip
= nb_running_get_entry(args
->dnode
, NULL
, true);
904 rip
->version_send
= yang_dnode_get_enum(args
->dnode
, NULL
);
910 * XPath: /frr-ripd:ripd/instance/default-bfd-profile
912 int ripd_instance_default_bfd_profile_modify(struct nb_cb_modify_args
*args
)
916 if (args
->event
!= NB_EV_APPLY
)
919 rip
= nb_running_get_entry(args
->dnode
, NULL
, true);
920 XFREE(MTYPE_RIP_BFD_PROFILE
, rip
->default_bfd_profile
);
921 rip
->default_bfd_profile
=
922 XSTRDUP(MTYPE_RIP_BFD_PROFILE
,
923 yang_dnode_get_string(args
->dnode
, NULL
));
924 rip_bfd_instance_update(rip
);
929 int ripd_instance_default_bfd_profile_destroy(struct nb_cb_destroy_args
*args
)
933 if (args
->event
!= NB_EV_APPLY
)
936 rip
= nb_running_get_entry(args
->dnode
, NULL
, true);
937 XFREE(MTYPE_RIP_BFD_PROFILE
, rip
->default_bfd_profile
);
938 rip_bfd_instance_update(rip
);
944 * XPath: /frr-interface:lib/interface/frr-ripd:rip/split-horizon
946 int lib_interface_rip_split_horizon_modify(struct nb_cb_modify_args
*args
)
948 struct interface
*ifp
;
949 struct rip_interface
*ri
;
951 if (args
->event
!= NB_EV_APPLY
)
954 ifp
= nb_running_get_entry(args
->dnode
, NULL
, true);
956 ri
->split_horizon
= yang_dnode_get_enum(args
->dnode
, NULL
);
962 * XPath: /frr-interface:lib/interface/frr-ripd:rip/v2-broadcast
964 int lib_interface_rip_v2_broadcast_modify(struct nb_cb_modify_args
*args
)
966 struct interface
*ifp
;
967 struct rip_interface
*ri
;
969 if (args
->event
!= NB_EV_APPLY
)
972 ifp
= nb_running_get_entry(args
->dnode
, NULL
, true);
974 ri
->v2_broadcast
= yang_dnode_get_bool(args
->dnode
, NULL
);
980 * XPath: /frr-interface:lib/interface/frr-ripd:rip/version-receive
982 int lib_interface_rip_version_receive_modify(struct nb_cb_modify_args
*args
)
984 struct interface
*ifp
;
985 struct rip_interface
*ri
;
987 if (args
->event
!= NB_EV_APPLY
)
990 ifp
= nb_running_get_entry(args
->dnode
, NULL
, true);
992 ri
->ri_receive
= yang_dnode_get_enum(args
->dnode
, NULL
);
998 * XPath: /frr-interface:lib/interface/frr-ripd:rip/version-send
1000 int lib_interface_rip_version_send_modify(struct nb_cb_modify_args
*args
)
1002 struct interface
*ifp
;
1003 struct rip_interface
*ri
;
1005 if (args
->event
!= NB_EV_APPLY
)
1008 ifp
= nb_running_get_entry(args
->dnode
, NULL
, true);
1010 ri
->ri_send
= yang_dnode_get_enum(args
->dnode
, NULL
);
1016 * XPath: /frr-interface:lib/interface/frr-ripd:rip/authentication-scheme/mode
1018 int lib_interface_rip_authentication_scheme_mode_modify(
1019 struct nb_cb_modify_args
*args
)
1021 struct interface
*ifp
;
1022 struct rip_interface
*ri
;
1024 if (args
->event
!= NB_EV_APPLY
)
1027 ifp
= nb_running_get_entry(args
->dnode
, NULL
, true);
1029 ri
->auth_type
= yang_dnode_get_enum(args
->dnode
, NULL
);
1036 * /frr-interface:lib/interface/frr-ripd:rip/authentication-scheme/md5-auth-length
1038 int lib_interface_rip_authentication_scheme_md5_auth_length_modify(
1039 struct nb_cb_modify_args
*args
)
1041 struct interface
*ifp
;
1042 struct rip_interface
*ri
;
1044 if (args
->event
!= NB_EV_APPLY
)
1047 ifp
= nb_running_get_entry(args
->dnode
, NULL
, true);
1049 ri
->md5_auth_len
= yang_dnode_get_enum(args
->dnode
, NULL
);
1054 int lib_interface_rip_authentication_scheme_md5_auth_length_destroy(
1055 struct nb_cb_destroy_args
*args
)
1057 struct interface
*ifp
;
1058 struct rip_interface
*ri
;
1060 if (args
->event
!= NB_EV_APPLY
)
1063 ifp
= nb_running_get_entry(args
->dnode
, NULL
, true);
1065 ri
->md5_auth_len
= yang_get_default_enum(
1066 "%s/authentication-scheme/md5-auth-length", RIP_IFACE
);
1072 * XPath: /frr-interface:lib/interface/frr-ripd:rip/authentication-password
1074 int lib_interface_rip_authentication_password_modify(
1075 struct nb_cb_modify_args
*args
)
1077 struct interface
*ifp
;
1078 struct rip_interface
*ri
;
1080 if (args
->event
!= NB_EV_APPLY
)
1083 ifp
= nb_running_get_entry(args
->dnode
, NULL
, true);
1085 XFREE(MTYPE_RIP_INTERFACE_STRING
, ri
->auth_str
);
1086 ri
->auth_str
= XSTRDUP(MTYPE_RIP_INTERFACE_STRING
,
1087 yang_dnode_get_string(args
->dnode
, NULL
));
1092 int lib_interface_rip_authentication_password_destroy(
1093 struct nb_cb_destroy_args
*args
)
1095 struct interface
*ifp
;
1096 struct rip_interface
*ri
;
1098 if (args
->event
!= NB_EV_APPLY
)
1101 ifp
= nb_running_get_entry(args
->dnode
, NULL
, true);
1103 XFREE(MTYPE_RIP_INTERFACE_STRING
, ri
->auth_str
);
1109 * XPath: /frr-interface:lib/interface/frr-ripd:rip/bfd-monitoring
1111 int lib_interface_rip_bfd_create(struct nb_cb_create_args
*args
)
1113 struct interface
*ifp
;
1114 struct rip_interface
*ri
;
1116 if (args
->event
!= NB_EV_APPLY
)
1119 ifp
= nb_running_get_entry(args
->dnode
, NULL
, true);
1121 ri
->bfd
.enabled
= yang_dnode_get_bool(args
->dnode
, "./enable");
1122 XFREE(MTYPE_RIP_BFD_PROFILE
, ri
->bfd
.profile
);
1123 if (yang_dnode_exists(args
->dnode
, "./profile"))
1124 ri
->bfd
.profile
= XSTRDUP(
1125 MTYPE_RIP_BFD_PROFILE
,
1126 yang_dnode_get_string(args
->dnode
, "./profile"));
1128 rip_bfd_interface_update(ri
);
1133 int lib_interface_rip_bfd_destroy(struct nb_cb_destroy_args
*args
)
1135 struct interface
*ifp
;
1136 struct rip_interface
*ri
;
1138 if (args
->event
!= NB_EV_APPLY
)
1141 ifp
= nb_running_get_entry(args
->dnode
, NULL
, true);
1143 ri
->bfd
.enabled
= false;
1144 XFREE(MTYPE_RIP_BFD_PROFILE
, ri
->bfd
.profile
);
1145 rip_bfd_interface_update(ri
);
1151 * XPath: /frr-interface:lib/interface/frr-ripd:rip/bfd-monitoring/enable
1153 int lib_interface_rip_bfd_enable_modify(struct nb_cb_modify_args
*args
)
1155 struct interface
*ifp
;
1156 struct rip_interface
*ri
;
1158 if (args
->event
!= NB_EV_APPLY
)
1161 ifp
= nb_running_get_entry(args
->dnode
, NULL
, true);
1163 ri
->bfd
.enabled
= yang_dnode_get_bool(args
->dnode
, NULL
);
1164 rip_bfd_interface_update(ri
);
1170 * XPath: /frr-interface:lib/interface/frr-ripd:rip/bfd-monitoring/profile
1172 int lib_interface_rip_bfd_profile_modify(struct nb_cb_modify_args
*args
)
1174 struct interface
*ifp
;
1175 struct rip_interface
*ri
;
1177 if (args
->event
!= NB_EV_APPLY
)
1180 ifp
= nb_running_get_entry(args
->dnode
, NULL
, true);
1182 XFREE(MTYPE_RIP_BFD_PROFILE
, ri
->bfd
.profile
);
1183 ri
->bfd
.profile
= XSTRDUP(MTYPE_RIP_BFD_PROFILE
,
1184 yang_dnode_get_string(args
->dnode
, NULL
));
1185 rip_bfd_interface_update(ri
);
1190 int lib_interface_rip_bfd_profile_destroy(struct nb_cb_destroy_args
*args
)
1192 struct interface
*ifp
;
1193 struct rip_interface
*ri
;
1195 if (args
->event
!= NB_EV_APPLY
)
1198 ifp
= nb_running_get_entry(args
->dnode
, NULL
, true);
1200 XFREE(MTYPE_RIP_BFD_PROFILE
, ri
->bfd
.profile
);
1201 rip_bfd_interface_update(ri
);
1207 * XPath: /frr-interface:lib/interface/frr-ripd:rip/authentication-key-chain
1209 int lib_interface_rip_authentication_key_chain_modify(
1210 struct nb_cb_modify_args
*args
)
1212 struct interface
*ifp
;
1213 struct rip_interface
*ri
;
1215 if (args
->event
!= NB_EV_APPLY
)
1218 ifp
= nb_running_get_entry(args
->dnode
, NULL
, true);
1220 XFREE(MTYPE_RIP_INTERFACE_STRING
, ri
->key_chain
);
1221 ri
->key_chain
= XSTRDUP(MTYPE_RIP_INTERFACE_STRING
,
1222 yang_dnode_get_string(args
->dnode
, NULL
));
1227 int lib_interface_rip_authentication_key_chain_destroy(
1228 struct nb_cb_destroy_args
*args
)
1230 struct interface
*ifp
;
1231 struct rip_interface
*ri
;
1233 if (args
->event
!= NB_EV_APPLY
)
1236 ifp
= nb_running_get_entry(args
->dnode
, NULL
, true);
1238 XFREE(MTYPE_RIP_INTERFACE_STRING
, ri
->key_chain
);