]> git.proxmox.com Git - mirror_frr.git/blame - isisd/isis_nb_config.c
isisd: add segment-routing CLI commands
[mirror_frr.git] / isisd / isis_nb_config.c
CommitLineData
2a1c520e
RW
1/*
2 * Copyright (C) 2001,2002 Sampo Saaristo
3 * Tampere University of Technology
4 * Institute of Communications Engineering
5 * Copyright (C) 2018 Volta Networks
6 * Emanuele Di Pascale
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; see the file COPYING; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23#include <zebra.h>
24
25#include "northbound.h"
26#include "linklist.h"
27#include "log.h"
28#include "bfd.h"
29#include "spf_backoff.h"
30#include "lib_errors.h"
31#include "vrf.h"
32
33#include "isisd/isisd.h"
34#include "isisd/isis_nb.h"
35#include "isisd/isis_common.h"
36#include "isisd/isis_bfd.h"
37#include "isisd/isis_circuit.h"
38#include "isisd/isis_lsp.h"
39#include "isisd/isis_dynhn.h"
40#include "isisd/isis_misc.h"
41#include "isisd/isis_csm.h"
42#include "isisd/isis_adjacency.h"
43#include "isisd/isis_spf.h"
44#include "isisd/isis_te.h"
45#include "isisd/isis_memory.h"
46#include "isisd/isis_mt.h"
47#include "isisd/isis_redist.h"
48
49/*
50 * XPath: /frr-isisd:isis/instance
51 */
60ee8be1 52int isis_instance_create(struct nb_cb_create_args *args)
2a1c520e
RW
53{
54 struct isis_area *area;
55 const char *area_tag;
56
60ee8be1 57 if (args->event != NB_EV_APPLY)
2a1c520e
RW
58 return NB_OK;
59
60ee8be1 60 area_tag = yang_dnode_get_string(args->dnode, "./area-tag");
2a1c520e
RW
61 area = isis_area_lookup(area_tag);
62 if (area)
63 return NB_ERR_INCONSISTENCY;
64
65 area = isis_area_create(area_tag);
66 /* save area in dnode to avoid looking it up all the time */
60ee8be1 67 nb_running_set_entry(args->dnode, area);
2a1c520e
RW
68
69 return NB_OK;
70}
71
60ee8be1 72int isis_instance_destroy(struct nb_cb_destroy_args *args)
2a1c520e
RW
73{
74 struct isis_area *area;
75
60ee8be1 76 if (args->event != NB_EV_APPLY)
2a1c520e
RW
77 return NB_OK;
78
60ee8be1 79 area = nb_running_unset_entry(args->dnode);
2a1c520e
RW
80 isis_area_destroy(area->area_tag);
81
82 return NB_OK;
83}
84
85/*
86 * XPath: /frr-isisd:isis/instance/is-type
87 */
60ee8be1 88int isis_instance_is_type_modify(struct nb_cb_modify_args *args)
2a1c520e
RW
89{
90 struct isis_area *area;
91 int type;
92
60ee8be1 93 if (args->event != NB_EV_APPLY)
2a1c520e
RW
94 return NB_OK;
95
60ee8be1
RW
96 area = nb_running_get_entry(args->dnode, NULL, true);
97 type = yang_dnode_get_enum(args->dnode, NULL);
2a1c520e
RW
98 isis_area_is_type_set(area, type);
99
100 return NB_OK;
101}
102
103/*
104 * XPath: /frr-isisd:isis/instance/area-address
105 */
60ee8be1 106int isis_instance_area_address_create(struct nb_cb_create_args *args)
2a1c520e
RW
107{
108 struct isis_area *area;
109 struct area_addr addr, *addrr = NULL, *addrp = NULL;
110 struct listnode *node;
111 uint8_t buff[255];
60ee8be1 112 const char *net_title = yang_dnode_get_string(args->dnode, NULL);
2a1c520e 113
60ee8be1 114 switch (args->event) {
2a1c520e
RW
115 case NB_EV_VALIDATE:
116 addr.addr_len = dotformat2buff(buff, net_title);
117 memcpy(addr.area_addr, buff, addr.addr_len);
118 if (addr.area_addr[addr.addr_len - 1] != 0) {
119 flog_warn(
120 EC_LIB_NB_CB_CONFIG_VALIDATE,
121 "nsel byte (last byte) in area address must be 0");
122 return NB_ERR_VALIDATION;
123 }
124 if (isis->sysid_set) {
125 /* Check that the SystemID portions match */
126 if (memcmp(isis->sysid, GETSYSID((&addr)),
127 ISIS_SYS_ID_LEN)) {
128 flog_warn(
129 EC_LIB_NB_CB_CONFIG_VALIDATE,
130 "System ID must not change when defining additional area addresses");
131 return NB_ERR_VALIDATION;
132 }
133 }
134 break;
135 case NB_EV_PREPARE:
136 addrr = XMALLOC(MTYPE_ISIS_AREA_ADDR, sizeof(struct area_addr));
137 addrr->addr_len = dotformat2buff(buff, net_title);
138 memcpy(addrr->area_addr, buff, addrr->addr_len);
60ee8be1 139 args->resource->ptr = addrr;
2a1c520e
RW
140 break;
141 case NB_EV_ABORT:
60ee8be1 142 XFREE(MTYPE_ISIS_AREA_ADDR, args->resource->ptr);
2a1c520e
RW
143 break;
144 case NB_EV_APPLY:
60ee8be1
RW
145 area = nb_running_get_entry(args->dnode, NULL, true);
146 addrr = args->resource->ptr;
2a1c520e
RW
147
148 if (isis->sysid_set == 0) {
149 /*
150 * First area address - get the SystemID for this router
151 */
152 memcpy(isis->sysid, GETSYSID(addrr), ISIS_SYS_ID_LEN);
153 isis->sysid_set = 1;
154 } else {
155 /* check that we don't already have this address */
156 for (ALL_LIST_ELEMENTS_RO(area->area_addrs, node,
157 addrp)) {
158 if ((addrp->addr_len + ISIS_SYS_ID_LEN
159 + ISIS_NSEL_LEN)
160 != (addrr->addr_len))
161 continue;
162 if (!memcmp(addrp->area_addr, addrr->area_addr,
163 addrr->addr_len)) {
164 XFREE(MTYPE_ISIS_AREA_ADDR, addrr);
165 return NB_OK; /* silent fail */
166 }
167 }
168 }
169
170 /*Forget the systemID part of the address */
171 addrr->addr_len -= (ISIS_SYS_ID_LEN + ISIS_NSEL_LEN);
172 assert(area->area_addrs); /* to silence scan-build sillyness */
173 listnode_add(area->area_addrs, addrr);
174
175 /* only now we can safely generate our LSPs for this area */
176 if (listcount(area->area_addrs) > 0) {
177 if (area->is_type & IS_LEVEL_1)
178 lsp_generate(area, IS_LEVEL_1);
179 if (area->is_type & IS_LEVEL_2)
180 lsp_generate(area, IS_LEVEL_2);
181 }
182 break;
183 }
184
185 return NB_OK;
186}
187
60ee8be1 188int isis_instance_area_address_destroy(struct nb_cb_destroy_args *args)
2a1c520e
RW
189{
190 struct area_addr addr, *addrp = NULL;
191 struct listnode *node;
192 uint8_t buff[255];
193 struct isis_area *area;
194 const char *net_title;
195
60ee8be1 196 if (args->event != NB_EV_APPLY)
2a1c520e
RW
197 return NB_OK;
198
60ee8be1 199 net_title = yang_dnode_get_string(args->dnode, NULL);
2a1c520e
RW
200 addr.addr_len = dotformat2buff(buff, net_title);
201 memcpy(addr.area_addr, buff, (int)addr.addr_len);
60ee8be1 202 area = nb_running_get_entry(args->dnode, NULL, true);
2a1c520e
RW
203 for (ALL_LIST_ELEMENTS_RO(area->area_addrs, node, addrp)) {
204 if ((addrp->addr_len + ISIS_SYS_ID_LEN + 1) == addr.addr_len
205 && !memcmp(addrp->area_addr, addr.area_addr, addr.addr_len))
206 break;
207 }
208 if (!addrp)
209 return NB_ERR_INCONSISTENCY;
210
211 listnode_delete(area->area_addrs, addrp);
212 XFREE(MTYPE_ISIS_AREA_ADDR, addrp);
213 /*
214 * Last area address - reset the SystemID for this router
215 */
216 if (listcount(area->area_addrs) == 0) {
217 memset(isis->sysid, 0, ISIS_SYS_ID_LEN);
218 isis->sysid_set = 0;
219 if (isis->debugs & DEBUG_EVENTS)
220 zlog_debug("Router has no SystemID");
221 }
222
223 return NB_OK;
224}
225
226/*
227 * XPath: /frr-isisd:isis/instance/dynamic-hostname
228 */
60ee8be1 229int isis_instance_dynamic_hostname_modify(struct nb_cb_modify_args *args)
2a1c520e
RW
230{
231 struct isis_area *area;
232
60ee8be1 233 if (args->event != NB_EV_APPLY)
2a1c520e
RW
234 return NB_OK;
235
60ee8be1
RW
236 area = nb_running_get_entry(args->dnode, NULL, true);
237 isis_area_dynhostname_set(area, yang_dnode_get_bool(args->dnode, NULL));
2a1c520e
RW
238
239 return NB_OK;
240}
241
242/*
243 * XPath: /frr-isisd:isis/instance/attached
244 */
60ee8be1 245int isis_instance_attached_modify(struct nb_cb_modify_args *args)
2a1c520e
RW
246{
247 struct isis_area *area;
248 bool attached;
249
60ee8be1 250 if (args->event != NB_EV_APPLY)
2a1c520e
RW
251 return NB_OK;
252
60ee8be1
RW
253 area = nb_running_get_entry(args->dnode, NULL, true);
254 attached = yang_dnode_get_bool(args->dnode, NULL);
2a1c520e
RW
255 isis_area_attached_bit_set(area, attached);
256
257 return NB_OK;
258}
259
260/*
261 * XPath: /frr-isisd:isis/instance/overload
262 */
60ee8be1 263int isis_instance_overload_modify(struct nb_cb_modify_args *args)
2a1c520e
RW
264{
265 struct isis_area *area;
266 bool overload;
267
60ee8be1 268 if (args->event != NB_EV_APPLY)
2a1c520e
RW
269 return NB_OK;
270
60ee8be1
RW
271 area = nb_running_get_entry(args->dnode, NULL, true);
272 overload = yang_dnode_get_bool(args->dnode, NULL);
2a1c520e
RW
273 isis_area_overload_bit_set(area, overload);
274
275 return NB_OK;
276}
277
278/*
279 * XPath: /frr-isisd:isis/instance/metric-style
280 */
60ee8be1 281int isis_instance_metric_style_modify(struct nb_cb_modify_args *args)
2a1c520e
RW
282{
283 struct isis_area *area;
284 bool old_metric, new_metric;
60ee8be1
RW
285 enum isis_metric_style metric_style =
286 yang_dnode_get_enum(args->dnode, NULL);
2a1c520e 287
60ee8be1 288 if (args->event != NB_EV_APPLY)
2a1c520e
RW
289 return NB_OK;
290
60ee8be1 291 area = nb_running_get_entry(args->dnode, NULL, true);
2a1c520e
RW
292 old_metric = (metric_style == ISIS_WIDE_METRIC) ? false : true;
293 new_metric = (metric_style == ISIS_NARROW_METRIC) ? false : true;
294 isis_area_metricstyle_set(area, old_metric, new_metric);
295
296 return NB_OK;
297}
298
299/*
300 * XPath: /frr-isisd:isis/instance/purge-originator
301 */
60ee8be1 302int isis_instance_purge_originator_modify(struct nb_cb_modify_args *args)
2a1c520e
RW
303{
304 struct isis_area *area;
305
60ee8be1 306 if (args->event != NB_EV_APPLY)
2a1c520e
RW
307 return NB_OK;
308
60ee8be1
RW
309 area = nb_running_get_entry(args->dnode, NULL, true);
310 area->purge_originator = yang_dnode_get_bool(args->dnode, NULL);
2a1c520e
RW
311
312 return NB_OK;
313}
314
315/*
316 * XPath: /frr-isisd:isis/instance/lsp/mtu
317 */
60ee8be1 318int isis_instance_lsp_mtu_modify(struct nb_cb_modify_args *args)
2a1c520e
RW
319{
320 struct listnode *node;
321 struct isis_circuit *circuit;
60ee8be1 322 uint16_t lsp_mtu = yang_dnode_get_uint16(args->dnode, NULL);
2a1c520e
RW
323 struct isis_area *area;
324
60ee8be1 325 switch (args->event) {
2a1c520e 326 case NB_EV_VALIDATE:
60ee8be1 327 area = nb_running_get_entry(args->dnode, NULL, false);
2a1c520e
RW
328 if (!area)
329 break;
330 for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) {
331 if (circuit->state != C_STATE_INIT
332 && circuit->state != C_STATE_UP)
333 continue;
334 if (lsp_mtu > isis_circuit_pdu_size(circuit)) {
335 flog_warn(
336 EC_LIB_NB_CB_CONFIG_VALIDATE,
337 "ISIS area contains circuit %s, which has a maximum PDU size of %zu",
338 circuit->interface->name,
339 isis_circuit_pdu_size(circuit));
340 return NB_ERR_VALIDATION;
341 }
342 }
343 break;
344 case NB_EV_PREPARE:
345 case NB_EV_ABORT:
346 break;
347 case NB_EV_APPLY:
60ee8be1 348 area = nb_running_get_entry(args->dnode, NULL, true);
2a1c520e
RW
349 isis_area_lsp_mtu_set(area, lsp_mtu);
350 break;
351 }
352
353 return NB_OK;
354}
355
356/*
d2c970ff 357 * XPath: /frr-isisd:isis/instance/lsp/timers/level-1/refresh-interval
2a1c520e
RW
358 */
359int isis_instance_lsp_refresh_interval_level_1_modify(
60ee8be1 360 struct nb_cb_modify_args *args)
2a1c520e
RW
361{
362 struct isis_area *area;
363 uint16_t refr_int;
364
60ee8be1 365 if (args->event != NB_EV_APPLY)
2a1c520e
RW
366 return NB_OK;
367
60ee8be1
RW
368 refr_int = yang_dnode_get_uint16(args->dnode, NULL);
369 area = nb_running_get_entry(args->dnode, NULL, true);
2a1c520e
RW
370 isis_area_lsp_refresh_set(area, IS_LEVEL_1, refr_int);
371
372 return NB_OK;
373}
374
375/*
d2c970ff 376 * XPath: /frr-isisd:isis/instance/lsp/timers/level-2/refresh-interval
2a1c520e
RW
377 */
378int isis_instance_lsp_refresh_interval_level_2_modify(
60ee8be1 379 struct nb_cb_modify_args *args)
2a1c520e
RW
380{
381 struct isis_area *area;
382 uint16_t refr_int;
383
60ee8be1 384 if (args->event != NB_EV_APPLY)
2a1c520e
RW
385 return NB_OK;
386
60ee8be1
RW
387 refr_int = yang_dnode_get_uint16(args->dnode, NULL);
388 area = nb_running_get_entry(args->dnode, NULL, true);
2a1c520e
RW
389 isis_area_lsp_refresh_set(area, IS_LEVEL_2, refr_int);
390
391 return NB_OK;
392}
393
394/*
d2c970ff 395 * XPath: /frr-isisd:isis/instance/lsp/timers/level-1/maximum-lifetime
2a1c520e
RW
396 */
397int isis_instance_lsp_maximum_lifetime_level_1_modify(
60ee8be1 398 struct nb_cb_modify_args *args)
2a1c520e
RW
399{
400 struct isis_area *area;
401 uint16_t max_lt;
402
60ee8be1 403 if (args->event != NB_EV_APPLY)
2a1c520e
RW
404 return NB_OK;
405
60ee8be1
RW
406 max_lt = yang_dnode_get_uint16(args->dnode, NULL);
407 area = nb_running_get_entry(args->dnode, NULL, true);
2a1c520e
RW
408 isis_area_max_lsp_lifetime_set(area, IS_LEVEL_1, max_lt);
409
410 return NB_OK;
411}
412
413/*
d2c970ff 414 * XPath: /frr-isisd:isis/instance/lsp/timers/level-2/maximum-lifetime
2a1c520e
RW
415 */
416int isis_instance_lsp_maximum_lifetime_level_2_modify(
60ee8be1 417 struct nb_cb_modify_args *args)
2a1c520e
RW
418{
419 struct isis_area *area;
420 uint16_t max_lt;
421
60ee8be1 422 if (args->event != NB_EV_APPLY)
2a1c520e
RW
423 return NB_OK;
424
60ee8be1
RW
425 max_lt = yang_dnode_get_uint16(args->dnode, NULL);
426 area = nb_running_get_entry(args->dnode, NULL, true);
2a1c520e
RW
427 isis_area_max_lsp_lifetime_set(area, IS_LEVEL_2, max_lt);
428
429 return NB_OK;
430}
431
432/*
d2c970ff 433 * XPath: /frr-isisd:isis/instance/lsp/timers/level-1/generation-interval
2a1c520e
RW
434 */
435int isis_instance_lsp_generation_interval_level_1_modify(
60ee8be1 436 struct nb_cb_modify_args *args)
2a1c520e
RW
437{
438 struct isis_area *area;
439 uint16_t gen_int;
440
60ee8be1 441 if (args->event != NB_EV_APPLY)
2a1c520e
RW
442 return NB_OK;
443
60ee8be1
RW
444 gen_int = yang_dnode_get_uint16(args->dnode, NULL);
445 area = nb_running_get_entry(args->dnode, NULL, true);
2a1c520e
RW
446 area->lsp_gen_interval[0] = gen_int;
447
448 return NB_OK;
449}
450
451/*
d2c970ff 452 * XPath: /frr-isisd:isis/instance/lsp/timers/level-2/generation-interval
2a1c520e
RW
453 */
454int isis_instance_lsp_generation_interval_level_2_modify(
60ee8be1 455 struct nb_cb_modify_args *args)
2a1c520e
RW
456{
457 struct isis_area *area;
458 uint16_t gen_int;
459
60ee8be1 460 if (args->event != NB_EV_APPLY)
2a1c520e
RW
461 return NB_OK;
462
60ee8be1
RW
463 gen_int = yang_dnode_get_uint16(args->dnode, NULL);
464 area = nb_running_get_entry(args->dnode, NULL, true);
2a1c520e
RW
465 area->lsp_gen_interval[1] = gen_int;
466
467 return NB_OK;
468}
469
470/*
471 * XPath: /frr-isisd:isis/instance/spf/ietf-backoff-delay
472 */
60ee8be1 473void ietf_backoff_delay_apply_finish(struct nb_cb_apply_finish_args *args)
2a1c520e 474{
60ee8be1
RW
475 long init_delay = yang_dnode_get_uint16(args->dnode, "./init-delay");
476 long short_delay = yang_dnode_get_uint16(args->dnode, "./short-delay");
477 long long_delay = yang_dnode_get_uint16(args->dnode, "./long-delay");
478 long holddown = yang_dnode_get_uint16(args->dnode, "./hold-down");
479 long timetolearn =
480 yang_dnode_get_uint16(args->dnode, "./time-to-learn");
481 struct isis_area *area = nb_running_get_entry(args->dnode, NULL, true);
2a1c520e
RW
482 size_t bufsiz = strlen(area->area_tag) + sizeof("IS-IS Lx");
483 char *buf = XCALLOC(MTYPE_TMP, bufsiz);
484
485 snprintf(buf, bufsiz, "IS-IS %s L1", area->area_tag);
486 spf_backoff_free(area->spf_delay_ietf[0]);
487 area->spf_delay_ietf[0] =
488 spf_backoff_new(master, buf, init_delay, short_delay,
489 long_delay, holddown, timetolearn);
490
491 snprintf(buf, bufsiz, "IS-IS %s L2", area->area_tag);
492 spf_backoff_free(area->spf_delay_ietf[1]);
493 area->spf_delay_ietf[1] =
494 spf_backoff_new(master, buf, init_delay, short_delay,
495 long_delay, holddown, timetolearn);
496
497 XFREE(MTYPE_TMP, buf);
498}
499
60ee8be1 500int isis_instance_spf_ietf_backoff_delay_create(struct nb_cb_create_args *args)
2a1c520e
RW
501{
502 /* All the work is done in the apply_finish */
503 return NB_OK;
504}
505
60ee8be1
RW
506int isis_instance_spf_ietf_backoff_delay_destroy(
507 struct nb_cb_destroy_args *args)
2a1c520e
RW
508{
509 struct isis_area *area;
510
60ee8be1 511 if (args->event != NB_EV_APPLY)
2a1c520e
RW
512 return NB_OK;
513
60ee8be1 514 area = nb_running_get_entry(args->dnode, NULL, true);
2a1c520e
RW
515 spf_backoff_free(area->spf_delay_ietf[0]);
516 spf_backoff_free(area->spf_delay_ietf[1]);
517 area->spf_delay_ietf[0] = NULL;
518 area->spf_delay_ietf[1] = NULL;
519
520 return NB_OK;
521}
522
523/*
524 * XPath: /frr-isisd:isis/instance/spf/ietf-backoff-delay/init-delay
525 */
526int isis_instance_spf_ietf_backoff_delay_init_delay_modify(
60ee8be1 527 struct nb_cb_modify_args *args)
2a1c520e
RW
528{
529 /* All the work is done in the apply_finish */
530 return NB_OK;
531}
532
533/*
534 * XPath: /frr-isisd:isis/instance/spf/ietf-backoff-delay/short-delay
535 */
536int isis_instance_spf_ietf_backoff_delay_short_delay_modify(
60ee8be1 537 struct nb_cb_modify_args *args)
2a1c520e
RW
538{
539 /* All the work is done in the apply_finish */
540 return NB_OK;
541}
542
543/*
544 * XPath: /frr-isisd:isis/instance/spf/ietf-backoff-delay/long-delay
545 */
546int isis_instance_spf_ietf_backoff_delay_long_delay_modify(
60ee8be1 547 struct nb_cb_modify_args *args)
2a1c520e
RW
548{
549 /* All the work is done in the apply_finish */
550 return NB_OK;
551}
552
553/*
554 * XPath: /frr-isisd:isis/instance/spf/ietf-backoff-delay/hold-down
555 */
556int isis_instance_spf_ietf_backoff_delay_hold_down_modify(
60ee8be1 557 struct nb_cb_modify_args *args)
2a1c520e
RW
558{
559 /* All the work is done in the apply_finish */
560 return NB_OK;
561}
562
563/*
564 * XPath: /frr-isisd:isis/instance/spf/ietf-backoff-delay/time-to-learn
565 */
566int isis_instance_spf_ietf_backoff_delay_time_to_learn_modify(
60ee8be1 567 struct nb_cb_modify_args *args)
2a1c520e
RW
568{
569 /* All the work is done in the apply_finish */
570 return NB_OK;
571}
572
573/*
574 * XPath: /frr-isisd:isis/instance/spf/minimum-interval/level-1
575 */
576int isis_instance_spf_minimum_interval_level_1_modify(
60ee8be1 577 struct nb_cb_modify_args *args)
2a1c520e
RW
578{
579 struct isis_area *area;
580
60ee8be1 581 if (args->event != NB_EV_APPLY)
2a1c520e
RW
582 return NB_OK;
583
60ee8be1
RW
584 area = nb_running_get_entry(args->dnode, NULL, true);
585 area->min_spf_interval[0] = yang_dnode_get_uint16(args->dnode, NULL);
2a1c520e
RW
586
587 return NB_OK;
588}
589
590/*
591 * XPath: /frr-isisd:isis/instance/spf/minimum-interval/level-2
592 */
593int isis_instance_spf_minimum_interval_level_2_modify(
60ee8be1 594 struct nb_cb_modify_args *args)
2a1c520e
RW
595{
596 struct isis_area *area;
597
60ee8be1 598 if (args->event != NB_EV_APPLY)
2a1c520e
RW
599 return NB_OK;
600
60ee8be1
RW
601 area = nb_running_get_entry(args->dnode, NULL, true);
602 area->min_spf_interval[1] = yang_dnode_get_uint16(args->dnode, NULL);
2a1c520e
RW
603
604 return NB_OK;
605}
606
607/*
608 * XPath: /frr-isisd:isis/instance/area-password
609 */
60ee8be1 610void area_password_apply_finish(struct nb_cb_apply_finish_args *args)
2a1c520e 611{
60ee8be1
RW
612 const char *password = yang_dnode_get_string(args->dnode, "./password");
613 struct isis_area *area = nb_running_get_entry(args->dnode, NULL, true);
614 int pass_type = yang_dnode_get_enum(args->dnode, "./password-type");
615 uint8_t snp_auth =
616 yang_dnode_get_enum(args->dnode, "./authenticate-snp");
2a1c520e
RW
617
618 switch (pass_type) {
619 case ISIS_PASSWD_TYPE_CLEARTXT:
620 isis_area_passwd_cleartext_set(area, IS_LEVEL_1, password,
621 snp_auth);
622 break;
623 case ISIS_PASSWD_TYPE_HMAC_MD5:
624 isis_area_passwd_hmac_md5_set(area, IS_LEVEL_1, password,
625 snp_auth);
626 break;
627 }
628}
629
60ee8be1 630int isis_instance_area_password_create(struct nb_cb_create_args *args)
2a1c520e
RW
631{
632 /* actual setting is done in apply_finish */
633 return NB_OK;
634}
635
60ee8be1 636int isis_instance_area_password_destroy(struct nb_cb_destroy_args *args)
2a1c520e
RW
637{
638 struct isis_area *area;
639
60ee8be1 640 if (args->event != NB_EV_APPLY)
2a1c520e
RW
641 return NB_OK;
642
60ee8be1 643 area = nb_running_get_entry(args->dnode, NULL, true);
2a1c520e
RW
644 isis_area_passwd_unset(area, IS_LEVEL_1);
645
646 return NB_OK;
647}
648
649/*
650 * XPath: /frr-isisd:isis/instance/area-password/password
651 */
60ee8be1 652int isis_instance_area_password_password_modify(struct nb_cb_modify_args *args)
2a1c520e
RW
653{
654 /* actual setting is done in apply_finish */
655 return NB_OK;
656}
657
658/*
659 * XPath: /frr-isisd:isis/instance/area-password/password-type
660 */
661int isis_instance_area_password_password_type_modify(
60ee8be1 662 struct nb_cb_modify_args *args)
2a1c520e
RW
663{
664 /* actual setting is done in apply_finish */
665 return NB_OK;
666}
667
668/*
669 * XPath: /frr-isisd:isis/instance/area-password/authenticate-snp
670 */
671int isis_instance_area_password_authenticate_snp_modify(
60ee8be1 672 struct nb_cb_modify_args *args)
2a1c520e
RW
673{
674 /* actual setting is done in apply_finish */
675 return NB_OK;
676}
677
678/*
679 * XPath: /frr-isisd:isis/instance/domain-password
680 */
60ee8be1 681void domain_password_apply_finish(struct nb_cb_apply_finish_args *args)
2a1c520e 682{
60ee8be1
RW
683 const char *password = yang_dnode_get_string(args->dnode, "./password");
684 struct isis_area *area = nb_running_get_entry(args->dnode, NULL, true);
685 int pass_type = yang_dnode_get_enum(args->dnode, "./password-type");
686 uint8_t snp_auth =
687 yang_dnode_get_enum(args->dnode, "./authenticate-snp");
2a1c520e
RW
688
689 switch (pass_type) {
690 case ISIS_PASSWD_TYPE_CLEARTXT:
691 isis_area_passwd_cleartext_set(area, IS_LEVEL_2, password,
692 snp_auth);
693 break;
694 case ISIS_PASSWD_TYPE_HMAC_MD5:
695 isis_area_passwd_hmac_md5_set(area, IS_LEVEL_2, password,
696 snp_auth);
697 break;
698 }
699}
700
60ee8be1 701int isis_instance_domain_password_create(struct nb_cb_create_args *args)
2a1c520e
RW
702{
703 /* actual setting is done in apply_finish */
704 return NB_OK;
705}
706
60ee8be1 707int isis_instance_domain_password_destroy(struct nb_cb_destroy_args *args)
2a1c520e
RW
708{
709 struct isis_area *area;
710
60ee8be1 711 if (args->event != NB_EV_APPLY)
2a1c520e
RW
712 return NB_OK;
713
60ee8be1 714 area = nb_running_get_entry(args->dnode, NULL, true);
2a1c520e
RW
715 isis_area_passwd_unset(area, IS_LEVEL_2);
716
717 return NB_OK;
718}
719
720/*
721 * XPath: /frr-isisd:isis/instance/domain-password/password
722 */
60ee8be1
RW
723int isis_instance_domain_password_password_modify(
724 struct nb_cb_modify_args *args)
2a1c520e
RW
725{
726 /* actual setting is done in apply_finish */
727 return NB_OK;
728}
729
730/*
731 * XPath: /frr-isisd:isis/instance/domain-password/password-type
732 */
733int isis_instance_domain_password_password_type_modify(
60ee8be1 734 struct nb_cb_modify_args *args)
2a1c520e
RW
735{
736 /* actual setting is done in apply_finish */
737 return NB_OK;
738}
739
740/*
741 * XPath: /frr-isisd:isis/instance/domain-password/authenticate-snp
742 */
743int isis_instance_domain_password_authenticate_snp_modify(
60ee8be1 744 struct nb_cb_modify_args *args)
2a1c520e
RW
745{
746 /* actual setting is done in apply_finish */
747 return NB_OK;
748}
749
750/*
751 * XPath: /frr-isisd:isis/instance/default-information-originate/ipv4
752 */
753void default_info_origin_apply_finish(const struct lyd_node *dnode, int family)
754{
755 int originate_type = DEFAULT_ORIGINATE;
756 unsigned long metric = 0;
757 const char *routemap = NULL;
758 struct isis_area *area = nb_running_get_entry(dnode, NULL, true);
759 int level = yang_dnode_get_enum(dnode, "./level");
760
761 if (yang_dnode_get_bool(dnode, "./always")) {
762 originate_type = DEFAULT_ORIGINATE_ALWAYS;
763 } else if (family == AF_INET6) {
764 zlog_warn(
765 "%s: Zebra doesn't implement default-originate for IPv6 yet, so use with care or use default-originate always.",
766 __func__);
767 }
768
769 if (yang_dnode_exists(dnode, "./metric"))
770 metric = yang_dnode_get_uint32(dnode, "./metric");
771 if (yang_dnode_exists(dnode, "./route-map"))
772 routemap = yang_dnode_get_string(dnode, "./route-map");
773
774 isis_redist_set(area, level, family, DEFAULT_ROUTE, metric, routemap,
775 originate_type);
776}
777
60ee8be1 778void default_info_origin_ipv4_apply_finish(struct nb_cb_apply_finish_args *args)
2a1c520e 779{
60ee8be1 780 default_info_origin_apply_finish(args->dnode, AF_INET);
2a1c520e
RW
781}
782
60ee8be1 783void default_info_origin_ipv6_apply_finish(struct nb_cb_apply_finish_args *args)
2a1c520e 784{
60ee8be1 785 default_info_origin_apply_finish(args->dnode, AF_INET6);
2a1c520e
RW
786}
787
788int isis_instance_default_information_originate_ipv4_create(
60ee8be1 789 struct nb_cb_create_args *args)
2a1c520e
RW
790{
791 /* It's all done by default_info_origin_apply_finish */
792 return NB_OK;
793}
794
795int isis_instance_default_information_originate_ipv4_destroy(
60ee8be1 796 struct nb_cb_destroy_args *args)
2a1c520e
RW
797{
798 struct isis_area *area;
799 int level;
800
60ee8be1 801 if (args->event != NB_EV_APPLY)
2a1c520e
RW
802 return NB_OK;
803
60ee8be1
RW
804 area = nb_running_get_entry(args->dnode, NULL, true);
805 level = yang_dnode_get_enum(args->dnode, "./level");
2a1c520e
RW
806 isis_redist_unset(area, level, AF_INET, DEFAULT_ROUTE);
807
808 return NB_OK;
809}
810
811/*
812 * XPath: /frr-isisd:isis/instance/default-information-originate/ipv4/always
813 */
814int isis_instance_default_information_originate_ipv4_always_modify(
60ee8be1 815 struct nb_cb_modify_args *args)
2a1c520e
RW
816{
817 /* It's all done by default_info_origin_apply_finish */
818 return NB_OK;
819}
820
821/*
822 * XPath: /frr-isisd:isis/instance/default-information-originate/ipv4/route-map
823 */
824int isis_instance_default_information_originate_ipv4_route_map_modify(
60ee8be1 825 struct nb_cb_modify_args *args)
2a1c520e
RW
826{
827 /* It's all done by default_info_origin_apply_finish */
828 return NB_OK;
829}
830
831int isis_instance_default_information_originate_ipv4_route_map_destroy(
60ee8be1 832 struct nb_cb_destroy_args *args)
2a1c520e
RW
833{
834 /* It's all done by default_info_origin_apply_finish */
835 return NB_OK;
836}
837
838/*
839 * XPath: /frr-isisd:isis/instance/default-information-originate/ipv4/metric
840 */
841int isis_instance_default_information_originate_ipv4_metric_modify(
60ee8be1 842 struct nb_cb_modify_args *args)
2a1c520e
RW
843{
844 /* It's all done by default_info_origin_apply_finish */
845 return NB_OK;
846}
847
848/*
849 * XPath: /frr-isisd:isis/instance/default-information-originate/ipv6
850 */
851int isis_instance_default_information_originate_ipv6_create(
60ee8be1 852 struct nb_cb_create_args *args)
2a1c520e
RW
853{
854 /* It's all done by default_info_origin_apply_finish */
855 return NB_OK;
856}
857
858int isis_instance_default_information_originate_ipv6_destroy(
60ee8be1 859 struct nb_cb_destroy_args *args)
2a1c520e
RW
860{
861 struct isis_area *area;
862 int level;
863
60ee8be1 864 if (args->event != NB_EV_APPLY)
2a1c520e
RW
865 return NB_OK;
866
60ee8be1
RW
867 area = nb_running_get_entry(args->dnode, NULL, true);
868 level = yang_dnode_get_enum(args->dnode, "./level");
2a1c520e
RW
869 isis_redist_unset(area, level, AF_INET6, DEFAULT_ROUTE);
870
871 return NB_OK;
872}
873
874/*
875 * XPath: /frr-isisd:isis/instance/default-information-originate/ipv6/always
876 */
877int isis_instance_default_information_originate_ipv6_always_modify(
60ee8be1 878 struct nb_cb_modify_args *args)
2a1c520e
RW
879{
880 /* It's all done by default_info_origin_apply_finish */
881 return NB_OK;
882}
883
884/*
885 * XPath: /frr-isisd:isis/instance/default-information-originate/ipv6/route-map
886 */
887int isis_instance_default_information_originate_ipv6_route_map_modify(
60ee8be1 888 struct nb_cb_modify_args *args)
2a1c520e
RW
889{
890 /* It's all done by default_info_origin_apply_finish */
891 return NB_OK;
892}
893
894int isis_instance_default_information_originate_ipv6_route_map_destroy(
60ee8be1 895 struct nb_cb_destroy_args *args)
2a1c520e
RW
896{
897 /* It's all done by default_info_origin_apply_finish */
898 return NB_OK;
899}
900
901/*
902 * XPath: /frr-isisd:isis/instance/default-information-originate/ipv6/metric
903 */
904int isis_instance_default_information_originate_ipv6_metric_modify(
60ee8be1 905 struct nb_cb_modify_args *args)
2a1c520e
RW
906{
907 /* It's all done by default_info_origin_apply_finish */
908 return NB_OK;
909}
910
911/*
912 * XPath: /frr-isisd:isis/instance/redistribute/ipv4
913 */
914void redistribute_apply_finish(const struct lyd_node *dnode, int family)
915{
916 assert(family == AF_INET || family == AF_INET6);
917 int type, level;
918 unsigned long metric = 0;
919 const char *routemap = NULL;
920 struct isis_area *area;
921
922 type = yang_dnode_get_enum(dnode, "./protocol");
923 level = yang_dnode_get_enum(dnode, "./level");
924 area = nb_running_get_entry(dnode, NULL, true);
925
926 if (yang_dnode_exists(dnode, "./metric"))
927 metric = yang_dnode_get_uint32(dnode, "./metric");
928 if (yang_dnode_exists(dnode, "./route-map"))
929 routemap = yang_dnode_get_string(dnode, "./route-map");
930
931 isis_redist_set(area, level, family, type, metric, routemap, 0);
932}
933
60ee8be1 934void redistribute_ipv4_apply_finish(struct nb_cb_apply_finish_args *args)
2a1c520e 935{
60ee8be1 936 redistribute_apply_finish(args->dnode, AF_INET);
2a1c520e
RW
937}
938
60ee8be1 939void redistribute_ipv6_apply_finish(struct nb_cb_apply_finish_args *args)
2a1c520e 940{
60ee8be1 941 redistribute_apply_finish(args->dnode, AF_INET6);
2a1c520e
RW
942}
943
60ee8be1 944int isis_instance_redistribute_ipv4_create(struct nb_cb_create_args *args)
2a1c520e
RW
945{
946 /* It's all done by redistribute_apply_finish */
947 return NB_OK;
948}
949
60ee8be1 950int isis_instance_redistribute_ipv4_destroy(struct nb_cb_destroy_args *args)
2a1c520e
RW
951{
952 struct isis_area *area;
953 int level, type;
954
60ee8be1 955 if (args->event != NB_EV_APPLY)
2a1c520e
RW
956 return NB_OK;
957
60ee8be1
RW
958 area = nb_running_get_entry(args->dnode, NULL, true);
959 level = yang_dnode_get_enum(args->dnode, "./level");
960 type = yang_dnode_get_enum(args->dnode, "./protocol");
2a1c520e
RW
961 isis_redist_unset(area, level, AF_INET, type);
962
963 return NB_OK;
964}
965
966/*
967 * XPath: /frr-isisd:isis/instance/redistribute/ipv4/route-map
968 */
969int isis_instance_redistribute_ipv4_route_map_modify(
60ee8be1 970 struct nb_cb_modify_args *args)
2a1c520e
RW
971{
972 /* It's all done by redistribute_apply_finish */
973 return NB_OK;
974}
975
976int isis_instance_redistribute_ipv4_route_map_destroy(
60ee8be1 977 struct nb_cb_destroy_args *args)
2a1c520e
RW
978{
979 /* It's all done by redistribute_apply_finish */
980 return NB_OK;
981}
982
983/*
984 * XPath: /frr-isisd:isis/instance/redistribute/ipv4/metric
985 */
60ee8be1
RW
986int isis_instance_redistribute_ipv4_metric_modify(
987 struct nb_cb_modify_args *args)
2a1c520e
RW
988{
989 /* It's all done by redistribute_apply_finish */
990 return NB_OK;
991}
992
993/*
994 * XPath: /frr-isisd:isis/instance/redistribute/ipv6
995 */
60ee8be1 996int isis_instance_redistribute_ipv6_create(struct nb_cb_create_args *args)
2a1c520e
RW
997{
998 /* It's all done by redistribute_apply_finish */
999 return NB_OK;
1000}
1001
60ee8be1 1002int isis_instance_redistribute_ipv6_destroy(struct nb_cb_destroy_args *args)
2a1c520e
RW
1003{
1004 struct isis_area *area;
1005 int level, type;
1006
60ee8be1 1007 if (args->event != NB_EV_APPLY)
2a1c520e
RW
1008 return NB_OK;
1009
60ee8be1
RW
1010 area = nb_running_get_entry(args->dnode, NULL, true);
1011 level = yang_dnode_get_enum(args->dnode, "./level");
1012 type = yang_dnode_get_enum(args->dnode, "./protocol");
2a1c520e
RW
1013 isis_redist_unset(area, level, AF_INET6, type);
1014
1015 return NB_OK;
1016}
1017
1018/*
1019 * XPath: /frr-isisd:isis/instance/redistribute/ipv6/route-map
1020 */
1021int isis_instance_redistribute_ipv6_route_map_modify(
60ee8be1 1022 struct nb_cb_modify_args *args)
2a1c520e
RW
1023{
1024 /* It's all done by redistribute_apply_finish */
1025 return NB_OK;
1026}
1027
1028int isis_instance_redistribute_ipv6_route_map_destroy(
60ee8be1 1029 struct nb_cb_destroy_args *args)
2a1c520e
RW
1030{
1031 /* It's all done by redistribute_apply_finish */
1032 return NB_OK;
1033}
1034
1035/*
1036 * XPath: /frr-isisd:isis/instance/redistribute/ipv6/metric
1037 */
60ee8be1
RW
1038int isis_instance_redistribute_ipv6_metric_modify(
1039 struct nb_cb_modify_args *args)
2a1c520e
RW
1040{
1041 /* It's all done by redistribute_apply_finish */
1042 return NB_OK;
1043}
1044
1045/*
1046 * XPath: /frr-isisd:isis/instance/multi-topology/ipv4-multicast
1047 */
1048static int isis_multi_topology_common(enum nb_event event,
1049 const struct lyd_node *dnode,
1050 const char *topology, bool create)
1051{
1052 struct isis_area *area;
1053 struct isis_area_mt_setting *setting;
1054 uint16_t mtid = isis_str2mtid(topology);
1055
1056 switch (event) {
1057 case NB_EV_VALIDATE:
1058 if (mtid == (uint16_t)-1) {
1059 flog_warn(EC_LIB_NB_CB_CONFIG_VALIDATE,
1060 "Unknown topology %s", topology);
1061 return NB_ERR_VALIDATION;
1062 }
1063 break;
1064 case NB_EV_PREPARE:
1065 case NB_EV_ABORT:
1066 break;
1067 case NB_EV_APPLY:
1068 area = nb_running_get_entry(dnode, NULL, true);
1069 setting = area_get_mt_setting(area, mtid);
1070 setting->enabled = create;
1071 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 0);
1072 break;
1073 }
1074
1075 return NB_OK;
1076}
1077
1078static int isis_multi_topology_overload_common(enum nb_event event,
1079 const struct lyd_node *dnode,
1080 const char *topology)
1081{
1082 struct isis_area *area;
1083 struct isis_area_mt_setting *setting;
1084 uint16_t mtid = isis_str2mtid(topology);
1085
1086 /* validation is done in isis_multi_topology_common */
1087 if (event != NB_EV_APPLY)
1088 return NB_OK;
1089
1090 area = nb_running_get_entry(dnode, NULL, true);
1091 setting = area_get_mt_setting(area, mtid);
1092 setting->overload = yang_dnode_get_bool(dnode, NULL);
1093 if (setting->enabled)
1094 lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 0);
1095
1096 return NB_OK;
1097}
1098
1099int isis_instance_multi_topology_ipv4_multicast_create(
60ee8be1 1100 struct nb_cb_create_args *args)
2a1c520e 1101{
60ee8be1
RW
1102 return isis_multi_topology_common(args->event, args->dnode,
1103 "ipv4-multicast", true);
2a1c520e
RW
1104}
1105
1106int isis_instance_multi_topology_ipv4_multicast_destroy(
60ee8be1 1107 struct nb_cb_destroy_args *args)
2a1c520e 1108{
60ee8be1
RW
1109 return isis_multi_topology_common(args->event, args->dnode,
1110 "ipv4-multicast", false);
2a1c520e
RW
1111}
1112
1113/*
1114 * XPath: /frr-isisd:isis/instance/multi-topology/ipv4-multicast/overload
1115 */
1116int isis_instance_multi_topology_ipv4_multicast_overload_modify(
60ee8be1 1117 struct nb_cb_modify_args *args)
2a1c520e 1118{
60ee8be1 1119 return isis_multi_topology_overload_common(args->event, args->dnode,
2a1c520e
RW
1120 "ipv4-multicast");
1121}
1122
1123/*
1124 * XPath: /frr-isisd:isis/instance/multi-topology/ipv4-management
1125 */
1126int isis_instance_multi_topology_ipv4_management_create(
60ee8be1 1127 struct nb_cb_create_args *args)
2a1c520e 1128{
60ee8be1
RW
1129 return isis_multi_topology_common(args->event, args->dnode, "ipv4-mgmt",
1130 true);
2a1c520e
RW
1131}
1132
1133int isis_instance_multi_topology_ipv4_management_destroy(
60ee8be1 1134 struct nb_cb_destroy_args *args)
2a1c520e 1135{
60ee8be1
RW
1136 return isis_multi_topology_common(args->event, args->dnode, "ipv4-mgmt",
1137 false);
2a1c520e
RW
1138}
1139
1140/*
1141 * XPath: /frr-isisd:isis/instance/multi-topology/ipv4-management/overload
1142 */
1143int isis_instance_multi_topology_ipv4_management_overload_modify(
60ee8be1 1144 struct nb_cb_modify_args *args)
2a1c520e 1145{
60ee8be1
RW
1146 return isis_multi_topology_overload_common(args->event, args->dnode,
1147 "ipv4-mgmt");
2a1c520e
RW
1148}
1149
1150/*
1151 * XPath: /frr-isisd:isis/instance/multi-topology/ipv6-unicast
1152 */
1153int isis_instance_multi_topology_ipv6_unicast_create(
60ee8be1 1154 struct nb_cb_create_args *args)
2a1c520e 1155{
60ee8be1
RW
1156 return isis_multi_topology_common(args->event, args->dnode,
1157 "ipv6-unicast", true);
2a1c520e
RW
1158}
1159
1160int isis_instance_multi_topology_ipv6_unicast_destroy(
60ee8be1 1161 struct nb_cb_destroy_args *args)
2a1c520e 1162{
60ee8be1
RW
1163 return isis_multi_topology_common(args->event, args->dnode,
1164 "ipv6-unicast", false);
2a1c520e
RW
1165}
1166
1167/*
1168 * XPath: /frr-isisd:isis/instance/multi-topology/ipv6-unicast/overload
1169 */
1170int isis_instance_multi_topology_ipv6_unicast_overload_modify(
60ee8be1 1171 struct nb_cb_modify_args *args)
2a1c520e 1172{
60ee8be1 1173 return isis_multi_topology_overload_common(args->event, args->dnode,
2a1c520e
RW
1174 "ipv6-unicast");
1175}
1176
1177/*
1178 * XPath: /frr-isisd:isis/instance/multi-topology/ipv6-multicast
1179 */
1180int isis_instance_multi_topology_ipv6_multicast_create(
60ee8be1 1181 struct nb_cb_create_args *args)
2a1c520e 1182{
60ee8be1
RW
1183 return isis_multi_topology_common(args->event, args->dnode,
1184 "ipv6-multicast", true);
2a1c520e
RW
1185}
1186
1187int isis_instance_multi_topology_ipv6_multicast_destroy(
60ee8be1 1188 struct nb_cb_destroy_args *args)
2a1c520e 1189{
60ee8be1
RW
1190 return isis_multi_topology_common(args->event, args->dnode,
1191 "ipv6-multicast", false);
2a1c520e
RW
1192}
1193
1194/*
1195 * XPath: /frr-isisd:isis/instance/multi-topology/ipv6-multicast/overload
1196 */
1197int isis_instance_multi_topology_ipv6_multicast_overload_modify(
60ee8be1 1198 struct nb_cb_modify_args *args)
2a1c520e 1199{
60ee8be1 1200 return isis_multi_topology_overload_common(args->event, args->dnode,
2a1c520e
RW
1201 "ipv6-multicast");
1202}
1203
1204/*
1205 * XPath: /frr-isisd:isis/instance/multi-topology/ipv6-management
1206 */
1207int isis_instance_multi_topology_ipv6_management_create(
60ee8be1 1208 struct nb_cb_create_args *args)
2a1c520e 1209{
60ee8be1
RW
1210 return isis_multi_topology_common(args->event, args->dnode, "ipv6-mgmt",
1211 true);
2a1c520e
RW
1212}
1213
1214int isis_instance_multi_topology_ipv6_management_destroy(
60ee8be1 1215 struct nb_cb_destroy_args *args)
2a1c520e 1216{
60ee8be1
RW
1217 return isis_multi_topology_common(args->event, args->dnode, "ipv6-mgmt",
1218 false);
2a1c520e
RW
1219}
1220
1221/*
1222 * XPath: /frr-isisd:isis/instance/multi-topology/ipv6-management/overload
1223 */
1224int isis_instance_multi_topology_ipv6_management_overload_modify(
60ee8be1 1225 struct nb_cb_modify_args *args)
2a1c520e 1226{
60ee8be1
RW
1227 return isis_multi_topology_overload_common(args->event, args->dnode,
1228 "ipv6-mgmt");
2a1c520e
RW
1229}
1230
1231/*
1232 * XPath: /frr-isisd:isis/instance/multi-topology/ipv6-dstsrc
1233 */
1234int isis_instance_multi_topology_ipv6_dstsrc_create(
60ee8be1 1235 struct nb_cb_create_args *args)
2a1c520e 1236{
60ee8be1
RW
1237 return isis_multi_topology_common(args->event, args->dnode,
1238 "ipv6-dstsrc", true);
2a1c520e
RW
1239}
1240
1241int isis_instance_multi_topology_ipv6_dstsrc_destroy(
60ee8be1 1242 struct nb_cb_destroy_args *args)
2a1c520e 1243{
60ee8be1
RW
1244 return isis_multi_topology_common(args->event, args->dnode,
1245 "ipv6-dstsrc", false);
2a1c520e
RW
1246}
1247
1248/*
1249 * XPath: /frr-isisd:isis/instance/multi-topology/ipv6-dstsrc/overload
1250 */
1251int isis_instance_multi_topology_ipv6_dstsrc_overload_modify(
60ee8be1 1252 struct nb_cb_modify_args *args)
2a1c520e 1253{
60ee8be1
RW
1254 return isis_multi_topology_overload_common(args->event, args->dnode,
1255 "ipv6-dstsrc");
2a1c520e
RW
1256}
1257
1258/*
1259 * XPath: /frr-isisd:isis/instance/log-adjacency-changes
1260 */
60ee8be1 1261int isis_instance_log_adjacency_changes_modify(struct nb_cb_modify_args *args)
2a1c520e
RW
1262{
1263 struct isis_area *area;
60ee8be1 1264 bool log = yang_dnode_get_bool(args->dnode, NULL);
2a1c520e 1265
60ee8be1 1266 if (args->event != NB_EV_APPLY)
2a1c520e
RW
1267 return NB_OK;
1268
60ee8be1 1269 area = nb_running_get_entry(args->dnode, NULL, true);
2a1c520e
RW
1270 area->log_adj_changes = log ? 1 : 0;
1271
1272 return NB_OK;
1273}
1274
1275/*
1276 * XPath: /frr-isisd:isis/instance/mpls-te
1277 */
60ee8be1 1278int isis_instance_mpls_te_create(struct nb_cb_create_args *args)
2a1c520e
RW
1279{
1280 struct listnode *node;
1281 struct isis_area *area;
1282 struct isis_circuit *circuit;
1283
60ee8be1 1284 if (args->event != NB_EV_APPLY)
2a1c520e
RW
1285 return NB_OK;
1286
60ee8be1 1287 area = nb_running_get_entry(args->dnode, NULL, true);
2a1c520e
RW
1288 if (area->mta == NULL) {
1289
1290 struct mpls_te_area *new;
1291
1292 zlog_debug("ISIS-TE(%s): Initialize MPLS Traffic Engineering",
1293 area->area_tag);
1294
1295 new = XCALLOC(MTYPE_ISIS_MPLS_TE, sizeof(struct mpls_te_area));
1296
1297 /* Initialize MPLS_TE structure */
1298 new->status = enable;
1299 new->level = 0;
1300 new->inter_as = off;
1301 new->interas_areaid.s_addr = 0;
1302 new->router_id.s_addr = 0;
1303
1304 area->mta = new;
1305 } else {
1306 area->mta->status = enable;
1307 }
1308
1309 /* Update Extended TLVs according to Interface link parameters */
1310 for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit))
1311 isis_link_params_update(circuit, circuit->interface);
1312
1313 /* Reoriginate STD_TE & GMPLS circuits */
1314 lsp_regenerate_schedule(area, area->is_type, 0);
1315
1316 return NB_OK;
1317}
1318
60ee8be1 1319int isis_instance_mpls_te_destroy(struct nb_cb_destroy_args *args)
2a1c520e
RW
1320{
1321 struct listnode *node;
1322 struct isis_area *area;
1323 struct isis_circuit *circuit;
1324
60ee8be1 1325 if (args->event != NB_EV_APPLY)
2a1c520e
RW
1326 return NB_OK;
1327
60ee8be1 1328 area = nb_running_get_entry(args->dnode, NULL, true);
2a1c520e
RW
1329 if (IS_MPLS_TE(area->mta))
1330 area->mta->status = disable;
1331 else
1332 return NB_OK;
1333
1334 /* Flush LSP if circuit engage */
1335 for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) {
1336 if (!IS_EXT_TE(circuit->ext))
1337 continue;
1338
1339 /* disable MPLS_TE Circuit keeping SR one's */
1340 if (IS_SUBTLV(circuit->ext, EXT_ADJ_SID))
1341 circuit->ext->status = EXT_ADJ_SID;
1342 else if (IS_SUBTLV(circuit->ext, EXT_LAN_ADJ_SID))
1343 circuit->ext->status = EXT_LAN_ADJ_SID;
1344 else
1345 circuit->ext->status = 0;
1346 }
1347
1348 /* Reoriginate STD_TE & GMPLS circuits */
1349 lsp_regenerate_schedule(area, area->is_type, 0);
1350
1351 zlog_debug("ISIS-TE(%s): Disabled MPLS Traffic Engineering",
1352 area->area_tag);
1353
1354 return NB_OK;
1355}
1356
1357/*
1358 * XPath: /frr-isisd:isis/instance/mpls-te/router-address
1359 */
60ee8be1 1360int isis_instance_mpls_te_router_address_modify(struct nb_cb_modify_args *args)
2a1c520e
RW
1361{
1362 struct in_addr value;
1363 struct isis_area *area;
1364
60ee8be1 1365 if (args->event != NB_EV_APPLY)
2a1c520e
RW
1366 return NB_OK;
1367
60ee8be1 1368 area = nb_running_get_entry(args->dnode, NULL, true);
2a1c520e
RW
1369 /* only proceed if MPLS-TE is enabled */
1370 if (!IS_MPLS_TE(area->mta))
1371 return NB_OK;
1372
1373 /* Update Area Router ID */
60ee8be1 1374 yang_dnode_get_ipv4(&value, args->dnode, NULL);
2a1c520e
RW
1375 area->mta->router_id.s_addr = value.s_addr;
1376
1377 /* And re-schedule LSP update */
1378 lsp_regenerate_schedule(area, area->is_type, 0);
1379
1380 return NB_OK;
1381}
1382
60ee8be1
RW
1383int isis_instance_mpls_te_router_address_destroy(
1384 struct nb_cb_destroy_args *args)
2a1c520e
RW
1385{
1386 struct isis_area *area;
1387
60ee8be1 1388 if (args->event != NB_EV_APPLY)
2a1c520e
RW
1389 return NB_OK;
1390
60ee8be1 1391 area = nb_running_get_entry(args->dnode, NULL, true);
2a1c520e
RW
1392 /* only proceed if MPLS-TE is enabled */
1393 if (!IS_MPLS_TE(area->mta))
1394 return NB_OK;
1395
1396 /* Reset Area Router ID */
1397 area->mta->router_id.s_addr = INADDR_ANY;
1398
1399 /* And re-schedule LSP update */
1400 lsp_regenerate_schedule(area, area->is_type, 0);
1401
1402 return NB_OK;
1403}
1404
7e405d3b
RW
1405/*
1406 * XPath: /frr-isisd:isis/instance/segment-routing/enabled
1407 */
1408int isis_instance_segment_routing_enabled_modify(enum nb_event event,
1409 const struct lyd_node *dnode,
1410 union nb_resource *resource)
1411{
1412 switch (event) {
1413 case NB_EV_VALIDATE:
1414 case NB_EV_PREPARE:
1415 case NB_EV_ABORT:
1416 case NB_EV_APPLY:
1417 /* TODO: implement me. */
1418 break;
1419 }
1420
1421 return NB_OK;
1422}
1423
1424/*
1425 * XPath: /frr-isisd:isis/instance/segment-routing/srgb/lower-bound
1426 */
1427int isis_instance_segment_routing_srgb_lower_bound_modify(
1428 enum nb_event event, const struct lyd_node *dnode,
1429 union nb_resource *resource)
1430{
1431 switch (event) {
1432 case NB_EV_VALIDATE:
1433 case NB_EV_PREPARE:
1434 case NB_EV_ABORT:
1435 case NB_EV_APPLY:
1436 /* TODO: implement me. */
1437 break;
1438 }
1439
1440 return NB_OK;
1441}
1442
1443/*
1444 * XPath: /frr-isisd:isis/instance/segment-routing/srgb/upper-bound
1445 */
1446int isis_instance_segment_routing_srgb_upper_bound_modify(
1447 enum nb_event event, const struct lyd_node *dnode,
1448 union nb_resource *resource)
1449{
1450 switch (event) {
1451 case NB_EV_VALIDATE:
1452 case NB_EV_PREPARE:
1453 case NB_EV_ABORT:
1454 case NB_EV_APPLY:
1455 /* TODO: implement me. */
1456 break;
1457 }
1458
1459 return NB_OK;
1460}
1461
1462/*
1463 * XPath: /frr-isisd:isis/instance/segment-routing/msd/node-msd
1464 */
1465int isis_instance_segment_routing_msd_node_msd_modify(
1466 enum nb_event event, const struct lyd_node *dnode,
1467 union nb_resource *resource)
1468{
1469 switch (event) {
1470 case NB_EV_VALIDATE:
1471 case NB_EV_PREPARE:
1472 case NB_EV_ABORT:
1473 case NB_EV_APPLY:
1474 /* TODO: implement me. */
1475 break;
1476 }
1477
1478 return NB_OK;
1479}
1480
1481int isis_instance_segment_routing_msd_node_msd_destroy(
1482 enum nb_event event, const struct lyd_node *dnode)
1483{
1484 switch (event) {
1485 case NB_EV_VALIDATE:
1486 case NB_EV_PREPARE:
1487 case NB_EV_ABORT:
1488 case NB_EV_APPLY:
1489 /* TODO: implement me. */
1490 break;
1491 }
1492
1493 return NB_OK;
1494}
1495
1496/*
1497 * XPath: /frr-isisd:isis/instance/segment-routing/prefix-sid-map/prefix-sid
1498 */
1499int isis_instance_segment_routing_prefix_sid_map_prefix_sid_create(
1500 enum nb_event event, const struct lyd_node *dnode,
1501 union nb_resource *resource)
1502{
1503 switch (event) {
1504 case NB_EV_VALIDATE:
1505 case NB_EV_PREPARE:
1506 case NB_EV_ABORT:
1507 case NB_EV_APPLY:
1508 /* TODO: implement me. */
1509 break;
1510 }
1511
1512 return NB_OK;
1513}
1514
1515int isis_instance_segment_routing_prefix_sid_map_prefix_sid_destroy(
1516 enum nb_event event, const struct lyd_node *dnode)
1517{
1518 switch (event) {
1519 case NB_EV_VALIDATE:
1520 case NB_EV_PREPARE:
1521 case NB_EV_ABORT:
1522 case NB_EV_APPLY:
1523 /* TODO: implement me. */
1524 break;
1525 }
1526
1527 return NB_OK;
1528}
1529
1530/*
1531 * XPath:
1532 * /frr-isisd:isis/instance/segment-routing/prefix-sid-map/prefix-sid/sid-value-type
1533 */
1534int isis_instance_segment_routing_prefix_sid_map_prefix_sid_sid_value_type_modify(
1535 enum nb_event event, const struct lyd_node *dnode,
1536 union nb_resource *resource)
1537{
1538 switch (event) {
1539 case NB_EV_VALIDATE:
1540 case NB_EV_PREPARE:
1541 case NB_EV_ABORT:
1542 case NB_EV_APPLY:
1543 /* TODO: implement me. */
1544 break;
1545 }
1546
1547 return NB_OK;
1548}
1549
1550/*
1551 * XPath:
1552 * /frr-isisd:isis/instance/segment-routing/prefix-sid-map/prefix-sid/sid-value
1553 */
1554int isis_instance_segment_routing_prefix_sid_map_prefix_sid_sid_value_modify(
1555 enum nb_event event, const struct lyd_node *dnode,
1556 union nb_resource *resource)
1557{
1558 switch (event) {
1559 case NB_EV_VALIDATE:
1560 case NB_EV_PREPARE:
1561 case NB_EV_ABORT:
1562 case NB_EV_APPLY:
1563 /* TODO: implement me. */
1564 break;
1565 }
1566
1567 return NB_OK;
1568}
1569
1570/*
1571 * XPath:
1572 * /frr-isisd:isis/instance/segment-routing/prefix-sid-map/prefix-sid/last-hop-behavior
1573 */
1574int isis_instance_segment_routing_prefix_sid_map_prefix_sid_last_hop_behavior_modify(
1575 enum nb_event event, const struct lyd_node *dnode,
1576 union nb_resource *resource)
1577{
1578 switch (event) {
1579 case NB_EV_VALIDATE:
1580 case NB_EV_PREPARE:
1581 case NB_EV_ABORT:
1582 case NB_EV_APPLY:
1583 /* TODO: implement me. */
1584 break;
1585 }
1586
1587 return NB_OK;
1588}
1589
2a1c520e
RW
1590/*
1591 * XPath: /frr-interface:lib/interface/frr-isisd:isis
1592 */
60ee8be1 1593int lib_interface_isis_create(struct nb_cb_create_args *args)
2a1c520e
RW
1594{
1595 struct isis_area *area;
1596 struct interface *ifp;
1597 struct isis_circuit *circuit;
60ee8be1 1598 const char *area_tag = yang_dnode_get_string(args->dnode, "./area-tag");
2a1c520e
RW
1599 uint32_t min_mtu, actual_mtu;
1600
60ee8be1 1601 switch (args->event) {
2a1c520e
RW
1602 case NB_EV_PREPARE:
1603 case NB_EV_ABORT:
1604 break;
1605 case NB_EV_VALIDATE:
1606 /* check if interface mtu is sufficient. If the area has not
1607 * been created yet, assume default MTU for the area
1608 */
60ee8be1 1609 ifp = nb_running_get_entry(args->dnode, NULL, false);
2a1c520e
RW
1610 /* zebra might not know yet about the MTU - nothing we can do */
1611 if (!ifp || ifp->mtu == 0)
1612 break;
1613 actual_mtu =
1614 if_is_broadcast(ifp) ? ifp->mtu - LLC_LEN : ifp->mtu;
1615 area = isis_area_lookup(area_tag);
1616 if (area)
1617 min_mtu = area->lsp_mtu;
1618 else
1619#ifndef FABRICD
1620 min_mtu = yang_get_default_uint16(
1621 "/frr-isisd:isis/instance/lsp/mtu");
1622#else
1623 min_mtu = DEFAULT_LSP_MTU;
1624#endif /* ifndef FABRICD */
1625 if (actual_mtu < min_mtu) {
1626 flog_warn(EC_LIB_NB_CB_CONFIG_VALIDATE,
1627 "Interface %s has MTU %" PRIu32
1628 ", minimum MTU for the area is %" PRIu32 "",
1629 ifp->name, actual_mtu, min_mtu);
1630 return NB_ERR_VALIDATION;
1631 }
1632 break;
1633 case NB_EV_APPLY:
1634 area = isis_area_lookup(area_tag);
1635 /* The area should have already be created. We are
1636 * setting the priority of the global isis area creation
1637 * slightly lower, so it should be executed first, but I
1638 * cannot rely on that so here I have to check.
1639 */
1640 if (!area) {
1641 flog_err(
1642 EC_LIB_NB_CB_CONFIG_APPLY,
1643 "%s: attempt to create circuit for area %s before the area has been created",
1644 __func__, area_tag);
1645 abort();
1646 }
1647
60ee8be1 1648 ifp = nb_running_get_entry(args->dnode, NULL, true);
2a1c520e
RW
1649 circuit = isis_circuit_create(area, ifp);
1650 assert(circuit
1651 && (circuit->state == C_STATE_CONF
1652 || circuit->state == C_STATE_UP));
60ee8be1 1653 nb_running_set_entry(args->dnode, circuit);
2a1c520e
RW
1654 break;
1655 }
1656
1657 return NB_OK;
1658}
1659
60ee8be1 1660int lib_interface_isis_destroy(struct nb_cb_destroy_args *args)
2a1c520e
RW
1661{
1662 struct isis_circuit *circuit;
1663
60ee8be1 1664 if (args->event != NB_EV_APPLY)
2a1c520e
RW
1665 return NB_OK;
1666
60ee8be1 1667 circuit = nb_running_unset_entry(args->dnode);
2a1c520e
RW
1668 if (!circuit)
1669 return NB_ERR_INCONSISTENCY;
2a1c520e 1670
d38a3cb2
EDP
1671 /* disable both AFs for this circuit. this will also update the
1672 * CSM state by sending an ISIS_DISABLED signal. If there is no
1673 * area associated to the circuit there is nothing to do
1674 */
1675 if (circuit->area)
1676 isis_circuit_af_set(circuit, false, false);
2a1c520e
RW
1677 return NB_OK;
1678}
1679
1680/*
1681 * XPath: /frr-interface:lib/interface/frr-isisd:isis/area-tag
1682 */
60ee8be1 1683int lib_interface_isis_area_tag_modify(struct nb_cb_modify_args *args)
2a1c520e
RW
1684{
1685 struct isis_circuit *circuit;
1686 struct interface *ifp;
1687 struct vrf *vrf;
1688 const char *area_tag, *ifname, *vrfname;
1689
60ee8be1 1690 if (args->event == NB_EV_VALIDATE) {
2a1c520e
RW
1691 /* libyang doesn't like relative paths across module boundaries
1692 */
60ee8be1
RW
1693 ifname = yang_dnode_get_string(args->dnode->parent->parent,
1694 "./name");
1695 vrfname = yang_dnode_get_string(args->dnode->parent->parent,
1696 "./vrf");
2a1c520e
RW
1697 vrf = vrf_lookup_by_name(vrfname);
1698 assert(vrf);
1699 ifp = if_lookup_by_name(ifname, vrf->vrf_id);
1700 if (!ifp)
1701 return NB_OK;
1702 circuit = circuit_lookup_by_ifp(ifp, isis->init_circ_list);
60ee8be1 1703 area_tag = yang_dnode_get_string(args->dnode, NULL);
2a1c520e
RW
1704 if (circuit && circuit->area && circuit->area->area_tag
1705 && strcmp(circuit->area->area_tag, area_tag)) {
1706 flog_warn(EC_LIB_NB_CB_CONFIG_VALIDATE,
1707 "ISIS circuit is already defined on %s",
1708 circuit->area->area_tag);
1709 return NB_ERR_VALIDATION;
1710 }
1711 }
1712
1713 return NB_OK;
1714}
1715
1716/*
1717 * XPath: /frr-interface:lib/interface/frr-isisd:isis/circuit-type
1718 */
60ee8be1 1719int lib_interface_isis_circuit_type_modify(struct nb_cb_modify_args *args)
2a1c520e 1720{
60ee8be1 1721 int circ_type = yang_dnode_get_enum(args->dnode, NULL);
2a1c520e
RW
1722 struct isis_circuit *circuit;
1723 struct interface *ifp;
1724 struct vrf *vrf;
1725 const char *ifname, *vrfname;
1726
60ee8be1 1727 switch (args->event) {
2a1c520e
RW
1728 case NB_EV_VALIDATE:
1729 /* libyang doesn't like relative paths across module boundaries
1730 */
60ee8be1
RW
1731 ifname = yang_dnode_get_string(args->dnode->parent->parent,
1732 "./name");
1733 vrfname = yang_dnode_get_string(args->dnode->parent->parent,
1734 "./vrf");
2a1c520e
RW
1735 vrf = vrf_lookup_by_name(vrfname);
1736 assert(vrf);
1737 ifp = if_lookup_by_name(ifname, vrf->vrf_id);
1738 if (!ifp)
1739 break;
1740 circuit = circuit_lookup_by_ifp(ifp, isis->init_circ_list);
1741 if (circuit && circuit->state == C_STATE_UP
1742 && circuit->area->is_type != IS_LEVEL_1_AND_2
1743 && circuit->area->is_type != circ_type) {
1744 flog_warn(EC_LIB_NB_CB_CONFIG_VALIDATE,
1745 "Invalid circuit level for area %s",
1746 circuit->area->area_tag);
1747 return NB_ERR_VALIDATION;
1748 }
1749 break;
1750 case NB_EV_PREPARE:
1751 case NB_EV_ABORT:
1752 break;
1753 case NB_EV_APPLY:
60ee8be1 1754 circuit = nb_running_get_entry(args->dnode, NULL, true);
2a1c520e
RW
1755 isis_circuit_is_type_set(circuit, circ_type);
1756 break;
1757 }
1758
1759 return NB_OK;
1760}
1761
1762/*
1763 * XPath: /frr-interface:lib/interface/frr-isisd:isis/ipv4-routing
1764 */
60ee8be1 1765int lib_interface_isis_ipv4_routing_modify(struct nb_cb_modify_args *args)
2a1c520e
RW
1766{
1767 bool ipv4, ipv6;
1768 struct isis_circuit *circuit;
1769
60ee8be1 1770 if (args->event != NB_EV_APPLY)
2a1c520e
RW
1771 return NB_OK;
1772
60ee8be1
RW
1773 circuit = nb_running_get_entry(args->dnode, NULL, true);
1774 ipv4 = yang_dnode_get_bool(args->dnode, NULL);
1775 ipv6 = yang_dnode_get_bool(args->dnode, "../ipv6-routing");
2a1c520e
RW
1776 isis_circuit_af_set(circuit, ipv4, ipv6);
1777
1778 return NB_OK;
1779}
1780
1781/*
1782 * XPath: /frr-interface:lib/interface/frr-isisd:isis/ipv6-routing
1783 */
60ee8be1 1784int lib_interface_isis_ipv6_routing_modify(struct nb_cb_modify_args *args)
2a1c520e
RW
1785{
1786 bool ipv4, ipv6;
1787 struct isis_circuit *circuit;
1788
60ee8be1 1789 if (args->event != NB_EV_APPLY)
2a1c520e
RW
1790 return NB_OK;
1791
60ee8be1
RW
1792 circuit = nb_running_get_entry(args->dnode, NULL, true);
1793 ipv4 = yang_dnode_exists(args->dnode, "../ipv4-routing");
1794 ipv6 = yang_dnode_get_bool(args->dnode, NULL);
2a1c520e
RW
1795 isis_circuit_af_set(circuit, ipv4, ipv6);
1796
1797 return NB_OK;
1798}
1799
1800/*
1801 * XPath: /frr-interface:lib/interface/frr-isisd:isis/bfd-monitoring
1802 */
60ee8be1 1803int lib_interface_isis_bfd_monitoring_modify(struct nb_cb_modify_args *args)
2a1c520e
RW
1804{
1805 struct isis_circuit *circuit;
1806 bool bfd_monitoring;
1807
60ee8be1 1808 if (args->event != NB_EV_APPLY)
2a1c520e
RW
1809 return NB_OK;
1810
60ee8be1
RW
1811 circuit = nb_running_get_entry(args->dnode, NULL, true);
1812 bfd_monitoring = yang_dnode_get_bool(args->dnode, NULL);
2a1c520e
RW
1813
1814 if (bfd_monitoring) {
1815 isis_bfd_circuit_param_set(circuit, BFD_DEF_MIN_RX,
1816 BFD_DEF_MIN_TX, BFD_DEF_DETECT_MULT,
1817 true);
1818 } else {
1819 isis_bfd_circuit_cmd(circuit, ZEBRA_BFD_DEST_DEREGISTER);
1820 bfd_info_free(&circuit->bfd_info);
1821 }
1822
1823 return NB_OK;
1824}
1825
1826/*
1827 * XPath: /frr-interface:lib/interface/frr-isisd:isis/csnp-interval/level-1
1828 */
1829int lib_interface_isis_csnp_interval_level_1_modify(
60ee8be1 1830 struct nb_cb_modify_args *args)
2a1c520e
RW
1831{
1832 struct isis_circuit *circuit;
1833
60ee8be1 1834 if (args->event != NB_EV_APPLY)
2a1c520e
RW
1835 return NB_OK;
1836
60ee8be1
RW
1837 circuit = nb_running_get_entry(args->dnode, NULL, true);
1838 circuit->csnp_interval[0] = yang_dnode_get_uint16(args->dnode, NULL);
2a1c520e
RW
1839
1840 return NB_OK;
1841}
1842
1843/*
1844 * XPath: /frr-interface:lib/interface/frr-isisd:isis/csnp-interval/level-2
1845 */
1846int lib_interface_isis_csnp_interval_level_2_modify(
60ee8be1 1847 struct nb_cb_modify_args *args)
2a1c520e
RW
1848{
1849 struct isis_circuit *circuit;
1850
60ee8be1 1851 if (args->event != NB_EV_APPLY)
2a1c520e
RW
1852 return NB_OK;
1853
60ee8be1
RW
1854 circuit = nb_running_get_entry(args->dnode, NULL, true);
1855 circuit->csnp_interval[1] = yang_dnode_get_uint16(args->dnode, NULL);
2a1c520e
RW
1856
1857 return NB_OK;
1858}
1859
1860/*
1861 * XPath: /frr-interface:lib/interface/frr-isisd:isis/psnp-interval/level-1
1862 */
1863int lib_interface_isis_psnp_interval_level_1_modify(
60ee8be1 1864 struct nb_cb_modify_args *args)
2a1c520e
RW
1865{
1866 struct isis_circuit *circuit;
1867
60ee8be1 1868 if (args->event != NB_EV_APPLY)
2a1c520e
RW
1869 return NB_OK;
1870
60ee8be1
RW
1871 circuit = nb_running_get_entry(args->dnode, NULL, true);
1872 circuit->psnp_interval[0] = yang_dnode_get_uint16(args->dnode, NULL);
2a1c520e
RW
1873
1874 return NB_OK;
1875}
1876
1877/*
1878 * XPath: /frr-interface:lib/interface/frr-isisd:isis/psnp-interval/level-2
1879 */
1880int lib_interface_isis_psnp_interval_level_2_modify(
60ee8be1 1881 struct nb_cb_modify_args *args)
2a1c520e
RW
1882{
1883 struct isis_circuit *circuit;
1884
60ee8be1 1885 if (args->event != NB_EV_APPLY)
2a1c520e
RW
1886 return NB_OK;
1887
60ee8be1
RW
1888 circuit = nb_running_get_entry(args->dnode, NULL, true);
1889 circuit->psnp_interval[1] = yang_dnode_get_uint16(args->dnode, NULL);
2a1c520e
RW
1890
1891 return NB_OK;
1892}
1893
1894/*
1895 * XPath: /frr-interface:lib/interface/frr-isisd:isis/hello/padding
1896 */
60ee8be1 1897int lib_interface_isis_hello_padding_modify(struct nb_cb_modify_args *args)
2a1c520e
RW
1898{
1899 struct isis_circuit *circuit;
1900
60ee8be1 1901 if (args->event != NB_EV_APPLY)
2a1c520e
RW
1902 return NB_OK;
1903
60ee8be1
RW
1904 circuit = nb_running_get_entry(args->dnode, NULL, true);
1905 circuit->pad_hellos = yang_dnode_get_bool(args->dnode, NULL);
2a1c520e
RW
1906
1907 return NB_OK;
1908}
1909
1910/*
1911 * XPath: /frr-interface:lib/interface/frr-isisd:isis/hello/interval/level-1
1912 */
1913int lib_interface_isis_hello_interval_level_1_modify(
60ee8be1 1914 struct nb_cb_modify_args *args)
2a1c520e
RW
1915{
1916 struct isis_circuit *circuit;
1917 uint32_t interval;
1918
60ee8be1 1919 if (args->event != NB_EV_APPLY)
2a1c520e
RW
1920 return NB_OK;
1921
60ee8be1
RW
1922 circuit = nb_running_get_entry(args->dnode, NULL, true);
1923 interval = yang_dnode_get_uint32(args->dnode, NULL);
2a1c520e
RW
1924 circuit->hello_interval[0] = interval;
1925
1926 return NB_OK;
1927}
1928
1929/*
1930 * XPath: /frr-interface:lib/interface/frr-isisd:isis/hello/interval/level-2
1931 */
1932int lib_interface_isis_hello_interval_level_2_modify(
60ee8be1 1933 struct nb_cb_modify_args *args)
2a1c520e
RW
1934{
1935 struct isis_circuit *circuit;
1936 uint32_t interval;
1937
60ee8be1 1938 if (args->event != NB_EV_APPLY)
2a1c520e
RW
1939 return NB_OK;
1940
60ee8be1
RW
1941 circuit = nb_running_get_entry(args->dnode, NULL, true);
1942 interval = yang_dnode_get_uint32(args->dnode, NULL);
2a1c520e
RW
1943 circuit->hello_interval[1] = interval;
1944
1945 return NB_OK;
1946}
1947
1948/*
1949 * XPath: /frr-interface:lib/interface/frr-isisd:isis/hello/multiplier/level-1
1950 */
1951int lib_interface_isis_hello_multiplier_level_1_modify(
60ee8be1 1952 struct nb_cb_modify_args *args)
2a1c520e
RW
1953{
1954 struct isis_circuit *circuit;
1955 uint16_t multi;
1956
60ee8be1 1957 if (args->event != NB_EV_APPLY)
2a1c520e
RW
1958 return NB_OK;
1959
60ee8be1
RW
1960 circuit = nb_running_get_entry(args->dnode, NULL, true);
1961 multi = yang_dnode_get_uint16(args->dnode, NULL);
2a1c520e
RW
1962 circuit->hello_multiplier[0] = multi;
1963
1964 return NB_OK;
1965}
1966
1967/*
1968 * XPath: /frr-interface:lib/interface/frr-isisd:isis/hello/multiplier/level-2
1969 */
1970int lib_interface_isis_hello_multiplier_level_2_modify(
60ee8be1 1971 struct nb_cb_modify_args *args)
2a1c520e
RW
1972{
1973 struct isis_circuit *circuit;
1974 uint16_t multi;
1975
60ee8be1 1976 if (args->event != NB_EV_APPLY)
2a1c520e
RW
1977 return NB_OK;
1978
60ee8be1
RW
1979 circuit = nb_running_get_entry(args->dnode, NULL, true);
1980 multi = yang_dnode_get_uint16(args->dnode, NULL);
2a1c520e
RW
1981 circuit->hello_multiplier[1] = multi;
1982
1983 return NB_OK;
1984}
1985
1986/*
1987 * XPath: /frr-interface:lib/interface/frr-isisd:isis/metric/level-1
1988 */
60ee8be1 1989int lib_interface_isis_metric_level_1_modify(struct nb_cb_modify_args *args)
2a1c520e
RW
1990{
1991 struct isis_circuit *circuit;
1992 unsigned int met;
1993
60ee8be1 1994 if (args->event != NB_EV_APPLY)
2a1c520e
RW
1995 return NB_OK;
1996
60ee8be1
RW
1997 circuit = nb_running_get_entry(args->dnode, NULL, true);
1998 met = yang_dnode_get_uint32(args->dnode, NULL);
2a1c520e
RW
1999 isis_circuit_metric_set(circuit, IS_LEVEL_1, met);
2000
2001 return NB_OK;
2002}
2003
2004/*
2005 * XPath: /frr-interface:lib/interface/frr-isisd:isis/metric/level-2
2006 */
60ee8be1 2007int lib_interface_isis_metric_level_2_modify(struct nb_cb_modify_args *args)
2a1c520e
RW
2008{
2009 struct isis_circuit *circuit;
2010 unsigned int met;
2011
60ee8be1 2012 if (args->event != NB_EV_APPLY)
2a1c520e
RW
2013 return NB_OK;
2014
60ee8be1
RW
2015 circuit = nb_running_get_entry(args->dnode, NULL, true);
2016 met = yang_dnode_get_uint32(args->dnode, NULL);
2a1c520e
RW
2017 isis_circuit_metric_set(circuit, IS_LEVEL_2, met);
2018
2019 return NB_OK;
2020}
2021
2022/*
2023 * XPath: /frr-interface:lib/interface/frr-isisd:isis/priority/level-1
2024 */
60ee8be1 2025int lib_interface_isis_priority_level_1_modify(struct nb_cb_modify_args *args)
2a1c520e
RW
2026{
2027 struct isis_circuit *circuit;
2028
60ee8be1 2029 if (args->event != NB_EV_APPLY)
2a1c520e
RW
2030 return NB_OK;
2031
60ee8be1
RW
2032 circuit = nb_running_get_entry(args->dnode, NULL, true);
2033 circuit->priority[0] = yang_dnode_get_uint8(args->dnode, NULL);
2a1c520e
RW
2034
2035 return NB_OK;
2036}
2037
2038/*
2039 * XPath: /frr-interface:lib/interface/frr-isisd:isis/priority/level-2
2040 */
60ee8be1 2041int lib_interface_isis_priority_level_2_modify(struct nb_cb_modify_args *args)
2a1c520e
RW
2042{
2043 struct isis_circuit *circuit;
2044
60ee8be1 2045 if (args->event != NB_EV_APPLY)
2a1c520e
RW
2046 return NB_OK;
2047
60ee8be1
RW
2048 circuit = nb_running_get_entry(args->dnode, NULL, true);
2049 circuit->priority[1] = yang_dnode_get_uint8(args->dnode, NULL);
2a1c520e
RW
2050
2051 return NB_OK;
2052}
2053
2054/*
2055 * XPath: /frr-interface:lib/interface/frr-isisd:isis/network-type
2056 */
60ee8be1 2057int lib_interface_isis_network_type_modify(struct nb_cb_modify_args *args)
2a1c520e
RW
2058{
2059 struct isis_circuit *circuit;
60ee8be1 2060 int net_type = yang_dnode_get_enum(args->dnode, NULL);
2a1c520e 2061
60ee8be1 2062 switch (args->event) {
2a1c520e 2063 case NB_EV_VALIDATE:
60ee8be1 2064 circuit = nb_running_get_entry(args->dnode, NULL, false);
2a1c520e
RW
2065 if (!circuit)
2066 break;
2067 if (circuit->circ_type == CIRCUIT_T_LOOPBACK) {
2068 flog_warn(
2069 EC_LIB_NB_CB_CONFIG_VALIDATE,
2070 "Cannot change network type on loopback interface");
2071 return NB_ERR_VALIDATION;
2072 }
2073 if (net_type == CIRCUIT_T_BROADCAST
2074 && circuit->state == C_STATE_UP
2075 && !if_is_broadcast(circuit->interface)) {
2076 flog_warn(
2077 EC_LIB_NB_CB_CONFIG_VALIDATE,
2078 "Cannot configure non-broadcast interface for broadcast operation");
2079 return NB_ERR_VALIDATION;
2080 }
2081 break;
2082 case NB_EV_PREPARE:
2083 case NB_EV_ABORT:
2084 break;
2085 case NB_EV_APPLY:
60ee8be1 2086 circuit = nb_running_get_entry(args->dnode, NULL, true);
2a1c520e
RW
2087 isis_circuit_circ_type_set(circuit, net_type);
2088 break;
2089 }
2090
2091 return NB_OK;
2092}
2093
2094/*
2095 * XPath: /frr-interface:lib/interface/frr-isisd:isis/passive
2096 */
60ee8be1 2097int lib_interface_isis_passive_modify(struct nb_cb_modify_args *args)
2a1c520e
RW
2098{
2099 struct isis_circuit *circuit;
2100 struct isis_area *area;
2101 struct interface *ifp;
60ee8be1 2102 bool passive = yang_dnode_get_bool(args->dnode, NULL);
2a1c520e
RW
2103
2104 /* validation only applies if we are setting passive to false */
60ee8be1
RW
2105 if (!passive && args->event == NB_EV_VALIDATE) {
2106 circuit = nb_running_get_entry(args->dnode, NULL, false);
2a1c520e
RW
2107 if (!circuit)
2108 return NB_OK;
2109 ifp = circuit->interface;
2110 if (!ifp)
2111 return NB_OK;
2112 if (if_is_loopback(ifp)) {
2113 flog_warn(EC_LIB_NB_CB_CONFIG_VALIDATE,
2114 "Loopback is always passive");
2115 return NB_ERR_VALIDATION;
2116 }
2117 }
2118
60ee8be1 2119 if (args->event != NB_EV_APPLY)
2a1c520e
RW
2120 return NB_OK;
2121
60ee8be1 2122 circuit = nb_running_get_entry(args->dnode, NULL, true);
2a1c520e
RW
2123 if (circuit->state != C_STATE_UP) {
2124 circuit->is_passive = passive;
2125 } else {
2126 area = circuit->area;
2127 isis_csm_state_change(ISIS_DISABLE, circuit, area);
2128 circuit->is_passive = passive;
2129 isis_csm_state_change(ISIS_ENABLE, circuit, area);
2130 }
2131
2132 return NB_OK;
2133}
2134
2135/*
2136 * XPath: /frr-interface:lib/interface/frr-isisd:isis/password
2137 */
60ee8be1 2138int lib_interface_isis_password_create(struct nb_cb_create_args *args)
2a1c520e
RW
2139{
2140 return NB_OK;
2141}
2142
60ee8be1 2143int lib_interface_isis_password_destroy(struct nb_cb_destroy_args *args)
2a1c520e
RW
2144{
2145 struct isis_circuit *circuit;
2146
60ee8be1 2147 if (args->event != NB_EV_APPLY)
2a1c520e
RW
2148 return NB_OK;
2149
60ee8be1 2150 circuit = nb_running_get_entry(args->dnode, NULL, true);
2a1c520e
RW
2151 isis_circuit_passwd_unset(circuit);
2152
2153 return NB_OK;
2154}
2155
2156/*
2157 * XPath: /frr-interface:lib/interface/frr-isisd:isis/password/password
2158 */
60ee8be1 2159int lib_interface_isis_password_password_modify(struct nb_cb_modify_args *args)
2a1c520e
RW
2160{
2161 struct isis_circuit *circuit;
2162 const char *password;
2163
60ee8be1 2164 if (args->event != NB_EV_APPLY)
2a1c520e
RW
2165 return NB_OK;
2166
60ee8be1
RW
2167 password = yang_dnode_get_string(args->dnode, NULL);
2168 circuit = nb_running_get_entry(args->dnode, NULL, true);
2a1c520e
RW
2169
2170 isis_circuit_passwd_set(circuit, circuit->passwd.type, password);
2171
2172 return NB_OK;
2173}
2174
2175/*
2176 * XPath: /frr-interface:lib/interface/frr-isisd:isis/password/password-type
2177 */
2178int lib_interface_isis_password_password_type_modify(
60ee8be1 2179 struct nb_cb_modify_args *args)
2a1c520e
RW
2180{
2181 struct isis_circuit *circuit;
2182 uint8_t pass_type;
2183
60ee8be1 2184 if (args->event != NB_EV_APPLY)
2a1c520e
RW
2185 return NB_OK;
2186
60ee8be1
RW
2187 pass_type = yang_dnode_get_enum(args->dnode, NULL);
2188 circuit = nb_running_get_entry(args->dnode, NULL, true);
2a1c520e
RW
2189 circuit->passwd.type = pass_type;
2190
2191 return NB_OK;
2192}
2193
2194/*
2195 * XPath:
2196 * /frr-interface:lib/interface/frr-isisd:isis/disable-three-way-handshake
2197 */
2198int lib_interface_isis_disable_three_way_handshake_modify(
60ee8be1 2199 struct nb_cb_modify_args *args)
2a1c520e
RW
2200{
2201 struct isis_circuit *circuit;
2202
60ee8be1 2203 if (args->event != NB_EV_APPLY)
2a1c520e
RW
2204 return NB_OK;
2205
60ee8be1
RW
2206 circuit = nb_running_get_entry(args->dnode, NULL, true);
2207 circuit->disable_threeway_adj = yang_dnode_get_bool(args->dnode, NULL);
2a1c520e
RW
2208
2209 return NB_OK;
2210}
2211
2212/*
2213 * XPath:
2214 * /frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv4-unicast
2215 */
2216static int lib_interface_isis_multi_topology_common(
2217 enum nb_event event, const struct lyd_node *dnode, uint16_t mtid)
2218{
2219 struct isis_circuit *circuit;
2220 bool value;
2221
2222 switch (event) {
2223 case NB_EV_VALIDATE:
2224 circuit = nb_running_get_entry(dnode, NULL, false);
2225 if (circuit && circuit->area && circuit->area->oldmetric) {
2226 flog_warn(
2227 EC_LIB_NB_CB_CONFIG_VALIDATE,
2228 "Multi topology IS-IS can only be used with wide metrics");
2229 return NB_ERR_VALIDATION;
2230 }
2231 break;
2232 case NB_EV_PREPARE:
2233 case NB_EV_ABORT:
2234 break;
2235 case NB_EV_APPLY:
2236 circuit = nb_running_get_entry(dnode, NULL, true);
2237 value = yang_dnode_get_bool(dnode, NULL);
2238 isis_circuit_mt_enabled_set(circuit, mtid, value);
2239 break;
2240 }
2241
2242 return NB_OK;
2243}
2244
2245int lib_interface_isis_multi_topology_ipv4_unicast_modify(
60ee8be1 2246 struct nb_cb_modify_args *args)
2a1c520e 2247{
60ee8be1
RW
2248 return lib_interface_isis_multi_topology_common(
2249 args->event, args->dnode, ISIS_MT_IPV4_UNICAST);
2a1c520e
RW
2250}
2251
2252/*
2253 * XPath:
2254 * /frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv4-multicast
2255 */
2256int lib_interface_isis_multi_topology_ipv4_multicast_modify(
60ee8be1 2257 struct nb_cb_modify_args *args)
2a1c520e 2258{
60ee8be1
RW
2259 return lib_interface_isis_multi_topology_common(
2260 args->event, args->dnode, ISIS_MT_IPV4_MULTICAST);
2a1c520e
RW
2261}
2262
2263/*
2264 * XPath:
2265 * /frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv4-management
2266 */
2267int lib_interface_isis_multi_topology_ipv4_management_modify(
60ee8be1 2268 struct nb_cb_modify_args *args)
2a1c520e 2269{
60ee8be1
RW
2270 return lib_interface_isis_multi_topology_common(
2271 args->event, args->dnode, ISIS_MT_IPV4_MGMT);
2a1c520e
RW
2272}
2273
2274/*
2275 * XPath:
2276 * /frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv6-unicast
2277 */
2278int lib_interface_isis_multi_topology_ipv6_unicast_modify(
60ee8be1 2279 struct nb_cb_modify_args *args)
2a1c520e 2280{
60ee8be1
RW
2281 return lib_interface_isis_multi_topology_common(
2282 args->event, args->dnode, ISIS_MT_IPV6_UNICAST);
2a1c520e
RW
2283}
2284
2285/*
2286 * XPath:
2287 * /frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv6-multicast
2288 */
2289int lib_interface_isis_multi_topology_ipv6_multicast_modify(
60ee8be1 2290 struct nb_cb_modify_args *args)
2a1c520e 2291{
60ee8be1
RW
2292 return lib_interface_isis_multi_topology_common(
2293 args->event, args->dnode, ISIS_MT_IPV6_MULTICAST);
2a1c520e
RW
2294}
2295
2296/*
2297 * XPath:
2298 * /frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv6-management
2299 */
2300int lib_interface_isis_multi_topology_ipv6_management_modify(
60ee8be1 2301 struct nb_cb_modify_args *args)
2a1c520e 2302{
60ee8be1
RW
2303 return lib_interface_isis_multi_topology_common(
2304 args->event, args->dnode, ISIS_MT_IPV6_MGMT);
2a1c520e
RW
2305}
2306
2307/*
2308 * XPath: /frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv6-dstsrc
2309 */
2310int lib_interface_isis_multi_topology_ipv6_dstsrc_modify(
60ee8be1 2311 struct nb_cb_modify_args *args)
2a1c520e 2312{
60ee8be1
RW
2313 return lib_interface_isis_multi_topology_common(
2314 args->event, args->dnode, ISIS_MT_IPV6_DSTSRC);
2a1c520e 2315}