]> git.proxmox.com Git - mirror_frr.git/blob - ripd/rip_northbound.c
Merge pull request #5197 from SumitAgarwal123/BFD_ADMIN_DOWN
[mirror_frr.git] / ripd / rip_northbound.c
1 /*
2 * Copyright (C) 1997, 1998, 1999 Kunihiro Ishiguro <kunihiro@zebra.org>
3 * Copyright (C) 2018 NetDEF, Inc.
4 * Renato Westphal
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #include <zebra.h>
22
23 #include "if.h"
24 #include "vrf.h"
25 #include "log.h"
26 #include "prefix.h"
27 #include "table.h"
28 #include "command.h"
29 #include "routemap.h"
30 #include "northbound.h"
31 #include "libfrr.h"
32
33 #include "ripd/ripd.h"
34 #include "ripd/rip_debug.h"
35 #include "ripd/rip_cli.h"
36 #include "ripd/rip_interface.h"
37
38 /*
39 * XPath: /frr-ripd:ripd/instance
40 */
41 static int ripd_instance_create(enum nb_event event,
42 const struct lyd_node *dnode,
43 union nb_resource *resource)
44 {
45 struct rip *rip;
46 struct vrf *vrf;
47 const char *vrf_name;
48 int socket;
49
50 vrf_name = yang_dnode_get_string(dnode, "./vrf");
51 vrf = vrf_lookup_by_name(vrf_name);
52
53 /*
54 * Try to create a RIP socket only if the VRF is enabled, otherwise
55 * create a disabled RIP instance and wait for the VRF to be enabled.
56 */
57 switch (event) {
58 case NB_EV_VALIDATE:
59 break;
60 case NB_EV_PREPARE:
61 if (!vrf || !vrf_is_enabled(vrf))
62 break;
63
64 socket = rip_create_socket(vrf);
65 if (socket < 0)
66 return NB_ERR_RESOURCE;
67 resource->fd = socket;
68 break;
69 case NB_EV_ABORT:
70 if (!vrf || !vrf_is_enabled(vrf))
71 break;
72
73 socket = resource->fd;
74 close(socket);
75 break;
76 case NB_EV_APPLY:
77 if (vrf && vrf_is_enabled(vrf))
78 socket = resource->fd;
79 else
80 socket = -1;
81
82 rip = rip_create(vrf_name, vrf, socket);
83 nb_running_set_entry(dnode, rip);
84 break;
85 }
86
87 return NB_OK;
88 }
89
90 static int ripd_instance_destroy(enum nb_event event,
91 const struct lyd_node *dnode)
92 {
93 struct rip *rip;
94
95 if (event != NB_EV_APPLY)
96 return NB_OK;
97
98 rip = nb_running_unset_entry(dnode);
99 rip_clean(rip);
100
101 return NB_OK;
102 }
103
104 static const void *ripd_instance_get_next(const void *parent_list_entry,
105 const void *list_entry)
106 {
107 struct rip *rip = (struct rip *)list_entry;
108
109 if (list_entry == NULL)
110 rip = RB_MIN(rip_instance_head, &rip_instances);
111 else
112 rip = RB_NEXT(rip_instance_head, rip);
113
114 return rip;
115 }
116
117 static int ripd_instance_get_keys(const void *list_entry,
118 struct yang_list_keys *keys)
119 {
120 const struct rip *rip = list_entry;
121
122 keys->num = 1;
123 strlcpy(keys->key[0], rip->vrf_name, sizeof(keys->key[0]));
124
125 return NB_OK;
126 }
127
128 static const void *ripd_instance_lookup_entry(const void *parent_list_entry,
129 const struct yang_list_keys *keys)
130 {
131 const char *vrf_name = keys->key[0];
132
133 return rip_lookup_by_vrf_name(vrf_name);
134 }
135
136 /*
137 * XPath: /frr-ripd:ripd/instance/allow-ecmp
138 */
139 static int ripd_instance_allow_ecmp_modify(enum nb_event event,
140 const struct lyd_node *dnode,
141 union nb_resource *resource)
142 {
143 struct rip *rip;
144
145 if (event != NB_EV_APPLY)
146 return NB_OK;
147
148 rip = nb_running_get_entry(dnode, NULL, true);
149 rip->ecmp = yang_dnode_get_bool(dnode, NULL);
150 if (!rip->ecmp)
151 rip_ecmp_disable(rip);
152
153 return NB_OK;
154 }
155
156 /*
157 * XPath: /frr-ripd:ripd/instance/default-information-originate
158 */
159 static int
160 ripd_instance_default_information_originate_modify(enum nb_event event,
161 const struct lyd_node *dnode,
162 union nb_resource *resource)
163 {
164 struct rip *rip;
165 bool default_information;
166 struct prefix_ipv4 p;
167
168 if (event != NB_EV_APPLY)
169 return NB_OK;
170
171 rip = nb_running_get_entry(dnode, NULL, true);
172 default_information = yang_dnode_get_bool(dnode, NULL);
173
174 memset(&p, 0, sizeof(struct prefix_ipv4));
175 p.family = AF_INET;
176 if (default_information) {
177 struct nexthop nh;
178
179 memset(&nh, 0, sizeof(nh));
180 nh.type = NEXTHOP_TYPE_IPV4;
181 rip_redistribute_add(rip, ZEBRA_ROUTE_RIP, RIP_ROUTE_DEFAULT,
182 &p, &nh, 0, 0, 0);
183 } else {
184 rip_redistribute_delete(rip, ZEBRA_ROUTE_RIP, RIP_ROUTE_DEFAULT,
185 &p, 0);
186 }
187
188 return NB_OK;
189 }
190
191 /*
192 * XPath: /frr-ripd:ripd/instance/default-metric
193 */
194 static int ripd_instance_default_metric_modify(enum nb_event event,
195 const struct lyd_node *dnode,
196 union nb_resource *resource)
197 {
198 struct rip *rip;
199
200 if (event != NB_EV_APPLY)
201 return NB_OK;
202
203 rip = nb_running_get_entry(dnode, NULL, true);
204 rip->default_metric = yang_dnode_get_uint8(dnode, NULL);
205 /* rip_update_default_metric (); */
206
207 return NB_OK;
208 }
209
210 /*
211 * XPath: /frr-ripd:ripd/instance/distance/default
212 */
213 static int ripd_instance_distance_default_modify(enum nb_event event,
214 const struct lyd_node *dnode,
215 union nb_resource *resource)
216 {
217 struct rip *rip;
218
219 if (event != NB_EV_APPLY)
220 return NB_OK;
221
222 rip = nb_running_get_entry(dnode, NULL, true);
223 rip->distance = yang_dnode_get_uint8(dnode, NULL);
224
225 return NB_OK;
226 }
227
228 /*
229 * XPath: /frr-ripd:ripd/instance/distance/source
230 */
231 static int ripd_instance_distance_source_create(enum nb_event event,
232 const struct lyd_node *dnode,
233 union nb_resource *resource)
234 {
235 struct rip *rip;
236 struct prefix_ipv4 prefix;
237 struct route_node *rn;
238
239 if (event != NB_EV_APPLY)
240 return NB_OK;
241
242 yang_dnode_get_ipv4p(&prefix, dnode, "./prefix");
243 apply_mask_ipv4(&prefix);
244
245 /* Get RIP distance node. */
246 rip = nb_running_get_entry(dnode, NULL, true);
247 rn = route_node_get(rip->distance_table, (struct prefix *)&prefix);
248 rn->info = rip_distance_new();
249 nb_running_set_entry(dnode, rn);
250
251 return NB_OK;
252 }
253
254 static int ripd_instance_distance_source_destroy(enum nb_event event,
255 const struct lyd_node *dnode)
256 {
257 struct route_node *rn;
258 struct rip_distance *rdistance;
259
260 if (event != NB_EV_APPLY)
261 return NB_OK;
262
263 rn = nb_running_unset_entry(dnode);
264 rdistance = rn->info;
265 rip_distance_free(rdistance);
266 rn->info = NULL;
267 route_unlock_node(rn);
268
269 return NB_OK;
270 }
271
272 /*
273 * XPath: /frr-ripd:ripd/instance/distance/source/distance
274 */
275 static int
276 ripd_instance_distance_source_distance_modify(enum nb_event event,
277 const struct lyd_node *dnode,
278 union nb_resource *resource)
279 {
280 struct route_node *rn;
281 uint8_t distance;
282 struct rip_distance *rdistance;
283
284 if (event != NB_EV_APPLY)
285 return NB_OK;
286
287 /* Set distance value. */
288 rn = nb_running_get_entry(dnode, NULL, true);
289 distance = yang_dnode_get_uint8(dnode, NULL);
290 rdistance = rn->info;
291 rdistance->distance = distance;
292
293 return NB_OK;
294 }
295
296 /*
297 * XPath: /frr-ripd:ripd/instance/distance/source/access-list
298 */
299 static int
300 ripd_instance_distance_source_access_list_modify(enum nb_event event,
301 const struct lyd_node *dnode,
302 union nb_resource *resource)
303 {
304 const char *acl_name;
305 struct route_node *rn;
306 struct rip_distance *rdistance;
307
308 if (event != NB_EV_APPLY)
309 return NB_OK;
310
311 acl_name = yang_dnode_get_string(dnode, NULL);
312
313 /* Set access-list */
314 rn = nb_running_get_entry(dnode, NULL, true);
315 rdistance = rn->info;
316 if (rdistance->access_list)
317 free(rdistance->access_list);
318 rdistance->access_list = strdup(acl_name);
319
320 return NB_OK;
321 }
322
323 static int
324 ripd_instance_distance_source_access_list_destroy(enum nb_event event,
325 const struct lyd_node *dnode)
326 {
327 struct route_node *rn;
328 struct rip_distance *rdistance;
329
330 if (event != NB_EV_APPLY)
331 return NB_OK;
332
333 /* Reset access-list configuration. */
334 rn = nb_running_get_entry(dnode, NULL, true);
335 rdistance = rn->info;
336 free(rdistance->access_list);
337 rdistance->access_list = NULL;
338
339 return NB_OK;
340 }
341
342 /*
343 * XPath: /frr-ripd:ripd/instance/explicit-neighbor
344 */
345 static int ripd_instance_explicit_neighbor_create(enum nb_event event,
346 const struct lyd_node *dnode,
347 union nb_resource *resource)
348 {
349 struct rip *rip;
350 struct prefix_ipv4 p;
351
352 if (event != NB_EV_APPLY)
353 return NB_OK;
354
355 rip = nb_running_get_entry(dnode, NULL, true);
356 p.family = AF_INET;
357 p.prefixlen = IPV4_MAX_BITLEN;
358 yang_dnode_get_ipv4(&p.prefix, dnode, NULL);
359
360 return rip_neighbor_add(rip, &p);
361 }
362
363 static int ripd_instance_explicit_neighbor_destroy(enum nb_event event,
364 const struct lyd_node *dnode)
365 {
366 struct rip *rip;
367 struct prefix_ipv4 p;
368
369 if (event != NB_EV_APPLY)
370 return NB_OK;
371
372 rip = nb_running_get_entry(dnode, NULL, true);
373 p.family = AF_INET;
374 p.prefixlen = IPV4_MAX_BITLEN;
375 yang_dnode_get_ipv4(&p.prefix, dnode, NULL);
376
377 return rip_neighbor_delete(rip, &p);
378 }
379
380 /*
381 * XPath: /frr-ripd:ripd/instance/network
382 */
383 static int ripd_instance_network_create(enum nb_event event,
384 const struct lyd_node *dnode,
385 union nb_resource *resource)
386 {
387 struct rip *rip;
388 struct prefix p;
389
390 if (event != NB_EV_APPLY)
391 return NB_OK;
392
393 rip = nb_running_get_entry(dnode, NULL, true);
394 yang_dnode_get_ipv4p(&p, dnode, NULL);
395 apply_mask_ipv4((struct prefix_ipv4 *)&p);
396
397 return rip_enable_network_add(rip, &p);
398 }
399
400 static int ripd_instance_network_destroy(enum nb_event event,
401 const struct lyd_node *dnode)
402 {
403 struct rip *rip;
404 struct prefix p;
405
406 if (event != NB_EV_APPLY)
407 return NB_OK;
408
409 rip = nb_running_get_entry(dnode, NULL, true);
410 yang_dnode_get_ipv4p(&p, dnode, NULL);
411 apply_mask_ipv4((struct prefix_ipv4 *)&p);
412
413 return rip_enable_network_delete(rip, &p);
414 }
415
416 /*
417 * XPath: /frr-ripd:ripd/instance/interface
418 */
419 static int ripd_instance_interface_create(enum nb_event event,
420 const struct lyd_node *dnode,
421 union nb_resource *resource)
422 {
423 struct rip *rip;
424 const char *ifname;
425
426 if (event != NB_EV_APPLY)
427 return NB_OK;
428
429 rip = nb_running_get_entry(dnode, NULL, true);
430 ifname = yang_dnode_get_string(dnode, NULL);
431
432 return rip_enable_if_add(rip, ifname);
433 }
434
435 static int ripd_instance_interface_destroy(enum nb_event event,
436 const struct lyd_node *dnode)
437 {
438 struct rip *rip;
439 const char *ifname;
440
441 if (event != NB_EV_APPLY)
442 return NB_OK;
443
444 rip = nb_running_get_entry(dnode, NULL, true);
445 ifname = yang_dnode_get_string(dnode, NULL);
446
447 return rip_enable_if_delete(rip, ifname);
448 }
449
450 /*
451 * XPath: /frr-ripd:ripd/instance/offset-list
452 */
453 static int ripd_instance_offset_list_create(enum nb_event event,
454 const struct lyd_node *dnode,
455 union nb_resource *resource)
456 {
457 struct rip *rip;
458 const char *ifname;
459 struct rip_offset_list *offset;
460
461 if (event != NB_EV_APPLY)
462 return NB_OK;
463
464 rip = nb_running_get_entry(dnode, NULL, true);
465 ifname = yang_dnode_get_string(dnode, "./interface");
466
467 offset = rip_offset_list_new(rip, ifname);
468 nb_running_set_entry(dnode, offset);
469
470 return NB_OK;
471 }
472
473 static int ripd_instance_offset_list_destroy(enum nb_event event,
474 const struct lyd_node *dnode)
475 {
476 int direct;
477 struct rip_offset_list *offset;
478
479 if (event != NB_EV_APPLY)
480 return NB_OK;
481
482 direct = yang_dnode_get_enum(dnode, "./direction");
483
484 offset = nb_running_unset_entry(dnode);
485 if (offset->direct[direct].alist_name) {
486 free(offset->direct[direct].alist_name);
487 offset->direct[direct].alist_name = NULL;
488 }
489 if (offset->direct[RIP_OFFSET_LIST_IN].alist_name == NULL
490 && offset->direct[RIP_OFFSET_LIST_OUT].alist_name == NULL)
491 offset_list_del(offset);
492
493 return NB_OK;
494 }
495
496 /*
497 * XPath: /frr-ripd:ripd/instance/offset-list/access-list
498 */
499 static int
500 ripd_instance_offset_list_access_list_modify(enum nb_event event,
501 const struct lyd_node *dnode,
502 union nb_resource *resource)
503 {
504 int direct;
505 struct rip_offset_list *offset;
506 const char *alist_name;
507
508 if (event != NB_EV_APPLY)
509 return NB_OK;
510
511 direct = yang_dnode_get_enum(dnode, "../direction");
512 alist_name = yang_dnode_get_string(dnode, NULL);
513
514 offset = nb_running_get_entry(dnode, NULL, true);
515 if (offset->direct[direct].alist_name)
516 free(offset->direct[direct].alist_name);
517 offset->direct[direct].alist_name = strdup(alist_name);
518
519 return NB_OK;
520 }
521
522 /*
523 * XPath: /frr-ripd:ripd/instance/offset-list/metric
524 */
525 static int ripd_instance_offset_list_metric_modify(enum nb_event event,
526 const struct lyd_node *dnode,
527 union nb_resource *resource)
528 {
529 int direct;
530 uint8_t metric;
531 struct rip_offset_list *offset;
532
533 if (event != NB_EV_APPLY)
534 return NB_OK;
535
536 direct = yang_dnode_get_enum(dnode, "../direction");
537 metric = yang_dnode_get_uint8(dnode, NULL);
538
539 offset = nb_running_get_entry(dnode, NULL, true);
540 offset->direct[direct].metric = metric;
541
542 return NB_OK;
543 }
544
545 /*
546 * XPath: /frr-ripd:ripd/instance/passive-default
547 */
548 static int ripd_instance_passive_default_modify(enum nb_event event,
549 const struct lyd_node *dnode,
550 union nb_resource *resource)
551 {
552 struct rip *rip;
553
554 if (event != NB_EV_APPLY)
555 return NB_OK;
556
557 rip = nb_running_get_entry(dnode, NULL, true);
558 rip->passive_default = yang_dnode_get_bool(dnode, NULL);
559 rip_passive_nondefault_clean(rip);
560
561 return NB_OK;
562 }
563
564 /*
565 * XPath: /frr-ripd:ripd/instance/passive-interface
566 */
567 static int ripd_instance_passive_interface_create(enum nb_event event,
568 const struct lyd_node *dnode,
569 union nb_resource *resource)
570 {
571 struct rip *rip;
572 const char *ifname;
573
574 if (event != NB_EV_APPLY)
575 return NB_OK;
576
577 rip = nb_running_get_entry(dnode, NULL, true);
578 ifname = yang_dnode_get_string(dnode, NULL);
579
580 return rip_passive_nondefault_set(rip, ifname);
581 }
582
583 static int ripd_instance_passive_interface_destroy(enum nb_event event,
584 const struct lyd_node *dnode)
585 {
586 struct rip *rip;
587 const char *ifname;
588
589 if (event != NB_EV_APPLY)
590 return NB_OK;
591
592 rip = nb_running_get_entry(dnode, NULL, true);
593 ifname = yang_dnode_get_string(dnode, NULL);
594
595 return rip_passive_nondefault_unset(rip, ifname);
596 }
597
598 /*
599 * XPath: /frr-ripd:ripd/instance/non-passive-interface
600 */
601 static int
602 ripd_instance_non_passive_interface_create(enum nb_event event,
603 const struct lyd_node *dnode,
604 union nb_resource *resource)
605 {
606 struct rip *rip;
607 const char *ifname;
608
609 if (event != NB_EV_APPLY)
610 return NB_OK;
611
612 rip = nb_running_get_entry(dnode, NULL, true);
613 ifname = yang_dnode_get_string(dnode, NULL);
614
615 return rip_passive_nondefault_unset(rip, ifname);
616 }
617
618 static int
619 ripd_instance_non_passive_interface_destroy(enum nb_event event,
620 const struct lyd_node *dnode)
621 {
622 struct rip *rip;
623 const char *ifname;
624
625 if (event != NB_EV_APPLY)
626 return NB_OK;
627
628 rip = nb_running_get_entry(dnode, NULL, true);
629 ifname = yang_dnode_get_string(dnode, NULL);
630
631 return rip_passive_nondefault_set(rip, ifname);
632 }
633
634 /*
635 * XPath: /frr-ripd:ripd/instance/redistribute
636 */
637 static int ripd_instance_redistribute_create(enum nb_event event,
638 const struct lyd_node *dnode,
639 union nb_resource *resource)
640 {
641 struct rip *rip;
642 int type;
643
644 if (event != NB_EV_APPLY)
645 return NB_OK;
646
647 rip = nb_running_get_entry(dnode, NULL, true);
648 type = yang_dnode_get_enum(dnode, "./protocol");
649
650 rip->redist[type].enabled = true;
651
652 return NB_OK;
653 }
654
655 static int ripd_instance_redistribute_destroy(enum nb_event event,
656 const struct lyd_node *dnode)
657 {
658 struct rip *rip;
659 int type;
660
661 if (event != NB_EV_APPLY)
662 return NB_OK;
663
664 rip = nb_running_get_entry(dnode, NULL, true);
665 type = yang_dnode_get_enum(dnode, "./protocol");
666
667 rip->redist[type].enabled = false;
668 if (rip->redist[type].route_map.name) {
669 free(rip->redist[type].route_map.name);
670 rip->redist[type].route_map.name = NULL;
671 rip->redist[type].route_map.map = NULL;
672 }
673 rip->redist[type].metric_config = false;
674 rip->redist[type].metric = 0;
675
676 if (rip->enabled)
677 rip_redistribute_conf_delete(rip, type);
678
679 return NB_OK;
680 }
681
682 static void
683 ripd_instance_redistribute_apply_finish(const struct lyd_node *dnode)
684 {
685 struct rip *rip;
686 int type;
687
688 rip = nb_running_get_entry(dnode, NULL, true);
689 type = yang_dnode_get_enum(dnode, "./protocol");
690
691 if (rip->enabled)
692 rip_redistribute_conf_update(rip, type);
693 }
694
695 /*
696 * XPath: /frr-ripd:ripd/instance/redistribute/route-map
697 */
698 static int
699 ripd_instance_redistribute_route_map_modify(enum nb_event event,
700 const struct lyd_node *dnode,
701 union nb_resource *resource)
702 {
703 struct rip *rip;
704 int type;
705 const char *rmap_name;
706
707 if (event != NB_EV_APPLY)
708 return NB_OK;
709
710 rip = nb_running_get_entry(dnode, NULL, true);
711 type = yang_dnode_get_enum(dnode, "../protocol");
712 rmap_name = yang_dnode_get_string(dnode, NULL);
713
714 if (rip->redist[type].route_map.name)
715 free(rip->redist[type].route_map.name);
716 rip->redist[type].route_map.name = strdup(rmap_name);
717 rip->redist[type].route_map.map = route_map_lookup_by_name(rmap_name);
718
719 return NB_OK;
720 }
721
722 static int
723 ripd_instance_redistribute_route_map_destroy(enum nb_event event,
724 const struct lyd_node *dnode)
725 {
726 struct rip *rip;
727 int type;
728
729 if (event != NB_EV_APPLY)
730 return NB_OK;
731
732 rip = nb_running_get_entry(dnode, NULL, true);
733 type = yang_dnode_get_enum(dnode, "../protocol");
734
735 free(rip->redist[type].route_map.name);
736 rip->redist[type].route_map.name = NULL;
737 rip->redist[type].route_map.map = NULL;
738
739 return NB_OK;
740 }
741
742 /*
743 * XPath: /frr-ripd:ripd/instance/redistribute/metric
744 */
745 static int
746 ripd_instance_redistribute_metric_modify(enum nb_event event,
747 const struct lyd_node *dnode,
748 union nb_resource *resource)
749 {
750 struct rip *rip;
751 int type;
752 uint8_t metric;
753
754 if (event != NB_EV_APPLY)
755 return NB_OK;
756
757 rip = nb_running_get_entry(dnode, NULL, true);
758 type = yang_dnode_get_enum(dnode, "../protocol");
759 metric = yang_dnode_get_uint8(dnode, NULL);
760
761 rip->redist[type].metric_config = true;
762 rip->redist[type].metric = metric;
763
764 return NB_OK;
765 }
766
767 static int
768 ripd_instance_redistribute_metric_destroy(enum nb_event event,
769 const struct lyd_node *dnode)
770 {
771 struct rip *rip;
772 int type;
773
774 if (event != NB_EV_APPLY)
775 return NB_OK;
776
777 rip = nb_running_get_entry(dnode, NULL, true);
778 type = yang_dnode_get_enum(dnode, "../protocol");
779
780 rip->redist[type].metric_config = false;
781 rip->redist[type].metric = 0;
782
783 return NB_OK;
784 }
785
786 /*
787 * XPath: /frr-ripd:ripd/instance/static-route
788 */
789 static int ripd_instance_static_route_create(enum nb_event event,
790 const struct lyd_node *dnode,
791 union nb_resource *resource)
792 {
793 struct rip *rip;
794 struct nexthop nh;
795 struct prefix_ipv4 p;
796
797 if (event != NB_EV_APPLY)
798 return NB_OK;
799
800 rip = nb_running_get_entry(dnode, NULL, true);
801 yang_dnode_get_ipv4p(&p, dnode, NULL);
802 apply_mask_ipv4(&p);
803
804 memset(&nh, 0, sizeof(nh));
805 nh.type = NEXTHOP_TYPE_IPV4;
806 rip_redistribute_add(rip, ZEBRA_ROUTE_RIP, RIP_ROUTE_STATIC, &p, &nh, 0,
807 0, 0);
808
809 return NB_OK;
810 }
811
812 static int ripd_instance_static_route_destroy(enum nb_event event,
813 const struct lyd_node *dnode)
814 {
815 struct rip *rip;
816 struct prefix_ipv4 p;
817
818 if (event != NB_EV_APPLY)
819 return NB_OK;
820
821 rip = nb_running_get_entry(dnode, NULL, true);
822 yang_dnode_get_ipv4p(&p, dnode, NULL);
823 apply_mask_ipv4(&p);
824
825 rip_redistribute_delete(rip, ZEBRA_ROUTE_RIP, RIP_ROUTE_STATIC, &p, 0);
826
827 return NB_OK;
828 }
829
830 /*
831 * XPath: /frr-ripd:ripd/instance/timers/
832 */
833 static void ripd_instance_timers_apply_finish(const struct lyd_node *dnode)
834 {
835 struct rip *rip;
836
837 rip = nb_running_get_entry(dnode, NULL, true);
838
839 /* Reset update timer thread. */
840 rip_event(rip, RIP_UPDATE_EVENT, 0);
841 }
842
843 /*
844 * XPath: /frr-ripd:ripd/instance/timers/flush-interval
845 */
846 static int
847 ripd_instance_timers_flush_interval_modify(enum nb_event event,
848 const struct lyd_node *dnode,
849 union nb_resource *resource)
850 {
851 struct rip *rip;
852
853 if (event != NB_EV_APPLY)
854 return NB_OK;
855
856 rip = nb_running_get_entry(dnode, NULL, true);
857 rip->garbage_time = yang_dnode_get_uint32(dnode, NULL);
858
859 return NB_OK;
860 }
861
862 /*
863 * XPath: /frr-ripd:ripd/instance/timers/holddown-interval
864 */
865 static int
866 ripd_instance_timers_holddown_interval_modify(enum nb_event event,
867 const struct lyd_node *dnode,
868 union nb_resource *resource)
869 {
870 struct rip *rip;
871
872 if (event != NB_EV_APPLY)
873 return NB_OK;
874
875 rip = nb_running_get_entry(dnode, NULL, true);
876 rip->timeout_time = yang_dnode_get_uint32(dnode, NULL);
877
878 return NB_OK;
879 }
880
881 /*
882 * XPath: /frr-ripd:ripd/instance/timers/update-interval
883 */
884 static int
885 ripd_instance_timers_update_interval_modify(enum nb_event event,
886 const struct lyd_node *dnode,
887 union nb_resource *resource)
888 {
889 struct rip *rip;
890
891 if (event != NB_EV_APPLY)
892 return NB_OK;
893
894 rip = nb_running_get_entry(dnode, NULL, true);
895 rip->update_time = yang_dnode_get_uint32(dnode, NULL);
896
897 return NB_OK;
898 }
899
900 /*
901 * XPath: /frr-ripd:ripd/instance/version/receive
902 */
903 static int ripd_instance_version_receive_modify(enum nb_event event,
904 const struct lyd_node *dnode,
905 union nb_resource *resource)
906 {
907 struct rip *rip;
908
909 if (event != NB_EV_APPLY)
910 return NB_OK;
911
912 rip = nb_running_get_entry(dnode, NULL, true);
913 rip->version_recv = yang_dnode_get_enum(dnode, NULL);
914
915 return NB_OK;
916 }
917
918 /*
919 * XPath: /frr-ripd:ripd/instance/version/send
920 */
921 static int ripd_instance_version_send_modify(enum nb_event event,
922 const struct lyd_node *dnode,
923 union nb_resource *resource)
924 {
925 struct rip *rip;
926
927 if (event != NB_EV_APPLY)
928 return NB_OK;
929
930 rip = nb_running_get_entry(dnode, NULL, true);
931 rip->version_send = yang_dnode_get_enum(dnode, NULL);
932
933 return NB_OK;
934 }
935
936 /*
937 * XPath: /frr-interface:lib/interface/frr-ripd:rip/split-horizon
938 */
939 static int lib_interface_rip_split_horizon_modify(enum nb_event event,
940 const struct lyd_node *dnode,
941 union nb_resource *resource)
942 {
943 struct interface *ifp;
944 struct rip_interface *ri;
945
946 if (event != NB_EV_APPLY)
947 return NB_OK;
948
949 ifp = nb_running_get_entry(dnode, NULL, true);
950 ri = ifp->info;
951 ri->split_horizon = yang_dnode_get_enum(dnode, NULL);
952
953 return NB_OK;
954 }
955
956 /*
957 * XPath: /frr-interface:lib/interface/frr-ripd:rip/v2-broadcast
958 */
959 static int lib_interface_rip_v2_broadcast_modify(enum nb_event event,
960 const struct lyd_node *dnode,
961 union nb_resource *resource)
962 {
963 struct interface *ifp;
964 struct rip_interface *ri;
965
966 if (event != NB_EV_APPLY)
967 return NB_OK;
968
969 ifp = nb_running_get_entry(dnode, NULL, true);
970 ri = ifp->info;
971 ri->v2_broadcast = yang_dnode_get_bool(dnode, NULL);
972
973 return NB_OK;
974 }
975
976 /*
977 * XPath: /frr-interface:lib/interface/frr-ripd:rip/version-receive
978 */
979 static int
980 lib_interface_rip_version_receive_modify(enum nb_event event,
981 const struct lyd_node *dnode,
982 union nb_resource *resource)
983 {
984 struct interface *ifp;
985 struct rip_interface *ri;
986
987 if (event != NB_EV_APPLY)
988 return NB_OK;
989
990 ifp = nb_running_get_entry(dnode, NULL, true);
991 ri = ifp->info;
992 ri->ri_receive = yang_dnode_get_enum(dnode, NULL);
993
994 return NB_OK;
995 }
996
997 /*
998 * XPath: /frr-interface:lib/interface/frr-ripd:rip/version-send
999 */
1000 static int lib_interface_rip_version_send_modify(enum nb_event event,
1001 const struct lyd_node *dnode,
1002 union nb_resource *resource)
1003 {
1004 struct interface *ifp;
1005 struct rip_interface *ri;
1006
1007 if (event != NB_EV_APPLY)
1008 return NB_OK;
1009
1010 ifp = nb_running_get_entry(dnode, NULL, true);
1011 ri = ifp->info;
1012 ri->ri_send = yang_dnode_get_enum(dnode, NULL);
1013
1014 return NB_OK;
1015 }
1016
1017 /*
1018 * XPath: /frr-interface:lib/interface/frr-ripd:rip/authentication-scheme/mode
1019 */
1020 static int lib_interface_rip_authentication_scheme_mode_modify(
1021 enum nb_event event, const struct lyd_node *dnode,
1022 union nb_resource *resource)
1023 {
1024 struct interface *ifp;
1025 struct rip_interface *ri;
1026
1027 if (event != NB_EV_APPLY)
1028 return NB_OK;
1029
1030 ifp = nb_running_get_entry(dnode, NULL, true);
1031 ri = ifp->info;
1032 ri->auth_type = yang_dnode_get_enum(dnode, NULL);
1033
1034 return NB_OK;
1035 }
1036
1037 /*
1038 * XPath:
1039 * /frr-interface:lib/interface/frr-ripd:rip/authentication-scheme/md5-auth-length
1040 */
1041 static int lib_interface_rip_authentication_scheme_md5_auth_length_modify(
1042 enum nb_event event, const struct lyd_node *dnode,
1043 union nb_resource *resource)
1044 {
1045 struct interface *ifp;
1046 struct rip_interface *ri;
1047
1048 if (event != NB_EV_APPLY)
1049 return NB_OK;
1050
1051 ifp = nb_running_get_entry(dnode, NULL, true);
1052 ri = ifp->info;
1053 ri->md5_auth_len = yang_dnode_get_enum(dnode, NULL);
1054
1055 return NB_OK;
1056 }
1057
1058 static int lib_interface_rip_authentication_scheme_md5_auth_length_destroy(
1059 enum nb_event event, const struct lyd_node *dnode)
1060 {
1061 struct interface *ifp;
1062 struct rip_interface *ri;
1063
1064 if (event != NB_EV_APPLY)
1065 return NB_OK;
1066
1067 ifp = nb_running_get_entry(dnode, NULL, true);
1068 ri = ifp->info;
1069 ri->md5_auth_len = yang_get_default_enum(
1070 "%s/authentication-scheme/md5-auth-length", RIP_IFACE);
1071
1072 return NB_OK;
1073 }
1074
1075 /*
1076 * XPath: /frr-interface:lib/interface/frr-ripd:rip/authentication-password
1077 */
1078 static int
1079 lib_interface_rip_authentication_password_modify(enum nb_event event,
1080 const struct lyd_node *dnode,
1081 union nb_resource *resource)
1082 {
1083 struct interface *ifp;
1084 struct rip_interface *ri;
1085
1086 if (event != NB_EV_APPLY)
1087 return NB_OK;
1088
1089 ifp = nb_running_get_entry(dnode, NULL, true);
1090 ri = ifp->info;
1091 XFREE(MTYPE_RIP_INTERFACE_STRING, ri->auth_str);
1092 ri->auth_str = XSTRDUP(MTYPE_RIP_INTERFACE_STRING,
1093 yang_dnode_get_string(dnode, NULL));
1094
1095 return NB_OK;
1096 }
1097
1098 static int
1099 lib_interface_rip_authentication_password_destroy(enum nb_event event,
1100 const struct lyd_node *dnode)
1101 {
1102 struct interface *ifp;
1103 struct rip_interface *ri;
1104
1105 if (event != NB_EV_APPLY)
1106 return NB_OK;
1107
1108 ifp = nb_running_get_entry(dnode, NULL, true);
1109 ri = ifp->info;
1110 XFREE(MTYPE_RIP_INTERFACE_STRING, ri->auth_str);
1111
1112 return NB_OK;
1113 }
1114
1115 /*
1116 * XPath: /frr-interface:lib/interface/frr-ripd:rip/authentication-key-chain
1117 */
1118 static int
1119 lib_interface_rip_authentication_key_chain_modify(enum nb_event event,
1120 const struct lyd_node *dnode,
1121 union nb_resource *resource)
1122 {
1123 struct interface *ifp;
1124 struct rip_interface *ri;
1125
1126 if (event != NB_EV_APPLY)
1127 return NB_OK;
1128
1129 ifp = nb_running_get_entry(dnode, NULL, true);
1130 ri = ifp->info;
1131 XFREE(MTYPE_RIP_INTERFACE_STRING, ri->key_chain);
1132 ri->key_chain = XSTRDUP(MTYPE_RIP_INTERFACE_STRING,
1133 yang_dnode_get_string(dnode, NULL));
1134
1135 return NB_OK;
1136 }
1137
1138 static int
1139 lib_interface_rip_authentication_key_chain_destroy(enum nb_event event,
1140 const struct lyd_node *dnode)
1141 {
1142 struct interface *ifp;
1143 struct rip_interface *ri;
1144
1145 if (event != NB_EV_APPLY)
1146 return NB_OK;
1147
1148 ifp = nb_running_get_entry(dnode, NULL, true);
1149 ri = ifp->info;
1150 XFREE(MTYPE_RIP_INTERFACE_STRING, ri->key_chain);
1151
1152 return NB_OK;
1153 }
1154
1155 /*
1156 * XPath: /frr-ripd:ripd/instance/state/neighbors/neighbor
1157 */
1158 static const void *
1159 ripd_instance_state_neighbors_neighbor_get_next(const void *parent_list_entry,
1160 const void *list_entry)
1161 {
1162 const struct rip *rip = parent_list_entry;
1163 struct listnode *node;
1164
1165 if (list_entry == NULL)
1166 node = listhead(rip->peer_list);
1167 else
1168 node = listnextnode((struct listnode *)list_entry);
1169
1170 return node;
1171 }
1172
1173 static int
1174 ripd_instance_state_neighbors_neighbor_get_keys(const void *list_entry,
1175 struct yang_list_keys *keys)
1176 {
1177 const struct listnode *node = list_entry;
1178 const struct rip_peer *peer = listgetdata(node);
1179
1180 keys->num = 1;
1181 (void)inet_ntop(AF_INET, &peer->addr, keys->key[0],
1182 sizeof(keys->key[0]));
1183
1184 return NB_OK;
1185 }
1186
1187 static const void *ripd_instance_state_neighbors_neighbor_lookup_entry(
1188 const void *parent_list_entry, const struct yang_list_keys *keys)
1189 {
1190 const struct rip *rip = parent_list_entry;
1191 struct in_addr address;
1192 struct rip_peer *peer;
1193 struct listnode *node;
1194
1195 yang_str2ipv4(keys->key[0], &address);
1196
1197 for (ALL_LIST_ELEMENTS_RO(rip->peer_list, node, peer)) {
1198 if (IPV4_ADDR_SAME(&peer->addr, &address))
1199 return node;
1200 }
1201
1202 return NULL;
1203 }
1204
1205 /*
1206 * XPath: /frr-ripd:ripd/instance/state/neighbors/neighbor/address
1207 */
1208 static struct yang_data *
1209 ripd_instance_state_neighbors_neighbor_address_get_elem(const char *xpath,
1210 const void *list_entry)
1211 {
1212 const struct listnode *node = list_entry;
1213 const struct rip_peer *peer = listgetdata(node);
1214
1215 return yang_data_new_ipv4(xpath, &peer->addr);
1216 }
1217
1218 /*
1219 * XPath: /frr-ripd:ripd/instance/state/neighbors/neighbor/last-update
1220 */
1221 static struct yang_data *
1222 ripd_instance_state_neighbors_neighbor_last_update_get_elem(
1223 const char *xpath, const void *list_entry)
1224 {
1225 /* TODO: yang:date-and-time is tricky */
1226 return NULL;
1227 }
1228
1229 /*
1230 * XPath: /frr-ripd:ripd/instance/state/neighbors/neighbor/bad-packets-rcvd
1231 */
1232 static struct yang_data *
1233 ripd_instance_state_neighbors_neighbor_bad_packets_rcvd_get_elem(
1234 const char *xpath, const void *list_entry)
1235 {
1236 const struct listnode *node = list_entry;
1237 const struct rip_peer *peer = listgetdata(node);
1238
1239 return yang_data_new_uint32(xpath, peer->recv_badpackets);
1240 }
1241
1242 /*
1243 * XPath: /frr-ripd:ripd/instance/state/neighbors/neighbor/bad-routes-rcvd
1244 */
1245 static struct yang_data *
1246 ripd_instance_state_neighbors_neighbor_bad_routes_rcvd_get_elem(
1247 const char *xpath, const void *list_entry)
1248 {
1249 const struct listnode *node = list_entry;
1250 const struct rip_peer *peer = listgetdata(node);
1251
1252 return yang_data_new_uint32(xpath, peer->recv_badroutes);
1253 }
1254
1255 /*
1256 * XPath: /frr-ripd:ripd/instance/state/routes/route
1257 */
1258 static const void *
1259 ripd_instance_state_routes_route_get_next(const void *parent_list_entry,
1260 const void *list_entry)
1261 {
1262 const struct rip *rip = parent_list_entry;
1263 struct route_node *rn;
1264
1265 if (list_entry == NULL)
1266 rn = route_top(rip->table);
1267 else
1268 rn = route_next((struct route_node *)list_entry);
1269 while (rn && rn->info == NULL)
1270 rn = route_next(rn);
1271
1272 return rn;
1273 }
1274
1275 static int
1276 ripd_instance_state_routes_route_get_keys(const void *list_entry,
1277 struct yang_list_keys *keys)
1278 {
1279 const struct route_node *rn = list_entry;
1280
1281 keys->num = 1;
1282 (void)prefix2str(&rn->p, keys->key[0], sizeof(keys->key[0]));
1283
1284 return NB_OK;
1285 }
1286
1287 static const void *
1288 ripd_instance_state_routes_route_lookup_entry(const void *parent_list_entry,
1289 const struct yang_list_keys *keys)
1290 {
1291 const struct rip *rip = parent_list_entry;
1292 struct prefix prefix;
1293 struct route_node *rn;
1294
1295 yang_str2ipv4p(keys->key[0], &prefix);
1296
1297 rn = route_node_lookup(rip->table, &prefix);
1298 if (!rn || !rn->info)
1299 return NULL;
1300
1301 route_unlock_node(rn);
1302
1303 return rn;
1304 }
1305
1306 /*
1307 * XPath: /frr-ripd:ripd/instance/state/routes/route/prefix
1308 */
1309 static struct yang_data *
1310 ripd_instance_state_routes_route_prefix_get_elem(const char *xpath,
1311 const void *list_entry)
1312 {
1313 const struct route_node *rn = list_entry;
1314 const struct rip_info *rinfo = listnode_head(rn->info);
1315
1316 return yang_data_new_ipv4p(xpath, &rinfo->rp->p);
1317 }
1318
1319 /*
1320 * XPath: /frr-ripd:ripd/instance/state/routes/route/next-hop
1321 */
1322 static struct yang_data *
1323 ripd_instance_state_routes_route_next_hop_get_elem(const char *xpath,
1324 const void *list_entry)
1325 {
1326 const struct route_node *rn = list_entry;
1327 const struct rip_info *rinfo = listnode_head(rn->info);
1328
1329 switch (rinfo->nh.type) {
1330 case NEXTHOP_TYPE_IPV4:
1331 case NEXTHOP_TYPE_IPV4_IFINDEX:
1332 return yang_data_new_ipv4(xpath, &rinfo->nh.gate.ipv4);
1333 default:
1334 return NULL;
1335 }
1336 }
1337
1338 /*
1339 * XPath: /frr-ripd:ripd/instance/state/routes/route/interface
1340 */
1341 static struct yang_data *
1342 ripd_instance_state_routes_route_interface_get_elem(const char *xpath,
1343 const void *list_entry)
1344 {
1345 const struct route_node *rn = list_entry;
1346 const struct rip_info *rinfo = listnode_head(rn->info);
1347 const struct rip *rip = rip_info_get_instance(rinfo);
1348
1349 switch (rinfo->nh.type) {
1350 case NEXTHOP_TYPE_IFINDEX:
1351 case NEXTHOP_TYPE_IPV4_IFINDEX:
1352 return yang_data_new_string(
1353 xpath,
1354 ifindex2ifname(rinfo->nh.ifindex, rip->vrf->vrf_id));
1355 default:
1356 return NULL;
1357 }
1358 }
1359
1360 /*
1361 * XPath: /frr-ripd:ripd/instance/state/routes/route/metric
1362 */
1363 static struct yang_data *
1364 ripd_instance_state_routes_route_metric_get_elem(const char *xpath,
1365 const void *list_entry)
1366 {
1367 const struct route_node *rn = list_entry;
1368 const struct rip_info *rinfo = listnode_head(rn->info);
1369
1370 return yang_data_new_uint8(xpath, rinfo->metric);
1371 }
1372
1373 /*
1374 * XPath: /frr-ripd:clear-rip-route
1375 */
1376 static void clear_rip_route(struct rip *rip)
1377 {
1378 struct route_node *rp;
1379
1380 if (IS_RIP_DEBUG_EVENT)
1381 zlog_debug("Clearing all RIP routes (VRF %s)", rip->vrf_name);
1382
1383 /* Clear received RIP routes */
1384 for (rp = route_top(rip->table); rp; rp = route_next(rp)) {
1385 struct list *list;
1386 struct listnode *listnode;
1387 struct rip_info *rinfo;
1388
1389 list = rp->info;
1390 if (!list)
1391 continue;
1392
1393 for (ALL_LIST_ELEMENTS_RO(list, listnode, rinfo)) {
1394 if (!rip_route_rte(rinfo))
1395 continue;
1396
1397 if (CHECK_FLAG(rinfo->flags, RIP_RTF_FIB))
1398 rip_zebra_ipv4_delete(rip, rp);
1399 break;
1400 }
1401
1402 if (rinfo) {
1403 RIP_TIMER_OFF(rinfo->t_timeout);
1404 RIP_TIMER_OFF(rinfo->t_garbage_collect);
1405 listnode_delete(list, rinfo);
1406 rip_info_free(rinfo);
1407 }
1408
1409 if (list_isempty(list)) {
1410 list_delete(&list);
1411 rp->info = NULL;
1412 route_unlock_node(rp);
1413 }
1414 }
1415 }
1416
1417 static int clear_rip_route_rpc(const char *xpath, const struct list *input,
1418 struct list *output)
1419 {
1420 struct rip *rip;
1421 struct yang_data *yang_vrf;
1422
1423 yang_vrf = yang_data_list_find(input, "%s/%s", xpath, "input/vrf");
1424 if (yang_vrf) {
1425 rip = rip_lookup_by_vrf_name(yang_vrf->value);
1426 if (rip)
1427 clear_rip_route(rip);
1428 } else {
1429 struct vrf *vrf;
1430
1431 RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
1432 rip = vrf->info;
1433 if (!rip)
1434 continue;
1435
1436 clear_rip_route(rip);
1437 }
1438 }
1439
1440 return NB_OK;
1441 }
1442
1443 /*
1444 * XPath: /frr-ripd:authentication-type-failure
1445 */
1446 void ripd_notif_send_auth_type_failure(const char *ifname)
1447 {
1448 const char *xpath = "/frr-ripd:authentication-type-failure";
1449 struct list *arguments;
1450 char xpath_arg[XPATH_MAXLEN];
1451 struct yang_data *data;
1452
1453 arguments = yang_data_list_new();
1454
1455 snprintf(xpath_arg, sizeof(xpath_arg), "%s/interface-name", xpath);
1456 data = yang_data_new_string(xpath_arg, ifname);
1457 listnode_add(arguments, data);
1458
1459 nb_notification_send(xpath, arguments);
1460 }
1461
1462 /*
1463 * XPath: /frr-ripd:authentication-failure
1464 */
1465 void ripd_notif_send_auth_failure(const char *ifname)
1466 {
1467 const char *xpath = "/frr-ripd:authentication-failure";
1468 struct list *arguments;
1469 char xpath_arg[XPATH_MAXLEN];
1470 struct yang_data *data;
1471
1472 arguments = yang_data_list_new();
1473
1474 snprintf(xpath_arg, sizeof(xpath_arg), "%s/interface-name", xpath);
1475 data = yang_data_new_string(xpath_arg, ifname);
1476 listnode_add(arguments, data);
1477
1478 nb_notification_send(xpath, arguments);
1479 }
1480
1481 /* clang-format off */
1482 const struct frr_yang_module_info frr_ripd_info = {
1483 .name = "frr-ripd",
1484 .nodes = {
1485 {
1486 .xpath = "/frr-ripd:ripd/instance",
1487 .cbs = {
1488 .cli_show = cli_show_router_rip,
1489 .create = ripd_instance_create,
1490 .destroy = ripd_instance_destroy,
1491 .get_keys = ripd_instance_get_keys,
1492 .get_next = ripd_instance_get_next,
1493 .lookup_entry = ripd_instance_lookup_entry,
1494 },
1495 },
1496 {
1497 .xpath = "/frr-ripd:ripd/instance/allow-ecmp",
1498 .cbs = {
1499 .cli_show = cli_show_rip_allow_ecmp,
1500 .modify = ripd_instance_allow_ecmp_modify,
1501 },
1502 },
1503 {
1504 .xpath = "/frr-ripd:ripd/instance/default-information-originate",
1505 .cbs = {
1506 .cli_show = cli_show_rip_default_information_originate,
1507 .modify = ripd_instance_default_information_originate_modify,
1508 },
1509 },
1510 {
1511 .xpath = "/frr-ripd:ripd/instance/default-metric",
1512 .cbs = {
1513 .cli_show = cli_show_rip_default_metric,
1514 .modify = ripd_instance_default_metric_modify,
1515 },
1516 },
1517 {
1518 .xpath = "/frr-ripd:ripd/instance/distance/default",
1519 .cbs = {
1520 .cli_show = cli_show_rip_distance,
1521 .modify = ripd_instance_distance_default_modify,
1522 },
1523 },
1524 {
1525 .xpath = "/frr-ripd:ripd/instance/distance/source",
1526 .cbs = {
1527 .cli_show = cli_show_rip_distance_source,
1528 .create = ripd_instance_distance_source_create,
1529 .destroy = ripd_instance_distance_source_destroy,
1530 },
1531 },
1532 {
1533 .xpath = "/frr-ripd:ripd/instance/distance/source/distance",
1534 .cbs = {
1535 .modify = ripd_instance_distance_source_distance_modify,
1536 },
1537 },
1538 {
1539 .xpath = "/frr-ripd:ripd/instance/distance/source/access-list",
1540 .cbs = {
1541 .destroy = ripd_instance_distance_source_access_list_destroy,
1542 .modify = ripd_instance_distance_source_access_list_modify,
1543 },
1544 },
1545 {
1546 .xpath = "/frr-ripd:ripd/instance/explicit-neighbor",
1547 .cbs = {
1548 .cli_show = cli_show_rip_neighbor,
1549 .create = ripd_instance_explicit_neighbor_create,
1550 .destroy = ripd_instance_explicit_neighbor_destroy,
1551 },
1552 },
1553 {
1554 .xpath = "/frr-ripd:ripd/instance/network",
1555 .cbs = {
1556 .cli_show = cli_show_rip_network_prefix,
1557 .create = ripd_instance_network_create,
1558 .destroy = ripd_instance_network_destroy,
1559 },
1560 },
1561 {
1562 .xpath = "/frr-ripd:ripd/instance/interface",
1563 .cbs = {
1564 .cli_show = cli_show_rip_network_interface,
1565 .create = ripd_instance_interface_create,
1566 .destroy = ripd_instance_interface_destroy,
1567 },
1568 },
1569 {
1570 .xpath = "/frr-ripd:ripd/instance/offset-list",
1571 .cbs = {
1572 .cli_show = cli_show_rip_offset_list,
1573 .create = ripd_instance_offset_list_create,
1574 .destroy = ripd_instance_offset_list_destroy,
1575 },
1576 },
1577 {
1578 .xpath = "/frr-ripd:ripd/instance/offset-list/access-list",
1579 .cbs = {
1580 .modify = ripd_instance_offset_list_access_list_modify,
1581 },
1582 },
1583 {
1584 .xpath = "/frr-ripd:ripd/instance/offset-list/metric",
1585 .cbs = {
1586 .modify = ripd_instance_offset_list_metric_modify,
1587 },
1588 },
1589 {
1590 .xpath = "/frr-ripd:ripd/instance/passive-default",
1591 .cbs = {
1592 .cli_show = cli_show_rip_passive_default,
1593 .modify = ripd_instance_passive_default_modify,
1594 },
1595 },
1596 {
1597 .xpath = "/frr-ripd:ripd/instance/passive-interface",
1598 .cbs = {
1599 .cli_show = cli_show_rip_passive_interface,
1600 .create = ripd_instance_passive_interface_create,
1601 .destroy = ripd_instance_passive_interface_destroy,
1602 },
1603 },
1604 {
1605 .xpath = "/frr-ripd:ripd/instance/non-passive-interface",
1606 .cbs = {
1607 .cli_show = cli_show_rip_non_passive_interface,
1608 .create = ripd_instance_non_passive_interface_create,
1609 .destroy = ripd_instance_non_passive_interface_destroy,
1610 },
1611 },
1612 {
1613 .xpath = "/frr-ripd:ripd/instance/redistribute",
1614 .cbs = {
1615 .apply_finish = ripd_instance_redistribute_apply_finish,
1616 .cli_show = cli_show_rip_redistribute,
1617 .create = ripd_instance_redistribute_create,
1618 .destroy = ripd_instance_redistribute_destroy,
1619 },
1620 },
1621 {
1622 .xpath = "/frr-ripd:ripd/instance/redistribute/route-map",
1623 .cbs = {
1624 .destroy = ripd_instance_redistribute_route_map_destroy,
1625 .modify = ripd_instance_redistribute_route_map_modify,
1626 },
1627 },
1628 {
1629 .xpath = "/frr-ripd:ripd/instance/redistribute/metric",
1630 .cbs = {
1631 .destroy = ripd_instance_redistribute_metric_destroy,
1632 .modify = ripd_instance_redistribute_metric_modify,
1633 },
1634 },
1635 {
1636 .xpath = "/frr-ripd:ripd/instance/static-route",
1637 .cbs = {
1638 .cli_show = cli_show_rip_route,
1639 .create = ripd_instance_static_route_create,
1640 .destroy = ripd_instance_static_route_destroy,
1641 },
1642 },
1643 {
1644 .xpath = "/frr-ripd:ripd/instance/timers",
1645 .cbs = {
1646 .apply_finish = ripd_instance_timers_apply_finish,
1647 .cli_show = cli_show_rip_timers,
1648 },
1649 },
1650 {
1651 .xpath = "/frr-ripd:ripd/instance/timers/flush-interval",
1652 .cbs = {
1653 .modify = ripd_instance_timers_flush_interval_modify,
1654 },
1655 },
1656 {
1657 .xpath = "/frr-ripd:ripd/instance/timers/holddown-interval",
1658 .cbs = {
1659 .modify = ripd_instance_timers_holddown_interval_modify,
1660 },
1661 },
1662 {
1663 .xpath = "/frr-ripd:ripd/instance/timers/update-interval",
1664 .cbs = {
1665 .modify = ripd_instance_timers_update_interval_modify,
1666 },
1667 },
1668 {
1669 .xpath = "/frr-ripd:ripd/instance/version",
1670 .cbs = {
1671 .cli_show = cli_show_rip_version,
1672 },
1673 },
1674 {
1675 .xpath = "/frr-ripd:ripd/instance/version/receive",
1676 .cbs = {
1677 .modify = ripd_instance_version_receive_modify,
1678 },
1679 },
1680 {
1681 .xpath = "/frr-ripd:ripd/instance/version/send",
1682 .cbs = {
1683 .modify = ripd_instance_version_send_modify,
1684 },
1685 },
1686 {
1687 .xpath = "/frr-interface:lib/interface/frr-ripd:rip/split-horizon",
1688 .cbs = {
1689 .cli_show = cli_show_ip_rip_split_horizon,
1690 .modify = lib_interface_rip_split_horizon_modify,
1691 },
1692 },
1693 {
1694 .xpath = "/frr-interface:lib/interface/frr-ripd:rip/v2-broadcast",
1695 .cbs = {
1696 .cli_show = cli_show_ip_rip_v2_broadcast,
1697 .modify = lib_interface_rip_v2_broadcast_modify,
1698 },
1699 },
1700 {
1701 .xpath = "/frr-interface:lib/interface/frr-ripd:rip/version-receive",
1702 .cbs = {
1703 .cli_show = cli_show_ip_rip_receive_version,
1704 .modify = lib_interface_rip_version_receive_modify,
1705 },
1706 },
1707 {
1708 .xpath = "/frr-interface:lib/interface/frr-ripd:rip/version-send",
1709 .cbs = {
1710 .cli_show = cli_show_ip_rip_send_version,
1711 .modify = lib_interface_rip_version_send_modify,
1712 },
1713 },
1714 {
1715 .xpath = "/frr-interface:lib/interface/frr-ripd:rip/authentication-scheme",
1716 .cbs = {
1717 .cli_show = cli_show_ip_rip_authentication_scheme,
1718 },
1719 },
1720 {
1721 .xpath = "/frr-interface:lib/interface/frr-ripd:rip/authentication-scheme/mode",
1722 .cbs = {
1723 .modify = lib_interface_rip_authentication_scheme_mode_modify,
1724 },
1725 },
1726 {
1727 .xpath = "/frr-interface:lib/interface/frr-ripd:rip/authentication-scheme/md5-auth-length",
1728 .cbs = {
1729 .destroy = lib_interface_rip_authentication_scheme_md5_auth_length_destroy,
1730 .modify = lib_interface_rip_authentication_scheme_md5_auth_length_modify,
1731 },
1732 },
1733 {
1734 .xpath = "/frr-interface:lib/interface/frr-ripd:rip/authentication-password",
1735 .cbs = {
1736 .cli_show = cli_show_ip_rip_authentication_string,
1737 .destroy = lib_interface_rip_authentication_password_destroy,
1738 .modify = lib_interface_rip_authentication_password_modify,
1739 },
1740 },
1741 {
1742 .xpath = "/frr-interface:lib/interface/frr-ripd:rip/authentication-key-chain",
1743 .cbs = {
1744 .cli_show = cli_show_ip_rip_authentication_key_chain,
1745 .destroy = lib_interface_rip_authentication_key_chain_destroy,
1746 .modify = lib_interface_rip_authentication_key_chain_modify,
1747 },
1748 },
1749 {
1750 .xpath = "/frr-ripd:ripd/instance/state/neighbors/neighbor",
1751 .cbs = {
1752 .get_keys = ripd_instance_state_neighbors_neighbor_get_keys,
1753 .get_next = ripd_instance_state_neighbors_neighbor_get_next,
1754 .lookup_entry = ripd_instance_state_neighbors_neighbor_lookup_entry,
1755 },
1756 },
1757 {
1758 .xpath = "/frr-ripd:ripd/instance/state/neighbors/neighbor/address",
1759 .cbs = {
1760 .get_elem = ripd_instance_state_neighbors_neighbor_address_get_elem,
1761 },
1762 },
1763 {
1764 .xpath = "/frr-ripd:ripd/instance/state/neighbors/neighbor/last-update",
1765 .cbs = {
1766 .get_elem = ripd_instance_state_neighbors_neighbor_last_update_get_elem,
1767 },
1768 },
1769 {
1770 .xpath = "/frr-ripd:ripd/instance/state/neighbors/neighbor/bad-packets-rcvd",
1771 .cbs = {
1772 .get_elem = ripd_instance_state_neighbors_neighbor_bad_packets_rcvd_get_elem,
1773 },
1774 },
1775 {
1776 .xpath = "/frr-ripd:ripd/instance/state/neighbors/neighbor/bad-routes-rcvd",
1777 .cbs = {
1778 .get_elem = ripd_instance_state_neighbors_neighbor_bad_routes_rcvd_get_elem,
1779 },
1780 },
1781 {
1782 .xpath = "/frr-ripd:ripd/instance/state/routes/route",
1783 .cbs = {
1784 .get_keys = ripd_instance_state_routes_route_get_keys,
1785 .get_next = ripd_instance_state_routes_route_get_next,
1786 .lookup_entry = ripd_instance_state_routes_route_lookup_entry,
1787 },
1788 },
1789 {
1790 .xpath = "/frr-ripd:ripd/instance/state/routes/route/prefix",
1791 .cbs = {
1792 .get_elem = ripd_instance_state_routes_route_prefix_get_elem,
1793 },
1794 },
1795 {
1796 .xpath = "/frr-ripd:ripd/instance/state/routes/route/next-hop",
1797 .cbs = {
1798 .get_elem = ripd_instance_state_routes_route_next_hop_get_elem,
1799 },
1800 },
1801 {
1802 .xpath = "/frr-ripd:ripd/instance/state/routes/route/interface",
1803 .cbs = {
1804 .get_elem = ripd_instance_state_routes_route_interface_get_elem,
1805 },
1806 },
1807 {
1808 .xpath = "/frr-ripd:ripd/instance/state/routes/route/metric",
1809 .cbs = {
1810 .get_elem = ripd_instance_state_routes_route_metric_get_elem,
1811 },
1812 },
1813 {
1814 .xpath = "/frr-ripd:clear-rip-route",
1815 .cbs = {
1816 .rpc = clear_rip_route_rpc,
1817 },
1818 },
1819 {
1820 .xpath = NULL,
1821 },
1822 }
1823 };