]> git.proxmox.com Git - mirror_frr.git/blob - zebra/redistribute.c
Merge pull request #1162 from opensourcerouting/clean_exit
[mirror_frr.git] / zebra / redistribute.c
1 /* Redistribution Handler
2 * Copyright (C) 1998 Kunihiro Ishiguro
3 *
4 * This file is part of GNU Zebra.
5 *
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #include <zebra.h>
22
23 #include "vector.h"
24 #include "vty.h"
25 #include "command.h"
26 #include "prefix.h"
27 #include "table.h"
28 #include "stream.h"
29 #include "zclient.h"
30 #include "linklist.h"
31 #include "log.h"
32 #include "vrf.h"
33 #include "srcdest_table.h"
34
35 #include "zebra/rib.h"
36 #include "zebra/zserv.h"
37 #include "zebra/zebra_ns.h"
38 #include "zebra/zebra_vrf.h"
39 #include "zebra/zebra_routemap.h"
40 #include "zebra/redistribute.h"
41 #include "zebra/debug.h"
42 #include "zebra/router-id.h"
43 #include "zebra/zebra_memory.h"
44 #include "zebra/zebra_vxlan.h"
45
46 #define ZEBRA_PTM_SUPPORT
47
48 /* array holding redistribute info about table redistribution */
49 /* bit AFI is set if that AFI is redistributing routes from this table */
50 static int zebra_import_table_used[AFI_MAX][ZEBRA_KERNEL_TABLE_MAX];
51 static u_int32_t zebra_import_table_distance[AFI_MAX][ZEBRA_KERNEL_TABLE_MAX];
52
53 int is_zebra_import_table_enabled(afi_t afi, u_int32_t table_id)
54 {
55 /*
56 * Make sure that what we are called with actualy makes sense
57 */
58 if (afi == AFI_MAX)
59 return 0;
60
61 if (is_zebra_valid_kernel_table(table_id))
62 return zebra_import_table_used[afi][table_id];
63 return 0;
64 }
65
66 static void zebra_redistribute_default(struct zserv *client, vrf_id_t vrf_id)
67 {
68 int afi;
69 struct prefix p;
70 struct route_table *table;
71 struct route_node *rn;
72 struct route_entry *newre;
73
74 for (afi = AFI_IP; afi <= AFI_IP6; afi++) {
75 /* Lookup table. */
76 table = zebra_vrf_table(afi, SAFI_UNICAST, vrf_id);
77 if (!table)
78 continue;
79
80 /* Lookup default route. */
81 memset(&p, 0, sizeof(p));
82 p.family = afi2family(afi);
83 rn = route_node_lookup(table, &p);
84 if (!rn)
85 continue;
86
87 RNODE_FOREACH_RE(rn, newre) {
88 if (CHECK_FLAG(newre->flags, ZEBRA_FLAG_SELECTED)
89 && newre->distance != DISTANCE_INFINITY)
90 zsend_redistribute_route(
91 ZEBRA_REDISTRIBUTE_ROUTE_ADD,
92 client, &rn->p, NULL, newre);
93 }
94
95 route_unlock_node(rn);
96 }
97 }
98
99 /* Redistribute routes. */
100 static void zebra_redistribute(struct zserv *client, int type, u_short instance,
101 vrf_id_t vrf_id, int afi)
102 {
103 struct route_entry *newre;
104 struct route_table *table;
105 struct route_node *rn;
106
107 table = zebra_vrf_table(afi, SAFI_UNICAST, vrf_id);
108 if (!table)
109 return;
110
111 for (rn = route_top(table); rn; rn = srcdest_route_next(rn))
112 RNODE_FOREACH_RE(rn, newre)
113 {
114 struct prefix *dst_p, *src_p;
115 srcdest_rnode_prefixes(rn, &dst_p, &src_p);
116
117 if (IS_ZEBRA_DEBUG_EVENT)
118 zlog_debug(
119 "%s: checking: selected=%d, type=%d, distance=%d, "
120 "zebra_check_addr=%d",
121 __func__,
122 CHECK_FLAG(newre->flags,
123 ZEBRA_FLAG_SELECTED),
124 newre->type, newre->distance,
125 zebra_check_addr(dst_p));
126
127 if (!CHECK_FLAG(newre->flags, ZEBRA_FLAG_SELECTED))
128 continue;
129 if ((type != ZEBRA_ROUTE_ALL
130 && (newre->type != type
131 || newre->instance != instance)))
132 continue;
133 if (newre->distance == DISTANCE_INFINITY)
134 continue;
135 if (!zebra_check_addr(dst_p))
136 continue;
137
138 zsend_redistribute_route(ZEBRA_REDISTRIBUTE_ROUTE_ADD,
139 client, dst_p, src_p, newre);
140 }
141 }
142
143 /* Either advertise a route for redistribution to registered clients or */
144 /* withdraw redistribution if add cannot be done for client */
145 void redistribute_update(struct prefix *p, struct prefix *src_p,
146 struct route_entry *re, struct route_entry *prev_re)
147 {
148 struct listnode *node, *nnode;
149 struct zserv *client;
150 int send_redistribute;
151 int afi;
152 char buf[INET6_ADDRSTRLEN];
153
154 if (IS_ZEBRA_DEBUG_RIB) {
155 inet_ntop(p->family, &p->u.prefix, buf, INET6_ADDRSTRLEN);
156 zlog_debug(
157 "%u:%s/%d: Redist update re %p (type %d), old %p (type %d)",
158 re->vrf_id, buf, p->prefixlen, re, re->type, prev_re,
159 prev_re ? prev_re->type : -1);
160 }
161
162 afi = family2afi(p->family);
163 if (!afi) {
164 zlog_warn("%s: Unknown AFI/SAFI prefix received\n",
165 __FUNCTION__);
166 return;
167 }
168
169 for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client)) {
170 send_redistribute = 0;
171
172 if (is_default_prefix(p)
173 && vrf_bitmap_check(client->redist_default, re->vrf_id))
174 send_redistribute = 1;
175 else if (vrf_bitmap_check(client->redist[afi][ZEBRA_ROUTE_ALL],
176 re->vrf_id))
177 send_redistribute = 1;
178 else if (re->instance
179 && redist_check_instance(
180 &client->mi_redist[afi][re->type],
181 re->instance))
182 send_redistribute = 1;
183 else if (vrf_bitmap_check(client->redist[afi][re->type],
184 re->vrf_id))
185 send_redistribute = 1;
186
187 if (send_redistribute) {
188 zsend_redistribute_route(ZEBRA_REDISTRIBUTE_ROUTE_ADD,
189 client, p, src_p, re);
190 } else if (prev_re
191 && ((re->instance
192 && redist_check_instance(
193 &client->mi_redist[afi]
194 [prev_re->type],
195 re->instance))
196 || vrf_bitmap_check(
197 client->redist[afi][prev_re->type],
198 re->vrf_id))) {
199 zsend_redistribute_route(ZEBRA_REDISTRIBUTE_ROUTE_DEL,
200 client, p, src_p, prev_re);
201 }
202 }
203 }
204
205 void redistribute_delete(struct prefix *p, struct prefix *src_p,
206 struct route_entry *re)
207 {
208 struct listnode *node, *nnode;
209 struct zserv *client;
210 char buf[INET6_ADDRSTRLEN];
211 int afi;
212
213 if (IS_ZEBRA_DEBUG_RIB) {
214 inet_ntop(p->family, &p->u.prefix, buf, INET6_ADDRSTRLEN);
215 zlog_debug("%u:%s/%d: Redist delete re %p (type %d)",
216 re->vrf_id, buf, p->prefixlen, re, re->type);
217 }
218
219 /* Add DISTANCE_INFINITY check. */
220 if (re->distance == DISTANCE_INFINITY)
221 return;
222
223 afi = family2afi(p->family);
224 if (!afi) {
225 zlog_warn("%s: Unknown AFI/SAFI prefix received\n",
226 __FUNCTION__);
227 return;
228 }
229
230 for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client)) {
231 if ((is_default_prefix(p)
232 && vrf_bitmap_check(client->redist_default, re->vrf_id))
233 || vrf_bitmap_check(client->redist[afi][ZEBRA_ROUTE_ALL],
234 re->vrf_id)
235 || (re->instance
236 && redist_check_instance(
237 &client->mi_redist[afi][re->type],
238 re->instance))
239 || vrf_bitmap_check(client->redist[afi][re->type],
240 re->vrf_id)) {
241 zsend_redistribute_route(ZEBRA_REDISTRIBUTE_ROUTE_DEL,
242 client, p, src_p, re);
243 }
244 }
245 }
246
247 void zebra_redistribute_add(int command, struct zserv *client, int length,
248 struct zebra_vrf *zvrf)
249 {
250 afi_t afi;
251 int type;
252 u_short instance;
253
254 afi = stream_getc(client->ibuf);
255 type = stream_getc(client->ibuf);
256 instance = stream_getw(client->ibuf);
257
258 if (type == 0 || type >= ZEBRA_ROUTE_MAX)
259 return;
260
261 if (instance) {
262 if (!redist_check_instance(&client->mi_redist[afi][type],
263 instance)) {
264 redist_add_instance(&client->mi_redist[afi][type],
265 instance);
266 zebra_redistribute(client, type, instance,
267 zvrf_id(zvrf), afi);
268 }
269 } else {
270 if (!vrf_bitmap_check(client->redist[afi][type],
271 zvrf_id(zvrf))) {
272 vrf_bitmap_set(client->redist[afi][type],
273 zvrf_id(zvrf));
274 zebra_redistribute(client, type, 0, zvrf_id(zvrf), afi);
275 }
276 }
277 }
278
279 void zebra_redistribute_delete(int command, struct zserv *client, int length,
280 struct zebra_vrf *zvrf)
281 {
282 afi_t afi;
283 int type;
284 u_short instance;
285
286 afi = stream_getc(client->ibuf);
287 type = stream_getc(client->ibuf);
288 instance = stream_getw(client->ibuf);
289
290 if (type == 0 || type >= ZEBRA_ROUTE_MAX)
291 return;
292
293 /*
294 * NOTE: no need to withdraw the previously advertised routes. The
295 * clients
296 * themselves should keep track of the received routes from zebra and
297 * withdraw them when necessary.
298 */
299 if (instance)
300 redist_del_instance(&client->mi_redist[afi][type], instance);
301 else
302 vrf_bitmap_unset(client->redist[afi][type], zvrf_id(zvrf));
303 }
304
305 void zebra_redistribute_default_add(int command, struct zserv *client,
306 int length, struct zebra_vrf *zvrf)
307 {
308 vrf_bitmap_set(client->redist_default, zvrf_id(zvrf));
309 zebra_redistribute_default(client, zvrf_id(zvrf));
310 }
311
312 void zebra_redistribute_default_delete(int command, struct zserv *client,
313 int length, struct zebra_vrf *zvrf)
314 {
315 vrf_bitmap_unset(client->redist_default, zvrf_id(zvrf));
316 }
317
318 /* Interface up information. */
319 void zebra_interface_up_update(struct interface *ifp)
320 {
321 struct listnode *node, *nnode;
322 struct zserv *client;
323
324 if (IS_ZEBRA_DEBUG_EVENT)
325 zlog_debug("MESSAGE: ZEBRA_INTERFACE_UP %s", ifp->name);
326
327 if (ifp->ptm_status || !ifp->ptm_enable) {
328 for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client))
329 if (client->ifinfo) {
330 zsend_interface_update(ZEBRA_INTERFACE_UP,
331 client, ifp);
332 zsend_interface_link_params(client, ifp);
333 }
334 }
335 }
336
337 /* Interface down information. */
338 void zebra_interface_down_update(struct interface *ifp)
339 {
340 struct listnode *node, *nnode;
341 struct zserv *client;
342
343 if (IS_ZEBRA_DEBUG_EVENT)
344 zlog_debug("MESSAGE: ZEBRA_INTERFACE_DOWN %s", ifp->name);
345
346 for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client)) {
347 zsend_interface_update(ZEBRA_INTERFACE_DOWN, client, ifp);
348 }
349 }
350
351 /* Interface information update. */
352 void zebra_interface_add_update(struct interface *ifp)
353 {
354 struct listnode *node, *nnode;
355 struct zserv *client;
356
357 if (IS_ZEBRA_DEBUG_EVENT)
358 zlog_debug("MESSAGE: ZEBRA_INTERFACE_ADD %s[%d]", ifp->name,
359 ifp->vrf_id);
360
361 for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client))
362 if (client->ifinfo) {
363 client->ifadd_cnt++;
364 zsend_interface_add(client, ifp);
365 zsend_interface_link_params(client, ifp);
366 }
367 }
368
369 void zebra_interface_delete_update(struct interface *ifp)
370 {
371 struct listnode *node, *nnode;
372 struct zserv *client;
373
374 if (IS_ZEBRA_DEBUG_EVENT)
375 zlog_debug("MESSAGE: ZEBRA_INTERFACE_DELETE %s", ifp->name);
376
377 for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client)) {
378 client->ifdel_cnt++;
379 zsend_interface_delete(client, ifp);
380 }
381 }
382
383 /* Interface address addition. */
384 void zebra_interface_address_add_update(struct interface *ifp,
385 struct connected *ifc)
386 {
387 struct listnode *node, *nnode;
388 struct zserv *client;
389 struct prefix *p;
390
391 if (IS_ZEBRA_DEBUG_EVENT) {
392 char buf[PREFIX_STRLEN];
393
394 p = ifc->address;
395 zlog_debug("MESSAGE: ZEBRA_INTERFACE_ADDRESS_ADD %s on %s",
396 prefix2str(p, buf, sizeof(buf)), ifc->ifp->name);
397 }
398
399 if (!CHECK_FLAG(ifc->conf, ZEBRA_IFC_REAL))
400 zlog_warn(
401 "WARNING: advertising address to clients that is not yet usable.");
402
403 zebra_vxlan_add_del_gw_macip(ifp, ifc->address, 1);
404
405 router_id_add_address(ifc);
406
407 for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client))
408 if (CHECK_FLAG(ifc->conf, ZEBRA_IFC_REAL)) {
409 client->connected_rt_add_cnt++;
410 zsend_interface_address(ZEBRA_INTERFACE_ADDRESS_ADD,
411 client, ifp, ifc);
412 }
413 }
414
415 /* Interface address deletion. */
416 void zebra_interface_address_delete_update(struct interface *ifp,
417 struct connected *ifc)
418 {
419 struct listnode *node, *nnode;
420 struct zserv *client;
421 struct prefix *p;
422
423 if (IS_ZEBRA_DEBUG_EVENT) {
424 char buf[PREFIX_STRLEN];
425
426 p = ifc->address;
427 zlog_debug("MESSAGE: ZEBRA_INTERFACE_ADDRESS_DELETE %s on %s",
428 prefix2str(p, buf, sizeof(buf)), ifc->ifp->name);
429 }
430
431 zebra_vxlan_add_del_gw_macip(ifp, ifc->address, 0);
432
433 router_id_del_address(ifc);
434
435 for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client))
436 if (CHECK_FLAG(ifc->conf, ZEBRA_IFC_REAL)) {
437 client->connected_rt_del_cnt++;
438 zsend_interface_address(ZEBRA_INTERFACE_ADDRESS_DELETE,
439 client, ifp, ifc);
440 }
441 }
442
443 /* Interface VRF change. May need to delete from clients not interested in
444 * the new VRF. Note that this function is invoked *prior* to the VRF change.
445 */
446 void zebra_interface_vrf_update_del(struct interface *ifp, vrf_id_t new_vrf_id)
447 {
448 struct listnode *node, *nnode;
449 struct zserv *client;
450
451 if (IS_ZEBRA_DEBUG_EVENT)
452 zlog_debug(
453 "MESSAGE: ZEBRA_INTERFACE_VRF_UPDATE/DEL %s VRF Id %u -> %u",
454 ifp->name, ifp->vrf_id, new_vrf_id);
455
456 for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client)) {
457 /* Need to delete if the client is not interested in the new
458 * VRF. */
459 zsend_interface_update(ZEBRA_INTERFACE_DOWN, client, ifp);
460 client->ifdel_cnt++;
461 zsend_interface_delete(client, ifp);
462 zsend_interface_vrf_update(client, ifp, new_vrf_id);
463 }
464 }
465
466 /* Interface VRF change. This function is invoked *post* VRF change and sends an
467 * add to clients who are interested in the new VRF but not in the old VRF.
468 */
469 void zebra_interface_vrf_update_add(struct interface *ifp, vrf_id_t old_vrf_id)
470 {
471 struct listnode *node, *nnode;
472 struct zserv *client;
473
474 if (IS_ZEBRA_DEBUG_EVENT)
475 zlog_debug(
476 "MESSAGE: ZEBRA_INTERFACE_VRF_UPDATE/ADD %s VRF Id %u -> %u",
477 ifp->name, old_vrf_id, ifp->vrf_id);
478
479 for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client)) {
480 /* Need to add if the client is interested in the new VRF. */
481 client->ifadd_cnt++;
482 zsend_interface_add(client, ifp);
483 zsend_interface_addresses(client, ifp);
484 }
485 }
486
487 int zebra_add_import_table_entry(struct route_node *rn, struct route_entry *re,
488 const char *rmap_name)
489 {
490 struct route_entry *newre;
491 struct route_entry *same;
492 struct prefix p;
493 route_map_result_t ret = RMAP_MATCH;
494 afi_t afi;
495
496 afi = family2afi(rn->p.family);
497 if (rmap_name)
498 ret = zebra_import_table_route_map_check(
499 afi, re->type, &rn->p, re->nexthop, re->vrf_id,
500 re->tag, rmap_name);
501
502 if (ret != RMAP_MATCH) {
503 zebra_del_import_table_entry(rn, re);
504 return 0;
505 }
506
507 prefix_copy(&p, &rn->p);
508
509 RNODE_FOREACH_RE(rn, same)
510 {
511 if (CHECK_FLAG(same->status,
512 ROUTE_ENTRY_REMOVED))
513 continue;
514
515 if (same->type == re->type
516 && same->instance == re->instance
517 && same->table == re->table
518 && same->type != ZEBRA_ROUTE_CONNECT)
519 break;
520 }
521
522 if (same)
523 zebra_del_import_table_entry(rn, same);
524
525 if (re->nexthop_num == 1) {
526 rib_add(afi, SAFI_UNICAST, re->vrf_id,
527 ZEBRA_ROUTE_TABLE, re->table, 0, &p,
528 NULL, re->nexthop,
529 zebrad.rtm_table_default, re->metric,
530 re->mtu,
531 zebra_import_table_distance[afi]
532 [re->table]);
533 } else if (re->nexthop_num > 1) {
534 newre = XCALLOC(MTYPE_RE,
535 sizeof(struct route_entry));
536 newre->type = ZEBRA_ROUTE_TABLE;
537 newre->distance =
538 zebra_import_table_distance[afi][re->table];
539 newre->flags = re->flags;
540 newre->metric = re->metric;
541 newre->mtu = re->mtu;
542 newre->table = zebrad.rtm_table_default;
543 newre->nexthop_num = 0;
544 newre->uptime = time(NULL);
545 newre->instance = re->table;
546 route_entry_copy_nexthops(newre, re->nexthop);
547
548 rib_add_multipath(afi, SAFI_UNICAST, &p,
549 NULL, newre);
550 }
551 return 0;
552 }
553
554 int zebra_del_import_table_entry(struct route_node *rn, struct route_entry *re)
555 {
556 struct prefix p;
557 afi_t afi;
558
559 afi = family2afi(rn->p.family);
560 prefix_copy(&p, &rn->p);
561
562 rib_delete(afi, SAFI_UNICAST, re->vrf_id, ZEBRA_ROUTE_TABLE,
563 re->table, re->flags, &p, NULL, NULL,
564 zebrad.rtm_table_default, re->metric);
565
566 return 0;
567 }
568
569 /* Assuming no one calls this with the main routing table */
570 int zebra_import_table(afi_t afi, u_int32_t table_id, u_int32_t distance,
571 const char *rmap_name, int add)
572 {
573 struct route_table *table;
574 struct route_entry *re;
575 struct route_node *rn;
576
577 if (!is_zebra_valid_kernel_table(table_id)
578 || ((table_id == RT_TABLE_MAIN)
579 || (table_id == zebrad.rtm_table_default)))
580 return (-1);
581
582 if (afi >= AFI_MAX)
583 return (-1);
584
585 table = zebra_vrf_other_route_table(afi, table_id, VRF_DEFAULT);
586 if (table == NULL) {
587 return 0;
588 } else if (IS_ZEBRA_DEBUG_RIB) {
589 zlog_debug("%s routes from table %d",
590 add ? "Importing" : "Unimporting", table_id);
591 }
592
593 if (add) {
594 if (rmap_name)
595 zebra_add_import_table_route_map(afi, rmap_name,
596 table_id);
597 else {
598 rmap_name =
599 zebra_get_import_table_route_map(afi, table_id);
600 if (rmap_name)
601 zebra_del_import_table_route_map(afi, table_id);
602 }
603
604 zebra_import_table_used[afi][table_id] = 1;
605 zebra_import_table_distance[afi][table_id] = distance;
606 } else {
607 zebra_import_table_used[afi][table_id] = 0;
608 zebra_import_table_distance[afi][table_id] =
609 ZEBRA_TABLE_DISTANCE_DEFAULT;
610
611 rmap_name = zebra_get_import_table_route_map(afi, table_id);
612 if (rmap_name)
613 zebra_del_import_table_route_map(afi, table_id);
614 }
615
616 for (rn = route_top(table); rn; rn = route_next(rn)) {
617 /* For each entry in the non-default routing table,
618 * add the entry in the main table
619 */
620 if (!rn->info)
621 continue;
622
623 RNODE_FOREACH_RE(rn, re)
624 {
625 if (CHECK_FLAG(re->status, ROUTE_ENTRY_REMOVED))
626 continue;
627 break;
628 }
629
630 if (!re)
631 continue;
632
633 if (((afi == AFI_IP) && (rn->p.family == AF_INET))
634 || ((afi == AFI_IP6) && (rn->p.family == AF_INET6))) {
635 if (add)
636 zebra_add_import_table_entry(rn, re, rmap_name);
637 else
638 zebra_del_import_table_entry(rn, re);
639 }
640 }
641 return 0;
642 }
643
644 int zebra_import_table_config(struct vty *vty)
645 {
646 int i;
647 afi_t afi;
648 int write = 0;
649 char afi_str[AFI_MAX][10] = {"", "ip", "ipv6", "ethernet"};
650 const char *rmap_name;
651
652 for (afi = AFI_IP; afi < AFI_MAX; afi++) {
653 for (i = 1; i < ZEBRA_KERNEL_TABLE_MAX; i++) {
654 if (!is_zebra_import_table_enabled(afi, i))
655 continue;
656
657 if (zebra_import_table_distance[afi][i]
658 != ZEBRA_TABLE_DISTANCE_DEFAULT) {
659 vty_out(vty,
660 "%s import-table %d distance %d",
661 afi_str[afi], i,
662 zebra_import_table_distance[afi][i]);
663 } else {
664 vty_out(vty, "%s import-table %d",
665 afi_str[afi], i);
666 }
667
668 rmap_name = zebra_get_import_table_route_map(afi, i);
669 if (rmap_name)
670 vty_out(vty, " route-map %s",
671 rmap_name);
672
673 vty_out(vty, "\n");
674 write = 1;
675 }
676 }
677
678 return write;
679 }
680
681 void zebra_import_table_rm_update()
682 {
683 afi_t afi;
684 int i;
685 struct route_table *table;
686 struct route_entry *re;
687 struct route_node *rn;
688 const char *rmap_name;
689
690 for (afi = AFI_IP; afi < AFI_MAX; afi++) {
691 for (i = 1; i < ZEBRA_KERNEL_TABLE_MAX; i++) {
692 if (!is_zebra_import_table_enabled(afi, i))
693 continue;
694
695 rmap_name = zebra_get_import_table_route_map(afi, i);
696 if (!rmap_name)
697 return;
698
699 table = zebra_vrf_other_route_table(afi,
700 i,
701 VRF_DEFAULT);
702 for (rn = route_top(table); rn;
703 rn = route_next(rn)) {
704 /* For each entry in the non-default
705 * routing table,
706 * add the entry in the main table
707 */
708 if (!rn->info)
709 continue;
710
711 RNODE_FOREACH_RE(rn, re)
712 {
713 if (CHECK_FLAG(
714 re->status,
715 ROUTE_ENTRY_REMOVED))
716 continue;
717 break;
718 }
719
720 if (!re)
721 continue;
722
723 if (((afi == AFI_IP)
724 && (rn->p.family == AF_INET))
725 || ((afi == AFI_IP6)
726 && (rn->p.family == AF_INET6)))
727 zebra_add_import_table_entry(
728 rn, re, rmap_name);
729 }
730 }
731 }
732
733 return;
734 }
735
736 /* Interface parameters update */
737 void zebra_interface_parameters_update(struct interface *ifp)
738 {
739 struct listnode *node, *nnode;
740 struct zserv *client;
741
742 if (IS_ZEBRA_DEBUG_EVENT)
743 zlog_debug("MESSAGE: ZEBRA_INTERFACE_LINK_PARAMS %s",
744 ifp->name);
745
746 for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client))
747 if (client->ifinfo)
748 zsend_interface_link_params(client, ifp);
749 }