]>
Commit | Line | Data |
---|---|---|
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 | 52 | int 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 | 72 | int 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 | 88 | int 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 | 106 | int 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 | 188 | int 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 | 229 | int 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 | 245 | int 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 | 263 | int 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 | 281 | int 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 | 302 | int 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 | 318 | int 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 | */ |
359 | int 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 | */ |
378 | int 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 | */ |
397 | int 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 | */ |
416 | int 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 | */ |
435 | int 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 | */ |
454 | int 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 | 473 | void 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 | 500 | int 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 |
506 | int 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 | */ | |
526 | int 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 | */ | |
536 | int 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 | */ | |
546 | int 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 | */ | |
556 | int 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 | */ | |
566 | int 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 | */ | |
576 | int 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 | */ | |
593 | int 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 | 610 | void 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 | 630 | int 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 | 636 | int 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 | 652 | int 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 | */ | |
661 | int 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 | */ | |
671 | int 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 | 681 | void 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 | 701 | int 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 | 707 | int 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 |
723 | int 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 | */ | |
733 | int 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 | */ | |
743 | int 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 | */ | |
753 | void 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 | 778 | void 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 | 783 | void 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 | ||
788 | int 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 | ||
795 | int 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 | */ | |
814 | int 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 | */ | |
824 | int 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 | ||
831 | int 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 | */ | |
841 | int 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 | */ | |
851 | int 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 | ||
858 | int 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 | */ | |
877 | int 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 | */ | |
887 | int 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 | ||
894 | int 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 | */ | |
904 | int 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 | */ | |
914 | void 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 | 934 | void 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 | 939 | void 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 | 944 | int 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 | 950 | int 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 | */ | |
969 | int 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 | ||
976 | int 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 |
986 | int 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 | 996 | int 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 | 1002 | int 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 | */ | |
1021 | int 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 | ||
1028 | int 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 |
1038 | int 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 | */ | |
1048 | static 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 | ||
1078 | static 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 | ||
1099 | int 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 | ||
1106 | int 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 | */ | |
1116 | int 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 | */ | |
1126 | int 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 | ||
1133 | int 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 | */ | |
1143 | int 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 | */ | |
1153 | int 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 | ||
1160 | int 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 | */ | |
1170 | int 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 | */ | |
1180 | int 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 | ||
1187 | int 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 | */ | |
1197 | int 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 | */ | |
1207 | int 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 | ||
1214 | int 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 | */ | |
1224 | int 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 | */ | |
1234 | int 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 | ||
1241 | int 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 | */ | |
1251 | int 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 | 1261 | int 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 | 1278 | int 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 | 1319 | int 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 | 1360 | int 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 |
1383 | int 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 | */ | |
26f6acaf RW |
1408 | int isis_instance_segment_routing_enabled_modify( |
1409 | struct nb_cb_modify_args *args) | |
7e405d3b | 1410 | { |
26f6acaf RW |
1411 | struct isis_area *area; |
1412 | ||
1413 | if (args->event != NB_EV_APPLY) | |
1414 | return NB_OK; | |
1415 | ||
1416 | area = nb_running_get_entry(args->dnode, NULL, true); | |
1417 | area->srdb.config.enabled = yang_dnode_get_bool(args->dnode, NULL); | |
1418 | ||
1419 | if (area->srdb.config.enabled) { | |
1420 | if (IS_DEBUG_ISIS(DEBUG_EVENTS)) | |
1421 | zlog_debug("SR: Segment Routing: OFF -> ON"); | |
1422 | ||
1423 | if (isis_sr_start(area) == 0) | |
1424 | area->srdb.enabled = true; | |
1425 | } else { | |
1426 | if (IS_DEBUG_ISIS(DEBUG_EVENTS)) | |
1427 | zlog_debug("SR: Segment Routing: ON -> OFF"); | |
1428 | ||
1429 | isis_sr_stop(area); | |
1430 | area->srdb.enabled = false; | |
7e405d3b RW |
1431 | } |
1432 | ||
1433 | return NB_OK; | |
1434 | } | |
1435 | ||
26f6acaf RW |
1436 | /* |
1437 | * XPath: /frr-isisd:isis/instance/segment-routing/srgb | |
1438 | */ | |
1439 | void isis_instance_segment_routing_srgb_apply_finish( | |
1440 | struct nb_cb_apply_finish_args *args) | |
1441 | { | |
1442 | struct isis_area *area; | |
1443 | uint32_t lower_bound, upper_bound; | |
1444 | int ret; | |
1445 | ||
1446 | area = nb_running_get_entry(args->dnode, NULL, true); | |
1447 | lower_bound = yang_dnode_get_uint32(args->dnode, "./lower-bound"); | |
1448 | upper_bound = yang_dnode_get_uint32(args->dnode, "./upper-bound"); | |
1449 | ||
1450 | ret = isis_sr_cfg_srgb_update(area, lower_bound, upper_bound); | |
1451 | if (area->srdb.config.enabled) { | |
1452 | if (ret == 0) | |
1453 | area->srdb.enabled = true; | |
1454 | else { | |
1455 | isis_sr_stop(area); | |
1456 | area->srdb.enabled = false; | |
1457 | } | |
1458 | } | |
1459 | } | |
1460 | ||
7e405d3b RW |
1461 | /* |
1462 | * XPath: /frr-isisd:isis/instance/segment-routing/srgb/lower-bound | |
1463 | */ | |
1464 | int isis_instance_segment_routing_srgb_lower_bound_modify( | |
26f6acaf | 1465 | struct nb_cb_modify_args *args) |
7e405d3b | 1466 | { |
26f6acaf RW |
1467 | uint32_t lower_bound = yang_dnode_get_uint32(args->dnode, NULL); |
1468 | ||
1469 | switch (args->event) { | |
7e405d3b | 1470 | case NB_EV_VALIDATE: |
26f6acaf RW |
1471 | if (!IS_MPLS_UNRESERVED_LABEL(lower_bound)) { |
1472 | zlog_warn("Invalid SRGB lower bound: %" PRIu32, | |
1473 | lower_bound); | |
1474 | return NB_ERR_VALIDATION; | |
1475 | } | |
1476 | break; | |
7e405d3b RW |
1477 | case NB_EV_PREPARE: |
1478 | case NB_EV_ABORT: | |
1479 | case NB_EV_APPLY: | |
7e405d3b RW |
1480 | break; |
1481 | } | |
1482 | ||
1483 | return NB_OK; | |
1484 | } | |
1485 | ||
1486 | /* | |
1487 | * XPath: /frr-isisd:isis/instance/segment-routing/srgb/upper-bound | |
1488 | */ | |
1489 | int isis_instance_segment_routing_srgb_upper_bound_modify( | |
26f6acaf | 1490 | struct nb_cb_modify_args *args) |
7e405d3b | 1491 | { |
26f6acaf RW |
1492 | uint32_t upper_bound = yang_dnode_get_uint32(args->dnode, NULL); |
1493 | ||
1494 | switch (args->event) { | |
7e405d3b | 1495 | case NB_EV_VALIDATE: |
26f6acaf RW |
1496 | if (!IS_MPLS_UNRESERVED_LABEL(upper_bound)) { |
1497 | zlog_warn("Invalid SRGB upper bound: %" PRIu32, | |
1498 | upper_bound); | |
1499 | return NB_ERR_VALIDATION; | |
1500 | } | |
1501 | break; | |
7e405d3b RW |
1502 | case NB_EV_PREPARE: |
1503 | case NB_EV_ABORT: | |
1504 | case NB_EV_APPLY: | |
7e405d3b RW |
1505 | break; |
1506 | } | |
1507 | ||
1508 | return NB_OK; | |
1509 | } | |
1510 | ||
1511 | /* | |
1512 | * XPath: /frr-isisd:isis/instance/segment-routing/msd/node-msd | |
1513 | */ | |
1514 | int isis_instance_segment_routing_msd_node_msd_modify( | |
26f6acaf | 1515 | struct nb_cb_modify_args *args) |
7e405d3b | 1516 | { |
26f6acaf RW |
1517 | struct isis_area *area; |
1518 | ||
1519 | if (args->event != NB_EV_APPLY) | |
1520 | return NB_OK; | |
1521 | ||
1522 | area = nb_running_get_entry(args->dnode, NULL, true); | |
1523 | area->srdb.config.msd = yang_dnode_get_uint8(args->dnode, NULL); | |
c3f7b406 OD |
1524 | |
1525 | /* Update and regenerate LSP */ | |
1526 | lsp_regenerate_schedule(area, area->is_type, 0); | |
7e405d3b RW |
1527 | |
1528 | return NB_OK; | |
1529 | } | |
1530 | ||
1531 | int isis_instance_segment_routing_msd_node_msd_destroy( | |
26f6acaf | 1532 | struct nb_cb_destroy_args *args) |
7e405d3b | 1533 | { |
26f6acaf RW |
1534 | struct isis_area *area; |
1535 | ||
1536 | if (args->event != NB_EV_APPLY) | |
1537 | return NB_OK; | |
1538 | ||
1539 | area = nb_running_get_entry(args->dnode, NULL, true); | |
1540 | area->srdb.config.msd = 0; | |
c3f7b406 OD |
1541 | |
1542 | /* Update and regenerate LSP */ | |
1543 | lsp_regenerate_schedule(area, area->is_type, 0); | |
7e405d3b RW |
1544 | |
1545 | return NB_OK; | |
1546 | } | |
1547 | ||
1548 | /* | |
1549 | * XPath: /frr-isisd:isis/instance/segment-routing/prefix-sid-map/prefix-sid | |
1550 | */ | |
1551 | int isis_instance_segment_routing_prefix_sid_map_prefix_sid_create( | |
26f6acaf | 1552 | struct nb_cb_create_args *args) |
7e405d3b | 1553 | { |
26f6acaf RW |
1554 | struct isis_area *area; |
1555 | struct prefix prefix; | |
1556 | struct sr_prefix_cfg *pcfg; | |
1557 | ||
1558 | if (args->event != NB_EV_APPLY) | |
1559 | return NB_OK; | |
1560 | ||
1561 | area = nb_running_get_entry(args->dnode, NULL, true); | |
1562 | yang_dnode_get_prefix(&prefix, args->dnode, "./prefix"); | |
1563 | ||
1564 | pcfg = isis_sr_cfg_prefix_add(area, &prefix); | |
1565 | nb_running_set_entry(args->dnode, pcfg); | |
7e405d3b RW |
1566 | |
1567 | return NB_OK; | |
1568 | } | |
1569 | ||
1570 | int isis_instance_segment_routing_prefix_sid_map_prefix_sid_destroy( | |
26f6acaf | 1571 | struct nb_cb_destroy_args *args) |
7e405d3b | 1572 | { |
26f6acaf RW |
1573 | struct sr_prefix_cfg *pcfg; |
1574 | struct isis_area *area; | |
1575 | ||
1576 | if (args->event != NB_EV_APPLY) | |
1577 | return NB_OK; | |
1578 | ||
1579 | pcfg = nb_running_unset_entry(args->dnode); | |
1580 | area = pcfg->area; | |
1581 | isis_sr_cfg_prefix_del(pcfg); | |
1582 | lsp_regenerate_schedule(area, area->is_type, 0); | |
1583 | ||
1584 | return NB_OK; | |
1585 | } | |
1586 | ||
1587 | int isis_instance_segment_routing_prefix_sid_map_prefix_sid_pre_validate( | |
1588 | struct nb_cb_pre_validate_args *args) | |
1589 | { | |
1590 | uint32_t srgb_lbound; | |
1591 | uint32_t srgb_ubound; | |
1592 | uint32_t srgb_range; | |
1593 | uint32_t sid; | |
1594 | enum sr_sid_value_type sid_type; | |
1595 | ||
1596 | srgb_lbound = yang_dnode_get_uint32(args->dnode, | |
1597 | "../../srgb/lower-bound"); | |
1598 | srgb_ubound = yang_dnode_get_uint32(args->dnode, | |
1599 | "../../srgb/upper-bound"); | |
1600 | sid = yang_dnode_get_uint32(args->dnode, "./sid-value"); | |
1601 | sid_type = yang_dnode_get_enum(args->dnode, "./sid-value-type"); | |
1602 | ||
1603 | srgb_range = srgb_ubound - srgb_lbound + 1; | |
1604 | switch (sid_type) { | |
1605 | case SR_SID_VALUE_TYPE_INDEX: | |
1606 | if (sid >= srgb_range) { | |
1607 | zlog_warn("SID index %u falls outside local SRGB range", | |
1608 | sid); | |
1609 | return NB_ERR_VALIDATION; | |
1610 | } | |
1611 | break; | |
1612 | case SR_SID_VALUE_TYPE_ABSOLUTE: | |
1613 | if (!IS_MPLS_UNRESERVED_LABEL(sid)) { | |
1614 | zlog_warn("Invalid absolute SID %u", sid); | |
1615 | return NB_ERR_VALIDATION; | |
1616 | } | |
7e405d3b RW |
1617 | break; |
1618 | } | |
1619 | ||
1620 | return NB_OK; | |
1621 | } | |
1622 | ||
26f6acaf RW |
1623 | void isis_instance_segment_routing_prefix_sid_map_prefix_sid_apply_finish( |
1624 | struct nb_cb_apply_finish_args *args) | |
1625 | { | |
1626 | struct sr_prefix_cfg *pcfg; | |
1627 | struct isis_area *area; | |
1628 | ||
1629 | pcfg = nb_running_get_entry(args->dnode, NULL, true); | |
1630 | area = pcfg->area; | |
1631 | lsp_regenerate_schedule(area, area->is_type, 0); | |
1632 | } | |
1633 | ||
7e405d3b RW |
1634 | /* |
1635 | * XPath: | |
1636 | * /frr-isisd:isis/instance/segment-routing/prefix-sid-map/prefix-sid/sid-value-type | |
1637 | */ | |
1638 | int isis_instance_segment_routing_prefix_sid_map_prefix_sid_sid_value_type_modify( | |
26f6acaf | 1639 | struct nb_cb_modify_args *args) |
7e405d3b | 1640 | { |
26f6acaf RW |
1641 | struct sr_prefix_cfg *pcfg; |
1642 | ||
1643 | if (args->event != NB_EV_APPLY) | |
1644 | return NB_OK; | |
1645 | ||
1646 | pcfg = nb_running_get_entry(args->dnode, NULL, true); | |
1647 | pcfg->sid_type = yang_dnode_get_enum(args->dnode, NULL); | |
7e405d3b RW |
1648 | |
1649 | return NB_OK; | |
1650 | } | |
1651 | ||
1652 | /* | |
1653 | * XPath: | |
1654 | * /frr-isisd:isis/instance/segment-routing/prefix-sid-map/prefix-sid/sid-value | |
1655 | */ | |
1656 | int isis_instance_segment_routing_prefix_sid_map_prefix_sid_sid_value_modify( | |
26f6acaf | 1657 | struct nb_cb_modify_args *args) |
7e405d3b | 1658 | { |
26f6acaf RW |
1659 | struct sr_prefix_cfg *pcfg; |
1660 | ||
1661 | if (args->event != NB_EV_APPLY) | |
1662 | return NB_OK; | |
1663 | ||
1664 | pcfg = nb_running_get_entry(args->dnode, NULL, true); | |
1665 | pcfg->sid = yang_dnode_get_uint32(args->dnode, NULL); | |
7e405d3b RW |
1666 | |
1667 | return NB_OK; | |
1668 | } | |
1669 | ||
1670 | /* | |
1671 | * XPath: | |
1672 | * /frr-isisd:isis/instance/segment-routing/prefix-sid-map/prefix-sid/last-hop-behavior | |
1673 | */ | |
1674 | int isis_instance_segment_routing_prefix_sid_map_prefix_sid_last_hop_behavior_modify( | |
26f6acaf | 1675 | struct nb_cb_modify_args *args) |
7e405d3b | 1676 | { |
26f6acaf RW |
1677 | struct sr_prefix_cfg *pcfg; |
1678 | ||
1679 | if (args->event != NB_EV_APPLY) | |
1680 | return NB_OK; | |
1681 | ||
1682 | pcfg = nb_running_get_entry(args->dnode, NULL, true); | |
1683 | pcfg->last_hop_behavior = yang_dnode_get_enum(args->dnode, NULL); | |
7e405d3b RW |
1684 | |
1685 | return NB_OK; | |
1686 | } | |
1687 | ||
2a1c520e RW |
1688 | /* |
1689 | * XPath: /frr-interface:lib/interface/frr-isisd:isis | |
1690 | */ | |
60ee8be1 | 1691 | int lib_interface_isis_create(struct nb_cb_create_args *args) |
2a1c520e RW |
1692 | { |
1693 | struct isis_area *area; | |
1694 | struct interface *ifp; | |
1695 | struct isis_circuit *circuit; | |
60ee8be1 | 1696 | const char *area_tag = yang_dnode_get_string(args->dnode, "./area-tag"); |
2a1c520e RW |
1697 | uint32_t min_mtu, actual_mtu; |
1698 | ||
60ee8be1 | 1699 | switch (args->event) { |
2a1c520e RW |
1700 | case NB_EV_PREPARE: |
1701 | case NB_EV_ABORT: | |
1702 | break; | |
1703 | case NB_EV_VALIDATE: | |
1704 | /* check if interface mtu is sufficient. If the area has not | |
1705 | * been created yet, assume default MTU for the area | |
1706 | */ | |
60ee8be1 | 1707 | ifp = nb_running_get_entry(args->dnode, NULL, false); |
2a1c520e RW |
1708 | /* zebra might not know yet about the MTU - nothing we can do */ |
1709 | if (!ifp || ifp->mtu == 0) | |
1710 | break; | |
1711 | actual_mtu = | |
1712 | if_is_broadcast(ifp) ? ifp->mtu - LLC_LEN : ifp->mtu; | |
1713 | area = isis_area_lookup(area_tag); | |
1714 | if (area) | |
1715 | min_mtu = area->lsp_mtu; | |
1716 | else | |
1717 | #ifndef FABRICD | |
1718 | min_mtu = yang_get_default_uint16( | |
1719 | "/frr-isisd:isis/instance/lsp/mtu"); | |
1720 | #else | |
1721 | min_mtu = DEFAULT_LSP_MTU; | |
1722 | #endif /* ifndef FABRICD */ | |
1723 | if (actual_mtu < min_mtu) { | |
1724 | flog_warn(EC_LIB_NB_CB_CONFIG_VALIDATE, | |
1725 | "Interface %s has MTU %" PRIu32 | |
1726 | ", minimum MTU for the area is %" PRIu32 "", | |
1727 | ifp->name, actual_mtu, min_mtu); | |
1728 | return NB_ERR_VALIDATION; | |
1729 | } | |
1730 | break; | |
1731 | case NB_EV_APPLY: | |
1732 | area = isis_area_lookup(area_tag); | |
1733 | /* The area should have already be created. We are | |
1734 | * setting the priority of the global isis area creation | |
1735 | * slightly lower, so it should be executed first, but I | |
1736 | * cannot rely on that so here I have to check. | |
1737 | */ | |
1738 | if (!area) { | |
1739 | flog_err( | |
1740 | EC_LIB_NB_CB_CONFIG_APPLY, | |
1741 | "%s: attempt to create circuit for area %s before the area has been created", | |
1742 | __func__, area_tag); | |
1743 | abort(); | |
1744 | } | |
1745 | ||
60ee8be1 | 1746 | ifp = nb_running_get_entry(args->dnode, NULL, true); |
2a1c520e RW |
1747 | circuit = isis_circuit_create(area, ifp); |
1748 | assert(circuit | |
1749 | && (circuit->state == C_STATE_CONF | |
1750 | || circuit->state == C_STATE_UP)); | |
60ee8be1 | 1751 | nb_running_set_entry(args->dnode, circuit); |
2a1c520e RW |
1752 | break; |
1753 | } | |
1754 | ||
1755 | return NB_OK; | |
1756 | } | |
1757 | ||
60ee8be1 | 1758 | int lib_interface_isis_destroy(struct nb_cb_destroy_args *args) |
2a1c520e RW |
1759 | { |
1760 | struct isis_circuit *circuit; | |
1761 | ||
60ee8be1 | 1762 | if (args->event != NB_EV_APPLY) |
2a1c520e RW |
1763 | return NB_OK; |
1764 | ||
60ee8be1 | 1765 | circuit = nb_running_unset_entry(args->dnode); |
2a1c520e RW |
1766 | if (!circuit) |
1767 | return NB_ERR_INCONSISTENCY; | |
2a1c520e | 1768 | |
d38a3cb2 EDP |
1769 | /* disable both AFs for this circuit. this will also update the |
1770 | * CSM state by sending an ISIS_DISABLED signal. If there is no | |
1771 | * area associated to the circuit there is nothing to do | |
1772 | */ | |
1773 | if (circuit->area) | |
1774 | isis_circuit_af_set(circuit, false, false); | |
2a1c520e RW |
1775 | return NB_OK; |
1776 | } | |
1777 | ||
1778 | /* | |
1779 | * XPath: /frr-interface:lib/interface/frr-isisd:isis/area-tag | |
1780 | */ | |
60ee8be1 | 1781 | int lib_interface_isis_area_tag_modify(struct nb_cb_modify_args *args) |
2a1c520e RW |
1782 | { |
1783 | struct isis_circuit *circuit; | |
1784 | struct interface *ifp; | |
1785 | struct vrf *vrf; | |
1786 | const char *area_tag, *ifname, *vrfname; | |
1787 | ||
60ee8be1 | 1788 | if (args->event == NB_EV_VALIDATE) { |
2a1c520e RW |
1789 | /* libyang doesn't like relative paths across module boundaries |
1790 | */ | |
60ee8be1 RW |
1791 | ifname = yang_dnode_get_string(args->dnode->parent->parent, |
1792 | "./name"); | |
1793 | vrfname = yang_dnode_get_string(args->dnode->parent->parent, | |
1794 | "./vrf"); | |
2a1c520e RW |
1795 | vrf = vrf_lookup_by_name(vrfname); |
1796 | assert(vrf); | |
1797 | ifp = if_lookup_by_name(ifname, vrf->vrf_id); | |
1798 | if (!ifp) | |
1799 | return NB_OK; | |
1800 | circuit = circuit_lookup_by_ifp(ifp, isis->init_circ_list); | |
60ee8be1 | 1801 | area_tag = yang_dnode_get_string(args->dnode, NULL); |
2a1c520e RW |
1802 | if (circuit && circuit->area && circuit->area->area_tag |
1803 | && strcmp(circuit->area->area_tag, area_tag)) { | |
1804 | flog_warn(EC_LIB_NB_CB_CONFIG_VALIDATE, | |
1805 | "ISIS circuit is already defined on %s", | |
1806 | circuit->area->area_tag); | |
1807 | return NB_ERR_VALIDATION; | |
1808 | } | |
1809 | } | |
1810 | ||
1811 | return NB_OK; | |
1812 | } | |
1813 | ||
1814 | /* | |
1815 | * XPath: /frr-interface:lib/interface/frr-isisd:isis/circuit-type | |
1816 | */ | |
60ee8be1 | 1817 | int lib_interface_isis_circuit_type_modify(struct nb_cb_modify_args *args) |
2a1c520e | 1818 | { |
60ee8be1 | 1819 | int circ_type = yang_dnode_get_enum(args->dnode, NULL); |
2a1c520e RW |
1820 | struct isis_circuit *circuit; |
1821 | struct interface *ifp; | |
1822 | struct vrf *vrf; | |
1823 | const char *ifname, *vrfname; | |
1824 | ||
60ee8be1 | 1825 | switch (args->event) { |
2a1c520e RW |
1826 | case NB_EV_VALIDATE: |
1827 | /* libyang doesn't like relative paths across module boundaries | |
1828 | */ | |
60ee8be1 RW |
1829 | ifname = yang_dnode_get_string(args->dnode->parent->parent, |
1830 | "./name"); | |
1831 | vrfname = yang_dnode_get_string(args->dnode->parent->parent, | |
1832 | "./vrf"); | |
2a1c520e RW |
1833 | vrf = vrf_lookup_by_name(vrfname); |
1834 | assert(vrf); | |
1835 | ifp = if_lookup_by_name(ifname, vrf->vrf_id); | |
1836 | if (!ifp) | |
1837 | break; | |
1838 | circuit = circuit_lookup_by_ifp(ifp, isis->init_circ_list); | |
1839 | if (circuit && circuit->state == C_STATE_UP | |
1840 | && circuit->area->is_type != IS_LEVEL_1_AND_2 | |
1841 | && circuit->area->is_type != circ_type) { | |
1842 | flog_warn(EC_LIB_NB_CB_CONFIG_VALIDATE, | |
1843 | "Invalid circuit level for area %s", | |
1844 | circuit->area->area_tag); | |
1845 | return NB_ERR_VALIDATION; | |
1846 | } | |
1847 | break; | |
1848 | case NB_EV_PREPARE: | |
1849 | case NB_EV_ABORT: | |
1850 | break; | |
1851 | case NB_EV_APPLY: | |
60ee8be1 | 1852 | circuit = nb_running_get_entry(args->dnode, NULL, true); |
2a1c520e RW |
1853 | isis_circuit_is_type_set(circuit, circ_type); |
1854 | break; | |
1855 | } | |
1856 | ||
1857 | return NB_OK; | |
1858 | } | |
1859 | ||
1860 | /* | |
1861 | * XPath: /frr-interface:lib/interface/frr-isisd:isis/ipv4-routing | |
1862 | */ | |
60ee8be1 | 1863 | int lib_interface_isis_ipv4_routing_modify(struct nb_cb_modify_args *args) |
2a1c520e RW |
1864 | { |
1865 | bool ipv4, ipv6; | |
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 | ipv4 = yang_dnode_get_bool(args->dnode, NULL); | |
1873 | ipv6 = yang_dnode_get_bool(args->dnode, "../ipv6-routing"); | |
2a1c520e RW |
1874 | isis_circuit_af_set(circuit, ipv4, ipv6); |
1875 | ||
1876 | return NB_OK; | |
1877 | } | |
1878 | ||
1879 | /* | |
1880 | * XPath: /frr-interface:lib/interface/frr-isisd:isis/ipv6-routing | |
1881 | */ | |
60ee8be1 | 1882 | int lib_interface_isis_ipv6_routing_modify(struct nb_cb_modify_args *args) |
2a1c520e RW |
1883 | { |
1884 | bool ipv4, ipv6; | |
1885 | struct isis_circuit *circuit; | |
1886 | ||
60ee8be1 | 1887 | if (args->event != NB_EV_APPLY) |
2a1c520e RW |
1888 | return NB_OK; |
1889 | ||
60ee8be1 RW |
1890 | circuit = nb_running_get_entry(args->dnode, NULL, true); |
1891 | ipv4 = yang_dnode_exists(args->dnode, "../ipv4-routing"); | |
1892 | ipv6 = yang_dnode_get_bool(args->dnode, NULL); | |
2a1c520e RW |
1893 | isis_circuit_af_set(circuit, ipv4, ipv6); |
1894 | ||
1895 | return NB_OK; | |
1896 | } | |
1897 | ||
1898 | /* | |
1899 | * XPath: /frr-interface:lib/interface/frr-isisd:isis/bfd-monitoring | |
1900 | */ | |
60ee8be1 | 1901 | int lib_interface_isis_bfd_monitoring_modify(struct nb_cb_modify_args *args) |
2a1c520e RW |
1902 | { |
1903 | struct isis_circuit *circuit; | |
1904 | bool bfd_monitoring; | |
1905 | ||
60ee8be1 | 1906 | if (args->event != NB_EV_APPLY) |
2a1c520e RW |
1907 | return NB_OK; |
1908 | ||
60ee8be1 RW |
1909 | circuit = nb_running_get_entry(args->dnode, NULL, true); |
1910 | bfd_monitoring = yang_dnode_get_bool(args->dnode, NULL); | |
2a1c520e RW |
1911 | |
1912 | if (bfd_monitoring) { | |
1913 | isis_bfd_circuit_param_set(circuit, BFD_DEF_MIN_RX, | |
1914 | BFD_DEF_MIN_TX, BFD_DEF_DETECT_MULT, | |
1915 | true); | |
1916 | } else { | |
1917 | isis_bfd_circuit_cmd(circuit, ZEBRA_BFD_DEST_DEREGISTER); | |
1918 | bfd_info_free(&circuit->bfd_info); | |
1919 | } | |
1920 | ||
1921 | return NB_OK; | |
1922 | } | |
1923 | ||
1924 | /* | |
1925 | * XPath: /frr-interface:lib/interface/frr-isisd:isis/csnp-interval/level-1 | |
1926 | */ | |
1927 | int lib_interface_isis_csnp_interval_level_1_modify( | |
60ee8be1 | 1928 | struct nb_cb_modify_args *args) |
2a1c520e RW |
1929 | { |
1930 | struct isis_circuit *circuit; | |
1931 | ||
60ee8be1 | 1932 | if (args->event != NB_EV_APPLY) |
2a1c520e RW |
1933 | return NB_OK; |
1934 | ||
60ee8be1 RW |
1935 | circuit = nb_running_get_entry(args->dnode, NULL, true); |
1936 | circuit->csnp_interval[0] = yang_dnode_get_uint16(args->dnode, NULL); | |
2a1c520e RW |
1937 | |
1938 | return NB_OK; | |
1939 | } | |
1940 | ||
1941 | /* | |
1942 | * XPath: /frr-interface:lib/interface/frr-isisd:isis/csnp-interval/level-2 | |
1943 | */ | |
1944 | int lib_interface_isis_csnp_interval_level_2_modify( | |
60ee8be1 | 1945 | struct nb_cb_modify_args *args) |
2a1c520e RW |
1946 | { |
1947 | struct isis_circuit *circuit; | |
1948 | ||
60ee8be1 | 1949 | if (args->event != NB_EV_APPLY) |
2a1c520e RW |
1950 | return NB_OK; |
1951 | ||
60ee8be1 RW |
1952 | circuit = nb_running_get_entry(args->dnode, NULL, true); |
1953 | circuit->csnp_interval[1] = yang_dnode_get_uint16(args->dnode, NULL); | |
2a1c520e RW |
1954 | |
1955 | return NB_OK; | |
1956 | } | |
1957 | ||
1958 | /* | |
1959 | * XPath: /frr-interface:lib/interface/frr-isisd:isis/psnp-interval/level-1 | |
1960 | */ | |
1961 | int lib_interface_isis_psnp_interval_level_1_modify( | |
60ee8be1 | 1962 | struct nb_cb_modify_args *args) |
2a1c520e RW |
1963 | { |
1964 | struct isis_circuit *circuit; | |
1965 | ||
60ee8be1 | 1966 | if (args->event != NB_EV_APPLY) |
2a1c520e RW |
1967 | return NB_OK; |
1968 | ||
60ee8be1 RW |
1969 | circuit = nb_running_get_entry(args->dnode, NULL, true); |
1970 | circuit->psnp_interval[0] = yang_dnode_get_uint16(args->dnode, NULL); | |
2a1c520e RW |
1971 | |
1972 | return NB_OK; | |
1973 | } | |
1974 | ||
1975 | /* | |
1976 | * XPath: /frr-interface:lib/interface/frr-isisd:isis/psnp-interval/level-2 | |
1977 | */ | |
1978 | int lib_interface_isis_psnp_interval_level_2_modify( | |
60ee8be1 | 1979 | struct nb_cb_modify_args *args) |
2a1c520e RW |
1980 | { |
1981 | struct isis_circuit *circuit; | |
1982 | ||
60ee8be1 | 1983 | if (args->event != NB_EV_APPLY) |
2a1c520e RW |
1984 | return NB_OK; |
1985 | ||
60ee8be1 RW |
1986 | circuit = nb_running_get_entry(args->dnode, NULL, true); |
1987 | circuit->psnp_interval[1] = yang_dnode_get_uint16(args->dnode, NULL); | |
2a1c520e RW |
1988 | |
1989 | return NB_OK; | |
1990 | } | |
1991 | ||
1992 | /* | |
1993 | * XPath: /frr-interface:lib/interface/frr-isisd:isis/hello/padding | |
1994 | */ | |
60ee8be1 | 1995 | int lib_interface_isis_hello_padding_modify(struct nb_cb_modify_args *args) |
2a1c520e RW |
1996 | { |
1997 | struct isis_circuit *circuit; | |
1998 | ||
60ee8be1 | 1999 | if (args->event != NB_EV_APPLY) |
2a1c520e RW |
2000 | return NB_OK; |
2001 | ||
60ee8be1 RW |
2002 | circuit = nb_running_get_entry(args->dnode, NULL, true); |
2003 | circuit->pad_hellos = yang_dnode_get_bool(args->dnode, NULL); | |
2a1c520e RW |
2004 | |
2005 | return NB_OK; | |
2006 | } | |
2007 | ||
2008 | /* | |
2009 | * XPath: /frr-interface:lib/interface/frr-isisd:isis/hello/interval/level-1 | |
2010 | */ | |
2011 | int lib_interface_isis_hello_interval_level_1_modify( | |
60ee8be1 | 2012 | struct nb_cb_modify_args *args) |
2a1c520e RW |
2013 | { |
2014 | struct isis_circuit *circuit; | |
2015 | uint32_t interval; | |
2016 | ||
60ee8be1 | 2017 | if (args->event != NB_EV_APPLY) |
2a1c520e RW |
2018 | return NB_OK; |
2019 | ||
60ee8be1 RW |
2020 | circuit = nb_running_get_entry(args->dnode, NULL, true); |
2021 | interval = yang_dnode_get_uint32(args->dnode, NULL); | |
2a1c520e RW |
2022 | circuit->hello_interval[0] = interval; |
2023 | ||
2024 | return NB_OK; | |
2025 | } | |
2026 | ||
2027 | /* | |
2028 | * XPath: /frr-interface:lib/interface/frr-isisd:isis/hello/interval/level-2 | |
2029 | */ | |
2030 | int lib_interface_isis_hello_interval_level_2_modify( | |
60ee8be1 | 2031 | struct nb_cb_modify_args *args) |
2a1c520e RW |
2032 | { |
2033 | struct isis_circuit *circuit; | |
2034 | uint32_t interval; | |
2035 | ||
60ee8be1 | 2036 | if (args->event != NB_EV_APPLY) |
2a1c520e RW |
2037 | return NB_OK; |
2038 | ||
60ee8be1 RW |
2039 | circuit = nb_running_get_entry(args->dnode, NULL, true); |
2040 | interval = yang_dnode_get_uint32(args->dnode, NULL); | |
2a1c520e RW |
2041 | circuit->hello_interval[1] = interval; |
2042 | ||
2043 | return NB_OK; | |
2044 | } | |
2045 | ||
2046 | /* | |
2047 | * XPath: /frr-interface:lib/interface/frr-isisd:isis/hello/multiplier/level-1 | |
2048 | */ | |
2049 | int lib_interface_isis_hello_multiplier_level_1_modify( | |
60ee8be1 | 2050 | struct nb_cb_modify_args *args) |
2a1c520e RW |
2051 | { |
2052 | struct isis_circuit *circuit; | |
2053 | uint16_t multi; | |
2054 | ||
60ee8be1 | 2055 | if (args->event != NB_EV_APPLY) |
2a1c520e RW |
2056 | return NB_OK; |
2057 | ||
60ee8be1 RW |
2058 | circuit = nb_running_get_entry(args->dnode, NULL, true); |
2059 | multi = yang_dnode_get_uint16(args->dnode, NULL); | |
2a1c520e RW |
2060 | circuit->hello_multiplier[0] = multi; |
2061 | ||
2062 | return NB_OK; | |
2063 | } | |
2064 | ||
2065 | /* | |
2066 | * XPath: /frr-interface:lib/interface/frr-isisd:isis/hello/multiplier/level-2 | |
2067 | */ | |
2068 | int lib_interface_isis_hello_multiplier_level_2_modify( | |
60ee8be1 | 2069 | struct nb_cb_modify_args *args) |
2a1c520e RW |
2070 | { |
2071 | struct isis_circuit *circuit; | |
2072 | uint16_t multi; | |
2073 | ||
60ee8be1 | 2074 | if (args->event != NB_EV_APPLY) |
2a1c520e RW |
2075 | return NB_OK; |
2076 | ||
60ee8be1 RW |
2077 | circuit = nb_running_get_entry(args->dnode, NULL, true); |
2078 | multi = yang_dnode_get_uint16(args->dnode, NULL); | |
2a1c520e RW |
2079 | circuit->hello_multiplier[1] = multi; |
2080 | ||
2081 | return NB_OK; | |
2082 | } | |
2083 | ||
2084 | /* | |
2085 | * XPath: /frr-interface:lib/interface/frr-isisd:isis/metric/level-1 | |
2086 | */ | |
60ee8be1 | 2087 | int lib_interface_isis_metric_level_1_modify(struct nb_cb_modify_args *args) |
2a1c520e RW |
2088 | { |
2089 | struct isis_circuit *circuit; | |
2090 | unsigned int met; | |
2091 | ||
60ee8be1 | 2092 | if (args->event != NB_EV_APPLY) |
2a1c520e RW |
2093 | return NB_OK; |
2094 | ||
60ee8be1 RW |
2095 | circuit = nb_running_get_entry(args->dnode, NULL, true); |
2096 | met = yang_dnode_get_uint32(args->dnode, NULL); | |
2a1c520e RW |
2097 | isis_circuit_metric_set(circuit, IS_LEVEL_1, met); |
2098 | ||
2099 | return NB_OK; | |
2100 | } | |
2101 | ||
2102 | /* | |
2103 | * XPath: /frr-interface:lib/interface/frr-isisd:isis/metric/level-2 | |
2104 | */ | |
60ee8be1 | 2105 | int lib_interface_isis_metric_level_2_modify(struct nb_cb_modify_args *args) |
2a1c520e RW |
2106 | { |
2107 | struct isis_circuit *circuit; | |
2108 | unsigned int met; | |
2109 | ||
60ee8be1 | 2110 | if (args->event != NB_EV_APPLY) |
2a1c520e RW |
2111 | return NB_OK; |
2112 | ||
60ee8be1 RW |
2113 | circuit = nb_running_get_entry(args->dnode, NULL, true); |
2114 | met = yang_dnode_get_uint32(args->dnode, NULL); | |
2a1c520e RW |
2115 | isis_circuit_metric_set(circuit, IS_LEVEL_2, met); |
2116 | ||
2117 | return NB_OK; | |
2118 | } | |
2119 | ||
2120 | /* | |
2121 | * XPath: /frr-interface:lib/interface/frr-isisd:isis/priority/level-1 | |
2122 | */ | |
60ee8be1 | 2123 | int lib_interface_isis_priority_level_1_modify(struct nb_cb_modify_args *args) |
2a1c520e RW |
2124 | { |
2125 | struct isis_circuit *circuit; | |
2126 | ||
60ee8be1 | 2127 | if (args->event != NB_EV_APPLY) |
2a1c520e RW |
2128 | return NB_OK; |
2129 | ||
60ee8be1 RW |
2130 | circuit = nb_running_get_entry(args->dnode, NULL, true); |
2131 | circuit->priority[0] = yang_dnode_get_uint8(args->dnode, NULL); | |
2a1c520e RW |
2132 | |
2133 | return NB_OK; | |
2134 | } | |
2135 | ||
2136 | /* | |
2137 | * XPath: /frr-interface:lib/interface/frr-isisd:isis/priority/level-2 | |
2138 | */ | |
60ee8be1 | 2139 | int lib_interface_isis_priority_level_2_modify(struct nb_cb_modify_args *args) |
2a1c520e RW |
2140 | { |
2141 | struct isis_circuit *circuit; | |
2142 | ||
60ee8be1 | 2143 | if (args->event != NB_EV_APPLY) |
2a1c520e RW |
2144 | return NB_OK; |
2145 | ||
60ee8be1 RW |
2146 | circuit = nb_running_get_entry(args->dnode, NULL, true); |
2147 | circuit->priority[1] = yang_dnode_get_uint8(args->dnode, NULL); | |
2a1c520e RW |
2148 | |
2149 | return NB_OK; | |
2150 | } | |
2151 | ||
2152 | /* | |
2153 | * XPath: /frr-interface:lib/interface/frr-isisd:isis/network-type | |
2154 | */ | |
60ee8be1 | 2155 | int lib_interface_isis_network_type_modify(struct nb_cb_modify_args *args) |
2a1c520e RW |
2156 | { |
2157 | struct isis_circuit *circuit; | |
60ee8be1 | 2158 | int net_type = yang_dnode_get_enum(args->dnode, NULL); |
2a1c520e | 2159 | |
60ee8be1 | 2160 | switch (args->event) { |
2a1c520e | 2161 | case NB_EV_VALIDATE: |
60ee8be1 | 2162 | circuit = nb_running_get_entry(args->dnode, NULL, false); |
2a1c520e RW |
2163 | if (!circuit) |
2164 | break; | |
2165 | if (circuit->circ_type == CIRCUIT_T_LOOPBACK) { | |
2166 | flog_warn( | |
2167 | EC_LIB_NB_CB_CONFIG_VALIDATE, | |
2168 | "Cannot change network type on loopback interface"); | |
2169 | return NB_ERR_VALIDATION; | |
2170 | } | |
2171 | if (net_type == CIRCUIT_T_BROADCAST | |
2172 | && circuit->state == C_STATE_UP | |
2173 | && !if_is_broadcast(circuit->interface)) { | |
2174 | flog_warn( | |
2175 | EC_LIB_NB_CB_CONFIG_VALIDATE, | |
2176 | "Cannot configure non-broadcast interface for broadcast operation"); | |
2177 | return NB_ERR_VALIDATION; | |
2178 | } | |
2179 | break; | |
2180 | case NB_EV_PREPARE: | |
2181 | case NB_EV_ABORT: | |
2182 | break; | |
2183 | case NB_EV_APPLY: | |
60ee8be1 | 2184 | circuit = nb_running_get_entry(args->dnode, NULL, true); |
2a1c520e RW |
2185 | isis_circuit_circ_type_set(circuit, net_type); |
2186 | break; | |
2187 | } | |
2188 | ||
2189 | return NB_OK; | |
2190 | } | |
2191 | ||
2192 | /* | |
2193 | * XPath: /frr-interface:lib/interface/frr-isisd:isis/passive | |
2194 | */ | |
60ee8be1 | 2195 | int lib_interface_isis_passive_modify(struct nb_cb_modify_args *args) |
2a1c520e RW |
2196 | { |
2197 | struct isis_circuit *circuit; | |
2198 | struct isis_area *area; | |
2199 | struct interface *ifp; | |
60ee8be1 | 2200 | bool passive = yang_dnode_get_bool(args->dnode, NULL); |
2a1c520e RW |
2201 | |
2202 | /* validation only applies if we are setting passive to false */ | |
60ee8be1 RW |
2203 | if (!passive && args->event == NB_EV_VALIDATE) { |
2204 | circuit = nb_running_get_entry(args->dnode, NULL, false); | |
2a1c520e RW |
2205 | if (!circuit) |
2206 | return NB_OK; | |
2207 | ifp = circuit->interface; | |
2208 | if (!ifp) | |
2209 | return NB_OK; | |
2210 | if (if_is_loopback(ifp)) { | |
2211 | flog_warn(EC_LIB_NB_CB_CONFIG_VALIDATE, | |
2212 | "Loopback is always passive"); | |
2213 | return NB_ERR_VALIDATION; | |
2214 | } | |
2215 | } | |
2216 | ||
60ee8be1 | 2217 | if (args->event != NB_EV_APPLY) |
2a1c520e RW |
2218 | return NB_OK; |
2219 | ||
60ee8be1 | 2220 | circuit = nb_running_get_entry(args->dnode, NULL, true); |
2a1c520e RW |
2221 | if (circuit->state != C_STATE_UP) { |
2222 | circuit->is_passive = passive; | |
2223 | } else { | |
2224 | area = circuit->area; | |
2225 | isis_csm_state_change(ISIS_DISABLE, circuit, area); | |
2226 | circuit->is_passive = passive; | |
2227 | isis_csm_state_change(ISIS_ENABLE, circuit, area); | |
2228 | } | |
2229 | ||
2230 | return NB_OK; | |
2231 | } | |
2232 | ||
2233 | /* | |
2234 | * XPath: /frr-interface:lib/interface/frr-isisd:isis/password | |
2235 | */ | |
60ee8be1 | 2236 | int lib_interface_isis_password_create(struct nb_cb_create_args *args) |
2a1c520e RW |
2237 | { |
2238 | return NB_OK; | |
2239 | } | |
2240 | ||
60ee8be1 | 2241 | int lib_interface_isis_password_destroy(struct nb_cb_destroy_args *args) |
2a1c520e RW |
2242 | { |
2243 | struct isis_circuit *circuit; | |
2244 | ||
60ee8be1 | 2245 | if (args->event != NB_EV_APPLY) |
2a1c520e RW |
2246 | return NB_OK; |
2247 | ||
60ee8be1 | 2248 | circuit = nb_running_get_entry(args->dnode, NULL, true); |
2a1c520e RW |
2249 | isis_circuit_passwd_unset(circuit); |
2250 | ||
2251 | return NB_OK; | |
2252 | } | |
2253 | ||
2254 | /* | |
2255 | * XPath: /frr-interface:lib/interface/frr-isisd:isis/password/password | |
2256 | */ | |
60ee8be1 | 2257 | int lib_interface_isis_password_password_modify(struct nb_cb_modify_args *args) |
2a1c520e RW |
2258 | { |
2259 | struct isis_circuit *circuit; | |
2260 | const char *password; | |
2261 | ||
60ee8be1 | 2262 | if (args->event != NB_EV_APPLY) |
2a1c520e RW |
2263 | return NB_OK; |
2264 | ||
60ee8be1 RW |
2265 | password = yang_dnode_get_string(args->dnode, NULL); |
2266 | circuit = nb_running_get_entry(args->dnode, NULL, true); | |
2a1c520e RW |
2267 | |
2268 | isis_circuit_passwd_set(circuit, circuit->passwd.type, password); | |
2269 | ||
2270 | return NB_OK; | |
2271 | } | |
2272 | ||
2273 | /* | |
2274 | * XPath: /frr-interface:lib/interface/frr-isisd:isis/password/password-type | |
2275 | */ | |
2276 | int lib_interface_isis_password_password_type_modify( | |
60ee8be1 | 2277 | struct nb_cb_modify_args *args) |
2a1c520e RW |
2278 | { |
2279 | struct isis_circuit *circuit; | |
2280 | uint8_t pass_type; | |
2281 | ||
60ee8be1 | 2282 | if (args->event != NB_EV_APPLY) |
2a1c520e RW |
2283 | return NB_OK; |
2284 | ||
60ee8be1 RW |
2285 | pass_type = yang_dnode_get_enum(args->dnode, NULL); |
2286 | circuit = nb_running_get_entry(args->dnode, NULL, true); | |
2a1c520e RW |
2287 | circuit->passwd.type = pass_type; |
2288 | ||
2289 | return NB_OK; | |
2290 | } | |
2291 | ||
2292 | /* | |
2293 | * XPath: | |
2294 | * /frr-interface:lib/interface/frr-isisd:isis/disable-three-way-handshake | |
2295 | */ | |
2296 | int lib_interface_isis_disable_three_way_handshake_modify( | |
60ee8be1 | 2297 | struct nb_cb_modify_args *args) |
2a1c520e RW |
2298 | { |
2299 | struct isis_circuit *circuit; | |
2300 | ||
60ee8be1 | 2301 | if (args->event != NB_EV_APPLY) |
2a1c520e RW |
2302 | return NB_OK; |
2303 | ||
60ee8be1 RW |
2304 | circuit = nb_running_get_entry(args->dnode, NULL, true); |
2305 | circuit->disable_threeway_adj = yang_dnode_get_bool(args->dnode, NULL); | |
2a1c520e RW |
2306 | |
2307 | return NB_OK; | |
2308 | } | |
2309 | ||
2310 | /* | |
2311 | * XPath: | |
2312 | * /frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv4-unicast | |
2313 | */ | |
2314 | static int lib_interface_isis_multi_topology_common( | |
2315 | enum nb_event event, const struct lyd_node *dnode, uint16_t mtid) | |
2316 | { | |
2317 | struct isis_circuit *circuit; | |
2318 | bool value; | |
2319 | ||
2320 | switch (event) { | |
2321 | case NB_EV_VALIDATE: | |
2322 | circuit = nb_running_get_entry(dnode, NULL, false); | |
2323 | if (circuit && circuit->area && circuit->area->oldmetric) { | |
2324 | flog_warn( | |
2325 | EC_LIB_NB_CB_CONFIG_VALIDATE, | |
2326 | "Multi topology IS-IS can only be used with wide metrics"); | |
2327 | return NB_ERR_VALIDATION; | |
2328 | } | |
2329 | break; | |
2330 | case NB_EV_PREPARE: | |
2331 | case NB_EV_ABORT: | |
2332 | break; | |
2333 | case NB_EV_APPLY: | |
2334 | circuit = nb_running_get_entry(dnode, NULL, true); | |
2335 | value = yang_dnode_get_bool(dnode, NULL); | |
2336 | isis_circuit_mt_enabled_set(circuit, mtid, value); | |
2337 | break; | |
2338 | } | |
2339 | ||
2340 | return NB_OK; | |
2341 | } | |
2342 | ||
2343 | int lib_interface_isis_multi_topology_ipv4_unicast_modify( | |
60ee8be1 | 2344 | struct nb_cb_modify_args *args) |
2a1c520e | 2345 | { |
60ee8be1 RW |
2346 | return lib_interface_isis_multi_topology_common( |
2347 | args->event, args->dnode, ISIS_MT_IPV4_UNICAST); | |
2a1c520e RW |
2348 | } |
2349 | ||
2350 | /* | |
2351 | * XPath: | |
2352 | * /frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv4-multicast | |
2353 | */ | |
2354 | int lib_interface_isis_multi_topology_ipv4_multicast_modify( | |
60ee8be1 | 2355 | struct nb_cb_modify_args *args) |
2a1c520e | 2356 | { |
60ee8be1 RW |
2357 | return lib_interface_isis_multi_topology_common( |
2358 | args->event, args->dnode, ISIS_MT_IPV4_MULTICAST); | |
2a1c520e RW |
2359 | } |
2360 | ||
2361 | /* | |
2362 | * XPath: | |
2363 | * /frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv4-management | |
2364 | */ | |
2365 | int lib_interface_isis_multi_topology_ipv4_management_modify( | |
60ee8be1 | 2366 | struct nb_cb_modify_args *args) |
2a1c520e | 2367 | { |
60ee8be1 RW |
2368 | return lib_interface_isis_multi_topology_common( |
2369 | args->event, args->dnode, ISIS_MT_IPV4_MGMT); | |
2a1c520e RW |
2370 | } |
2371 | ||
2372 | /* | |
2373 | * XPath: | |
2374 | * /frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv6-unicast | |
2375 | */ | |
2376 | int lib_interface_isis_multi_topology_ipv6_unicast_modify( | |
60ee8be1 | 2377 | struct nb_cb_modify_args *args) |
2a1c520e | 2378 | { |
60ee8be1 RW |
2379 | return lib_interface_isis_multi_topology_common( |
2380 | args->event, args->dnode, ISIS_MT_IPV6_UNICAST); | |
2a1c520e RW |
2381 | } |
2382 | ||
2383 | /* | |
2384 | * XPath: | |
2385 | * /frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv6-multicast | |
2386 | */ | |
2387 | int lib_interface_isis_multi_topology_ipv6_multicast_modify( | |
60ee8be1 | 2388 | struct nb_cb_modify_args *args) |
2a1c520e | 2389 | { |
60ee8be1 RW |
2390 | return lib_interface_isis_multi_topology_common( |
2391 | args->event, args->dnode, ISIS_MT_IPV6_MULTICAST); | |
2a1c520e RW |
2392 | } |
2393 | ||
2394 | /* | |
2395 | * XPath: | |
2396 | * /frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv6-management | |
2397 | */ | |
2398 | int lib_interface_isis_multi_topology_ipv6_management_modify( | |
60ee8be1 | 2399 | struct nb_cb_modify_args *args) |
2a1c520e | 2400 | { |
60ee8be1 RW |
2401 | return lib_interface_isis_multi_topology_common( |
2402 | args->event, args->dnode, ISIS_MT_IPV6_MGMT); | |
2a1c520e RW |
2403 | } |
2404 | ||
2405 | /* | |
2406 | * XPath: /frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv6-dstsrc | |
2407 | */ | |
2408 | int lib_interface_isis_multi_topology_ipv6_dstsrc_modify( | |
60ee8be1 | 2409 | struct nb_cb_modify_args *args) |
2a1c520e | 2410 | { |
60ee8be1 RW |
2411 | return lib_interface_isis_multi_topology_common( |
2412 | args->event, args->dnode, ISIS_MT_IPV6_DSTSRC); | |
2a1c520e | 2413 | } |