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