]> git.proxmox.com Git - mirror_frr.git/blob - zebra/redistribute.c
Merge pull request #1210 from opensourcerouting/misc-mpls-bgp-lu-fixes
[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, client,
92 &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 struct prefix *dst_p, *src_p;
114 srcdest_rnode_prefixes(rn, &dst_p, &src_p);
115
116 if (IS_ZEBRA_DEBUG_EVENT)
117 zlog_debug(
118 "%s: checking: selected=%d, type=%d, distance=%d, "
119 "zebra_check_addr=%d",
120 __func__,
121 CHECK_FLAG(newre->flags,
122 ZEBRA_FLAG_SELECTED),
123 newre->type, newre->distance,
124 zebra_check_addr(dst_p));
125
126 if (!CHECK_FLAG(newre->flags, ZEBRA_FLAG_SELECTED))
127 continue;
128 if ((type != ZEBRA_ROUTE_ALL
129 && (newre->type != type
130 || newre->instance != instance)))
131 continue;
132 if (newre->distance == DISTANCE_INFINITY)
133 continue;
134 if (!zebra_check_addr(dst_p))
135 continue;
136
137 zsend_redistribute_route(ZEBRA_REDISTRIBUTE_ROUTE_ADD,
138 client, dst_p, src_p, newre);
139 }
140 }
141
142 /* Either advertise a route for redistribution to registered clients or */
143 /* withdraw redistribution if add cannot be done for client */
144 void redistribute_update(struct prefix *p, struct prefix *src_p,
145 struct route_entry *re, struct route_entry *prev_re)
146 {
147 struct listnode *node, *nnode;
148 struct zserv *client;
149 int send_redistribute;
150 int afi;
151 char buf[INET6_ADDRSTRLEN];
152
153 if (IS_ZEBRA_DEBUG_RIB) {
154 inet_ntop(p->family, &p->u.prefix, buf, INET6_ADDRSTRLEN);
155 zlog_debug(
156 "%u:%s/%d: Redist update re %p (type %d), old %p (type %d)",
157 re->vrf_id, buf, p->prefixlen, re, re->type, prev_re,
158 prev_re ? prev_re->type : -1);
159 }
160
161 afi = family2afi(p->family);
162 if (!afi) {
163 zlog_warn("%s: Unknown AFI/SAFI prefix received\n",
164 __FUNCTION__);
165 return;
166 }
167
168 for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client)) {
169 send_redistribute = 0;
170
171 if (is_default_prefix(p)
172 && vrf_bitmap_check(client->redist_default, re->vrf_id))
173 send_redistribute = 1;
174 else if (vrf_bitmap_check(client->redist[afi][ZEBRA_ROUTE_ALL],
175 re->vrf_id))
176 send_redistribute = 1;
177 else if (re->instance
178 && redist_check_instance(
179 &client->mi_redist[afi][re->type],
180 re->instance))
181 send_redistribute = 1;
182 else if (vrf_bitmap_check(client->redist[afi][re->type],
183 re->vrf_id))
184 send_redistribute = 1;
185
186 if (send_redistribute) {
187 zsend_redistribute_route(ZEBRA_REDISTRIBUTE_ROUTE_ADD,
188 client, p, src_p, re);
189 } else if (prev_re
190 && ((re->instance
191 && redist_check_instance(
192 &client->mi_redist[afi]
193 [prev_re->type],
194 re->instance))
195 || vrf_bitmap_check(
196 client->redist[afi][prev_re->type],
197 re->vrf_id))) {
198 zsend_redistribute_route(ZEBRA_REDISTRIBUTE_ROUTE_DEL,
199 client, p, src_p, prev_re);
200 }
201 }
202 }
203
204 void redistribute_delete(struct prefix *p, struct prefix *src_p,
205 struct route_entry *re)
206 {
207 struct listnode *node, *nnode;
208 struct zserv *client;
209 char buf[INET6_ADDRSTRLEN];
210 int afi;
211
212 if (IS_ZEBRA_DEBUG_RIB) {
213 inet_ntop(p->family, &p->u.prefix, buf, INET6_ADDRSTRLEN);
214 zlog_debug("%u:%s/%d: Redist delete re %p (type %d)",
215 re->vrf_id, buf, p->prefixlen, re, re->type);
216 }
217
218 /* Add DISTANCE_INFINITY check. */
219 if (re->distance == DISTANCE_INFINITY)
220 return;
221
222 afi = family2afi(p->family);
223 if (!afi) {
224 zlog_warn("%s: Unknown AFI/SAFI prefix received\n",
225 __FUNCTION__);
226 return;
227 }
228
229 for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client)) {
230 if ((is_default_prefix(p)
231 && vrf_bitmap_check(client->redist_default, re->vrf_id))
232 || vrf_bitmap_check(client->redist[afi][ZEBRA_ROUTE_ALL],
233 re->vrf_id)
234 || (re->instance
235 && redist_check_instance(
236 &client->mi_redist[afi][re->type],
237 re->instance))
238 || vrf_bitmap_check(client->redist[afi][re->type],
239 re->vrf_id)) {
240 zsend_redistribute_route(ZEBRA_REDISTRIBUTE_ROUTE_DEL,
241 client, p, src_p, re);
242 }
243 }
244 }
245
246 void zebra_redistribute_add(int command, struct zserv *client, int length,
247 struct zebra_vrf *zvrf)
248 {
249 afi_t afi;
250 int type;
251 u_short instance;
252
253 afi = stream_getc(client->ibuf);
254 type = stream_getc(client->ibuf);
255 instance = stream_getw(client->ibuf);
256
257 if (type == 0 || type >= ZEBRA_ROUTE_MAX)
258 return;
259
260 if (instance) {
261 if (!redist_check_instance(&client->mi_redist[afi][type],
262 instance)) {
263 redist_add_instance(&client->mi_redist[afi][type],
264 instance);
265 zebra_redistribute(client, type, instance,
266 zvrf_id(zvrf), afi);
267 }
268 } else {
269 if (!vrf_bitmap_check(client->redist[afi][type],
270 zvrf_id(zvrf))) {
271 vrf_bitmap_set(client->redist[afi][type],
272 zvrf_id(zvrf));
273 zebra_redistribute(client, type, 0, zvrf_id(zvrf), afi);
274 }
275 }
276 }
277
278 void zebra_redistribute_delete(int command, struct zserv *client, int length,
279 struct zebra_vrf *zvrf)
280 {
281 afi_t afi;
282 int type;
283 u_short instance;
284
285 afi = stream_getc(client->ibuf);
286 type = stream_getc(client->ibuf);
287 instance = stream_getw(client->ibuf);
288
289 if (type == 0 || type >= ZEBRA_ROUTE_MAX)
290 return;
291
292 /*
293 * NOTE: no need to withdraw the previously advertised routes. The
294 * clients
295 * themselves should keep track of the received routes from zebra and
296 * withdraw them when necessary.
297 */
298 if (instance)
299 redist_del_instance(&client->mi_redist[afi][type], instance);
300 else
301 vrf_bitmap_unset(client->redist[afi][type], zvrf_id(zvrf));
302 }
303
304 void zebra_redistribute_default_add(int command, struct zserv *client,
305 int length, struct zebra_vrf *zvrf)
306 {
307 vrf_bitmap_set(client->redist_default, zvrf_id(zvrf));
308 zebra_redistribute_default(client, zvrf_id(zvrf));
309 }
310
311 void zebra_redistribute_default_delete(int command, struct zserv *client,
312 int length, struct zebra_vrf *zvrf)
313 {
314 vrf_bitmap_unset(client->redist_default, zvrf_id(zvrf));
315 }
316
317 /* Interface up information. */
318 void zebra_interface_up_update(struct interface *ifp)
319 {
320 struct listnode *node, *nnode;
321 struct zserv *client;
322
323 if (IS_ZEBRA_DEBUG_EVENT)
324 zlog_debug("MESSAGE: ZEBRA_INTERFACE_UP %s", ifp->name);
325
326 if (ifp->ptm_status || !ifp->ptm_enable) {
327 for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client))
328 if (client->ifinfo) {
329 zsend_interface_update(ZEBRA_INTERFACE_UP,
330 client, ifp);
331 zsend_interface_link_params(client, ifp);
332 }
333 }
334 }
335
336 /* Interface down information. */
337 void zebra_interface_down_update(struct interface *ifp)
338 {
339 struct listnode *node, *nnode;
340 struct zserv *client;
341
342 if (IS_ZEBRA_DEBUG_EVENT)
343 zlog_debug("MESSAGE: ZEBRA_INTERFACE_DOWN %s", ifp->name);
344
345 for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client)) {
346 zsend_interface_update(ZEBRA_INTERFACE_DOWN, client, ifp);
347 }
348 }
349
350 /* Interface information update. */
351 void zebra_interface_add_update(struct interface *ifp)
352 {
353 struct listnode *node, *nnode;
354 struct zserv *client;
355
356 if (IS_ZEBRA_DEBUG_EVENT)
357 zlog_debug("MESSAGE: ZEBRA_INTERFACE_ADD %s[%d]", ifp->name,
358 ifp->vrf_id);
359
360 for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client))
361 if (client->ifinfo) {
362 client->ifadd_cnt++;
363 zsend_interface_add(client, ifp);
364 zsend_interface_link_params(client, ifp);
365 }
366 }
367
368 void zebra_interface_delete_update(struct interface *ifp)
369 {
370 struct listnode *node, *nnode;
371 struct zserv *client;
372
373 if (IS_ZEBRA_DEBUG_EVENT)
374 zlog_debug("MESSAGE: ZEBRA_INTERFACE_DELETE %s", ifp->name);
375
376 for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client)) {
377 client->ifdel_cnt++;
378 zsend_interface_delete(client, ifp);
379 }
380 }
381
382 /* Interface address addition. */
383 void zebra_interface_address_add_update(struct interface *ifp,
384 struct connected *ifc)
385 {
386 struct listnode *node, *nnode;
387 struct zserv *client;
388 struct prefix *p;
389
390 if (IS_ZEBRA_DEBUG_EVENT) {
391 char buf[PREFIX_STRLEN];
392
393 p = ifc->address;
394 zlog_debug("MESSAGE: ZEBRA_INTERFACE_ADDRESS_ADD %s on %s",
395 prefix2str(p, buf, sizeof(buf)), ifc->ifp->name);
396 }
397
398 if (!CHECK_FLAG(ifc->conf, ZEBRA_IFC_REAL))
399 zlog_warn(
400 "WARNING: advertising address to clients that is not yet usable.");
401
402 zebra_vxlan_add_del_gw_macip(ifp, ifc->address, 1);
403
404 router_id_add_address(ifc);
405
406 for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client))
407 if (CHECK_FLAG(ifc->conf, ZEBRA_IFC_REAL)) {
408 client->connected_rt_add_cnt++;
409 zsend_interface_address(ZEBRA_INTERFACE_ADDRESS_ADD,
410 client, ifp, ifc);
411 }
412 }
413
414 /* Interface address deletion. */
415 void zebra_interface_address_delete_update(struct interface *ifp,
416 struct connected *ifc)
417 {
418 struct listnode *node, *nnode;
419 struct zserv *client;
420 struct prefix *p;
421
422 if (IS_ZEBRA_DEBUG_EVENT) {
423 char buf[PREFIX_STRLEN];
424
425 p = ifc->address;
426 zlog_debug("MESSAGE: ZEBRA_INTERFACE_ADDRESS_DELETE %s on %s",
427 prefix2str(p, buf, sizeof(buf)), ifc->ifp->name);
428 }
429
430 zebra_vxlan_add_del_gw_macip(ifp, ifc->address, 0);
431
432 router_id_del_address(ifc);
433
434 for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client))
435 if (CHECK_FLAG(ifc->conf, ZEBRA_IFC_REAL)) {
436 client->connected_rt_del_cnt++;
437 zsend_interface_address(ZEBRA_INTERFACE_ADDRESS_DELETE,
438 client, ifp, ifc);
439 }
440 }
441
442 /* Interface VRF change. May need to delete from clients not interested in
443 * the new VRF. Note that this function is invoked *prior* to the VRF change.
444 */
445 void zebra_interface_vrf_update_del(struct interface *ifp, vrf_id_t new_vrf_id)
446 {
447 struct listnode *node, *nnode;
448 struct zserv *client;
449
450 if (IS_ZEBRA_DEBUG_EVENT)
451 zlog_debug(
452 "MESSAGE: ZEBRA_INTERFACE_VRF_UPDATE/DEL %s VRF Id %u -> %u",
453 ifp->name, ifp->vrf_id, new_vrf_id);
454
455 for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client)) {
456 /* Need to delete if the client is not interested in the new
457 * VRF. */
458 zsend_interface_update(ZEBRA_INTERFACE_DOWN, client, ifp);
459 client->ifdel_cnt++;
460 zsend_interface_delete(client, ifp);
461 zsend_interface_vrf_update(client, ifp, new_vrf_id);
462 }
463 }
464
465 /* Interface VRF change. This function is invoked *post* VRF change and sends an
466 * add to clients who are interested in the new VRF but not in the old VRF.
467 */
468 void zebra_interface_vrf_update_add(struct interface *ifp, vrf_id_t old_vrf_id)
469 {
470 struct listnode *node, *nnode;
471 struct zserv *client;
472
473 if (IS_ZEBRA_DEBUG_EVENT)
474 zlog_debug(
475 "MESSAGE: ZEBRA_INTERFACE_VRF_UPDATE/ADD %s VRF Id %u -> %u",
476 ifp->name, old_vrf_id, ifp->vrf_id);
477
478 for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client)) {
479 /* Need to add if the client is interested in the new VRF. */
480 client->ifadd_cnt++;
481 zsend_interface_add(client, ifp);
482 zsend_interface_addresses(client, ifp);
483 }
484 }
485
486 int zebra_add_import_table_entry(struct route_node *rn, struct route_entry *re,
487 const char *rmap_name)
488 {
489 struct route_entry *newre;
490 struct route_entry *same;
491 struct prefix p;
492 route_map_result_t ret = RMAP_MATCH;
493 afi_t afi;
494
495 afi = family2afi(rn->p.family);
496 if (rmap_name)
497 ret = zebra_import_table_route_map_check(
498 afi, re->type, &rn->p, re->nexthop, re->vrf_id,
499 re->tag, rmap_name);
500
501 if (ret != RMAP_MATCH) {
502 zebra_del_import_table_entry(rn, re);
503 return 0;
504 }
505
506 prefix_copy(&p, &rn->p);
507
508 RNODE_FOREACH_RE (rn, same) {
509 if (CHECK_FLAG(same->status, ROUTE_ENTRY_REMOVED))
510 continue;
511
512 if (same->type == re->type
513 && same->instance == re->instance
514 && same->table == re->table
515 && same->type != ZEBRA_ROUTE_CONNECT)
516 break;
517 }
518
519 if (same)
520 zebra_del_import_table_entry(rn, same);
521
522 newre = XCALLOC(MTYPE_RE,sizeof(struct route_entry));
523 newre->type = ZEBRA_ROUTE_TABLE;
524 newre->distance = zebra_import_table_distance[afi][re->table];
525 newre->flags = re->flags;
526 newre->metric = re->metric;
527 newre->mtu = re->mtu;
528 newre->table = zebrad.rtm_table_default;
529 newre->nexthop_num = 0;
530 newre->uptime = time(NULL);
531 newre->instance = re->table;
532 route_entry_copy_nexthops(newre, re->nexthop);
533
534 rib_add_multipath(afi, SAFI_UNICAST, &p, NULL, newre);
535
536 return 0;
537 }
538
539 int zebra_del_import_table_entry(struct route_node *rn, struct route_entry *re)
540 {
541 struct prefix p;
542 afi_t afi;
543
544 afi = family2afi(rn->p.family);
545 prefix_copy(&p, &rn->p);
546
547 rib_delete(afi, SAFI_UNICAST, re->vrf_id, ZEBRA_ROUTE_TABLE,
548 re->table, re->flags, &p, NULL, re->nexthop,
549 zebrad.rtm_table_default, re->metric, false);
550
551 return 0;
552 }
553
554 /* Assuming no one calls this with the main routing table */
555 int zebra_import_table(afi_t afi, u_int32_t table_id, u_int32_t distance,
556 const char *rmap_name, int add)
557 {
558 struct route_table *table;
559 struct route_entry *re;
560 struct route_node *rn;
561
562 if (!is_zebra_valid_kernel_table(table_id)
563 || ((table_id == RT_TABLE_MAIN)
564 || (table_id == zebrad.rtm_table_default)))
565 return (-1);
566
567 if (afi >= AFI_MAX)
568 return (-1);
569
570 table = zebra_vrf_other_route_table(afi, table_id, VRF_DEFAULT);
571 if (table == NULL) {
572 return 0;
573 } else if (IS_ZEBRA_DEBUG_RIB) {
574 zlog_debug("%s routes from table %d",
575 add ? "Importing" : "Unimporting", table_id);
576 }
577
578 if (add) {
579 if (rmap_name)
580 zebra_add_import_table_route_map(afi, rmap_name,
581 table_id);
582 else {
583 rmap_name =
584 zebra_get_import_table_route_map(afi, table_id);
585 if (rmap_name)
586 zebra_del_import_table_route_map(afi, table_id);
587 }
588
589 zebra_import_table_used[afi][table_id] = 1;
590 zebra_import_table_distance[afi][table_id] = distance;
591 } else {
592 zebra_import_table_used[afi][table_id] = 0;
593 zebra_import_table_distance[afi][table_id] =
594 ZEBRA_TABLE_DISTANCE_DEFAULT;
595
596 rmap_name = zebra_get_import_table_route_map(afi, table_id);
597 if (rmap_name)
598 zebra_del_import_table_route_map(afi, table_id);
599 }
600
601 for (rn = route_top(table); rn; rn = route_next(rn)) {
602 /* For each entry in the non-default routing table,
603 * add the entry in the main table
604 */
605 if (!rn->info)
606 continue;
607
608 RNODE_FOREACH_RE (rn, re) {
609 if (CHECK_FLAG(re->status, ROUTE_ENTRY_REMOVED))
610 continue;
611 break;
612 }
613
614 if (!re)
615 continue;
616
617 if (((afi == AFI_IP) && (rn->p.family == AF_INET))
618 || ((afi == AFI_IP6) && (rn->p.family == AF_INET6))) {
619 if (add)
620 zebra_add_import_table_entry(rn, re, rmap_name);
621 else
622 zebra_del_import_table_entry(rn, re);
623 }
624 }
625 return 0;
626 }
627
628 int zebra_import_table_config(struct vty *vty)
629 {
630 int i;
631 afi_t afi;
632 int write = 0;
633 char afi_str[AFI_MAX][10] = {"", "ip", "ipv6", "ethernet"};
634 const char *rmap_name;
635
636 for (afi = AFI_IP; afi < AFI_MAX; afi++) {
637 for (i = 1; i < ZEBRA_KERNEL_TABLE_MAX; i++) {
638 if (!is_zebra_import_table_enabled(afi, i))
639 continue;
640
641 if (zebra_import_table_distance[afi][i]
642 != ZEBRA_TABLE_DISTANCE_DEFAULT) {
643 vty_out(vty,
644 "%s import-table %d distance %d",
645 afi_str[afi], i,
646 zebra_import_table_distance[afi][i]);
647 } else {
648 vty_out(vty, "%s import-table %d",
649 afi_str[afi], i);
650 }
651
652 rmap_name = zebra_get_import_table_route_map(afi, i);
653 if (rmap_name)
654 vty_out(vty, " route-map %s",
655 rmap_name);
656
657 vty_out(vty, "\n");
658 write = 1;
659 }
660 }
661
662 return write;
663 }
664
665 void zebra_import_table_rm_update()
666 {
667 afi_t afi;
668 int i;
669 struct route_table *table;
670 struct route_entry *re;
671 struct route_node *rn;
672 const char *rmap_name;
673
674 for (afi = AFI_IP; afi < AFI_MAX; afi++) {
675 for (i = 1; i < ZEBRA_KERNEL_TABLE_MAX; i++) {
676 if (!is_zebra_import_table_enabled(afi, i))
677 continue;
678
679 rmap_name = zebra_get_import_table_route_map(afi, i);
680 if (!rmap_name)
681 return;
682
683 table = zebra_vrf_other_route_table(afi,
684 i,
685 VRF_DEFAULT);
686 for (rn = route_top(table); rn;
687 rn = route_next(rn)) {
688 /* For each entry in the non-default
689 * routing table,
690 * add the entry in the main table
691 */
692 if (!rn->info)
693 continue;
694
695 RNODE_FOREACH_RE (rn, re) {
696 if (CHECK_FLAG(re->status,
697 ROUTE_ENTRY_REMOVED))
698 continue;
699 break;
700 }
701
702 if (!re)
703 continue;
704
705 if (((afi == AFI_IP)
706 && (rn->p.family == AF_INET))
707 || ((afi == AFI_IP6)
708 && (rn->p.family == AF_INET6)))
709 zebra_add_import_table_entry(
710 rn, re, rmap_name);
711 }
712 }
713 }
714
715 return;
716 }
717
718 /* Interface parameters update */
719 void zebra_interface_parameters_update(struct interface *ifp)
720 {
721 struct listnode *node, *nnode;
722 struct zserv *client;
723
724 if (IS_ZEBRA_DEBUG_EVENT)
725 zlog_debug("MESSAGE: ZEBRA_INTERFACE_LINK_PARAMS %s",
726 ifp->name);
727
728 for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client))
729 if (client->ifinfo)
730 zsend_interface_link_params(client, ifp);
731 }