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