1 /* Redistribution Handler
2 * Copyright (C) 1998 Kunihiro Ishiguro
4 * This file is part of GNU Zebra.
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
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.
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Zebra; see the file COPYING. If not, write to the Free
18 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
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"
44 #define ZEBRA_PTM_SUPPORT
46 /* array holding redistribute info about table redistribution */
47 /* bit AFI is set if that AFI is redistributing routes from this table */
48 static u_char zebra_import_table_used
[ZEBRA_KERNEL_TABLE_MAX
];
49 static u_int32_t zebra_import_table_distance
[AFI_MAX
][ZEBRA_KERNEL_TABLE_MAX
];
52 is_zebra_import_table_enabled(afi_t afi
, u_int32_t table_id
)
54 if (is_zebra_valid_kernel_table(table_id
))
56 if (CHECK_FLAG(zebra_import_table_used
[table_id
], (u_char
)afi
))
66 is_default (struct prefix
*p
)
68 if (p
->family
== AF_INET
)
69 if (p
->u
.prefix4
.s_addr
== 0 && p
->prefixlen
== 0)
72 #if 0 /* IPv6 default separation is now pending until protocol daemon
74 if (p
->family
== AF_INET6
)
75 if (IN6_IS_ADDR_UNSPECIFIED (&p
->u
.prefix6
) && p
->prefixlen
== 0)
78 #endif /* HAVE_IPV6 */
83 zebra_redistribute_default (struct zserv
*client
, vrf_id_t vrf_id
)
86 struct route_table
*table
;
87 struct route_node
*rn
;
90 struct prefix_ipv6 p6
;
91 #endif /* HAVE_IPV6 */
94 /* Lookup default route. */
95 memset (&p
, 0, sizeof (struct prefix_ipv4
));
99 table
= zebra_vrf_table (AFI_IP
, SAFI_UNICAST
, vrf_id
);
102 rn
= route_node_lookup (table
, (struct prefix
*)&p
);
105 RNODE_FOREACH_RIB (rn
, newrib
)
106 if (CHECK_FLAG (newrib
->flags
, ZEBRA_FLAG_SELECTED
)
107 && newrib
->distance
!= DISTANCE_INFINITY
)
108 zsend_redistribute_route (ZEBRA_REDISTRIBUTE_IPV4_ADD
, client
, &rn
->p
, newrib
);
109 route_unlock_node (rn
);
114 /* Lookup default route. */
115 memset (&p6
, 0, sizeof (struct prefix_ipv6
));
116 p6
.family
= AF_INET6
;
119 table
= zebra_vrf_table (AFI_IP6
, SAFI_UNICAST
, vrf_id
);
122 rn
= route_node_lookup (table
, (struct prefix
*)&p6
);
125 RNODE_FOREACH_RIB (rn
, newrib
)
126 if (CHECK_FLAG (newrib
->flags
, ZEBRA_FLAG_SELECTED
)
127 && newrib
->distance
!= DISTANCE_INFINITY
)
128 zsend_redistribute_route (ZEBRA_REDISTRIBUTE_IPV6_ADD
, client
, &rn
->p
, newrib
);
129 route_unlock_node (rn
);
132 #endif /* HAVE_IPV6 */
135 /* Redistribute routes. */
137 zebra_redistribute (struct zserv
*client
, int type
, u_short instance
, vrf_id_t vrf_id
)
140 struct route_table
*table
;
141 struct route_node
*rn
;
143 table
= zebra_vrf_table (AFI_IP
, SAFI_UNICAST
, vrf_id
);
145 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
146 RNODE_FOREACH_RIB (rn
, newrib
)
147 if (CHECK_FLAG (newrib
->flags
, ZEBRA_FLAG_SELECTED
)
148 && newrib
->type
== type
149 && newrib
->instance
== instance
150 && newrib
->distance
!= DISTANCE_INFINITY
151 && zebra_check_addr (&rn
->p
))
153 client
->redist_v4_add_cnt
++;
154 zsend_redistribute_route (ZEBRA_REDISTRIBUTE_IPV4_ADD
, client
, &rn
->p
, newrib
);
158 table
= zebra_vrf_table (AFI_IP6
, SAFI_UNICAST
, vrf_id
);
160 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
161 RNODE_FOREACH_RIB (rn
, newrib
)
162 if (CHECK_FLAG (newrib
->flags
, ZEBRA_FLAG_SELECTED
)
163 && newrib
->type
== type
164 && newrib
->instance
== instance
165 && newrib
->distance
!= DISTANCE_INFINITY
166 && zebra_check_addr (&rn
->p
))
168 client
->redist_v6_add_cnt
++;
169 zsend_redistribute_route (ZEBRA_REDISTRIBUTE_IPV6_ADD
, client
, &rn
->p
, newrib
);
171 #endif /* HAVE_IPV6 */
174 /* Either advertise a route for redistribution to registered clients or */
175 /* withdraw redistribution if add cannot be done for client */
177 redistribute_update (struct prefix
*p
, struct rib
*rib
, struct rib
*prev_rib
)
179 struct listnode
*node
, *nnode
;
180 struct zserv
*client
;
181 int send_redistribute
;
183 char buf
[INET6_ADDRSTRLEN
];
185 if (IS_ZEBRA_DEBUG_RIB
)
187 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, INET6_ADDRSTRLEN
);
188 zlog_debug ("%u:%s/%d: Redist update rib %p (type %d), old %p (type %d)",
189 rib
->vrf_id
, buf
, p
->prefixlen
, rib
, rib
->type
,
190 prev_rib
, prev_rib
? prev_rib
->type
: -1);
193 afi
= family2afi(p
->family
);
196 zlog_warn("%s: Unknown AFI/SAFI prefix received\n", __FUNCTION__
);
200 for (ALL_LIST_ELEMENTS (zebrad
.client_list
, node
, nnode
, client
))
202 send_redistribute
= 0;
204 if (is_default(p
) && client
->redist_default
)
205 send_redistribute
= 1;
207 if (rib
->instance
&& redist_check_instance(&client
->mi_redist
[afi
][rib
->type
],
209 send_redistribute
= 1;
211 if ((is_default (p
) &&
212 vrf_bitmap_check (client
->redist_default
, rib
->vrf_id
))
213 || vrf_bitmap_check (client
->redist
[afi
][rib
->type
], rib
->vrf_id
))
214 send_redistribute
= 1;
216 if (send_redistribute
)
221 client
->redist_v4_add_cnt
++;
222 zsend_redistribute_route (ZEBRA_REDISTRIBUTE_IPV4_ADD
, client
,
226 client
->redist_v6_add_cnt
++;
227 zsend_redistribute_route (ZEBRA_REDISTRIBUTE_IPV6_ADD
, client
,
231 zlog_warn("%s: Unknown AFI/SAFI prefix received\n", __FUNCTION__
);
237 redist_check_instance(&client
->mi_redist
[afi
][prev_rib
->type
],
239 vrf_bitmap_check (client
->redist
[afi
][prev_rib
->type
], rib
->vrf_id
)))
244 client
->redist_v4_del_cnt
++;
245 zsend_redistribute_route (ZEBRA_REDISTRIBUTE_IPV4_DEL
, client
, p
,
249 client
->redist_v6_del_cnt
++;
250 zsend_redistribute_route (ZEBRA_REDISTRIBUTE_IPV6_DEL
, client
, p
,
261 redistribute_delete (struct prefix
*p
, struct rib
*rib
)
263 struct listnode
*node
, *nnode
;
264 struct zserv
*client
;
265 char buf
[INET6_ADDRSTRLEN
];
267 if (IS_ZEBRA_DEBUG_RIB
)
269 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, INET6_ADDRSTRLEN
);
270 zlog_debug ("%u:%s/%d: Redist delete rib %p (type %d)",
271 rib
->vrf_id
, buf
, p
->prefixlen
, rib
, rib
->type
);
274 /* Add DISTANCE_INFINITY check. */
275 if (rib
->distance
== DISTANCE_INFINITY
)
278 for (ALL_LIST_ELEMENTS (zebrad
.client_list
, node
, nnode
, client
))
282 if ((p
->family
== AF_INET
) &&
283 (vrf_bitmap_check (client
->redist_default
, rib
->vrf_id
) ||
285 redist_check_instance(&client
->mi_redist
[AFI_IP
][rib
->type
],
287 vrf_bitmap_check (client
->redist
[AFI_IP
][rib
->type
], rib
->vrf_id
)))
288 zsend_redistribute_route (ZEBRA_REDISTRIBUTE_IPV4_DEL
, client
, p
,
291 if ((p
->family
== AF_INET6
) &&
292 (vrf_bitmap_check (client
->redist_default
, rib
->vrf_id
) ||
294 redist_check_instance(&client
->mi_redist
[AFI_IP6
][rib
->type
],
296 vrf_bitmap_check (client
->redist
[AFI_IP6
][rib
->type
], rib
->vrf_id
)))
297 zsend_redistribute_route (ZEBRA_REDISTRIBUTE_IPV6_DEL
, client
, p
,
299 #endif /* HAVE_IPV6 */
303 if ((p
->family
== AF_INET
) &&
305 redist_check_instance(&client
->mi_redist
[AFI_IP
][rib
->type
],
307 vrf_bitmap_check (client
->redist
[AFI_IP
][rib
->type
], rib
->vrf_id
)))
308 zsend_redistribute_route (ZEBRA_REDISTRIBUTE_IPV4_DEL
, client
, p
,
311 if ((p
->family
== AF_INET6
) &&
313 redist_check_instance(&client
->mi_redist
[AFI_IP6
][rib
->type
],
315 vrf_bitmap_check (client
->redist
[AFI_IP6
][rib
->type
], rib
->vrf_id
)))
316 zsend_redistribute_route (ZEBRA_REDISTRIBUTE_IPV6_DEL
, client
, p
,
318 #endif /* HAVE_IPV6 */
324 zebra_redistribute_add (int command
, struct zserv
*client
, int length
,
325 struct zebra_vrf
*zvrf
)
331 afi
= stream_getc (client
->ibuf
);
332 type
= stream_getc (client
->ibuf
);
333 instance
= stream_getw (client
->ibuf
);
335 if (type
== 0 || type
>= ZEBRA_ROUTE_MAX
)
338 if (instance
&& !redist_check_instance(&client
->mi_redist
[afi
][type
], instance
))
340 redist_add_instance(&client
->mi_redist
[afi
][type
], instance
);
341 zebra_redistribute (client
, type
, instance
, zvrf
->vrf_id
);
344 if (! vrf_bitmap_check (client
->redist
[afi
][type
], zvrf
->vrf_id
))
346 vrf_bitmap_set (client
->redist
[afi
][type
], zvrf
->vrf_id
);
347 zebra_redistribute (client
, type
, 0, zvrf
->vrf_id
);
352 zebra_redistribute_delete (int command
, struct zserv
*client
, int length
,
353 struct zebra_vrf
*zvrf
)
359 afi
= stream_getc (client
->ibuf
);
360 type
= stream_getc (client
->ibuf
);
361 instance
= stream_getw (client
->ibuf
);
363 if (type
== 0 || type
>= ZEBRA_ROUTE_MAX
)
366 if (instance
&& redist_check_instance(&client
->mi_redist
[afi
][type
], instance
))
368 redist_del_instance(&client
->mi_redist
[afi
][type
], instance
);
369 //Pending: why no reaction here?
371 vrf_bitmap_unset (client
->redist
[afi
][type
], zvrf
->vrf_id
);
375 zebra_redistribute_default_add (int command
, struct zserv
*client
, int length
,
376 struct zebra_vrf
*zvrf
)
378 vrf_bitmap_set (client
->redist_default
, zvrf
->vrf_id
);
379 zebra_redistribute_default (client
, zvrf
->vrf_id
);
383 zebra_redistribute_default_delete (int command
, struct zserv
*client
,
384 int length
, struct zebra_vrf
*zvrf
)
386 vrf_bitmap_unset (client
->redist_default
, zvrf
->vrf_id
);
389 /* Interface up information. */
391 zebra_interface_up_update (struct interface
*ifp
)
393 struct listnode
*node
, *nnode
;
394 struct zserv
*client
;
396 if (IS_ZEBRA_DEBUG_EVENT
)
397 zlog_debug ("MESSAGE: ZEBRA_INTERFACE_UP %s", ifp
->name
);
399 if (ifp
->ptm_status
|| !ifp
->ptm_enable
) {
400 for (ALL_LIST_ELEMENTS (zebrad
.client_list
, node
, nnode
, client
))
402 zsend_interface_update (ZEBRA_INTERFACE_UP
, client
, ifp
);
407 /* Interface down information. */
409 zebra_interface_down_update (struct interface
*ifp
)
411 struct listnode
*node
, *nnode
;
412 struct zserv
*client
;
414 if (IS_ZEBRA_DEBUG_EVENT
)
415 zlog_debug ("MESSAGE: ZEBRA_INTERFACE_DOWN %s", ifp
->name
);
417 for (ALL_LIST_ELEMENTS (zebrad
.client_list
, node
, nnode
, client
))
419 zsend_interface_update (ZEBRA_INTERFACE_DOWN
, client
, ifp
);
423 /* Interface information update. */
425 zebra_interface_add_update (struct interface
*ifp
)
427 struct listnode
*node
, *nnode
;
428 struct zserv
*client
;
430 if (IS_ZEBRA_DEBUG_EVENT
)
431 zlog_debug ("MESSAGE: ZEBRA_INTERFACE_ADD %s[%d]", ifp
->name
, ifp
->vrf_id
);
433 for (ALL_LIST_ELEMENTS (zebrad
.client_list
, node
, nnode
, client
))
436 zsend_interface_add (client
, ifp
);
441 zebra_interface_delete_update (struct interface
*ifp
)
443 struct listnode
*node
, *nnode
;
444 struct zserv
*client
;
446 if (IS_ZEBRA_DEBUG_EVENT
)
447 zlog_debug ("MESSAGE: ZEBRA_INTERFACE_DELETE %s", ifp
->name
);
449 for (ALL_LIST_ELEMENTS (zebrad
.client_list
, node
, nnode
, client
))
452 zsend_interface_delete (client
, ifp
);
456 /* Interface address addition. */
458 zebra_interface_address_add_update (struct interface
*ifp
,
459 struct connected
*ifc
)
461 struct listnode
*node
, *nnode
;
462 struct zserv
*client
;
465 if (IS_ZEBRA_DEBUG_EVENT
)
467 char buf
[INET6_ADDRSTRLEN
];
470 zlog_debug ("MESSAGE: ZEBRA_INTERFACE_ADDRESS_ADD %s/%d on %s",
471 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, INET6_ADDRSTRLEN
),
472 p
->prefixlen
, ifc
->ifp
->name
);
475 if (!CHECK_FLAG(ifc
->conf
, ZEBRA_IFC_REAL
))
476 zlog_warn("WARNING: advertising address to clients that is not yet usable.");
478 router_id_add_address(ifc
);
480 for (ALL_LIST_ELEMENTS (zebrad
.client_list
, node
, nnode
, client
))
481 if (CHECK_FLAG (ifc
->conf
, ZEBRA_IFC_REAL
))
483 client
->connected_rt_add_cnt
++;
484 zsend_interface_address (ZEBRA_INTERFACE_ADDRESS_ADD
, client
, ifp
, ifc
);
488 /* Interface address deletion. */
490 zebra_interface_address_delete_update (struct interface
*ifp
,
491 struct connected
*ifc
)
493 struct listnode
*node
, *nnode
;
494 struct zserv
*client
;
497 if (IS_ZEBRA_DEBUG_EVENT
)
499 char buf
[INET6_ADDRSTRLEN
];
502 zlog_debug ("MESSAGE: ZEBRA_INTERFACE_ADDRESS_DELETE %s/%d on %s",
503 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, INET6_ADDRSTRLEN
),
504 p
->prefixlen
, ifc
->ifp
->name
);
507 router_id_del_address(ifc
);
509 for (ALL_LIST_ELEMENTS (zebrad
.client_list
, node
, nnode
, client
))
510 if (CHECK_FLAG (ifc
->conf
, ZEBRA_IFC_REAL
))
512 client
->connected_rt_del_cnt
++;
513 zsend_interface_address (ZEBRA_INTERFACE_ADDRESS_DELETE
, client
, ifp
, ifc
);
517 /* Interface VRF change. May need to delete from clients not interested in
518 * the new VRF. Note that this function is invoked *prior* to the VRF change.
521 zebra_interface_vrf_update_del (struct interface
*ifp
, vrf_id_t new_vrf_id
)
523 struct listnode
*node
, *nnode
;
524 struct zserv
*client
;
526 if (IS_ZEBRA_DEBUG_EVENT
)
527 zlog_debug ("MESSAGE: ZEBRA_INTERFACE_VRF_UPDATE/DEL %s VRF Id %u -> %u",
528 ifp
->name
, ifp
->vrf_id
, new_vrf_id
);
530 for (ALL_LIST_ELEMENTS (zebrad
.client_list
, node
, nnode
, client
))
532 /* Need to delete if the client is not interested in the new VRF. */
533 zsend_interface_update (ZEBRA_INTERFACE_DOWN
, client
, ifp
);
535 zsend_interface_delete (client
, ifp
);
536 zsend_interface_vrf_update (client
, ifp
, new_vrf_id
);
540 /* Interface VRF change. This function is invoked *post* VRF change and sends an
541 * add to clients who are interested in the new VRF but not in the old VRF.
544 zebra_interface_vrf_update_add (struct interface
*ifp
, vrf_id_t old_vrf_id
)
546 struct listnode
*node
, *nnode
;
547 struct zserv
*client
;
549 if (IS_ZEBRA_DEBUG_EVENT
)
550 zlog_debug ("MESSAGE: ZEBRA_INTERFACE_VRF_UPDATE/ADD %s VRF Id %u -> %u",
551 ifp
->name
, old_vrf_id
, ifp
->vrf_id
);
553 for (ALL_LIST_ELEMENTS (zebrad
.client_list
, node
, nnode
, client
))
555 /* Need to add if the client is interested in the new VRF. */
557 zsend_interface_add (client
, ifp
);
558 zsend_interface_addresses (client
, ifp
);
563 zebra_add_import_table_entry (struct route_node
*rn
, struct rib
*rib
, const char *rmap_name
)
566 struct prefix_ipv4 p4
;
567 struct nexthop
*nhop
;
568 struct in_addr
*gate
;
569 route_map_result_t ret
= RMAP_MATCH
;
572 ret
= zebra_import_table_route_map_check (AFI_IP
, rib
->type
, &rn
->p
, rib
->nexthop
, rib
->vrf_id
,
573 rib
->tag
, rmap_name
);
575 if (ret
== RMAP_MATCH
)
577 if (rn
->p
.family
== AF_INET
)
580 p4
.prefixlen
= rn
->p
.prefixlen
;
581 p4
.prefix
= rn
->p
.u
.prefix4
;
583 if (rib
->nexthop_num
== 1)
586 if (nhop
->type
== NEXTHOP_TYPE_IFINDEX
)
589 gate
= &nhop
->gate
.ipv4
;
591 rib_add_ipv4(ZEBRA_ROUTE_TABLE
, rib
->table
, 0, &p4
,
592 gate
, &nhop
->src
.ipv4
,
593 nhop
->ifindex
, rib
->vrf_id
, zebrad
.rtm_table_default
,
595 zebra_import_table_distance
[AFI_IP
][rib
->table
],
598 else if (rib
->nexthop_num
> 1)
600 newrib
= XCALLOC (MTYPE_RIB
, sizeof (struct rib
));
601 newrib
->type
= ZEBRA_ROUTE_TABLE
;
602 newrib
->distance
= zebra_import_table_distance
[AFI_IP
][rib
->table
];
603 newrib
->flags
= rib
->flags
;
604 newrib
->metric
= rib
->metric
;
605 newrib
->table
= zebrad
.rtm_table_default
;
606 newrib
->nexthop_num
= 0;
607 newrib
->uptime
= time(NULL
);
608 newrib
->instance
= rib
->table
;
610 /* Assuming these routes are never recursive */
611 for (nhop
= rib
->nexthop
; nhop
; nhop
= nhop
->next
)
612 rib_copy_nexthops(newrib
, nhop
);
614 rib_add_ipv4_multipath(&p4
, newrib
, SAFI_UNICAST
);
620 zebra_del_import_table_entry (rn
, rib
);
622 /* DD: Add IPv6 code */
627 zebra_del_import_table_entry (struct route_node
*rn
, struct rib
*rib
)
629 struct prefix_ipv4 p4
;
631 if (rn
->p
.family
== AF_INET
)
634 p4
.prefixlen
= rn
->p
.prefixlen
;
635 p4
.prefix
= rn
->p
.u
.prefix4
;
637 rib_delete_ipv4(ZEBRA_ROUTE_TABLE
, rib
->table
, rib
->flags
, &p4
, NULL
,
638 0, rib
->vrf_id
, zebrad
.rtm_table_default
, SAFI_UNICAST
);
640 /* DD: Add IPv6 code */
645 /* Assuming no one calls this with the main routing table */
647 zebra_import_table (afi_t afi
, u_int32_t table_id
, u_int32_t distance
, const char *rmap_name
, int add
)
649 struct route_table
*table
;
651 struct route_node
*rn
;
653 if (!is_zebra_valid_kernel_table(table_id
) ||
654 ((table_id
== RT_TABLE_MAIN
) || (table_id
== zebrad
.rtm_table_default
)))
660 table
= zebra_vrf_other_route_table(afi
, table_id
, VRF_DEFAULT
);
665 else if (IS_ZEBRA_DEBUG_RIB
)
667 zlog_debug ("%s routes from table %d",
668 add
? "Importing" : "Unimporting", table_id
);
674 zebra_add_import_table_route_map (afi
, rmap_name
, table_id
);
677 rmap_name
= zebra_get_import_table_route_map (afi
, table_id
);
679 zebra_del_import_table_route_map (afi
, table_id
);
682 SET_FLAG(zebra_import_table_used
[table_id
], afi
);
683 zebra_import_table_distance
[afi
][table_id
] = distance
;
687 UNSET_FLAG(zebra_import_table_used
[table_id
], (u_char
)afi
);
688 zebra_import_table_distance
[afi
][table_id
] = ZEBRA_TABLE_DISTANCE_DEFAULT
;
690 rmap_name
= zebra_get_import_table_route_map (afi
, table_id
);
692 zebra_del_import_table_route_map (afi
, table_id
);
695 for (rn
= route_top(table
); rn
; rn
= route_next(rn
))
697 /* For each entry in the non-default routing table,
698 * add the entry in the main table
703 RNODE_FOREACH_RIB (rn
, rib
)
705 if (CHECK_FLAG (rib
->status
, RIB_ENTRY_REMOVED
))
713 if (((afi
== AFI_IP
) && (rn
->p
.family
== AF_INET
)) ||
714 ((afi
== AFI_IP6
) && (rn
->p
.family
== AF_INET6
)))
717 zebra_add_import_table_entry (rn
, rib
, rmap_name
);
719 zebra_del_import_table_entry (rn
, rib
);
726 zebra_import_table_config (struct vty
*vty
)
731 char afi_str
[AFI_MAX
][6] = {"", "ip", "ipv6"};
732 const char *rmap_name
;
734 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
736 for (i
= 1; i
< ZEBRA_KERNEL_TABLE_MAX
; i
++)
738 if (is_zebra_import_table_enabled(afi
, i
))
740 if (zebra_import_table_distance
[afi
][i
] != ZEBRA_TABLE_DISTANCE_DEFAULT
)
742 vty_out(vty
, "%s import-table %d distance %d", afi_str
[afi
],
743 i
, zebra_import_table_distance
[afi
][i
]);
747 vty_out(vty
, "%s import-table %d", afi_str
[afi
], i
);
750 rmap_name
= zebra_get_import_table_route_map (afi
, i
);
752 vty_out(vty
, " route-map %s", rmap_name
);
754 vty_out(vty
, "%s", VTY_NEWLINE
);
764 zebra_import_table_rm_update ()
768 struct route_table
*table
;
770 struct route_node
*rn
;
771 const char *rmap_name
;
773 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
775 for (i
= 1; i
< ZEBRA_KERNEL_TABLE_MAX
; i
++)
777 if (is_zebra_import_table_enabled(afi
, i
))
779 rmap_name
= zebra_get_import_table_route_map (afi
, i
);
783 table
= zebra_vrf_other_route_table(afi
, i
, VRF_DEFAULT
);
784 for (rn
= route_top(table
); rn
; rn
= route_next(rn
))
786 /* For each entry in the non-default routing table,
787 * add the entry in the main table
792 RNODE_FOREACH_RIB (rn
, rib
)
794 if (CHECK_FLAG (rib
->status
, RIB_ENTRY_REMOVED
))
802 if (((afi
== AFI_IP
) && (rn
->p
.family
== AF_INET
)) ||
803 ((afi
== AFI_IP6
) && (rn
->p
.family
== AF_INET6
)))
804 zebra_add_import_table_entry (rn
, rib
, rmap_name
);