]> git.proxmox.com Git - mirror_frr.git/blob - lib/routemap_northbound.c
Merge pull request #8459 from taspelund/no_rmac_on_mac_only
[mirror_frr.git] / lib / routemap_northbound.c
1 /*
2 * Route map northbound implementation.
3 *
4 * Copyright (C) 2019 Network Device Education Foundation, Inc. ("NetDEF")
5 * Rafael Zalamena
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301 USA.
21 */
22
23 #include <zebra.h>
24
25 #include "lib/command.h"
26 #include "lib/log.h"
27 #include "lib/northbound.h"
28 #include "lib/routemap.h"
29
30 /*
31 * Auxiliary functions to avoid code duplication:
32 *
33 * lib_route_map_entry_set_destroy: unset `set` commands.
34 * lib_route_map_entry_match_destroy: unset `match` commands.
35 */
36 int lib_route_map_entry_match_destroy(struct nb_cb_destroy_args *args)
37 {
38 struct routemap_hook_context *rhc;
39 int rv;
40
41 if (args->event != NB_EV_APPLY)
42 return NB_OK;
43
44 rhc = nb_running_get_entry(args->dnode, NULL, true);
45 if (rhc->rhc_mhook == NULL)
46 return NB_OK;
47
48 rv = rhc->rhc_mhook(rhc->rhc_rmi, rhc->rhc_rule, NULL,
49 rhc->rhc_event,
50 args->errmsg, args->errmsg_len);
51 if (rv != CMD_SUCCESS)
52 return NB_ERR_INCONSISTENCY;
53
54 return NB_OK;
55 }
56
57 int lib_route_map_entry_set_destroy(struct nb_cb_destroy_args *args)
58 {
59 struct routemap_hook_context *rhc;
60 int rv;
61
62 if (args->event != NB_EV_APPLY)
63 return NB_OK;
64
65 rhc = nb_running_get_entry(args->dnode, NULL, true);
66 if (rhc->rhc_shook == NULL)
67 return NB_OK;
68
69 rv = rhc->rhc_shook(rhc->rhc_rmi, rhc->rhc_rule, NULL,
70 args->errmsg, args->errmsg_len);
71 if (rv != CMD_SUCCESS)
72 return NB_ERR_INCONSISTENCY;
73
74 return NB_OK;
75 }
76
77 /*
78 * Auxiliary hook context list manipulation functions.
79 */
80 struct routemap_hook_context *
81 routemap_hook_context_insert(struct route_map_index *rmi)
82 {
83 struct routemap_hook_context *rhc;
84
85 rhc = XCALLOC(MTYPE_TMP, sizeof(*rhc));
86 rhc->rhc_rmi = rmi;
87 TAILQ_INSERT_TAIL(&rmi->rhclist, rhc, rhc_entry);
88
89 return rhc;
90 }
91
92 void routemap_hook_context_free(struct routemap_hook_context *rhc)
93 {
94 struct route_map_index *rmi = rhc->rhc_rmi;
95
96 TAILQ_REMOVE(&rmi->rhclist, rhc, rhc_entry);
97 XFREE(MTYPE_TMP, rhc);
98 }
99
100 /*
101 * XPath: /frr-route-map:lib/route-map
102 */
103 static int lib_route_map_create(struct nb_cb_create_args *args)
104 {
105 struct route_map *rm;
106 const char *rm_name;
107
108 switch (args->event) {
109 case NB_EV_VALIDATE:
110 case NB_EV_PREPARE:
111 case NB_EV_ABORT:
112 /* NOTHING */
113 break;
114 case NB_EV_APPLY:
115 rm_name = yang_dnode_get_string(args->dnode, "./name");
116 rm = route_map_get(rm_name);
117 nb_running_set_entry(args->dnode, rm);
118 break;
119 }
120
121 return NB_OK;
122 }
123
124 static int lib_route_map_destroy(struct nb_cb_destroy_args *args)
125 {
126 struct route_map *rm;
127
128 switch (args->event) {
129 case NB_EV_VALIDATE:
130 case NB_EV_PREPARE:
131 case NB_EV_ABORT:
132 /* NOTHING */
133 break;
134 case NB_EV_APPLY:
135 rm = nb_running_unset_entry(args->dnode);
136 route_map_delete(rm);
137 break;
138 }
139
140 return NB_OK;
141 }
142
143 /*
144 * XPath: /frr-route-map:lib/route-map/optimization-disabled
145 */
146 static int
147 lib_route_map_optimization_disabled_modify(struct nb_cb_modify_args *args)
148 {
149 struct route_map *rm;
150 bool disabled = yang_dnode_get_bool(args->dnode, NULL);
151
152 switch (args->event) {
153 case NB_EV_VALIDATE:
154 case NB_EV_PREPARE:
155 case NB_EV_ABORT:
156 /* NOTHING */
157 break;
158 case NB_EV_APPLY:
159 rm = nb_running_get_entry(args->dnode, NULL, true);
160 rm->optimization_disabled = disabled;
161 break;
162 }
163
164 return NB_OK;
165 }
166
167 /*
168 * XPath: /frr-route-map:lib/route-map/entry
169 */
170 static int lib_route_map_entry_create(struct nb_cb_create_args *args)
171 {
172 struct route_map_index *rmi;
173 struct route_map *rm;
174 uint16_t sequence;
175 int action;
176
177 switch (args->event) {
178 case NB_EV_VALIDATE:
179 case NB_EV_PREPARE:
180 case NB_EV_ABORT:
181 /* NOTHING */
182 break;
183 case NB_EV_APPLY:
184 sequence = yang_dnode_get_uint16(args->dnode, "./sequence");
185 action = yang_dnode_get_enum(args->dnode, "./action") == 0
186 ? RMAP_PERMIT
187 : RMAP_DENY;
188 rm = nb_running_get_entry(args->dnode, NULL, true);
189 rmi = route_map_index_get(rm, action, sequence);
190 nb_running_set_entry(args->dnode, rmi);
191 break;
192 }
193
194 return NB_OK;
195 }
196
197 static int lib_route_map_entry_destroy(struct nb_cb_destroy_args *args)
198 {
199 struct route_map_index *rmi;
200
201 switch (args->event) {
202 case NB_EV_VALIDATE:
203 case NB_EV_PREPARE:
204 case NB_EV_ABORT:
205 /* NOTHING */
206 break;
207 case NB_EV_APPLY:
208 rmi = nb_running_unset_entry(args->dnode);
209 route_map_index_delete(rmi, 1);
210 break;
211 }
212
213 return NB_OK;
214 }
215
216 /*
217 * XPath: /frr-route-map:lib/route-map/entry/description
218 */
219 static int
220 lib_route_map_entry_description_modify(struct nb_cb_modify_args *args)
221 {
222 struct route_map_index *rmi;
223 const char *description;
224
225 switch (args->event) {
226 case NB_EV_VALIDATE:
227 /* NOTHING */
228 break;
229 case NB_EV_PREPARE:
230 description = yang_dnode_get_string(args->dnode, NULL);
231 args->resource->ptr = XSTRDUP(MTYPE_TMP, description);
232 if (args->resource->ptr == NULL)
233 return NB_ERR_RESOURCE;
234 break;
235 case NB_EV_ABORT:
236 XFREE(MTYPE_TMP, args->resource->ptr);
237 break;
238 case NB_EV_APPLY:
239 rmi = nb_running_get_entry(args->dnode, NULL, true);
240 XFREE(MTYPE_TMP, rmi->description);
241 rmi->description = args->resource->ptr;
242 break;
243 }
244
245 return NB_OK;
246 }
247
248 static int
249 lib_route_map_entry_description_destroy(struct nb_cb_destroy_args *args)
250 {
251 struct route_map_index *rmi;
252
253 switch (args->event) {
254 case NB_EV_VALIDATE:
255 case NB_EV_PREPARE:
256 case NB_EV_ABORT:
257 /* NOTHING */
258 break;
259 case NB_EV_APPLY:
260 rmi = nb_running_get_entry(args->dnode, NULL, true);
261 XFREE(MTYPE_TMP, rmi->description);
262 break;
263 }
264
265 return NB_OK;
266 }
267
268 /*
269 * XPath: /frr-route-map:lib/route-map/entry/action
270 */
271 static int lib_route_map_entry_action_modify(struct nb_cb_modify_args *args)
272 {
273 struct route_map_index *rmi;
274 struct route_map *map;
275
276 switch (args->event) {
277 case NB_EV_VALIDATE:
278 case NB_EV_PREPARE:
279 case NB_EV_ABORT:
280 /* NOTHING */
281 break;
282 case NB_EV_APPLY:
283 rmi = nb_running_get_entry(args->dnode, NULL, true);
284 rmi->type = yang_dnode_get_enum(args->dnode, NULL);
285 map = rmi->map;
286
287 /* Execute event hook. */
288 if (route_map_master.event_hook) {
289 (*route_map_master.event_hook)(map->name);
290 route_map_notify_dependencies(map->name,
291 RMAP_EVENT_CALL_ADDED);
292 }
293
294 break;
295 }
296
297 return NB_OK;
298 }
299
300 /*
301 * XPath: /frr-route-map:lib/route-map/entry/call
302 */
303 static int lib_route_map_entry_call_modify(struct nb_cb_modify_args *args)
304 {
305 struct route_map_index *rmi;
306 const char *rm_name, *rmn_name;
307
308 switch (args->event) {
309 case NB_EV_VALIDATE:
310 rm_name = yang_dnode_get_string(args->dnode, "../../name");
311 rmn_name = yang_dnode_get_string(args->dnode, NULL);
312 /* Don't allow to jump to the same route map instance. */
313 if (strcmp(rm_name, rmn_name) == 0)
314 return NB_ERR_VALIDATION;
315
316 /* TODO: detect circular route map sequences. */
317 break;
318 case NB_EV_PREPARE:
319 rmn_name = yang_dnode_get_string(args->dnode, NULL);
320 args->resource->ptr = XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmn_name);
321 break;
322 case NB_EV_ABORT:
323 XFREE(MTYPE_ROUTE_MAP_NAME, args->resource->ptr);
324 break;
325 case NB_EV_APPLY:
326 rmi = nb_running_get_entry(args->dnode, NULL, true);
327 if (rmi->nextrm) {
328 route_map_upd8_dependency(RMAP_EVENT_CALL_DELETED,
329 rmi->nextrm, rmi->map->name);
330 XFREE(MTYPE_ROUTE_MAP_NAME, rmi->nextrm);
331 }
332 rmi->nextrm = args->resource->ptr;
333 route_map_upd8_dependency(RMAP_EVENT_CALL_ADDED, rmi->nextrm,
334 rmi->map->name);
335 break;
336 }
337
338 return NB_OK;
339 }
340
341 static int lib_route_map_entry_call_destroy(struct nb_cb_destroy_args *args)
342 {
343 struct route_map_index *rmi;
344
345 switch (args->event) {
346 case NB_EV_VALIDATE:
347 case NB_EV_PREPARE:
348 case NB_EV_ABORT:
349 /* NOTHING */
350 break;
351 case NB_EV_APPLY:
352 rmi = nb_running_get_entry(args->dnode, NULL, true);
353 route_map_upd8_dependency(RMAP_EVENT_CALL_DELETED, rmi->nextrm,
354 rmi->map->name);
355 XFREE(MTYPE_ROUTE_MAP_NAME, rmi->nextrm);
356 rmi->nextrm = NULL;
357 break;
358 }
359
360 return NB_OK;
361 }
362
363 /*
364 * XPath: /frr-route-map:lib/route-map/entry/exit-policy
365 */
366 static int
367 lib_route_map_entry_exit_policy_modify(struct nb_cb_modify_args *args)
368 {
369 struct route_map_index *rmi;
370 int rm_action;
371 int policy;
372
373 switch (args->event) {
374 case NB_EV_VALIDATE:
375 policy = yang_dnode_get_enum(args->dnode, NULL);
376 switch (policy) {
377 case 0: /* permit-or-deny */
378 break;
379 case 1: /* next */
380 /* FALLTHROUGH */
381 case 2: /* goto */
382 rm_action =
383 yang_dnode_get_enum(args->dnode, "../action");
384 if (rm_action == 1 /* deny */) {
385 /*
386 * On deny it is not possible to 'goto'
387 * anywhere.
388 */
389 return NB_ERR_VALIDATION;
390 }
391 break;
392 }
393 break;
394 case NB_EV_PREPARE:
395 case NB_EV_ABORT:
396 break;
397 case NB_EV_APPLY:
398 rmi = nb_running_get_entry(args->dnode, NULL, true);
399 policy = yang_dnode_get_enum(args->dnode, NULL);
400
401 switch (policy) {
402 case 0: /* permit-or-deny */
403 rmi->exitpolicy = RMAP_EXIT;
404 break;
405 case 1: /* next */
406 rmi->exitpolicy = RMAP_NEXT;
407 break;
408 case 2: /* goto */
409 rmi->exitpolicy = RMAP_GOTO;
410 break;
411 }
412 break;
413 }
414
415 return NB_OK;
416 }
417
418 /*
419 * XPath: /frr-route-map:lib/route-map/entry/goto-value
420 */
421 static int lib_route_map_entry_goto_value_modify(struct nb_cb_modify_args *args)
422 {
423 struct route_map_index *rmi;
424 uint16_t rmi_index;
425 uint16_t rmi_next;
426
427 switch (args->event) {
428 case NB_EV_VALIDATE:
429 rmi_index = yang_dnode_get_uint16(args->dnode, "../sequence");
430 rmi_next = yang_dnode_get_uint16(args->dnode, NULL);
431 if (rmi_next <= rmi_index) {
432 /* Can't jump backwards on a route map. */
433 return NB_ERR_VALIDATION;
434 }
435 break;
436 case NB_EV_PREPARE:
437 case NB_EV_ABORT:
438 /* NOTHING */
439 break;
440 case NB_EV_APPLY:
441 rmi = nb_running_get_entry(args->dnode, NULL, true);
442 rmi->nextpref = yang_dnode_get_uint16(args->dnode, NULL);
443 break;
444 }
445
446 return NB_OK;
447 }
448
449 static int
450 lib_route_map_entry_goto_value_destroy(struct nb_cb_destroy_args *args)
451 {
452 struct route_map_index *rmi;
453
454 switch (args->event) {
455 case NB_EV_VALIDATE:
456 case NB_EV_PREPARE:
457 case NB_EV_ABORT:
458 /* NOTHING */
459 break;
460 case NB_EV_APPLY:
461 rmi = nb_running_get_entry(args->dnode, NULL, true);
462 rmi->nextpref = 0;
463 break;
464 }
465
466 return NB_OK;
467 }
468
469 /*
470 * XPath: /frr-route-map:lib/route-map/entry/match-condition
471 */
472 static int
473 lib_route_map_entry_match_condition_create(struct nb_cb_create_args *args)
474 {
475 struct routemap_hook_context *rhc;
476 struct route_map_index *rmi;
477
478 switch (args->event) {
479 case NB_EV_VALIDATE:
480 case NB_EV_PREPARE:
481 case NB_EV_ABORT:
482 /* NOTHING */
483 break;
484 case NB_EV_APPLY:
485 rmi = nb_running_get_entry(args->dnode, NULL, true);
486 rhc = routemap_hook_context_insert(rmi);
487 nb_running_set_entry(args->dnode, rhc);
488 break;
489 }
490
491 return NB_OK;
492 }
493
494 static int
495 lib_route_map_entry_match_condition_destroy(struct nb_cb_destroy_args *args)
496 {
497 struct routemap_hook_context *rhc;
498 int rv;
499
500 if (args->event != NB_EV_APPLY)
501 return NB_OK;
502
503 rv = lib_route_map_entry_match_destroy(args);
504 rhc = nb_running_unset_entry(args->dnode);
505 routemap_hook_context_free(rhc);
506
507 return rv;
508 }
509
510 /*
511 * XPath: /frr-route-map:lib/route-map/entry/match-condition/interface
512 */
513 static int lib_route_map_entry_match_condition_interface_modify(
514 struct nb_cb_modify_args *args)
515 {
516 struct routemap_hook_context *rhc;
517 const char *ifname;
518 int rv;
519
520 if (args->event != NB_EV_APPLY)
521 return NB_OK;
522
523 /* Check for hook function. */
524 if (rmap_match_set_hook.match_interface == NULL)
525 return NB_OK;
526
527 /* Add configuration. */
528 rhc = nb_running_get_entry(args->dnode, NULL, true);
529 ifname = yang_dnode_get_string(args->dnode, NULL);
530
531 /* Set destroy information. */
532 rhc->rhc_mhook = rmap_match_set_hook.no_match_interface;
533 rhc->rhc_rule = "interface";
534 rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
535
536 rv = rmap_match_set_hook.match_interface(rhc->rhc_rmi,
537 "interface", ifname,
538 RMAP_EVENT_MATCH_ADDED,
539 args->errmsg, args->errmsg_len);
540 if (rv != CMD_SUCCESS) {
541 rhc->rhc_mhook = NULL;
542 return NB_ERR_INCONSISTENCY;
543 }
544
545 return NB_OK;
546 }
547
548 static int lib_route_map_entry_match_condition_interface_destroy(
549 struct nb_cb_destroy_args *args)
550 {
551 return lib_route_map_entry_match_destroy(args);
552 }
553
554 /*
555 * XPath: /frr-route-map:lib/route-map/entry/match-condition/list-name
556 */
557 static int lib_route_map_entry_match_condition_list_name_modify(
558 struct nb_cb_modify_args *args)
559 {
560 struct routemap_hook_context *rhc;
561 const char *acl;
562 const char *condition;
563 int rv;
564
565 if (args->event != NB_EV_APPLY)
566 return NB_OK;
567
568 /* Check for hook installation, otherwise we can just stop. */
569 acl = yang_dnode_get_string(args->dnode, NULL);
570 rhc = nb_running_get_entry(args->dnode, NULL, true);
571 condition = yang_dnode_get_string(args->dnode, "../../condition");
572
573 if (IS_MATCH_IPv4_ADDRESS_LIST(condition)) {
574 if (rmap_match_set_hook.match_ip_address == NULL)
575 return NB_OK;
576 rhc->rhc_mhook = rmap_match_set_hook.no_match_ip_address;
577 rhc->rhc_rule = "ip address";
578 rhc->rhc_event = RMAP_EVENT_FILTER_DELETED;
579 rv = rmap_match_set_hook.match_ip_address(
580 rhc->rhc_rmi, "ip address", acl,
581 RMAP_EVENT_FILTER_ADDED,
582 args->errmsg, args->errmsg_len);
583 } else if (IS_MATCH_IPv4_PREFIX_LIST(condition)) {
584 if (rmap_match_set_hook.match_ip_address_prefix_list == NULL)
585 return NB_OK;
586 rhc->rhc_mhook =
587 rmap_match_set_hook.no_match_ip_address_prefix_list;
588 rhc->rhc_rule = "ip address prefix-list";
589 rhc->rhc_event = RMAP_EVENT_PLIST_DELETED;
590 rv = rmap_match_set_hook.match_ip_address_prefix_list(
591 rhc->rhc_rmi, "ip address prefix-list", acl,
592 RMAP_EVENT_PLIST_ADDED,
593 args->errmsg, args->errmsg_len);
594 } else if (IS_MATCH_IPv4_NEXTHOP_LIST(condition)) {
595 if (rmap_match_set_hook.match_ip_next_hop == NULL)
596 return NB_OK;
597 rhc->rhc_mhook = rmap_match_set_hook.no_match_ip_next_hop;
598 rhc->rhc_rule = "ip next-hop";
599 rhc->rhc_event = RMAP_EVENT_FILTER_DELETED;
600 rv = rmap_match_set_hook.match_ip_next_hop(
601 rhc->rhc_rmi, "ip next-hop", acl,
602 RMAP_EVENT_FILTER_ADDED,
603 args->errmsg, args->errmsg_len);
604 } else if (IS_MATCH_IPv4_NEXTHOP_PREFIX_LIST(condition)) {
605 if (rmap_match_set_hook.match_ip_next_hop_prefix_list == NULL)
606 return NB_OK;
607 rhc->rhc_mhook =
608 rmap_match_set_hook.no_match_ip_next_hop_prefix_list;
609 rhc->rhc_rule = "ip next-hop prefix-list";
610 rhc->rhc_event = RMAP_EVENT_PLIST_DELETED;
611 rv = rmap_match_set_hook.match_ip_next_hop_prefix_list(
612 rhc->rhc_rmi, "ip next-hop prefix-list", acl,
613 RMAP_EVENT_PLIST_ADDED,
614 args->errmsg, args->errmsg_len);
615 } else if (IS_MATCH_IPv6_ADDRESS_LIST(condition)) {
616 if (rmap_match_set_hook.match_ipv6_address == NULL)
617 return NB_OK;
618 rhc->rhc_mhook = rmap_match_set_hook.no_match_ipv6_address;
619 rhc->rhc_rule = "ipv6 address";
620 rhc->rhc_event = RMAP_EVENT_FILTER_DELETED;
621 rv = rmap_match_set_hook.match_ipv6_address(
622 rhc->rhc_rmi, "ipv6 address", acl,
623 RMAP_EVENT_FILTER_ADDED,
624 args->errmsg, args->errmsg_len);
625 } else if (IS_MATCH_IPv6_PREFIX_LIST(condition)) {
626 if (rmap_match_set_hook.match_ipv6_address_prefix_list == NULL)
627 return NB_OK;
628 rhc->rhc_mhook =
629 rmap_match_set_hook.no_match_ipv6_address_prefix_list;
630 rhc->rhc_rule = "ipv6 address prefix-list";
631 rhc->rhc_event = RMAP_EVENT_PLIST_DELETED;
632 rv = rmap_match_set_hook.match_ipv6_address_prefix_list(
633 rhc->rhc_rmi, "ipv6 address prefix-list", acl,
634 RMAP_EVENT_PLIST_ADDED,
635 args->errmsg, args->errmsg_len);
636 } else
637 rv = CMD_ERR_NO_MATCH;
638
639 if (rv != CMD_SUCCESS) {
640 rhc->rhc_mhook = NULL;
641 return NB_ERR_INCONSISTENCY;
642 }
643
644 return NB_OK;
645 }
646
647 static int lib_route_map_entry_match_condition_list_name_destroy(
648 struct nb_cb_destroy_args *args)
649 {
650 return lib_route_map_entry_match_destroy(args);
651 }
652
653 /*
654 * XPath: /frr-route-map:lib/route-map/entry/match-condition/ipv4-next-hop-type
655 */
656 static int lib_route_map_entry_match_condition_ipv4_next_hop_type_modify(
657 struct nb_cb_modify_args *args)
658 {
659 struct routemap_hook_context *rhc;
660 const char *type;
661 int rv;
662
663 if (args->event != NB_EV_APPLY)
664 return NB_OK;
665
666 /* Check for hook function. */
667 if (rmap_match_set_hook.match_ip_next_hop_type == NULL)
668 return NB_OK;
669
670 /* Add configuration. */
671 rhc = nb_running_get_entry(args->dnode, NULL, true);
672 type = yang_dnode_get_string(args->dnode, NULL);
673
674 /* Set destroy information. */
675 rhc->rhc_mhook = rmap_match_set_hook.no_match_ip_next_hop_type;
676 rhc->rhc_rule = "ip next-hop type";
677 rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
678
679 rv = rmap_match_set_hook.match_ip_next_hop_type(
680 rhc->rhc_rmi, "ip next-hop type", type,
681 RMAP_EVENT_MATCH_ADDED,
682 args->errmsg, args->errmsg_len);
683 if (rv != CMD_SUCCESS) {
684 rhc->rhc_mhook = NULL;
685 return NB_ERR_INCONSISTENCY;
686 }
687
688 return NB_OK;
689 }
690
691 static int lib_route_map_entry_match_condition_ipv4_next_hop_type_destroy(
692 struct nb_cb_destroy_args *args)
693 {
694 return lib_route_map_entry_match_destroy(args);
695 }
696
697 /*
698 * XPath: /frr-route-map:lib/route-map/entry/match-condition/ipv6-next-hop-type
699 */
700 static int lib_route_map_entry_match_condition_ipv6_next_hop_type_modify(
701 struct nb_cb_modify_args *args)
702 {
703 struct routemap_hook_context *rhc;
704 const char *type;
705 int rv;
706
707 if (args->event != NB_EV_APPLY)
708 return NB_OK;
709
710 /* Check for hook function. */
711 if (rmap_match_set_hook.match_ipv6_next_hop_type == NULL)
712 return NB_OK;
713
714 /* Add configuration. */
715 rhc = nb_running_get_entry(args->dnode, NULL, true);
716 type = yang_dnode_get_string(args->dnode, NULL);
717
718 /* Set destroy information. */
719 rhc->rhc_mhook = rmap_match_set_hook.no_match_ipv6_next_hop_type;
720 rhc->rhc_rule = "ipv6 next-hop type";
721 rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
722
723 rv = rmap_match_set_hook.match_ipv6_next_hop_type(
724 rhc->rhc_rmi, "ipv6 next-hop type", type,
725 RMAP_EVENT_MATCH_ADDED,
726 args->errmsg, args->errmsg_len);
727 if (rv != CMD_SUCCESS) {
728 rhc->rhc_mhook = NULL;
729 return NB_ERR_INCONSISTENCY;
730 }
731
732 return NB_OK;
733 }
734
735 static int lib_route_map_entry_match_condition_ipv6_next_hop_type_destroy(
736 struct nb_cb_destroy_args *args)
737 {
738 return lib_route_map_entry_match_destroy(args);
739 }
740
741 /*
742 * XPath: /frr-route-map:lib/route-map/entry/match-condition/metric
743 */
744 static int lib_route_map_entry_match_condition_metric_modify(
745 struct nb_cb_modify_args *args)
746 {
747 struct routemap_hook_context *rhc;
748 const char *type;
749 int rv;
750
751 if (args->event != NB_EV_APPLY)
752 return NB_OK;
753
754 /* Check for hook function. */
755 if (rmap_match_set_hook.match_metric == NULL)
756 return NB_OK;
757
758 /* Add configuration. */
759 rhc = nb_running_get_entry(args->dnode, NULL, true);
760 type = yang_dnode_get_string(args->dnode, NULL);
761
762 /* Set destroy information. */
763 rhc->rhc_mhook = rmap_match_set_hook.no_match_metric;
764 rhc->rhc_rule = "metric";
765 rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
766
767 rv = rmap_match_set_hook.match_metric(rhc->rhc_rmi, "metric",
768 type, RMAP_EVENT_MATCH_ADDED,
769 args->errmsg, args->errmsg_len);
770 if (rv != CMD_SUCCESS) {
771 rhc->rhc_mhook = NULL;
772 return NB_ERR_INCONSISTENCY;
773 }
774
775 return NB_OK;
776 }
777
778 static int lib_route_map_entry_match_condition_metric_destroy(
779 struct nb_cb_destroy_args *args)
780 {
781 return lib_route_map_entry_match_destroy(args);
782 }
783
784 /*
785 * XPath: /frr-route-map:lib/route-map/entry/match-condition/tag
786 */
787 static int
788 lib_route_map_entry_match_condition_tag_modify(struct nb_cb_modify_args *args)
789 {
790 struct routemap_hook_context *rhc;
791 const char *tag;
792 int rv;
793
794 if (args->event != NB_EV_APPLY)
795 return NB_OK;
796
797 /* Check for hook function. */
798 if (rmap_match_set_hook.match_tag == NULL)
799 return NB_OK;
800
801 /* Add configuration. */
802 rhc = nb_running_get_entry(args->dnode, NULL, true);
803 tag = yang_dnode_get_string(args->dnode, NULL);
804
805 /* Set destroy information. */
806 rhc->rhc_mhook = rmap_match_set_hook.no_match_tag;
807 rhc->rhc_rule = "tag";
808 rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
809
810 rv = rmap_match_set_hook.match_tag(rhc->rhc_rmi, "tag", tag,
811 RMAP_EVENT_MATCH_ADDED,
812 args->errmsg, args->errmsg_len);
813 if (rv != CMD_SUCCESS) {
814 rhc->rhc_mhook = NULL;
815 return NB_ERR_INCONSISTENCY;
816 }
817
818 return NB_OK;
819 }
820
821 static int
822 lib_route_map_entry_match_condition_tag_destroy(struct nb_cb_destroy_args *args)
823 {
824 return lib_route_map_entry_match_destroy(args);
825 }
826
827 /*
828 * XPath: /frr-route-map:lib/route-map/entry/set-action
829 */
830 static int lib_route_map_entry_set_action_create(struct nb_cb_create_args *args)
831 {
832 return lib_route_map_entry_match_condition_create(args);
833 }
834
835 static int
836 lib_route_map_entry_set_action_destroy(struct nb_cb_destroy_args *args)
837 {
838 struct routemap_hook_context *rhc;
839 int rv;
840
841 if (args->event != NB_EV_APPLY)
842 return NB_OK;
843
844 rv = lib_route_map_entry_set_destroy(args);
845 rhc = nb_running_unset_entry(args->dnode);
846 routemap_hook_context_free(rhc);
847
848 return rv;
849 }
850
851 /*
852 * XPath: /frr-route-map:lib/route-map/entry/set-action/ipv4-address
853 */
854 static int lib_route_map_entry_set_action_ipv4_address_modify(
855 struct nb_cb_modify_args *args)
856 {
857 struct routemap_hook_context *rhc;
858 const char *address;
859 struct in_addr ia;
860 int rv;
861
862 switch (args->event) {
863 case NB_EV_VALIDATE:
864 /*
865 * NOTE: validate if 'action' is 'ipv4-next-hop',
866 * currently it is not necessary because this is the
867 * only implemented action.
868 */
869 yang_dnode_get_ipv4(&ia, args->dnode, NULL);
870 if (ia.s_addr == INADDR_ANY || IPV4_CLASS_DE(ntohl(ia.s_addr)))
871 return NB_ERR_VALIDATION;
872 /* FALLTHROUGH */
873 case NB_EV_PREPARE:
874 case NB_EV_ABORT:
875 return NB_OK;
876 case NB_EV_APPLY:
877 break;
878 }
879
880 /* Check for hook function. */
881 if (rmap_match_set_hook.set_ip_nexthop == NULL)
882 return NB_OK;
883
884 /* Add configuration. */
885 rhc = nb_running_get_entry(args->dnode, NULL, true);
886 address = yang_dnode_get_string(args->dnode, NULL);
887
888 /* Set destroy information. */
889 rhc->rhc_shook = rmap_match_set_hook.no_set_ip_nexthop;
890 rhc->rhc_rule = "ip next-hop";
891
892 rv = rmap_match_set_hook.set_ip_nexthop(rhc->rhc_rmi, "ip next-hop",
893 address,
894 args->errmsg, args->errmsg_len);
895 if (rv != CMD_SUCCESS) {
896 rhc->rhc_shook = NULL;
897 return NB_ERR_INCONSISTENCY;
898 }
899
900 return NB_OK;
901 }
902
903 static int lib_route_map_entry_set_action_ipv4_address_destroy(
904 struct nb_cb_destroy_args *args)
905 {
906 return lib_route_map_entry_set_destroy(args);
907 }
908
909 /*
910 * XPath: /frr-route-map:lib/route-map/entry/set-action/ipv6-address
911 */
912 static int lib_route_map_entry_set_action_ipv6_address_modify(
913 struct nb_cb_modify_args *args)
914 {
915 struct routemap_hook_context *rhc;
916 const char *address;
917 struct in6_addr i6a;
918 int rv;
919
920 switch (args->event) {
921 case NB_EV_VALIDATE:
922 /*
923 * NOTE: validate if 'action' is 'ipv6-next-hop',
924 * currently it is not necessary because this is the
925 * only implemented action. Other actions might have
926 * different validations.
927 */
928 yang_dnode_get_ipv6(&i6a, args->dnode, NULL);
929 if (!IN6_IS_ADDR_LINKLOCAL(&i6a))
930 return NB_ERR_VALIDATION;
931 /* FALLTHROUGH */
932 case NB_EV_PREPARE:
933 case NB_EV_ABORT:
934 return NB_OK;
935 case NB_EV_APPLY:
936 break;
937 }
938
939 /* Check for hook function. */
940 if (rmap_match_set_hook.set_ipv6_nexthop_local == NULL)
941 return NB_OK;
942
943 /* Add configuration. */
944 rhc = nb_running_get_entry(args->dnode, NULL, true);
945 address = yang_dnode_get_string(args->dnode, NULL);
946
947 /* Set destroy information. */
948 rhc->rhc_shook = rmap_match_set_hook.no_set_ipv6_nexthop_local;
949 rhc->rhc_rule = "ipv6 next-hop local";
950
951 rv = rmap_match_set_hook.set_ipv6_nexthop_local(
952 rhc->rhc_rmi, "ipv6 next-hop local", address,
953 args->errmsg, args->errmsg_len);
954 if (rv != CMD_SUCCESS) {
955 rhc->rhc_shook = NULL;
956 return NB_ERR_INCONSISTENCY;
957 }
958
959 return NB_OK;
960 }
961
962 static int lib_route_map_entry_set_action_ipv6_address_destroy(
963 struct nb_cb_destroy_args *args)
964 {
965 return lib_route_map_entry_set_destroy(args);
966 }
967
968 /*
969 * XPath: /frr-route-map:lib/route-map/entry/set-action/value
970 */
971 static int set_action_modify(enum nb_event event, const struct lyd_node *dnode,
972 union nb_resource *resource, const char *value,
973 char *errmsg, size_t errmsg_len)
974 {
975 struct routemap_hook_context *rhc;
976 int rv;
977
978 /*
979 * NOTE: validate if 'action' is 'metric', currently it is not
980 * necessary because this is the only implemented action. Other
981 * actions might have different validations.
982 */
983 if (event != NB_EV_APPLY)
984 return NB_OK;
985
986 /* Check for hook function. */
987 if (rmap_match_set_hook.set_metric == NULL)
988 return NB_OK;
989
990 /* Add configuration. */
991 rhc = nb_running_get_entry(dnode, NULL, true);
992
993 /* Set destroy information. */
994 rhc->rhc_shook = rmap_match_set_hook.no_set_metric;
995 rhc->rhc_rule = "metric";
996
997 rv = rmap_match_set_hook.set_metric(rhc->rhc_rmi, "metric",
998 value,
999 errmsg, errmsg_len
1000 );
1001 if (rv != CMD_SUCCESS) {
1002 rhc->rhc_shook = NULL;
1003 return NB_ERR_INCONSISTENCY;
1004 }
1005
1006 return NB_OK;
1007 }
1008
1009 static int
1010 lib_route_map_entry_set_action_value_modify(struct nb_cb_modify_args *args)
1011 {
1012 const char *metric = yang_dnode_get_string(args->dnode, NULL);
1013
1014 return set_action_modify(args->event, args->dnode, args->resource,
1015 metric, args->errmsg, args->errmsg_len);
1016 }
1017
1018 static int
1019 lib_route_map_entry_set_action_value_destroy(struct nb_cb_destroy_args *args)
1020 {
1021 return lib_route_map_entry_set_destroy(args);
1022 }
1023
1024 /*
1025 * XPath: /frr-route-map:lib/route-map/entry/set-action/add-metric
1026 */
1027 static int
1028 lib_route_map_entry_set_action_add_metric_modify(struct nb_cb_modify_args *args)
1029 {
1030 char metric_str[16];
1031
1032 if (args->event == NB_EV_VALIDATE
1033 && yang_dnode_get_uint32(args->dnode, NULL) == 0) {
1034 snprintf(args->errmsg, args->errmsg_len,
1035 "Can't add zero to metric");
1036 return NB_ERR_VALIDATION;
1037 }
1038
1039 snprintf(metric_str, sizeof(metric_str), "+%s",
1040 yang_dnode_get_string(args->dnode, NULL));
1041 return set_action_modify(args->event, args->dnode, args->resource,
1042 metric_str,
1043 args->errmsg, args->errmsg_len);
1044 }
1045
1046 static int lib_route_map_entry_set_action_add_metric_destroy(
1047 struct nb_cb_destroy_args *args)
1048 {
1049 return lib_route_map_entry_set_action_value_destroy(args);
1050 }
1051
1052 /*
1053 * XPath: /frr-route-map:lib/route-map/entry/set-action/subtract-metric
1054 */
1055 static int lib_route_map_entry_set_action_subtract_metric_modify(
1056 struct nb_cb_modify_args *args)
1057 {
1058 char metric_str[16];
1059
1060 if (args->event == NB_EV_VALIDATE
1061 && yang_dnode_get_uint32(args->dnode, NULL) == 0) {
1062 snprintf(args->errmsg, args->errmsg_len,
1063 "Can't subtract zero from metric");
1064 return NB_ERR_VALIDATION;
1065 }
1066
1067 snprintf(metric_str, sizeof(metric_str), "-%s",
1068 yang_dnode_get_string(args->dnode, NULL));
1069 return set_action_modify(args->event, args->dnode, args->resource,
1070 metric_str,
1071 args->errmsg, args->errmsg_len);
1072 }
1073
1074 static int lib_route_map_entry_set_action_subtract_metric_destroy(
1075 struct nb_cb_destroy_args *args)
1076 {
1077 return lib_route_map_entry_set_action_value_destroy(args);
1078 }
1079
1080 /*
1081 * XPath: /frr-route-map:lib/route-map/entry/set-action/use-round-trip-time
1082 */
1083 static int lib_route_map_entry_set_action_use_round_trip_time_modify(
1084 struct nb_cb_modify_args *args)
1085 {
1086 return set_action_modify(args->event, args->dnode, args->resource,
1087 "rtt",
1088 args->errmsg, args->errmsg_len);
1089 }
1090
1091 static int lib_route_map_entry_set_action_use_round_trip_time_destroy(
1092 struct nb_cb_destroy_args *args)
1093 {
1094 return lib_route_map_entry_set_action_value_destroy(args);
1095 }
1096
1097 /*
1098 * XPath: /frr-route-map:lib/route-map/entry/set-action/add-round-trip-time
1099 */
1100 static int lib_route_map_entry_set_action_add_round_trip_time_modify(
1101 struct nb_cb_modify_args *args)
1102 {
1103 return set_action_modify(args->event, args->dnode, args->resource,
1104 "+rtt",
1105 args->errmsg, args->errmsg_len);
1106 }
1107
1108 static int lib_route_map_entry_set_action_add_round_trip_time_destroy(
1109 struct nb_cb_destroy_args *args)
1110 {
1111 return lib_route_map_entry_set_action_value_destroy(args);
1112 }
1113
1114 /*
1115 * XPath: /frr-route-map:lib/route-map/entry/set-action/subtract-round-trip-time
1116 */
1117 static int lib_route_map_entry_set_action_subtract_round_trip_time_modify(
1118 struct nb_cb_modify_args *args)
1119 {
1120 return set_action_modify(args->event, args->dnode, args->resource,
1121 "-rtt", args->errmsg, args->errmsg_len);
1122 }
1123
1124 static int lib_route_map_entry_set_action_subtract_round_trip_time_destroy(
1125 struct nb_cb_destroy_args *args)
1126 {
1127 return lib_route_map_entry_set_action_value_destroy(args);
1128 }
1129
1130 /*
1131 * XPath: /frr-route-map:lib/route-map/entry/set-action/tag
1132 */
1133 static int
1134 lib_route_map_entry_set_action_tag_modify(struct nb_cb_modify_args *args)
1135 {
1136 struct routemap_hook_context *rhc;
1137 const char *tag;
1138 int rv;
1139
1140 /*
1141 * NOTE: validate if 'action' is 'tag', currently it is not
1142 * necessary because this is the only implemented action. Other
1143 * actions might have different validations.
1144 */
1145 if (args->event != NB_EV_APPLY)
1146 return NB_OK;
1147
1148 /* Check for hook function. */
1149 if (rmap_match_set_hook.set_tag == NULL)
1150 return NB_OK;
1151
1152 /* Add configuration. */
1153 rhc = nb_running_get_entry(args->dnode, NULL, true);
1154 tag = yang_dnode_get_string(args->dnode, NULL);
1155
1156 /* Set destroy information. */
1157 rhc->rhc_shook = rmap_match_set_hook.no_set_tag;
1158 rhc->rhc_rule = "tag";
1159
1160 rv = rmap_match_set_hook.set_tag(rhc->rhc_rmi, "tag", tag,
1161 args->errmsg, args->errmsg_len);
1162 if (rv != CMD_SUCCESS) {
1163 rhc->rhc_shook = NULL;
1164 return NB_ERR_INCONSISTENCY;
1165 }
1166
1167 return NB_OK;
1168 }
1169
1170 static int
1171 lib_route_map_entry_set_action_tag_destroy(struct nb_cb_destroy_args *args)
1172 {
1173 return lib_route_map_entry_set_destroy(args);
1174 }
1175
1176 /*
1177 * XPath: /frr-route-map:lib/route-map/entry/set-action/policy
1178 */
1179 static int
1180 lib_route_map_entry_set_action_policy_modify(struct nb_cb_modify_args *args)
1181 {
1182 struct routemap_hook_context *rhc;
1183 const char *policy;
1184 int rv;
1185
1186 /*
1187 * NOTE: validate if 'action' is 'tag', currently it is not
1188 * necessary because this is the only implemented action. Other
1189 * actions might have different validations.
1190 */
1191 if (args->event != NB_EV_APPLY)
1192 return NB_OK;
1193
1194 /* Check for hook function. */
1195 if (rmap_match_set_hook.set_srte_color == NULL)
1196 return NB_OK;
1197
1198 /* Add configuration. */
1199 rhc = nb_running_get_entry(args->dnode, NULL, true);
1200 policy = yang_dnode_get_string(args->dnode, NULL);
1201
1202 /* Set destroy information. */
1203 rhc->rhc_shook = rmap_match_set_hook.no_set_tag;
1204 rhc->rhc_rule = "sr-te color";
1205
1206 rv = rmap_match_set_hook.set_tag(rhc->rhc_rmi, "sr-te color", policy,
1207 args->errmsg, args->errmsg_len);
1208 if (rv != CMD_SUCCESS) {
1209 rhc->rhc_shook = NULL;
1210 return NB_ERR_INCONSISTENCY;
1211 }
1212
1213 return NB_OK;
1214 }
1215
1216 static int
1217 lib_route_map_entry_set_action_policy_destroy(struct nb_cb_destroy_args *args)
1218 {
1219 return lib_route_map_entry_set_destroy(args);
1220 }
1221
1222 /* clang-format off */
1223 const struct frr_yang_module_info frr_route_map_info = {
1224 .name = "frr-route-map",
1225 .nodes = {
1226 {
1227 .xpath = "/frr-route-map:lib/route-map",
1228 .cbs = {
1229 .create = lib_route_map_create,
1230 .destroy = lib_route_map_destroy,
1231 }
1232 },
1233 {
1234 .xpath = "/frr-route-map:lib/route-map/optimization-disabled",
1235 .cbs = {
1236 .modify = lib_route_map_optimization_disabled_modify,
1237 .cli_show = route_map_optimization_disabled_show,
1238 }
1239 },
1240 {
1241 .xpath = "/frr-route-map:lib/route-map/entry",
1242 .cbs = {
1243 .create = lib_route_map_entry_create,
1244 .destroy = lib_route_map_entry_destroy,
1245 .cli_cmp = route_map_instance_cmp,
1246 .cli_show = route_map_instance_show,
1247 .cli_show_end = route_map_instance_show_end,
1248 }
1249 },
1250 {
1251 .xpath = "/frr-route-map:lib/route-map/entry/description",
1252 .cbs = {
1253 .modify = lib_route_map_entry_description_modify,
1254 .destroy = lib_route_map_entry_description_destroy,
1255 .cli_show = route_map_description_show,
1256 }
1257 },
1258 {
1259 .xpath = "/frr-route-map:lib/route-map/entry/action",
1260 .cbs = {
1261 .modify = lib_route_map_entry_action_modify,
1262 }
1263 },
1264 {
1265 .xpath = "/frr-route-map:lib/route-map/entry/call",
1266 .cbs = {
1267 .modify = lib_route_map_entry_call_modify,
1268 .destroy = lib_route_map_entry_call_destroy,
1269 .cli_show = route_map_call_show,
1270 }
1271 },
1272 {
1273 .xpath = "/frr-route-map:lib/route-map/entry/exit-policy",
1274 .cbs = {
1275 .modify = lib_route_map_entry_exit_policy_modify,
1276 .cli_show = route_map_exit_policy_show,
1277 }
1278 },
1279 {
1280 .xpath = "/frr-route-map:lib/route-map/entry/goto-value",
1281 .cbs = {
1282 .modify = lib_route_map_entry_goto_value_modify,
1283 .destroy = lib_route_map_entry_goto_value_destroy,
1284 }
1285 },
1286 {
1287 .xpath = "/frr-route-map:lib/route-map/entry/match-condition",
1288 .cbs = {
1289 .create = lib_route_map_entry_match_condition_create,
1290 .destroy = lib_route_map_entry_match_condition_destroy,
1291 .cli_show = route_map_condition_show,
1292 }
1293 },
1294 {
1295 .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/interface",
1296 .cbs = {
1297 .modify = lib_route_map_entry_match_condition_interface_modify,
1298 .destroy = lib_route_map_entry_match_condition_interface_destroy,
1299 }
1300 },
1301 {
1302 .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/list-name",
1303 .cbs = {
1304 .modify = lib_route_map_entry_match_condition_list_name_modify,
1305 .destroy = lib_route_map_entry_match_condition_list_name_destroy,
1306 }
1307 },
1308 {
1309 .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/ipv4-next-hop-type",
1310 .cbs = {
1311 .modify = lib_route_map_entry_match_condition_ipv4_next_hop_type_modify,
1312 .destroy = lib_route_map_entry_match_condition_ipv4_next_hop_type_destroy,
1313 }
1314 },
1315 {
1316 .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/ipv6-next-hop-type",
1317 .cbs = {
1318 .modify = lib_route_map_entry_match_condition_ipv6_next_hop_type_modify,
1319 .destroy = lib_route_map_entry_match_condition_ipv6_next_hop_type_destroy,
1320 }
1321 },
1322 {
1323 .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/metric",
1324 .cbs = {
1325 .modify = lib_route_map_entry_match_condition_metric_modify,
1326 .destroy = lib_route_map_entry_match_condition_metric_destroy,
1327 }
1328 },
1329 {
1330 .xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/tag",
1331 .cbs = {
1332 .modify = lib_route_map_entry_match_condition_tag_modify,
1333 .destroy = lib_route_map_entry_match_condition_tag_destroy,
1334 }
1335 },
1336 {
1337 .xpath = "/frr-route-map:lib/route-map/entry/set-action",
1338 .cbs = {
1339 .create = lib_route_map_entry_set_action_create,
1340 .destroy = lib_route_map_entry_set_action_destroy,
1341 .cli_show = route_map_action_show,
1342 }
1343 },
1344 {
1345 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/ipv4-address",
1346 .cbs = {
1347 .modify = lib_route_map_entry_set_action_ipv4_address_modify,
1348 .destroy = lib_route_map_entry_set_action_ipv4_address_destroy,
1349 }
1350 },
1351 {
1352 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/ipv6-address",
1353 .cbs = {
1354 .modify = lib_route_map_entry_set_action_ipv6_address_modify,
1355 .destroy = lib_route_map_entry_set_action_ipv6_address_destroy,
1356 }
1357 },
1358 {
1359 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/value",
1360 .cbs = {
1361 .modify = lib_route_map_entry_set_action_value_modify,
1362 .destroy = lib_route_map_entry_set_action_value_destroy,
1363 }
1364 },
1365 {
1366 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/add-metric",
1367 .cbs = {
1368 .modify = lib_route_map_entry_set_action_add_metric_modify,
1369 .destroy = lib_route_map_entry_set_action_add_metric_destroy,
1370 }
1371 },
1372 {
1373 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/subtract-metric",
1374 .cbs = {
1375 .modify = lib_route_map_entry_set_action_subtract_metric_modify,
1376 .destroy = lib_route_map_entry_set_action_subtract_metric_destroy,
1377 }
1378 },
1379 {
1380 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/use-round-trip-time",
1381 .cbs = {
1382 .modify = lib_route_map_entry_set_action_use_round_trip_time_modify,
1383 .destroy = lib_route_map_entry_set_action_use_round_trip_time_destroy,
1384 }
1385 },
1386 {
1387 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/add-round-trip-time",
1388 .cbs = {
1389 .modify = lib_route_map_entry_set_action_add_round_trip_time_modify,
1390 .destroy = lib_route_map_entry_set_action_add_round_trip_time_destroy,
1391 }
1392 },
1393 {
1394 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/subtract-round-trip-time",
1395 .cbs = {
1396 .modify = lib_route_map_entry_set_action_subtract_round_trip_time_modify,
1397 .destroy = lib_route_map_entry_set_action_subtract_round_trip_time_destroy,
1398 }
1399 },
1400 {
1401 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/tag",
1402 .cbs = {
1403 .modify = lib_route_map_entry_set_action_tag_modify,
1404 .destroy = lib_route_map_entry_set_action_tag_destroy,
1405 }
1406 },
1407 {
1408 .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/policy",
1409 .cbs = {
1410 .modify = lib_route_map_entry_set_action_policy_modify,
1411 .destroy = lib_route_map_entry_set_action_policy_destroy,
1412 }
1413 },
1414
1415 {
1416 .xpath = NULL,
1417 },
1418 }
1419 };