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