]> git.proxmox.com Git - mirror_frr.git/blame - lib/filter_nb.c
*: integrate remaining daemons with filter
[mirror_frr.git] / lib / filter_nb.c
CommitLineData
4470143b
RZ
1/*
2 * FRR filter 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
4470143b
RZ
25#include "lib/northbound.h"
26#include "lib/prefix.h"
27
28#include "lib/filter.h"
29#include "lib/plist.h"
30#include "lib/plist_int.h"
31
fb8884f3
RZ
32/* Helper function. */
33static in_addr_t
34ipv4_network_addr(in_addr_t hostaddr, int masklen)
35{
36 struct in_addr mask;
37
38 masklen2ip(masklen, &mask);
39 return hostaddr & mask.s_addr;
40}
41
4362a768
RZ
42static enum nb_error
43prefix_list_length_validate(const struct lyd_node *dnode)
44{
45 int type = yang_dnode_get_enum(dnode, "../../type");
46 const char *xpath_le = NULL, *xpath_ge = NULL;
47 struct prefix p;
48 uint8_t le, ge;
49
50 if (type == 0 /* ipv4 */) {
51 yang_dnode_get_prefix(&p, dnode, "../ipv4-prefix");
52 xpath_le = "../ipv4-prefix-length-lesser-or-equal";
53 xpath_ge = "../ipv4-prefix-length-greater-or-equal";
54 } else {
55 yang_dnode_get_prefix(&p, dnode, "../ipv6-prefix");
56 xpath_le = "../ipv6-prefix-length-lesser-or-equal";
57 xpath_ge = "../ipv6-prefix-length-greater-or-equal";
58 }
59
60 /*
61 * Check rule:
62 * prefix length <= le.
63 */
64 if (yang_dnode_exists(dnode, xpath_le)) {
65 le = yang_dnode_get_uint8(dnode, xpath_le);
66 if (p.prefixlen > le)
67 goto log_and_fail;
68
69 }
70
71 /*
72 * Check rule:
73 * prefix length < ge.
74 */
75 if (yang_dnode_exists(dnode, xpath_ge)) {
76 ge = yang_dnode_get_uint8(dnode, xpath_ge);
77 if (p.prefixlen >= ge)
78 goto log_and_fail;
79 }
80
81 /*
82 * Check rule:
83 * ge <= le.
84 */
85 if (yang_dnode_exists(dnode, xpath_le) &&
86 yang_dnode_exists(dnode, xpath_ge)) {
87 le = yang_dnode_get_uint8(dnode, xpath_le);
88 ge = yang_dnode_get_uint8(dnode, xpath_ge);
89 if (ge > le)
90 goto log_and_fail;
91 }
92
93 return NB_OK;
94
95 log_and_fail:
96 zlog_info("prefix-list: invalid prefix range for %pFX: "
97 "Make sure that mask length < ge <= le", &p);
98 return NB_ERR_VALIDATION;
99}
100
81b50422
RZ
101/**
102 * Sets prefix list entry to blank value.
103 *
104 * \param[out] ple prefix list entry to modify.
105 */
106static void prefix_list_entry_set_empty(struct prefix_list_entry *ple)
107{
108 ple->any = false;
109 memset(&ple->prefix, 0, sizeof(ple->prefix));
110 ple->ge = 0;
111 ple->le = 0;
112}
113
4470143b
RZ
114/*
115 * XPath: /frr-filter:lib/access-list-legacy
116 */
fb8884f3 117static int lib_access_list_legacy_create(struct nb_cb_create_args *args)
4470143b
RZ
118{
119 struct access_list *acl;
120 const char *acl_name;
121
fb8884f3 122 if (args->event != NB_EV_APPLY)
4470143b
RZ
123 return NB_OK;
124
fb8884f3 125 acl_name = yang_dnode_get_string(args->dnode, "./number");
4470143b 126 acl = access_list_get(AFI_IP, acl_name);
fb8884f3 127 nb_running_set_entry(args->dnode, acl);
4470143b
RZ
128
129 return NB_OK;
130}
131
fb8884f3 132static int lib_access_list_legacy_destroy(struct nb_cb_destroy_args *args)
4470143b
RZ
133{
134 struct access_master *am;
135 struct access_list *acl;
136
fb8884f3 137 if (args->event != NB_EV_APPLY)
4470143b
RZ
138 return NB_OK;
139
fb8884f3 140 acl = nb_running_unset_entry(args->dnode);
4470143b
RZ
141 am = acl->master;
142 if (am->delete_hook)
143 am->delete_hook(acl);
144
145 access_list_delete(acl);
146
147 return NB_OK;
148}
149
150/*
151 * XPath: /frr-filter:lib/access-list-legacy/remark
152 */
fb8884f3 153static int lib_access_list_legacy_remark_modify(struct nb_cb_modify_args *args)
4470143b
RZ
154{
155 struct access_list *acl;
156 const char *remark;
157
fb8884f3 158 if (args->event != NB_EV_APPLY)
4470143b
RZ
159 return NB_OK;
160
fb8884f3 161 acl = nb_running_get_entry(args->dnode, NULL, true);
4470143b
RZ
162 if (acl->remark)
163 XFREE(MTYPE_TMP, acl->remark);
164
fb8884f3 165 remark = yang_dnode_get_string(args->dnode, NULL);
4470143b
RZ
166 acl->remark = XSTRDUP(MTYPE_TMP, remark);
167
168 return NB_OK;
169}
170
fb8884f3
RZ
171static int
172lib_access_list_legacy_remark_destroy(struct nb_cb_destroy_args *args)
4470143b
RZ
173{
174 struct access_list *acl;
175
fb8884f3 176 if (args->event != NB_EV_APPLY)
4470143b
RZ
177 return NB_OK;
178
fb8884f3 179 acl = nb_running_get_entry(args->dnode, NULL, true);
4470143b
RZ
180 if (acl->remark)
181 XFREE(MTYPE_TMP, acl->remark);
182
183 acl->remark = NULL;
184
185 return NB_OK;
186}
187
188/*
189 * XPath: /frr-filter:lib/access-list-legacy/entry
190 */
fb8884f3 191static int lib_access_list_legacy_entry_create(struct nb_cb_create_args *args)
4470143b
RZ
192{
193 struct filter_cisco *fc;
194 struct access_list *acl;
195 struct filter *f;
196 uint32_t aclno;
197
198 /* TODO: validate `filter_lookup_cisco` returns NULL. */
199
fb8884f3 200 if (args->event != NB_EV_APPLY)
4470143b
RZ
201 return NB_OK;
202
fb8884f3 203 aclno = yang_dnode_get_uint16(args->dnode, "../number");
4470143b
RZ
204
205 f = filter_new();
206 f->cisco = 1;
fb8884f3 207 f->seq = yang_dnode_get_uint32(args->dnode, "./sequence");
4470143b
RZ
208 fc = &f->u.cfilter;
209 if ((aclno >= 1 && aclno <= 99) || (aclno >= 1300 && aclno <= 1999))
210 fc->extended = 0;
211 else
212 fc->extended = 1;
213
fb8884f3 214 acl = nb_running_get_entry(args->dnode, NULL, true);
4470143b
RZ
215 f->acl = acl;
216 access_list_filter_add(acl, f);
fb8884f3 217 nb_running_set_entry(args->dnode, f);
4470143b
RZ
218
219 return NB_OK;
220}
221
fb8884f3 222static int lib_access_list_legacy_entry_destroy(struct nb_cb_destroy_args *args)
4470143b
RZ
223{
224 struct access_list *acl;
225 struct filter *f;
226
fb8884f3 227 if (args->event != NB_EV_APPLY)
4470143b
RZ
228 return NB_OK;
229
fb8884f3 230 f = nb_running_unset_entry(args->dnode);
4470143b
RZ
231 acl = f->acl;
232 access_list_filter_delete(acl, f);
233
234 return NB_OK;
235}
236
237/*
238 * XPath: /frr-filter:lib/access-list-legacy/entry/action
239 */
240static int
fb8884f3 241lib_access_list_legacy_entry_action_modify(struct nb_cb_modify_args *args)
4470143b
RZ
242{
243 const char *filter_type;
244 struct filter *f;
245
fb8884f3 246 if (args->event != NB_EV_APPLY)
4470143b
RZ
247 return NB_OK;
248
fb8884f3
RZ
249 f = nb_running_get_entry(args->dnode, NULL, true);
250 filter_type = yang_dnode_get_string(args->dnode, NULL);
4470143b
RZ
251 if (strcmp(filter_type, "permit") == 0)
252 f->type = FILTER_PERMIT;
253 else
254 f->type = FILTER_DENY;
255
256 return NB_OK;
257}
258
259/*
260 * XPath: /frr-filter:lib/access-list-legacy/entry/host
261 */
262static int
fb8884f3 263lib_access_list_legacy_entry_host_modify(struct nb_cb_modify_args *args)
4470143b
RZ
264{
265 struct filter_cisco *fc;
266 struct filter *f;
267
fb8884f3 268 if (args->event != NB_EV_APPLY)
4470143b
RZ
269 return NB_OK;
270
fb8884f3 271 f = nb_running_get_entry(args->dnode, NULL, true);
4470143b 272 fc = &f->u.cfilter;
fb8884f3 273 yang_dnode_get_ipv4(&fc->addr, args->dnode, NULL);
4470143b
RZ
274 fc->addr_mask.s_addr = INADDR_ANY;
275
276 return NB_OK;
277}
278
279static int
fb8884f3 280lib_access_list_legacy_entry_host_destroy(struct nb_cb_destroy_args *args)
4470143b
RZ
281{
282 struct filter_cisco *fc;
283 struct filter *f;
284
fb8884f3 285 if (args->event != NB_EV_APPLY)
4470143b
RZ
286 return NB_OK;
287
fb8884f3 288 f = nb_running_get_entry(args->dnode, NULL, true);
4470143b
RZ
289 fc = &f->u.cfilter;
290 fc->addr.s_addr = INADDR_ANY;
291 fc->addr_mask.s_addr = INADDR_NONE;
292
293 return NB_OK;
294}
295
296/*
297 * XPath: /frr-filter:lib/access-list-legacy/entry/network
298 */
299static int
fb8884f3 300lib_access_list_legacy_entry_network_modify(struct nb_cb_modify_args *args)
4470143b
RZ
301{
302 struct filter_cisco *fc;
303 struct filter *f;
304 struct prefix p;
305
fb8884f3 306 if (args->event != NB_EV_APPLY)
4470143b
RZ
307 return NB_OK;
308
fb8884f3 309 f = nb_running_get_entry(args->dnode, NULL, true);
4470143b 310 fc = &f->u.cfilter;
fb8884f3 311 yang_dnode_get_prefix(&p, args->dnode, NULL);
4470143b
RZ
312 fc->addr.s_addr = ipv4_network_addr(p.u.prefix4.s_addr, p.prefixlen);
313 masklen2ip(p.prefixlen, &fc->addr_mask);
314
315 return NB_OK;
316}
317
318static int
fb8884f3 319lib_access_list_legacy_entry_network_destroy(struct nb_cb_destroy_args *args)
4470143b
RZ
320{
321 struct filter_cisco *fc;
322 struct filter *f;
323
fb8884f3 324 if (args->event != NB_EV_APPLY)
4470143b
RZ
325 return NB_OK;
326
fb8884f3 327 f = nb_running_get_entry(args->dnode, NULL, true);
4470143b
RZ
328 fc = &f->u.cfilter;
329 fc->addr.s_addr = INADDR_ANY;
330 fc->addr_mask.s_addr = INADDR_NONE;
331
332 return NB_OK;
333}
334
335/*
336 * XPath: /frr-filter:lib/access-list-legacy/entry/any
337 */
fb8884f3
RZ
338static int
339lib_access_list_legacy_entry_any_create(struct nb_cb_create_args *args)
4470143b
RZ
340{
341 struct filter_cisco *fc;
342 struct filter *f;
343
fb8884f3 344 if (args->event != NB_EV_APPLY)
4470143b
RZ
345 return NB_OK;
346
fb8884f3 347 f = nb_running_get_entry(args->dnode, NULL, true);
4470143b
RZ
348 fc = &f->u.cfilter;
349 fc->addr.s_addr = INADDR_ANY;
350 fc->addr_mask.s_addr = INADDR_NONE;
351
352 return NB_OK;
353}
354
355static int
fb8884f3 356lib_access_list_legacy_entry_any_destroy(struct nb_cb_destroy_args *args)
4470143b
RZ
357{
358 struct filter_cisco *fc;
359 struct filter *f;
360
fb8884f3 361 if (args->event != NB_EV_APPLY)
4470143b
RZ
362 return NB_OK;
363
fb8884f3 364 f = nb_running_get_entry(args->dnode, NULL, true);
4470143b
RZ
365 fc = &f->u.cfilter;
366 fc->addr.s_addr = INADDR_ANY;
367 fc->addr_mask.s_addr = INADDR_NONE;
368
369 return NB_OK;
370}
371
372/*
373 * XPath: /frr-filter:lib/access-list-legacy/entry/destination-host
374 */
375static int lib_access_list_legacy_entry_destination_host_modify(
fb8884f3 376 struct nb_cb_modify_args *args)
4470143b
RZ
377{
378 struct filter_cisco *fc;
379 struct filter *f;
380
fb8884f3 381 if (args->event != NB_EV_APPLY)
4470143b
RZ
382 return NB_OK;
383
fb8884f3 384 f = nb_running_get_entry(args->dnode, NULL, true);
4470143b 385 fc = &f->u.cfilter;
fb8884f3 386 yang_dnode_get_ipv4(&fc->mask, args->dnode, NULL);
4470143b
RZ
387 fc->mask_mask.s_addr = INADDR_ANY;
388
389 return NB_OK;
390}
391
392static int lib_access_list_legacy_entry_destination_host_destroy(
fb8884f3 393 struct nb_cb_destroy_args *args)
4470143b
RZ
394{
395 struct filter_cisco *fc;
396 struct filter *f;
397
fb8884f3 398 if (args->event != NB_EV_APPLY)
4470143b
RZ
399 return NB_OK;
400
fb8884f3 401 f = nb_running_get_entry(args->dnode, NULL, true);
4470143b
RZ
402 fc = &f->u.cfilter;
403 fc->mask.s_addr = INADDR_ANY;
404 fc->mask_mask.s_addr = INADDR_NONE;
405
406 return NB_OK;
407}
408
409/*
410 * XPath: /frr-filter:lib/access-list-legacy/entry/destination-network
411 */
412static int lib_access_list_legacy_entry_destination_network_modify(
fb8884f3 413 struct nb_cb_modify_args *args)
4470143b
RZ
414{
415 struct filter_cisco *fc;
416 struct filter *f;
417 struct prefix p;
418
fb8884f3 419 if (args->event != NB_EV_APPLY)
4470143b
RZ
420 return NB_OK;
421
fb8884f3 422 f = nb_running_get_entry(args->dnode, NULL, true);
4470143b 423 fc = &f->u.cfilter;
fb8884f3 424 yang_dnode_get_prefix(&p, args->dnode, NULL);
744ad1af
RZ
425 fc->mask.s_addr = ipv4_network_addr(p.u.prefix4.s_addr, p.prefixlen);
426 masklen2ip(p.prefixlen, &fc->mask_mask);
4470143b
RZ
427
428 return NB_OK;
429}
430
431static int lib_access_list_legacy_entry_destination_network_destroy(
fb8884f3 432 struct nb_cb_destroy_args *args)
4470143b
RZ
433{
434 struct filter_cisco *fc;
435 struct filter *f;
436
fb8884f3 437 if (args->event != NB_EV_APPLY)
4470143b
RZ
438 return NB_OK;
439
fb8884f3 440 f = nb_running_get_entry(args->dnode, NULL, true);
4470143b
RZ
441 fc = &f->u.cfilter;
442 fc->mask.s_addr = INADDR_ANY;
443 fc->mask_mask.s_addr = INADDR_NONE;
444
445 return NB_OK;
446}
447
448/*
449 * XPath: /frr-filter:lib/access-list-legacy/entry/destination-any
450 */
451static int lib_access_list_legacy_entry_destination_any_create(
fb8884f3 452 struct nb_cb_create_args *args)
4470143b
RZ
453{
454 struct filter_cisco *fc;
455 struct filter *f;
456
fb8884f3 457 if (args->event != NB_EV_APPLY)
4470143b
RZ
458 return NB_OK;
459
fb8884f3 460 f = nb_running_get_entry(args->dnode, NULL, true);
4470143b
RZ
461 fc = &f->u.cfilter;
462 fc->mask.s_addr = INADDR_ANY;
463 fc->mask_mask.s_addr = INADDR_NONE;
464
465 return NB_OK;
466}
467
468static int lib_access_list_legacy_entry_destination_any_destroy(
fb8884f3 469 struct nb_cb_destroy_args *args)
4470143b
RZ
470{
471 struct filter_cisco *fc;
472 struct filter *f;
473
fb8884f3 474 if (args->event != NB_EV_APPLY)
4470143b
RZ
475 return NB_OK;
476
fb8884f3 477 f = nb_running_get_entry(args->dnode, NULL, true);
4470143b
RZ
478 fc = &f->u.cfilter;
479 fc->mask.s_addr = INADDR_ANY;
480 fc->mask_mask.s_addr = INADDR_NONE;
481
482 return NB_OK;
483}
484
485/*
486 * XPath: /frr-filter:lib/access-list
487 */
fb8884f3 488static int lib_access_list_create(struct nb_cb_create_args *args)
4470143b 489{
ff94358e 490 struct access_list *acl = NULL;
4470143b
RZ
491 const char *acl_name;
492 int type;
493
fb8884f3 494 if (args->event != NB_EV_APPLY)
4470143b
RZ
495 return NB_OK;
496
fb8884f3
RZ
497 type = yang_dnode_get_enum(args->dnode, "./type");
498 acl_name = yang_dnode_get_string(args->dnode, "./name");
4470143b
RZ
499
500 switch (type) {
501 case 0: /* ipv4 */
502 acl = access_list_get(AFI_IP, acl_name);
503 break;
504 case 1: /* ipv6 */
505 acl = access_list_get(AFI_IP6, acl_name);
506 break;
507 case 2: /* mac */
508 acl = access_list_get(AFI_L2VPN, acl_name);
509 break;
510 }
511
fb8884f3 512 nb_running_set_entry(args->dnode, acl);
4470143b
RZ
513
514 return NB_OK;
515}
516
fb8884f3 517static int lib_access_list_destroy(struct nb_cb_destroy_args *args)
4470143b
RZ
518{
519 struct access_master *am;
520 struct access_list *acl;
521
fb8884f3 522 if (args->event != NB_EV_APPLY)
4470143b
RZ
523 return NB_OK;
524
fb8884f3 525 acl = nb_running_unset_entry(args->dnode);
4470143b
RZ
526 am = acl->master;
527 if (am->delete_hook)
528 am->delete_hook(acl);
529
530 access_list_delete(acl);
531
532 return NB_OK;
533}
534
535/*
536 * XPath: /frr-filter:lib/access-list/remark
537 */
fb8884f3 538static int lib_access_list_remark_modify(struct nb_cb_modify_args *args)
4470143b 539{
fb8884f3 540 return lib_access_list_legacy_remark_modify(args);
4470143b
RZ
541}
542
fb8884f3 543static int lib_access_list_remark_destroy(struct nb_cb_destroy_args *args)
4470143b 544{
fb8884f3 545 return lib_access_list_legacy_remark_destroy(args);
4470143b
RZ
546}
547
548/*
549 * XPath: /frr-filter:lib/access-list/entry
550 */
fb8884f3 551static int lib_access_list_entry_create(struct nb_cb_create_args *args)
4470143b
RZ
552{
553 struct access_list *acl;
554 struct filter *f;
555
556 /* TODO: validate `filter_lookup_zebra` returns NULL. */
557
fb8884f3 558 if (args->event != NB_EV_APPLY)
4470143b
RZ
559 return NB_OK;
560
561 f = filter_new();
fb8884f3 562 f->seq = yang_dnode_get_uint32(args->dnode, "./sequence");
4470143b 563
fb8884f3 564 acl = nb_running_get_entry(args->dnode, NULL, true);
4470143b
RZ
565 f->acl = acl;
566 access_list_filter_add(acl, f);
fb8884f3 567 nb_running_set_entry(args->dnode, f);
4470143b
RZ
568
569 return NB_OK;
570}
571
fb8884f3 572static int lib_access_list_entry_destroy(struct nb_cb_destroy_args *args)
4470143b
RZ
573{
574 struct access_list *acl;
575 struct filter *f;
576
fb8884f3 577 if (args->event != NB_EV_APPLY)
4470143b
RZ
578 return NB_OK;
579
fb8884f3 580 f = nb_running_unset_entry(args->dnode);
4470143b
RZ
581 acl = f->acl;
582 access_list_filter_delete(acl, f);
583
584 return NB_OK;
585}
586
587/*
588 * XPath: /frr-filter:lib/access-list/entry/action
589 */
fb8884f3 590static int lib_access_list_entry_action_modify(struct nb_cb_modify_args *args)
4470143b 591{
fb8884f3 592 return lib_access_list_legacy_entry_action_modify(args);
4470143b
RZ
593}
594
595/*
596 * XPath: /frr-filter:lib/access-list/entry/ipv4-prefix
597 */
598static int
fb8884f3 599lib_access_list_entry_ipv4_prefix_modify(struct nb_cb_modify_args *args)
4470143b
RZ
600{
601 struct filter_zebra *fz;
602 struct filter *f;
603
fb8884f3 604 if (args->event != NB_EV_APPLY)
4470143b
RZ
605 return NB_OK;
606
fb8884f3 607 f = nb_running_get_entry(args->dnode, NULL, true);
4470143b 608 fz = &f->u.zfilter;
fb8884f3 609 yang_dnode_get_prefix(&fz->prefix, args->dnode, NULL);
4470143b
RZ
610
611 return NB_OK;
612}
613
614static int
fb8884f3 615lib_access_list_entry_ipv4_prefix_destroy(struct nb_cb_destroy_args *args)
4470143b
RZ
616{
617 struct filter_zebra *fz;
618 struct filter *f;
619
fb8884f3 620 if (args->event != NB_EV_APPLY)
4470143b
RZ
621 return NB_OK;
622
fb8884f3 623 f = nb_running_get_entry(args->dnode, NULL, true);
4470143b
RZ
624 fz = &f->u.zfilter;
625 memset(&fz->prefix, 0, sizeof(fz->prefix));
626
627 return NB_OK;
628}
629
630/*
631 * XPath: /frr-filter:lib/access-list/entry/ipv4-exact-match
632 */
633static int
fb8884f3 634lib_access_list_entry_ipv4_exact_match_modify(struct nb_cb_modify_args *args)
4470143b
RZ
635{
636 struct filter_zebra *fz;
637 struct filter *f;
638
fb8884f3 639 if (args->event != NB_EV_APPLY)
4470143b
RZ
640 return NB_OK;
641
fb8884f3 642 f = nb_running_get_entry(args->dnode, NULL, true);
4470143b 643 fz = &f->u.zfilter;
fb8884f3 644 fz->exact = yang_dnode_get_bool(args->dnode, NULL);
4470143b
RZ
645
646 return NB_OK;
647}
648
649static int
fb8884f3 650lib_access_list_entry_ipv4_exact_match_destroy(struct nb_cb_destroy_args *args)
4470143b
RZ
651{
652 struct filter_zebra *fz;
653 struct filter *f;
654
fb8884f3 655 if (args->event != NB_EV_APPLY)
4470143b
RZ
656 return NB_OK;
657
fb8884f3 658 f = nb_running_get_entry(args->dnode, NULL, true);
4470143b
RZ
659 fz = &f->u.zfilter;
660 fz->exact = 0;
661
662 return NB_OK;
663}
664
665/*
666 * XPath: /frr-filter:lib/access-list/entry/ipv6-prefix
667 */
668static int
fb8884f3 669lib_access_list_entry_ipv6_prefix_modify(struct nb_cb_modify_args *args)
4470143b 670{
fb8884f3 671 return lib_access_list_entry_ipv4_prefix_modify(args);
4470143b
RZ
672}
673
674static int
fb8884f3 675lib_access_list_entry_ipv6_prefix_destroy(struct nb_cb_destroy_args *args)
4470143b 676{
fb8884f3 677 return lib_access_list_entry_ipv4_prefix_destroy(args);
4470143b
RZ
678}
679
680/*
681 * XPath: /frr-filter:lib/access-list/entry/ipv6-exact-match
682 */
683static int
fb8884f3 684lib_access_list_entry_ipv6_exact_match_modify(struct nb_cb_modify_args *args)
4470143b 685{
fb8884f3 686 return lib_access_list_entry_ipv4_exact_match_modify(args);
4470143b
RZ
687}
688
689static int
fb8884f3 690lib_access_list_entry_ipv6_exact_match_destroy(struct nb_cb_destroy_args *args)
4470143b 691{
fb8884f3 692 return lib_access_list_entry_ipv4_exact_match_destroy(args);
4470143b
RZ
693}
694
695/*
696 * XPath: /frr-filter:lib/access-list/entry/mac
697 */
fb8884f3 698static int lib_access_list_entry_mac_modify(struct nb_cb_modify_args *args)
4470143b 699{
fb8884f3 700 return lib_access_list_entry_ipv4_prefix_modify(args);
4470143b
RZ
701}
702
fb8884f3 703static int lib_access_list_entry_mac_destroy(struct nb_cb_destroy_args *args)
4470143b 704{
fb8884f3 705 return lib_access_list_entry_ipv4_prefix_destroy(args);
4470143b
RZ
706}
707
708/*
709 * XPath: /frr-filter:lib/access-list/entry/any
710 */
fb8884f3 711static int lib_access_list_entry_any_create(struct nb_cb_create_args *args)
4470143b
RZ
712{
713 struct filter_zebra *fz;
714 struct filter *f;
715 int type;
716
fb8884f3 717 if (args->event != NB_EV_APPLY)
4470143b
RZ
718 return NB_OK;
719
fb8884f3 720 f = nb_running_get_entry(args->dnode, NULL, true);
4470143b
RZ
721 fz = &f->u.zfilter;
722 memset(&fz->prefix, 0, sizeof(fz->prefix));
723
fb8884f3 724 type = yang_dnode_get_enum(args->dnode, "../../type");
4470143b
RZ
725 switch (type) {
726 case 0: /* ipv4 */
727 fz->prefix.family = AF_INET;
728 break;
729 case 1: /* ipv6 */
730 fz->prefix.family = AF_INET6;
731 break;
732 case 2: /* mac */
733 fz->prefix.family = AF_ETHERNET;
734 break;
735 }
736
737 return NB_OK;
738}
739
fb8884f3 740static int lib_access_list_entry_any_destroy(struct nb_cb_destroy_args *args)
4470143b
RZ
741{
742 struct filter_zebra *fz;
743 struct filter *f;
744
fb8884f3 745 if (args->event != NB_EV_APPLY)
4470143b
RZ
746 return NB_OK;
747
fb8884f3 748 f = nb_running_get_entry(args->dnode, NULL, true);
4470143b
RZ
749 fz = &f->u.zfilter;
750 fz->prefix.family = 0;
751
752 return NB_OK;
753}
754
755/*
756 * XPath: /frr-filter:lib/prefix-list
757 */
fb8884f3 758static int lib_prefix_list_create(struct nb_cb_create_args *args)
4470143b 759{
ff94358e 760 struct prefix_list *pl = NULL;
4470143b
RZ
761 const char *name;
762 int type;
763
fb8884f3 764 if (args->event != NB_EV_APPLY)
4470143b
RZ
765 return NB_OK;
766
fb8884f3
RZ
767 type = yang_dnode_get_enum(args->dnode, "./type");
768 name = yang_dnode_get_string(args->dnode, "./name");
4470143b
RZ
769 switch (type) {
770 case 0: /* ipv4 */
771 pl = prefix_list_get(AFI_IP, 0, name);
772 break;
773 case 1: /* ipv6 */
774 pl = prefix_list_get(AFI_IP6, 0, name);
775 break;
776 }
777
fb8884f3 778 nb_running_set_entry(args->dnode, pl);
4470143b
RZ
779
780 return NB_OK;
781}
782
fb8884f3 783static int lib_prefix_list_destroy(struct nb_cb_destroy_args *args)
4470143b
RZ
784{
785 struct prefix_list *pl;
786
fb8884f3 787 if (args->event != NB_EV_APPLY)
4470143b
RZ
788 return NB_OK;
789
fb8884f3 790 pl = nb_running_unset_entry(args->dnode);
4470143b
RZ
791 prefix_list_delete(pl);
792
793 return NB_OK;
794}
795
796/*
cc82bcc1 797 * XPath: /frr-filter:lib/prefix-list/remark
4470143b 798 */
cc82bcc1 799static int lib_prefix_list_remark_modify(struct nb_cb_modify_args *args)
4470143b
RZ
800{
801 struct prefix_list *pl;
802 const char *remark;
803
fb8884f3 804 if (args->event != NB_EV_APPLY)
4470143b
RZ
805 return NB_OK;
806
fb8884f3 807 pl = nb_running_get_entry(args->dnode, NULL, true);
4470143b
RZ
808 if (pl->desc)
809 XFREE(MTYPE_TMP, pl->desc);
810
fb8884f3 811 remark = yang_dnode_get_string(args->dnode, NULL);
4470143b
RZ
812 pl->desc = XSTRDUP(MTYPE_TMP, remark);
813
814 return NB_OK;
815}
816
cc82bcc1 817static int lib_prefix_list_remark_destroy(struct nb_cb_destroy_args *args)
4470143b
RZ
818{
819 struct prefix_list *pl;
820
fb8884f3 821 if (args->event != NB_EV_APPLY)
4470143b
RZ
822 return NB_OK;
823
fb8884f3 824 pl = nb_running_get_entry(args->dnode, NULL, true);
4470143b
RZ
825 if (pl->desc)
826 XFREE(MTYPE_TMP, pl->desc);
827
828 pl->desc = NULL;
829
830 return NB_OK;
831}
832
833/*
834 * XPath: /frr-filter:lib/prefix-list/entry
835 */
fb8884f3 836static int lib_prefix_list_entry_create(struct nb_cb_create_args *args)
4470143b
RZ
837{
838 struct prefix_list_entry *ple;
839 struct prefix_list *pl;
840 struct prefix p;
841
fb8884f3 842 if (args->event != NB_EV_APPLY)
4470143b
RZ
843 return NB_OK;
844
845 memset(&p, 0, sizeof(p));
846
fb8884f3 847 pl = nb_running_get_entry(args->dnode, NULL, true);
4470143b
RZ
848 ple = prefix_list_entry_new();
849 ple->pl = pl;
cc82bcc1 850 ple->seq = yang_dnode_get_uint32(args->dnode, "./sequence");
81b50422 851 prefix_list_entry_set_empty(ple);
a7b28218 852 nb_running_set_entry(args->dnode, ple);
4470143b
RZ
853
854 return NB_OK;
855}
856
fb8884f3 857static int lib_prefix_list_entry_destroy(struct nb_cb_destroy_args *args)
4470143b
RZ
858{
859 struct prefix_list_entry *ple;
860
fb8884f3 861 if (args->event != NB_EV_APPLY)
4470143b
RZ
862 return NB_OK;
863
fb8884f3 864 ple = nb_running_unset_entry(args->dnode);
a7b28218 865 if (ple->installed)
81b50422 866 prefix_list_entry_delete2(ple);
a7b28218
RZ
867 else
868 prefix_list_entry_free(ple);
4470143b
RZ
869
870 return NB_OK;
871}
872
873/*
874 * XPath: /frr-filter:lib/prefix-list/entry/action
875 */
fb8884f3 876static int lib_prefix_list_entry_action_modify(struct nb_cb_modify_args *args)
4470143b
RZ
877{
878 struct prefix_list_entry *ple;
879 const char *action_str;
880
fb8884f3 881 if (args->event != NB_EV_APPLY)
4470143b
RZ
882 return NB_OK;
883
fb8884f3 884 ple = nb_running_get_entry(args->dnode, NULL, true);
a7b28218
RZ
885
886 /* Start prefix entry update procedure. */
887 prefix_list_entry_update_start(ple);
888
cc82bcc1 889 action_str = yang_dnode_get_string(args->dnode, NULL);
4470143b
RZ
890 if (strcmp(action_str, "permit") == 0)
891 ple->type = PREFIX_PERMIT;
892 else
893 ple->type = PREFIX_DENY;
894
a7b28218
RZ
895 /* Finish prefix entry update procedure. */
896 prefix_list_entry_update_finish(ple);
897
4470143b
RZ
898 return NB_OK;
899}
900
901/*
902 * XPath: /frr-filter:lib/prefix-list/entry/ipv4-prefix
903 */
904static int
fb8884f3 905lib_prefix_list_entry_ipv4_prefix_modify(struct nb_cb_modify_args *args)
4470143b
RZ
906{
907 struct prefix_list_entry *ple;
cf4472c4
RZ
908 struct prefix p;
909
910 if (args->event == NB_EV_VALIDATE) {
911 /*
912 * TODO: validate prefix_entry_dup_check() passes.
913 *
914 * This needs to be implemented using YANG lyd_node
915 * navigation, because the `priv` data structures are not
916 * available at `NB_EV_VALIDATE` phase. An easier
917 * alternative would be mark `ipvx-prefix` as unique
918 * (see RFC 7950, Section 7.8.3. The list "unique" Statement).
919 */
920 return NB_OK;
921 }
4470143b 922
fb8884f3 923 if (args->event != NB_EV_APPLY)
4470143b
RZ
924 return NB_OK;
925
fb8884f3 926 ple = nb_running_get_entry(args->dnode, NULL, true);
a7b28218
RZ
927
928 /* Start prefix entry update procedure. */
929 prefix_list_entry_update_start(ple);
930
fb8884f3 931 yang_dnode_get_prefix(&ple->prefix, args->dnode, NULL);
4470143b 932
cf4472c4
RZ
933 /* Apply mask and correct original address if necessary. */
934 prefix_copy(&p, &ple->prefix);
935 apply_mask(&p);
936 if (!prefix_same(&ple->prefix, &p)) {
937 zlog_info("%s: bad network %pFX correcting it to %pFX",
938 __func__, &ple->prefix, &p);
939 prefix_copy(&ple->prefix, &p);
940 }
941
942
a7b28218
RZ
943 /* Finish prefix entry update procedure. */
944 prefix_list_entry_update_finish(ple);
945
4470143b
RZ
946 return NB_OK;
947}
948
949static int
fb8884f3 950lib_prefix_list_entry_ipv4_prefix_destroy(struct nb_cb_destroy_args *args)
4470143b
RZ
951{
952 struct prefix_list_entry *ple;
953
fb8884f3 954 if (args->event != NB_EV_APPLY)
4470143b
RZ
955 return NB_OK;
956
fb8884f3 957 ple = nb_running_get_entry(args->dnode, NULL, true);
a7b28218
RZ
958
959 /* Start prefix entry update procedure. */
960 prefix_list_entry_update_start(ple);
961
4470143b 962 memset(&ple->prefix, 0, sizeof(ple->prefix));
4470143b 963
a7b28218
RZ
964 /* Finish prefix entry update procedure. */
965 prefix_list_entry_update_finish(ple);
966
4470143b
RZ
967 return NB_OK;
968}
969
970/*
971 * XPath: /frr-filter:lib/prefix-list/entry/ipv4-prefix-length-greater-or-equal
972 */
973static int lib_prefix_list_entry_ipv4_prefix_length_greater_or_equal_modify(
fb8884f3 974 struct nb_cb_modify_args *args)
4470143b
RZ
975{
976 struct prefix_list_entry *ple;
977
4362a768
RZ
978 if (args->event == NB_EV_VALIDATE &&
979 prefix_list_length_validate(args->dnode) != NB_OK)
980 return NB_ERR_VALIDATION;
981
fb8884f3 982 if (args->event != NB_EV_APPLY)
4470143b
RZ
983 return NB_OK;
984
fb8884f3 985 ple = nb_running_get_entry(args->dnode, NULL, true);
a7b28218
RZ
986
987 /* Start prefix entry update procedure. */
988 prefix_list_entry_update_start(ple);
989
fb8884f3 990 ple->ge = yang_dnode_get_uint8(args->dnode, NULL);
4470143b 991
a7b28218
RZ
992 /* Finish prefix entry update procedure. */
993 prefix_list_entry_update_finish(ple);
994
4470143b
RZ
995 return NB_OK;
996}
997
998static int lib_prefix_list_entry_ipv4_prefix_length_greater_or_equal_destroy(
fb8884f3 999 struct nb_cb_destroy_args *args)
4470143b
RZ
1000{
1001 struct prefix_list_entry *ple;
1002
fb8884f3 1003 if (args->event != NB_EV_APPLY)
4470143b
RZ
1004 return NB_OK;
1005
fb8884f3 1006 ple = nb_running_get_entry(args->dnode, NULL, true);
a7b28218
RZ
1007
1008 /* Start prefix entry update procedure. */
1009 prefix_list_entry_update_start(ple);
1010
4470143b
RZ
1011 ple->ge = 0;
1012
a7b28218
RZ
1013 /* Finish prefix entry update procedure. */
1014 prefix_list_entry_update_finish(ple);
1015
4470143b
RZ
1016 return NB_OK;
1017}
1018
1019/*
1020 * XPath: /frr-filter:lib/prefix-list/entry/ipv4-prefix-length-lesser-or-equal
1021 */
1022static int lib_prefix_list_entry_ipv4_prefix_length_lesser_or_equal_modify(
fb8884f3 1023 struct nb_cb_modify_args *args)
4470143b
RZ
1024{
1025 struct prefix_list_entry *ple;
1026
4362a768
RZ
1027 if (args->event == NB_EV_VALIDATE &&
1028 prefix_list_length_validate(args->dnode) != NB_OK)
1029 return NB_ERR_VALIDATION;
1030
fb8884f3 1031 if (args->event != NB_EV_APPLY)
4470143b
RZ
1032 return NB_OK;
1033
fb8884f3 1034 ple = nb_running_get_entry(args->dnode, NULL, true);
a7b28218
RZ
1035
1036 /* Start prefix entry update procedure. */
1037 prefix_list_entry_update_start(ple);
1038
fb8884f3 1039 ple->le = yang_dnode_get_uint8(args->dnode, NULL);
4470143b 1040
a7b28218
RZ
1041 /* Finish prefix entry update procedure. */
1042 prefix_list_entry_update_finish(ple);
1043
4470143b
RZ
1044 return NB_OK;
1045}
1046
1047static int lib_prefix_list_entry_ipv4_prefix_length_lesser_or_equal_destroy(
fb8884f3 1048 struct nb_cb_destroy_args *args)
4470143b
RZ
1049{
1050 struct prefix_list_entry *ple;
1051
fb8884f3 1052 if (args->event != NB_EV_APPLY)
4470143b
RZ
1053 return NB_OK;
1054
fb8884f3 1055 ple = nb_running_get_entry(args->dnode, NULL, true);
a7b28218
RZ
1056
1057 /* Start prefix entry update procedure. */
1058 prefix_list_entry_update_start(ple);
1059
4470143b
RZ
1060 ple->le = 0;
1061
a7b28218
RZ
1062 /* Finish prefix entry update procedure. */
1063 prefix_list_entry_update_finish(ple);
1064
4470143b
RZ
1065 return NB_OK;
1066}
1067
1068/*
1069 * XPath: /frr-filter:lib/prefix-list/entry/ipv6-prefix
1070 */
1071static int
fb8884f3 1072lib_prefix_list_entry_ipv6_prefix_modify(struct nb_cb_modify_args *args)
4470143b 1073{
fb8884f3 1074 return lib_prefix_list_entry_ipv4_prefix_modify(args);
4470143b
RZ
1075}
1076
1077static int
fb8884f3 1078lib_prefix_list_entry_ipv6_prefix_destroy(struct nb_cb_destroy_args *args)
4470143b 1079{
fb8884f3 1080 return lib_prefix_list_entry_ipv4_prefix_destroy(args);
4470143b
RZ
1081}
1082
1083/*
1084 * XPath: /frr-filter:lib/prefix-list/entry/ipv6-prefix-length-greater-or-equal
1085 */
1086static int lib_prefix_list_entry_ipv6_prefix_length_greater_or_equal_modify(
fb8884f3 1087 struct nb_cb_modify_args *args)
4470143b
RZ
1088{
1089 return lib_prefix_list_entry_ipv4_prefix_length_greater_or_equal_modify(
fb8884f3 1090 args);
4470143b
RZ
1091}
1092
1093static int lib_prefix_list_entry_ipv6_prefix_length_greater_or_equal_destroy(
fb8884f3 1094 struct nb_cb_destroy_args *args)
4470143b
RZ
1095{
1096 return lib_prefix_list_entry_ipv4_prefix_length_greater_or_equal_destroy(
fb8884f3 1097 args);
4470143b
RZ
1098}
1099
1100/*
1101 * XPath: /frr-filter:lib/prefix-list/entry/ipv6-prefix-length-lesser-or-equal
1102 */
1103static int lib_prefix_list_entry_ipv6_prefix_length_lesser_or_equal_modify(
fb8884f3 1104 struct nb_cb_modify_args *args)
4470143b
RZ
1105{
1106 return lib_prefix_list_entry_ipv4_prefix_length_lesser_or_equal_modify(
fb8884f3 1107 args);
4470143b
RZ
1108}
1109
1110static int lib_prefix_list_entry_ipv6_prefix_length_lesser_or_equal_destroy(
fb8884f3 1111 struct nb_cb_destroy_args *args)
4470143b
RZ
1112{
1113 return lib_prefix_list_entry_ipv4_prefix_length_lesser_or_equal_destroy(
fb8884f3 1114 args);
4470143b
RZ
1115}
1116
1117/*
1118 * XPath: /frr-filter:lib/prefix-list/entry/any
1119 */
fb8884f3 1120static int lib_prefix_list_entry_any_create(struct nb_cb_create_args *args)
4470143b
RZ
1121{
1122 struct prefix_list_entry *ple;
81b50422 1123 int type;
4470143b 1124
fb8884f3 1125 if (args->event != NB_EV_APPLY)
4470143b
RZ
1126 return NB_OK;
1127
fb8884f3 1128 ple = nb_running_get_entry(args->dnode, NULL, true);
a7b28218
RZ
1129
1130 /* Start prefix entry update procedure. */
1131 prefix_list_entry_update_start(ple);
1132
81b50422
RZ
1133 ple->any = true;
1134
1135 /* Fill prefix struct from scratch. */
4470143b 1136 memset(&ple->prefix, 0, sizeof(ple->prefix));
81b50422
RZ
1137
1138 type = yang_dnode_get_enum(args->dnode, "../../type");
1139 switch (type) {
1140 case 0: /* ipv4 */
1141 ple->prefix.family = AF_INET;
1142 ple->ge = 0;
1143 ple->le = IPV4_MAX_BITLEN;
1144 break;
1145 case 1: /* ipv6 */
1146 ple->prefix.family = AF_INET6;
1147 ple->ge = 0;
1148 ple->le = IPV6_MAX_BITLEN;
1149 break;
1150 }
4470143b 1151
a7b28218
RZ
1152 /* Finish prefix entry update procedure. */
1153 prefix_list_entry_update_finish(ple);
1154
4470143b
RZ
1155 return NB_OK;
1156}
1157
fb8884f3 1158static int lib_prefix_list_entry_any_destroy(struct nb_cb_destroy_args *args)
4470143b
RZ
1159{
1160 struct prefix_list_entry *ple;
1161
fb8884f3 1162 if (args->event != NB_EV_APPLY)
4470143b
RZ
1163 return NB_OK;
1164
fb8884f3 1165 ple = nb_running_get_entry(args->dnode, NULL, true);
a7b28218
RZ
1166
1167 /* Start prefix entry update procedure. */
1168 prefix_list_entry_update_start(ple);
1169
81b50422 1170 prefix_list_entry_set_empty(ple);
4470143b 1171
a7b28218
RZ
1172 /* Finish prefix entry update procedure. */
1173 prefix_list_entry_update_finish(ple);
1174
4470143b
RZ
1175 return NB_OK;
1176}
1177
1178/* clang-format off */
1179const struct frr_yang_module_info frr_filter_info = {
1180 .name = "frr-filter",
1181 .nodes = {
1182 {
1183 .xpath = "/frr-filter:lib/access-list-legacy",
1184 .cbs = {
1185 .create = lib_access_list_legacy_create,
1186 .destroy = lib_access_list_legacy_destroy,
1187 }
1188 },
1189 {
1190 .xpath = "/frr-filter:lib/access-list-legacy/remark",
1191 .cbs = {
1192 .modify = lib_access_list_legacy_remark_modify,
1193 .destroy = lib_access_list_legacy_remark_destroy,
1d3c4b66 1194 .cli_show = access_list_legacy_remark_show,
4470143b
RZ
1195 }
1196 },
1197 {
1198 .xpath = "/frr-filter:lib/access-list-legacy/entry",
1199 .cbs = {
1200 .create = lib_access_list_legacy_entry_create,
1201 .destroy = lib_access_list_legacy_entry_destroy,
1d3c4b66 1202 .cli_show = access_list_legacy_show,
4470143b
RZ
1203 }
1204 },
1205 {
1206 .xpath = "/frr-filter:lib/access-list-legacy/entry/action",
1207 .cbs = {
1208 .modify = lib_access_list_legacy_entry_action_modify,
1209 }
1210 },
1211 {
1212 .xpath = "/frr-filter:lib/access-list-legacy/entry/host",
1213 .cbs = {
1214 .modify = lib_access_list_legacy_entry_host_modify,
1215 .destroy = lib_access_list_legacy_entry_host_destroy,
1216 }
1217 },
1218 {
1219 .xpath = "/frr-filter:lib/access-list-legacy/entry/network",
1220 .cbs = {
1221 .modify = lib_access_list_legacy_entry_network_modify,
1222 .destroy = lib_access_list_legacy_entry_network_destroy,
1223 }
1224 },
1225 {
1226 .xpath = "/frr-filter:lib/access-list-legacy/entry/any",
1227 .cbs = {
1228 .create = lib_access_list_legacy_entry_any_create,
1229 .destroy = lib_access_list_legacy_entry_any_destroy,
1230 }
1231 },
1232 {
1233 .xpath = "/frr-filter:lib/access-list-legacy/entry/destination-host",
1234 .cbs = {
1235 .modify = lib_access_list_legacy_entry_destination_host_modify,
1236 .destroy = lib_access_list_legacy_entry_destination_host_destroy,
1237 }
1238 },
1239 {
1240 .xpath = "/frr-filter:lib/access-list-legacy/entry/destination-network",
1241 .cbs = {
1242 .modify = lib_access_list_legacy_entry_destination_network_modify,
1243 .destroy = lib_access_list_legacy_entry_destination_network_destroy,
1244 }
1245 },
1246 {
1247 .xpath = "/frr-filter:lib/access-list-legacy/entry/destination-any",
1248 .cbs = {
1249 .create = lib_access_list_legacy_entry_destination_any_create,
1250 .destroy = lib_access_list_legacy_entry_destination_any_destroy,
1251 }
1252 },
1253 {
1254 .xpath = "/frr-filter:lib/access-list",
1255 .cbs = {
1256 .create = lib_access_list_create,
1257 .destroy = lib_access_list_destroy,
1258 }
1259 },
1260 {
1261 .xpath = "/frr-filter:lib/access-list/remark",
1262 .cbs = {
1263 .modify = lib_access_list_remark_modify,
1264 .destroy = lib_access_list_remark_destroy,
1d3c4b66 1265 .cli_show = access_list_remark_show,
4470143b
RZ
1266 }
1267 },
1268 {
1269 .xpath = "/frr-filter:lib/access-list/entry",
1270 .cbs = {
1271 .create = lib_access_list_entry_create,
1272 .destroy = lib_access_list_entry_destroy,
1d3c4b66 1273 .cli_show = access_list_show,
4470143b
RZ
1274 }
1275 },
1276 {
1277 .xpath = "/frr-filter:lib/access-list/entry/action",
1278 .cbs = {
1279 .modify = lib_access_list_entry_action_modify,
1280 }
1281 },
1282 {
1283 .xpath = "/frr-filter:lib/access-list/entry/ipv4-prefix",
1284 .cbs = {
1285 .modify = lib_access_list_entry_ipv4_prefix_modify,
1286 .destroy = lib_access_list_entry_ipv4_prefix_destroy,
1287 }
1288 },
1289 {
1290 .xpath = "/frr-filter:lib/access-list/entry/ipv4-exact-match",
1291 .cbs = {
1292 .modify = lib_access_list_entry_ipv4_exact_match_modify,
1293 .destroy = lib_access_list_entry_ipv4_exact_match_destroy,
1294 }
1295 },
1296 {
1297 .xpath = "/frr-filter:lib/access-list/entry/ipv6-prefix",
1298 .cbs = {
1299 .modify = lib_access_list_entry_ipv6_prefix_modify,
1300 .destroy = lib_access_list_entry_ipv6_prefix_destroy,
1301 }
1302 },
1303 {
1304 .xpath = "/frr-filter:lib/access-list/entry/ipv6-exact-match",
1305 .cbs = {
1306 .modify = lib_access_list_entry_ipv6_exact_match_modify,
1307 .destroy = lib_access_list_entry_ipv6_exact_match_destroy,
1308 }
1309 },
1310 {
1311 .xpath = "/frr-filter:lib/access-list/entry/mac",
1312 .cbs = {
1313 .modify = lib_access_list_entry_mac_modify,
1314 .destroy = lib_access_list_entry_mac_destroy,
1315 }
1316 },
1317 {
1318 .xpath = "/frr-filter:lib/access-list/entry/any",
1319 .cbs = {
1320 .create = lib_access_list_entry_any_create,
1321 .destroy = lib_access_list_entry_any_destroy,
1322 }
1323 },
1324 {
1325 .xpath = "/frr-filter:lib/prefix-list",
1326 .cbs = {
1327 .create = lib_prefix_list_create,
1328 .destroy = lib_prefix_list_destroy,
1329 }
1330 },
1331 {
cc82bcc1 1332 .xpath = "/frr-filter:lib/prefix-list/remark",
4470143b 1333 .cbs = {
cc82bcc1
RZ
1334 .modify = lib_prefix_list_remark_modify,
1335 .destroy = lib_prefix_list_remark_destroy,
1d3c4b66 1336 .cli_show = prefix_list_remark_show,
4470143b
RZ
1337 }
1338 },
1339 {
1340 .xpath = "/frr-filter:lib/prefix-list/entry",
1341 .cbs = {
1342 .create = lib_prefix_list_entry_create,
1343 .destroy = lib_prefix_list_entry_destroy,
1d3c4b66 1344 .cli_show = prefix_list_show,
4470143b
RZ
1345 }
1346 },
1347 {
1348 .xpath = "/frr-filter:lib/prefix-list/entry/action",
1349 .cbs = {
1350 .modify = lib_prefix_list_entry_action_modify,
1351 }
1352 },
1353 {
1354 .xpath = "/frr-filter:lib/prefix-list/entry/ipv4-prefix",
1355 .cbs = {
1356 .modify = lib_prefix_list_entry_ipv4_prefix_modify,
1357 .destroy = lib_prefix_list_entry_ipv4_prefix_destroy,
1358 }
1359 },
1360 {
1361 .xpath = "/frr-filter:lib/prefix-list/entry/ipv4-prefix-length-greater-or-equal",
1362 .cbs = {
1363 .modify = lib_prefix_list_entry_ipv4_prefix_length_greater_or_equal_modify,
1364 .destroy = lib_prefix_list_entry_ipv4_prefix_length_greater_or_equal_destroy,
1365 }
1366 },
1367 {
1368 .xpath = "/frr-filter:lib/prefix-list/entry/ipv4-prefix-length-lesser-or-equal",
1369 .cbs = {
1370 .modify = lib_prefix_list_entry_ipv4_prefix_length_lesser_or_equal_modify,
1371 .destroy = lib_prefix_list_entry_ipv4_prefix_length_lesser_or_equal_destroy,
1372 }
1373 },
1374 {
1375 .xpath = "/frr-filter:lib/prefix-list/entry/ipv6-prefix",
1376 .cbs = {
1377 .modify = lib_prefix_list_entry_ipv6_prefix_modify,
1378 .destroy = lib_prefix_list_entry_ipv6_prefix_destroy,
1379 }
1380 },
1381 {
1382 .xpath = "/frr-filter:lib/prefix-list/entry/ipv6-prefix-length-greater-or-equal",
1383 .cbs = {
1384 .modify = lib_prefix_list_entry_ipv6_prefix_length_greater_or_equal_modify,
1385 .destroy = lib_prefix_list_entry_ipv6_prefix_length_greater_or_equal_destroy,
1386 }
1387 },
1388 {
1389 .xpath = "/frr-filter:lib/prefix-list/entry/ipv6-prefix-length-lesser-or-equal",
1390 .cbs = {
1391 .modify = lib_prefix_list_entry_ipv6_prefix_length_lesser_or_equal_modify,
1392 .destroy = lib_prefix_list_entry_ipv6_prefix_length_lesser_or_equal_destroy,
1393 }
1394 },
1395 {
1396 .xpath = "/frr-filter:lib/prefix-list/entry/any",
1397 .cbs = {
1398 .create = lib_prefix_list_entry_any_create,
1399 .destroy = lib_prefix_list_entry_any_destroy,
1400 }
1401 },
1402 {
1403 .xpath = NULL,
1404 },
1405 }
1406};