Line data Source code
1 : /*
2 : * Router ID for zebra daemon.
3 : *
4 : * Copyright (C) 2004 James R. Leu
5 : *
6 : * This file is part of Quagga routing suite.
7 : *
8 : * Quagga 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
10 : * Free Software Foundation; either version 2, or (at your option) any
11 : * later version.
12 : *
13 : * Quagga is distributed in the hope that it will be useful, but
14 : * WITHOUT ANY WARRANTY; without even the implied warranty of
15 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 : * General Public License for 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 "if.h"
26 : #include "vty.h"
27 : #include "sockunion.h"
28 : #include "prefix.h"
29 : #include "stream.h"
30 : #include "command.h"
31 : #include "memory.h"
32 : #include "ioctl.h"
33 : #include "connected.h"
34 : #include "network.h"
35 : #include "log.h"
36 : #include "table.h"
37 : #include "rib.h"
38 : #include "vrf.h"
39 :
40 : #include "zebra/zebra_router.h"
41 : #include "zebra/zapi_msg.h"
42 : #include "zebra/zebra_vrf.h"
43 : #include "zebra/router-id.h"
44 : #include "zebra/redistribute.h"
45 :
46 19 : static struct connected *router_id_find_node(struct list *l,
47 : struct connected *ifc)
48 : {
49 19 : struct listnode *node;
50 19 : struct connected *c;
51 :
52 40 : for (ALL_LIST_ELEMENTS_RO(l, node, c))
53 5 : if (prefix_same(ifc->address, c->address))
54 3 : return c;
55 :
56 : return NULL;
57 : }
58 :
59 24 : static int router_id_bad_address(struct connected *ifc)
60 : {
61 : /* non-redistributable addresses shouldn't be used for RIDs either */
62 24 : if (!zebra_check_addr(ifc->address))
63 : return 1;
64 :
65 : return 0;
66 : }
67 :
68 16 : static bool router_id_v6_is_any(struct prefix *p)
69 : {
70 16 : return memcmp(&p->u.prefix6, &in6addr_any, sizeof(struct in6_addr))
71 : == 0;
72 : }
73 :
74 46 : int router_id_get(afi_t afi, struct prefix *p, struct zebra_vrf *zvrf)
75 : {
76 46 : struct listnode *node;
77 46 : struct connected *c;
78 46 : struct in6_addr *addr = NULL;
79 :
80 46 : switch (afi) {
81 30 : case AFI_IP:
82 30 : p->u.prefix4.s_addr = INADDR_ANY;
83 30 : p->family = AF_INET;
84 30 : p->prefixlen = IPV4_MAX_BITLEN;
85 30 : if (zvrf->rid_user_assigned.u.prefix4.s_addr != INADDR_ANY)
86 0 : p->u.prefix4.s_addr =
87 : zvrf->rid_user_assigned.u.prefix4.s_addr;
88 30 : else if (!list_isempty(zvrf->rid_lo_sorted_list)) {
89 26 : node = listtail(zvrf->rid_lo_sorted_list);
90 26 : c = listgetdata(node);
91 26 : p->u.prefix4.s_addr = c->address->u.prefix4.s_addr;
92 4 : } else if (!list_isempty(zvrf->rid_all_sorted_list)) {
93 0 : node = listtail(zvrf->rid_all_sorted_list);
94 0 : c = listgetdata(node);
95 0 : p->u.prefix4.s_addr = c->address->u.prefix4.s_addr;
96 : }
97 : return 0;
98 16 : case AFI_IP6:
99 16 : p->u.prefix6 = in6addr_any;
100 16 : p->family = AF_INET6;
101 16 : p->prefixlen = IPV6_MAX_BITLEN;
102 16 : if (!router_id_v6_is_any(&zvrf->rid6_user_assigned))
103 : addr = &zvrf->rid6_user_assigned.u.prefix6;
104 16 : else if (!list_isempty(zvrf->rid6_lo_sorted_list)) {
105 12 : node = listtail(zvrf->rid6_lo_sorted_list);
106 12 : c = listgetdata(node);
107 12 : addr = &c->address->u.prefix6;
108 4 : } else if (!list_isempty(zvrf->rid6_all_sorted_list)) {
109 0 : node = listtail(zvrf->rid6_all_sorted_list);
110 0 : c = listgetdata(node);
111 0 : addr = &c->address->u.prefix6;
112 : }
113 12 : if (addr)
114 12 : memcpy(&p->u.prefix6, addr, sizeof(struct in6_addr));
115 : return 0;
116 : case AFI_UNSPEC:
117 : case AFI_L2VPN:
118 : case AFI_MAX:
119 : return -1;
120 : }
121 :
122 0 : assert(!"Reached end of function we should never hit");
123 : }
124 :
125 0 : static int router_id_set(afi_t afi, struct prefix *p, struct zebra_vrf *zvrf)
126 : {
127 0 : struct prefix after, before;
128 0 : struct listnode *node;
129 0 : struct zserv *client;
130 :
131 0 : router_id_get(afi, &before, zvrf);
132 :
133 0 : switch (afi) {
134 0 : case AFI_IP:
135 0 : zvrf->rid_user_assigned.u.prefix4.s_addr = p->u.prefix4.s_addr;
136 0 : break;
137 0 : case AFI_IP6:
138 0 : zvrf->rid6_user_assigned.u.prefix6 = p->u.prefix6;
139 0 : break;
140 : case AFI_UNSPEC:
141 : case AFI_L2VPN:
142 : case AFI_MAX:
143 : return -1;
144 : }
145 :
146 0 : router_id_get(afi, &after, zvrf);
147 :
148 : /*
149 : * If we've been told that the router-id is exactly the same
150 : * do we need to really do anything here?
151 : */
152 0 : if (prefix_same(&before, &after))
153 : return 0;
154 :
155 0 : for (ALL_LIST_ELEMENTS_RO(zrouter.client_list, node, client))
156 0 : zsend_router_id_update(client, afi, &after, zvrf->vrf->vrf_id);
157 :
158 : return 0;
159 : }
160 :
161 24 : void router_id_add_address(struct connected *ifc)
162 : {
163 24 : struct list *l = NULL;
164 24 : struct listnode *node;
165 24 : struct prefix before;
166 24 : struct prefix after;
167 24 : struct zserv *client;
168 24 : struct zebra_vrf *zvrf = ifc->ifp->vrf->info;
169 24 : afi_t afi;
170 24 : struct list *rid_lo;
171 24 : struct list *rid_all;
172 :
173 24 : if (router_id_bad_address(ifc))
174 16 : return;
175 :
176 19 : switch (ifc->address->family) {
177 11 : case AF_INET:
178 11 : afi = AFI_IP;
179 11 : rid_lo = zvrf->rid_lo_sorted_list;
180 11 : rid_all = zvrf->rid_all_sorted_list;
181 11 : break;
182 8 : case AF_INET6:
183 8 : afi = AFI_IP6;
184 8 : rid_lo = zvrf->rid6_lo_sorted_list;
185 8 : rid_all = zvrf->rid6_all_sorted_list;
186 8 : break;
187 : default:
188 : return;
189 : }
190 :
191 19 : router_id_get(afi, &before, zvrf);
192 :
193 19 : l = if_is_loopback(ifc->ifp) ? rid_lo : rid_all;
194 :
195 19 : if (!router_id_find_node(l, ifc))
196 16 : listnode_add_sort(l, ifc);
197 :
198 19 : router_id_get(afi, &after, zvrf);
199 :
200 19 : if (prefix_same(&before, &after))
201 : return;
202 :
203 16 : for (ALL_LIST_ELEMENTS_RO(zrouter.client_list, node, client))
204 0 : zsend_router_id_update(client, afi, &after, zvrf_id(zvrf));
205 : }
206 :
207 0 : void router_id_del_address(struct connected *ifc)
208 : {
209 0 : struct connected *c;
210 0 : struct list *l;
211 0 : struct prefix after;
212 0 : struct prefix before;
213 0 : struct listnode *node;
214 0 : struct zserv *client;
215 0 : struct zebra_vrf *zvrf = ifc->ifp->vrf->info;
216 0 : afi_t afi;
217 0 : struct list *rid_lo;
218 0 : struct list *rid_all;
219 :
220 0 : if (router_id_bad_address(ifc))
221 0 : return;
222 :
223 0 : switch (ifc->address->family) {
224 0 : case AF_INET:
225 0 : afi = AFI_IP;
226 0 : rid_lo = zvrf->rid_lo_sorted_list;
227 0 : rid_all = zvrf->rid_all_sorted_list;
228 0 : break;
229 0 : case AF_INET6:
230 0 : afi = AFI_IP6;
231 0 : rid_lo = zvrf->rid6_lo_sorted_list;
232 0 : rid_all = zvrf->rid6_all_sorted_list;
233 0 : break;
234 : default:
235 : return;
236 : }
237 :
238 0 : router_id_get(afi, &before, zvrf);
239 :
240 0 : if (if_is_loopback(ifc->ifp))
241 : l = rid_lo;
242 : else
243 0 : l = rid_all;
244 :
245 0 : if ((c = router_id_find_node(l, ifc)))
246 0 : listnode_delete(l, c);
247 :
248 0 : router_id_get(afi, &after, zvrf);
249 :
250 0 : if (prefix_same(&before, &after))
251 : return;
252 :
253 0 : for (ALL_LIST_ELEMENTS_RO(zrouter.client_list, node, client))
254 0 : zsend_router_id_update(client, afi, &after, zvrf_id(zvrf));
255 : }
256 :
257 0 : void router_id_write(struct vty *vty, struct zebra_vrf *zvrf)
258 : {
259 0 : char space[2];
260 :
261 0 : memset(space, 0, sizeof(space));
262 :
263 0 : if (zvrf_id(zvrf) != VRF_DEFAULT)
264 0 : snprintf(space, sizeof(space), "%s", " ");
265 :
266 0 : if (zvrf->rid_user_assigned.u.prefix4.s_addr != INADDR_ANY) {
267 0 : vty_out(vty, "%sip router-id %pI4\n", space,
268 : &zvrf->rid_user_assigned.u.prefix4);
269 : }
270 0 : if (!router_id_v6_is_any(&zvrf->rid6_user_assigned)) {
271 0 : vty_out(vty, "%sipv6 router-id %pI6\n", space,
272 : &zvrf->rid_user_assigned.u.prefix6);
273 : }
274 0 : }
275 :
276 0 : DEFUN (ip_router_id,
277 : ip_router_id_cmd,
278 : "ip router-id A.B.C.D vrf NAME",
279 : IP_STR
280 : "Manually set the router-id\n"
281 : "IP address to use for router-id\n"
282 : VRF_CMD_HELP_STR)
283 : {
284 0 : int idx = 0;
285 0 : struct prefix rid;
286 0 : vrf_id_t vrf_id;
287 0 : struct zebra_vrf *zvrf;
288 :
289 0 : argv_find(argv, argc, "A.B.C.D", &idx);
290 :
291 0 : if (!inet_pton(AF_INET, argv[idx]->arg, &rid.u.prefix4))
292 : return CMD_WARNING_CONFIG_FAILED;
293 :
294 0 : rid.prefixlen = IPV4_MAX_BITLEN;
295 0 : rid.family = AF_INET;
296 :
297 0 : argv_find(argv, argc, "NAME", &idx);
298 0 : VRF_GET_ID(vrf_id, argv[idx]->arg, false);
299 :
300 0 : zvrf = vrf_info_lookup(vrf_id);
301 0 : router_id_set(AFI_IP, &rid, zvrf);
302 :
303 0 : return CMD_SUCCESS;
304 : }
305 :
306 : ALIAS (ip_router_id,
307 : router_id_cmd,
308 : "router-id A.B.C.D vrf NAME",
309 : "Manually set the router-id\n"
310 : "IP address to use for router-id\n"
311 : VRF_CMD_HELP_STR);
312 :
313 0 : DEFUN (ipv6_router_id,
314 : ipv6_router_id_cmd,
315 : "ipv6 router-id X:X::X:X vrf NAME",
316 : IPV6_STR
317 : "Manually set the router-id\n"
318 : "IPv6 address to use for router-id\n"
319 : VRF_CMD_HELP_STR)
320 : {
321 0 : int idx = 0;
322 0 : struct prefix rid;
323 0 : vrf_id_t vrf_id;
324 0 : struct zebra_vrf *zvrf;
325 :
326 0 : argv_find(argv, argc, "X:X::X:X", &idx);
327 :
328 0 : if (!inet_pton(AF_INET6, argv[idx]->arg, &rid.u.prefix6))
329 : return CMD_WARNING_CONFIG_FAILED;
330 :
331 0 : rid.prefixlen = IPV6_MAX_BITLEN;
332 0 : rid.family = AF_INET6;
333 :
334 0 : argv_find(argv, argc, "NAME", &idx);
335 0 : VRF_GET_ID(vrf_id, argv[idx]->arg, false);
336 :
337 0 : zvrf = vrf_info_lookup(vrf_id);
338 0 : router_id_set(AFI_IP6, &rid, zvrf);
339 :
340 0 : return CMD_SUCCESS;
341 : }
342 :
343 :
344 0 : DEFUN (ip_router_id_in_vrf,
345 : ip_router_id_in_vrf_cmd,
346 : "ip router-id A.B.C.D",
347 : IP_STR
348 : "Manually set the router-id\n"
349 : "IP address to use for router-id\n")
350 : {
351 0 : ZEBRA_DECLVAR_CONTEXT_VRF(vrf, zvrf);
352 0 : int idx = 0;
353 0 : struct prefix rid;
354 :
355 0 : argv_find(argv, argc, "A.B.C.D", &idx);
356 :
357 0 : if (!inet_pton(AF_INET, argv[idx]->arg, &rid.u.prefix4))
358 : return CMD_WARNING_CONFIG_FAILED;
359 :
360 0 : rid.prefixlen = IPV4_MAX_BITLEN;
361 0 : rid.family = AF_INET;
362 :
363 0 : router_id_set(AFI_IP, &rid, zvrf);
364 :
365 0 : return CMD_SUCCESS;
366 : }
367 :
368 : ALIAS (ip_router_id_in_vrf,
369 : router_id_in_vrf_cmd,
370 : "router-id A.B.C.D",
371 : "Manually set the router-id\n"
372 : "IP address to use for router-id\n");
373 :
374 0 : DEFUN (ipv6_router_id_in_vrf,
375 : ipv6_router_id_in_vrf_cmd,
376 : "ipv6 router-id X:X::X:X",
377 : IP6_STR
378 : "Manually set the IPv6 router-id\n"
379 : "IPV6 address to use for router-id\n")
380 : {
381 0 : ZEBRA_DECLVAR_CONTEXT_VRF(vrf, zvrf);
382 0 : int idx = 0;
383 0 : struct prefix rid;
384 :
385 0 : argv_find(argv, argc, "X:X::X:X", &idx);
386 :
387 0 : if (!inet_pton(AF_INET6, argv[idx]->arg, &rid.u.prefix6))
388 : return CMD_WARNING_CONFIG_FAILED;
389 :
390 0 : rid.prefixlen = IPV6_MAX_BITLEN;
391 0 : rid.family = AF_INET6;
392 :
393 0 : router_id_set(AFI_IP6, &rid, zvrf);
394 :
395 0 : return CMD_SUCCESS;
396 : }
397 :
398 0 : DEFUN (no_ip_router_id,
399 : no_ip_router_id_cmd,
400 : "no ip router-id [A.B.C.D vrf NAME]",
401 : NO_STR
402 : IP_STR
403 : "Remove the manually configured router-id\n"
404 : "IP address to use for router-id\n"
405 : VRF_CMD_HELP_STR)
406 : {
407 0 : int idx = 0;
408 0 : struct prefix rid;
409 0 : vrf_id_t vrf_id = VRF_DEFAULT;
410 0 : struct zebra_vrf *zvrf;
411 :
412 0 : rid.u.prefix4.s_addr = 0;
413 0 : rid.prefixlen = 0;
414 0 : rid.family = AF_INET;
415 :
416 0 : if (argv_find(argv, argc, "NAME", &idx))
417 0 : VRF_GET_ID(vrf_id, argv[idx]->arg, false);
418 :
419 0 : zvrf = vrf_info_lookup(vrf_id);
420 0 : router_id_set(AFI_IP, &rid, zvrf);
421 :
422 0 : return CMD_SUCCESS;
423 : }
424 :
425 : ALIAS (no_ip_router_id,
426 : no_router_id_cmd,
427 : "no router-id [A.B.C.D vrf NAME]",
428 : NO_STR
429 : "Remove the manually configured router-id\n"
430 : "IP address to use for router-id\n"
431 : VRF_CMD_HELP_STR);
432 :
433 0 : DEFUN (no_ipv6_router_id,
434 : no_ipv6_router_id_cmd,
435 : "no ipv6 router-id [X:X::X:X vrf NAME]",
436 : NO_STR
437 : IPV6_STR
438 : "Remove the manually configured IPv6 router-id\n"
439 : "IPv6 address to use for router-id\n"
440 : VRF_CMD_HELP_STR)
441 : {
442 0 : int idx = 0;
443 0 : struct prefix rid;
444 0 : vrf_id_t vrf_id = VRF_DEFAULT;
445 0 : struct zebra_vrf *zvrf;
446 :
447 0 : memset(&rid, 0, sizeof(rid));
448 0 : rid.family = AF_INET;
449 :
450 0 : if (argv_find(argv, argc, "NAME", &idx))
451 0 : VRF_GET_ID(vrf_id, argv[idx]->arg, false);
452 :
453 0 : zvrf = vrf_info_lookup(vrf_id);
454 0 : router_id_set(AFI_IP6, &rid, zvrf);
455 :
456 0 : return CMD_SUCCESS;
457 : }
458 :
459 0 : DEFUN (no_ip_router_id_in_vrf,
460 : no_ip_router_id_in_vrf_cmd,
461 : "no ip router-id [A.B.C.D]",
462 : NO_STR
463 : IP_STR
464 : "Remove the manually configured router-id\n"
465 : "IP address to use for router-id\n")
466 : {
467 0 : ZEBRA_DECLVAR_CONTEXT_VRF(vrf, zvrf);
468 :
469 0 : struct prefix rid;
470 :
471 0 : rid.u.prefix4.s_addr = 0;
472 0 : rid.prefixlen = 0;
473 0 : rid.family = AF_INET;
474 :
475 0 : router_id_set(AFI_IP, &rid, zvrf);
476 :
477 0 : return CMD_SUCCESS;
478 : }
479 :
480 : ALIAS (no_ip_router_id_in_vrf,
481 : no_router_id_in_vrf_cmd,
482 : "no router-id [A.B.C.D]",
483 : NO_STR
484 : "Remove the manually configured router-id\n"
485 : "IP address to use for router-id\n");
486 :
487 0 : DEFUN (no_ipv6_router_id_in_vrf,
488 : no_ipv6_router_id_in_vrf_cmd,
489 : "no ipv6 router-id [X:X::X:X]",
490 : NO_STR
491 : IP6_STR
492 : "Remove the manually configured IPv6 router-id\n"
493 : "IPv6 address to use for router-id\n")
494 : {
495 0 : ZEBRA_DECLVAR_CONTEXT_VRF(vrf, zvrf);
496 :
497 0 : struct prefix rid;
498 :
499 0 : memset(&rid, 0, sizeof(rid));
500 0 : rid.family = AF_INET;
501 :
502 0 : router_id_set(AFI_IP6, &rid, zvrf);
503 :
504 0 : return CMD_SUCCESS;
505 : }
506 :
507 0 : DEFUN (show_ip_router_id,
508 : show_ip_router_id_cmd,
509 : "show [ip|ipv6] router-id [vrf NAME]",
510 : SHOW_STR
511 : IP_STR
512 : IPV6_STR
513 : "Show the configured router-id\n"
514 : VRF_CMD_HELP_STR)
515 : {
516 0 : int idx = 0;
517 0 : vrf_id_t vrf_id = VRF_DEFAULT;
518 0 : struct zebra_vrf *zvrf;
519 0 : const char *vrf_name = "default";
520 0 : char addr_name[INET6_ADDRSTRLEN];
521 0 : int is_ipv6 = 0;
522 :
523 0 : is_ipv6 = argv_find(argv, argc, "ipv6", &idx);
524 :
525 0 : if (argv_find(argv, argc, "NAME", &idx)) {
526 0 : VRF_GET_ID(vrf_id, argv[idx]->arg, false);
527 0 : vrf_name = argv[idx]->arg;
528 : }
529 :
530 0 : zvrf = vrf_info_lookup(vrf_id);
531 :
532 0 : if (zvrf != NULL) {
533 0 : if (is_ipv6) {
534 0 : if (router_id_v6_is_any(&zvrf->rid6_user_assigned))
535 : return CMD_SUCCESS;
536 0 : inet_ntop(AF_INET6, &zvrf->rid6_user_assigned.u.prefix6,
537 : addr_name, sizeof(addr_name));
538 : } else {
539 0 : if (zvrf->rid_user_assigned.u.prefix4.s_addr
540 : == INADDR_ANY)
541 : return CMD_SUCCESS;
542 0 : inet_ntop(AF_INET, &zvrf->rid_user_assigned.u.prefix4,
543 : addr_name, sizeof(addr_name));
544 : }
545 :
546 0 : vty_out(vty, "zebra:\n");
547 0 : vty_out(vty, " router-id %s vrf %s\n", addr_name, vrf_name);
548 : }
549 :
550 : return CMD_SUCCESS;
551 : }
552 :
553 1 : static int router_id_cmp(void *a, void *b)
554 : {
555 1 : const struct connected *ifa = (const struct connected *)a;
556 1 : const struct connected *ifb = (const struct connected *)b;
557 :
558 1 : return IPV4_ADDR_CMP(&ifa->address->u.prefix4.s_addr,
559 : &ifb->address->u.prefix4.s_addr);
560 : }
561 :
562 0 : static int router_id_v6_cmp(void *a, void *b)
563 : {
564 0 : const struct connected *ifa = (const struct connected *)a;
565 0 : const struct connected *ifb = (const struct connected *)b;
566 :
567 0 : return IPV6_ADDR_CMP(&ifa->address->u.prefix6,
568 : &ifb->address->u.prefix6);
569 : }
570 :
571 4 : void router_id_cmd_init(void)
572 : {
573 4 : install_element(CONFIG_NODE, &ip_router_id_cmd);
574 4 : install_element(CONFIG_NODE, &router_id_cmd);
575 4 : install_element(CONFIG_NODE, &ipv6_router_id_cmd);
576 4 : install_element(CONFIG_NODE, &no_ip_router_id_cmd);
577 4 : install_element(CONFIG_NODE, &no_router_id_cmd);
578 4 : install_element(CONFIG_NODE, &ip_router_id_in_vrf_cmd);
579 4 : install_element(VRF_NODE, &ip_router_id_in_vrf_cmd);
580 4 : install_element(CONFIG_NODE, &router_id_in_vrf_cmd);
581 4 : install_element(VRF_NODE, &router_id_in_vrf_cmd);
582 4 : install_element(CONFIG_NODE, &ipv6_router_id_in_vrf_cmd);
583 4 : install_element(VRF_NODE, &ipv6_router_id_in_vrf_cmd);
584 4 : install_element(CONFIG_NODE, &no_ipv6_router_id_cmd);
585 4 : install_element(CONFIG_NODE, &no_ip_router_id_in_vrf_cmd);
586 4 : install_element(VRF_NODE, &no_ip_router_id_in_vrf_cmd);
587 4 : install_element(CONFIG_NODE, &no_router_id_in_vrf_cmd);
588 4 : install_element(VRF_NODE, &no_router_id_in_vrf_cmd);
589 4 : install_element(CONFIG_NODE, &no_ipv6_router_id_in_vrf_cmd);
590 4 : install_element(VRF_NODE, &no_ipv6_router_id_in_vrf_cmd);
591 4 : install_element(VIEW_NODE, &show_ip_router_id_cmd);
592 4 : }
593 :
594 4 : void router_id_init(struct zebra_vrf *zvrf)
595 : {
596 4 : zvrf->rid_all_sorted_list = &zvrf->_rid_all_sorted_list;
597 4 : zvrf->rid_lo_sorted_list = &zvrf->_rid_lo_sorted_list;
598 4 : zvrf->rid6_all_sorted_list = &zvrf->_rid6_all_sorted_list;
599 4 : zvrf->rid6_lo_sorted_list = &zvrf->_rid6_lo_sorted_list;
600 :
601 4 : memset(zvrf->rid_all_sorted_list, 0,
602 : sizeof(zvrf->_rid_all_sorted_list));
603 4 : memset(zvrf->rid_lo_sorted_list, 0, sizeof(zvrf->_rid_lo_sorted_list));
604 4 : memset(&zvrf->rid_user_assigned, 0, sizeof(zvrf->rid_user_assigned));
605 4 : memset(zvrf->rid6_all_sorted_list, 0,
606 : sizeof(zvrf->_rid6_all_sorted_list));
607 4 : memset(zvrf->rid6_lo_sorted_list, 0,
608 : sizeof(zvrf->_rid6_lo_sorted_list));
609 4 : memset(&zvrf->rid6_user_assigned, 0, sizeof(zvrf->rid6_user_assigned));
610 :
611 4 : zvrf->rid_all_sorted_list->cmp = router_id_cmp;
612 4 : zvrf->rid_lo_sorted_list->cmp = router_id_cmp;
613 4 : zvrf->rid6_all_sorted_list->cmp = router_id_v6_cmp;
614 4 : zvrf->rid6_lo_sorted_list->cmp = router_id_v6_cmp;
615 :
616 4 : zvrf->rid_user_assigned.family = AF_INET;
617 4 : zvrf->rid_user_assigned.prefixlen = IPV4_MAX_BITLEN;
618 4 : zvrf->rid6_user_assigned.family = AF_INET6;
619 4 : zvrf->rid6_user_assigned.prefixlen = IPV6_MAX_BITLEN;
620 4 : }
|