2 * Copyright (C) 1997, 98, 99 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
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
29 #include "sockunion.h"
33 #include "bgpd/bgpd.h"
34 #include "bgpd/bgp_route.h"
35 #include "bgpd/bgp_attr.h"
36 #include "bgpd/bgp_nexthop.h"
38 int bgp_interface_add (int, struct zclient
*, zebra_size_t
);
39 int bgp_interface_delete (int, struct zclient
*, zebra_size_t
);
40 int bgp_interface_address_add (int, struct zclient
*, zebra_size_t
);
41 int bgp_interface_address_delete (int, struct zclient
*, zebra_size_t
);
43 /* All information about zebra. */
44 static struct zclient
*zclient
= NULL
;
46 /* Update default router id. */
48 bgp_if_update (struct interface
*ifp
)
54 struct peer_conf
*conf
;
56 for (cn
= listhead (ifp
->connected
); cn
; nextnode (cn
))
63 if (co
->address
->family
== AF_INET
)
65 addr
= co
->address
->u
.prefix4
;
68 if (IPV4_NET127 (ntohl (addr
.s_addr
)))
71 LIST_LOOP (bgp_list
, bgp
, nn
)
73 /* Respect configured router id */
74 if (! (bgp
->config
& BGP_CONFIG_ROUTER_ID
))
75 if (ntohl (bgp
->id
.s_addr
) < ntohl (addr
.s_addr
))
78 LIST_LOOP (bgp
->peer_conf
, conf
, nm
)
80 conf
->peer
->local_id
= addr
;
93 struct interface
*ifp
;
95 for (node
= listhead (iflist
); node
; node
= nextnode (node
))
103 /* Inteface addition message from zebra. */
105 bgp_interface_add (int command
, struct zclient
*zclient
, zebra_size_t length
)
107 struct interface
*ifp
;
109 ifp
= zebra_interface_add_read (zclient
->ibuf
);
112 if (IS_BGP_DEBUG_ZEBRA
)
113 zlog_info ("BGP interface add %s index %d flags %d metric %d mtu %d",
114 ifp
->name
, ifp
->ifindex
, ifp
->flags
, ifp
->metric
, ifp
->mtu
);
123 bgp_interface_delete (int command
, struct zclient
*zclient
,
127 struct interface
*ifp
;
130 ifp
= zebra_interface_state_read (s
);
136 bgp_interface_up (int command
, struct zclient
*zclient
, zebra_size_t length
)
139 struct interface
*ifp
;
144 ifp
= zebra_interface_state_read (s
);
149 for (node
= listhead (ifp
->connected
); node
; nextnode (node
))
152 bgp_connected_add (c
);
159 bgp_interface_down (int command
, struct zclient
*zclient
, zebra_size_t length
)
162 struct interface
*ifp
;
167 ifp
= zebra_interface_state_read (s
);
171 for (node
= listhead (ifp
->connected
); node
; nextnode (node
))
174 bgp_connected_delete (c
);
181 bgp_interface_address_add (int command
, struct zclient
*zclient
,
184 struct connected
*ifc
;
186 ifc
= zebra_interface_address_add_read (zclient
->ibuf
);
192 if (IS_BGP_DEBUG_ZEBRA
)
195 char buf
[INET6_ADDRSTRLEN
];
198 if (p
->family
== AF_INET6
)
199 zlog_info ("BGP connected address %s/%d",
200 inet_ntop (AF_INET6
, &p
->u
.prefix6
, buf
, INET6_ADDRSTRLEN
),
205 bgp_if_update (ifc
->ifp
);
207 if (if_is_up (ifc
->ifp
))
208 bgp_connected_add (ifc
);
214 bgp_interface_address_delete (int command
, struct zclient
*zclient
,
217 struct connected
*ifc
;
219 ifc
= zebra_interface_address_delete_read (zclient
->ibuf
);
224 bgp_if_update (ifc
->ifp
);
226 if (if_is_up (ifc
->ifp
))
227 bgp_connected_delete (ifc
);
229 connected_free (ifc
);
234 /* Zebra route add and delete treatment. */
236 zebra_read_ipv4 (int command
, struct zclient
*zclient
, zebra_size_t length
)
239 struct zapi_ipv4 api
;
240 unsigned long ifindex
;
241 struct in_addr nexthop
;
242 struct prefix_ipv4 p
;
248 /* Type, flags, message. */
249 api
.type
= stream_getc (s
);
250 api
.flags
= stream_getc (s
);
251 api
.message
= stream_getc (s
);
254 memset (&p
, 0, sizeof (struct prefix_ipv4
));
256 p
.prefixlen
= stream_getc (s
);
257 stream_get (&p
.prefix
, s
, PSIZE (p
.prefixlen
));
259 /* Nexthop, ifindex, distance, metric. */
260 if (CHECK_FLAG (api
.message
, ZAPI_MESSAGE_NEXTHOP
))
262 api
.nexthop_num
= stream_getc (s
);
263 nexthop
.s_addr
= stream_get_ipv4 (s
);
265 if (CHECK_FLAG (api
.message
, ZAPI_MESSAGE_IFINDEX
))
267 api
.ifindex_num
= stream_getc (s
);
268 ifindex
= stream_getl (s
);
270 if (CHECK_FLAG (api
.message
, ZAPI_MESSAGE_DISTANCE
))
271 api
.distance
= stream_getc (s
);
272 if (CHECK_FLAG (api
.message
, ZAPI_MESSAGE_METRIC
))
273 api
.metric
= stream_getl (s
);
277 if (command
== ZEBRA_IPV4_ROUTE_ADD
)
278 bgp_redistribute_add ((struct prefix
*)&p
, &nexthop
, api
.metric
, api
.type
);
280 bgp_redistribute_delete ((struct prefix
*)&p
, api
.type
);
286 /* Zebra route add and delete treatment. */
288 zebra_read_ipv6 (int command
, struct zclient
*zclient
, zebra_size_t length
)
291 struct zapi_ipv6 api
;
292 unsigned long ifindex
;
293 struct in6_addr nexthop
;
294 struct prefix_ipv6 p
;
298 memset (&nexthop
, 0, sizeof (struct in6_addr
));
300 /* Type, flags, message. */
301 api
.type
= stream_getc (s
);
302 api
.flags
= stream_getc (s
);
303 api
.message
= stream_getc (s
);
306 memset (&p
, 0, sizeof (struct prefix_ipv6
));
308 p
.prefixlen
= stream_getc (s
);
309 stream_get (&p
.prefix
, s
, PSIZE (p
.prefixlen
));
311 /* Nexthop, ifindex, distance, metric. */
312 if (CHECK_FLAG (api
.message
, ZAPI_MESSAGE_NEXTHOP
))
314 api
.nexthop_num
= stream_getc (s
);
315 stream_get (&nexthop
, s
, 16);
317 if (CHECK_FLAG (api
.message
, ZAPI_MESSAGE_IFINDEX
))
319 api
.ifindex_num
= stream_getc (s
);
320 ifindex
= stream_getl (s
);
322 if (CHECK_FLAG (api
.message
, ZAPI_MESSAGE_DISTANCE
))
323 api
.distance
= stream_getc (s
);
326 if (CHECK_FLAG (api
.message
, ZAPI_MESSAGE_METRIC
))
327 api
.metric
= stream_getl (s
);
331 /* Simply ignore link-local address. */
332 if (IN6_IS_ADDR_LINKLOCAL (&p
.prefix
))
335 if (command
== ZEBRA_IPV6_ROUTE_ADD
)
336 bgp_redistribute_add ((struct prefix
*)&p
, NULL
, api
.metric
, api
.type
);
338 bgp_redistribute_delete ((struct prefix
*) &p
, api
.type
);
342 #endif /* HAVE_IPV6 */
344 /* Other routes redistribution into BGP. */
346 bgp_redistribute_set (struct bgp
*bgp
, afi_t afi
, int type
)
348 /* Set flag to BGP instance. */
349 bgp
->redist
[afi
][type
] = 1;
351 /* Return if already redistribute flag is set. */
352 if (zclient
->redist
[type
])
355 zclient
->redist
[type
] = 1;
357 /* Return if zebra connection is not established. */
358 if (zclient
->sock
< 0)
361 /* Send distribute add message to zebra. */
362 zebra_redistribute_send (ZEBRA_REDISTRIBUTE_ADD
, zclient
->sock
, type
);
365 /* Redistribute with route-map specification. */
367 bgp_redistribute_routemap_set (struct bgp
*bgp
, afi_t afi
, int type
,
370 bgp_redistribute_set (bgp
, afi
, type
);
372 if (bgp
->rmap
[afi
][type
].name
)
373 free (bgp
->rmap
[afi
][type
].name
);
375 bgp
->rmap
[afi
][type
].name
= strdup (name
);
376 bgp
->rmap
[afi
][type
].map
= route_map_lookup_by_name (name
);
379 /* Unset redistribution. */
381 bgp_redistribute_unset (struct bgp
*bgp
, afi_t afi
, int type
)
383 /* Unset flag from BGP instance. */
384 bgp
->redist
[afi
][type
] = 0;
386 /* Unset route-map. */
387 if (bgp
->rmap
[afi
][type
].name
)
388 free (bgp
->rmap
[afi
][type
].name
);
389 bgp
->rmap
[afi
][type
].name
= NULL
;
390 bgp
->rmap
[afi
][type
].map
= NULL
;
392 /* Return if zebra connection is disabled. */
393 if (! zclient
->redist
[type
])
395 zclient
->redist
[type
] = 0;
397 if (bgp
->redist
[AFI_IP
][type
] == 0
398 && bgp
->redist
[AFI_IP6
][type
] == 0
399 && zclient
->sock
>= 0)
400 /* Send distribute delete message to zebra. */
401 zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE
, zclient
->sock
, type
);
403 /* Withdraw redistributed routes from current BGP's routing table. */
404 bgp_redistribute_withdraw (bgp
, afi
, type
);
407 DEFUN (bgp_redistribute_kernel
,
408 bgp_redistribute_kernel_cmd
,
409 "redistribute kernel",
410 "Redistribute information from another routing protocol\n"
413 bgp_redistribute_set (vty
->index
, AFI_IP
, ZEBRA_ROUTE_KERNEL
);
417 DEFUN (bgp_redistribute_kernel_routemap
,
418 bgp_redistribute_kernel_routemap_cmd
,
419 "redistribute kernel route-map WORD",
420 "Redistribute information from another routing protocol\n"
422 "Route map reference\n"
423 "Pointer to route-map entries\n")
425 bgp_redistribute_routemap_set (vty
->index
, AFI_IP
, ZEBRA_ROUTE_KERNEL
, argv
[0]);
429 DEFUN (no_bgp_redistribute_kernel
,
430 no_bgp_redistribute_kernel_cmd
,
431 "no redistribute kernel",
433 "Redistribute information from another routing protocol\n"
436 bgp_redistribute_unset (vty
->index
, AFI_IP
, ZEBRA_ROUTE_KERNEL
);
440 DEFUN (no_bgp_redistribute_kernel_routemap
,
441 no_bgp_redistribute_kernel_routemap_cmd
,
442 "no redistribute kernel route-map WORD",
444 "Redistribute information from another routing protocol\n"
446 "Route map reference\n"
447 "Pointer to route-map entries\n")
449 bgp_redistribute_unset (vty
->index
, AFI_IP
, ZEBRA_ROUTE_KERNEL
);
453 DEFUN (bgp_redistribute_static
,
454 bgp_redistribute_static_cmd
,
455 "redistribute static",
456 "Redistribute information from another routing protocol\n"
459 bgp_redistribute_set (vty
->index
, AFI_IP
, ZEBRA_ROUTE_STATIC
);
463 DEFUN (bgp_redistribute_static_routemap
,
464 bgp_redistribute_static_routemap_cmd
,
465 "redistribute static route-map WORD",
466 "Redistribute information from another routing protocol\n"
468 "Route map reference\n"
469 "Pointer to route-map entries\n")
471 bgp_redistribute_routemap_set (vty
->index
, AFI_IP
, ZEBRA_ROUTE_STATIC
, argv
[0]);
475 DEFUN (no_bgp_redistribute_static
,
476 no_bgp_redistribute_static_cmd
,
477 "no redistribute static",
479 "Redistribute information from another routing protocol\n"
482 bgp_redistribute_unset (vty
->index
, AFI_IP
, ZEBRA_ROUTE_STATIC
);
486 DEFUN (no_bgp_redistribute_static_routemap
,
487 no_bgp_redistribute_static_routemap_cmd
,
488 "no redistribute static route-map WORD",
490 "Redistribute information from another routing protocol\n"
492 "Route map reference\n"
493 "Pointer to route-map entries\n")
495 bgp_redistribute_unset (vty
->index
, AFI_IP
, ZEBRA_ROUTE_STATIC
);
499 DEFUN (bgp_redistribute_connected
,
500 bgp_redistribute_connected_cmd
,
501 "redistribute connected",
502 "Redistribute information from another routing protocol\n"
505 bgp_redistribute_set (vty
->index
, AFI_IP
, ZEBRA_ROUTE_CONNECT
);
509 DEFUN (bgp_redistribute_connected_routemap
,
510 bgp_redistribute_connected_routemap_cmd
,
511 "redistribute connected route-map WORD",
512 "Redistribute information from another routing protocol\n"
514 "Route map reference\n"
515 "Pointer to route-map entries\n")
517 bgp_redistribute_routemap_set (vty
->index
, AFI_IP
, ZEBRA_ROUTE_CONNECT
, argv
[0]);
521 DEFUN (no_bgp_redistribute_connected
,
522 no_bgp_redistribute_connected_cmd
,
523 "no redistribute connected",
525 "Redistribute information from another routing protocol\n"
528 bgp_redistribute_unset (vty
->index
, AFI_IP
, ZEBRA_ROUTE_CONNECT
);
532 DEFUN (no_bgp_redistribute_connected_routemap
,
533 no_bgp_redistribute_connected_routemap_cmd
,
534 "no redistribute connected route-map WORD",
536 "Redistribute information from another routing protocol\n"
538 "Route map reference\n"
539 "Pointer to route-map entries\n")
541 bgp_redistribute_unset (vty
->index
, AFI_IP
, ZEBRA_ROUTE_CONNECT
);
545 DEFUN (bgp_redistribute_rip
,
546 bgp_redistribute_rip_cmd
,
548 "Redistribute information from another routing protocol\n"
549 "Routing Information Protocol (RIP)\n")
551 bgp_redistribute_set (vty
->index
, AFI_IP
, ZEBRA_ROUTE_RIP
);
555 DEFUN (bgp_redistribute_rip_routemap
,
556 bgp_redistribute_rip_routemap_cmd
,
557 "redistribute rip route-map WORD",
558 "Redistribute information from another routing protocol\n"
559 "Routing Information Protocol (RIP)\n"
560 "Route map reference\n"
561 "Pointer to route-map entries\n")
563 bgp_redistribute_routemap_set (vty
->index
, AFI_IP
, ZEBRA_ROUTE_RIP
, argv
[0]);
567 DEFUN (no_bgp_redistribute_rip
,
568 no_bgp_redistribute_rip_cmd
,
569 "no redistribute rip",
571 "Redistribute information from another routing protocol\n"
572 "Routing Information Protocol (RIP)\n")
574 bgp_redistribute_unset (vty
->index
, AFI_IP
, ZEBRA_ROUTE_RIP
);
578 DEFUN (no_bgp_redistribute_rip_routemap
,
579 no_bgp_redistribute_rip_routemap_cmd
,
580 "no redistribute rip route-map WORD",
582 "Redistribute information from another routing protocol\n"
583 "Routing Information Protocol (RIP)\n"
584 "Route map reference\n"
585 "Pointer to route-map entries\n")
587 bgp_redistribute_unset (vty
->index
, AFI_IP
, ZEBRA_ROUTE_RIP
);
591 DEFUN (bgp_redistribute_ospf
,
592 bgp_redistribute_ospf_cmd
,
594 "Redistribute information from another routing protocol\n"
595 "Open Shortest Path First (OSPF)\n")
597 bgp_redistribute_set (vty
->index
, AFI_IP
, ZEBRA_ROUTE_OSPF
);
601 DEFUN (bgp_redistribute_ospf_routemap
,
602 bgp_redistribute_ospf_routemap_cmd
,
603 "redistribute ospf route-map WORD",
604 "Redistribute information from another routing protocol\n"
605 "Open Shortest Path First (OSPF)\n"
606 "Route map reference\n"
607 "Pointer to route-map entries\n")
609 bgp_redistribute_routemap_set (vty
->index
, AFI_IP
, ZEBRA_ROUTE_OSPF
, argv
[0]);
613 DEFUN (no_bgp_redistribute_ospf
,
614 no_bgp_redistribute_ospf_cmd
,
615 "no redistribute ospf",
617 "Redistribute information from another routing protocol\n"
618 "Open Shortest Path First (OSPF)\n")
620 bgp_redistribute_unset (vty
->index
, AFI_IP
, ZEBRA_ROUTE_OSPF
);
624 DEFUN (no_bgp_redistribute_ospf_routemap
,
625 no_bgp_redistribute_ospf_routemap_cmd
,
626 "no redistribute ospf route-map WORD",
628 "Redistribute information from another routing protocol\n"
629 "Open Shortest Path First (OSPF)\n"
630 "Route map reference\n"
631 "Pointer to route-map entries\n")
633 bgp_redistribute_unset (vty
->index
, AFI_IP
, ZEBRA_ROUTE_OSPF
);
638 DEFUN (ipv6_bgp_redistribute_kernel
,
639 ipv6_bgp_redistribute_kernel_cmd
,
640 "redistribute kernel",
641 "Redistribute information from another routing protocol\n"
644 bgp_redistribute_set (vty
->index
, AFI_IP6
, ZEBRA_ROUTE_KERNEL
);
648 DEFUN (ipv6_bgp_redistribute_kernel_routemap
,
649 ipv6_bgp_redistribute_kernel_routemap_cmd
,
650 "redistribute kernel route-map WORD",
651 "Redistribute information from another routing protocol\n"
653 "Route map reference\n"
654 "Pointer to route-map entries\n")
656 bgp_redistribute_routemap_set (vty
->index
, AFI_IP6
, ZEBRA_ROUTE_KERNEL
, argv
[0]);
660 DEFUN (no_ipv6_bgp_redistribute_kernel
,
661 no_ipv6_bgp_redistribute_kernel_cmd
,
662 "no redistribute kernel",
664 "Redistribute information from another routing protocol\n"
667 bgp_redistribute_unset (vty
->index
, AFI_IP6
, ZEBRA_ROUTE_KERNEL
);
671 DEFUN (no_ipv6_bgp_redistribute_kernel_routemap
,
672 no_ipv6_bgp_redistribute_kernel_routemap_cmd
,
673 "no redistribute kernel route-map WORD",
675 "Redistribute information from another routing protocol\n"
677 "Route map reference\n"
678 "Pointer to route-map entries\n")
680 bgp_redistribute_unset (vty
->index
, AFI_IP6
, ZEBRA_ROUTE_KERNEL
);
684 DEFUN (ipv6_bgp_redistribute_static
,
685 ipv6_bgp_redistribute_static_cmd
,
686 "redistribute static",
687 "Redistribute information from another routing protocol\n"
690 bgp_redistribute_set (vty
->index
, AFI_IP6
, ZEBRA_ROUTE_STATIC
);
694 DEFUN (ipv6_bgp_redistribute_static_routemap
,
695 ipv6_bgp_redistribute_static_routemap_cmd
,
696 "redistribute static route-map WORD",
697 "Redistribute information from another routing protocol\n"
699 "Route map reference\n"
700 "Pointer to route-map entries\n")
702 bgp_redistribute_routemap_set (vty
->index
, AFI_IP6
, ZEBRA_ROUTE_STATIC
, argv
[0]);
706 DEFUN (no_ipv6_bgp_redistribute_static
,
707 no_ipv6_bgp_redistribute_static_cmd
,
708 "no redistribute static",
710 "Redistribute information from another routing protocol\n"
713 bgp_redistribute_unset (vty
->index
, AFI_IP6
, ZEBRA_ROUTE_STATIC
);
717 DEFUN (no_ipv6_bgp_redistribute_static_routemap
,
718 no_ipv6_bgp_redistribute_static_routemap_cmd
,
719 "no redistribute static route-map WORD",
721 "Redistribute information from another routing protocol\n"
723 "Route map reference\n"
724 "Pointer to route-map entries\n")
726 bgp_redistribute_unset (vty
->index
, AFI_IP6
, ZEBRA_ROUTE_STATIC
);
730 DEFUN (ipv6_bgp_redistribute_connected
,
731 ipv6_bgp_redistribute_connected_cmd
,
732 "redistribute connected",
733 "Redistribute information from another routing protocol\n"
736 bgp_redistribute_set (vty
->index
, AFI_IP6
, ZEBRA_ROUTE_CONNECT
);
740 DEFUN (ipv6_bgp_redistribute_connected_routemap
,
741 ipv6_bgp_redistribute_connected_routemap_cmd
,
742 "redistribute connected route-map WORD",
743 "Redistribute information from another routing protocol\n"
745 "Route map reference\n"
746 "Pointer to route-map entries\n")
748 bgp_redistribute_routemap_set (vty
->index
, AFI_IP6
, ZEBRA_ROUTE_CONNECT
, argv
[0]);
752 DEFUN (no_ipv6_bgp_redistribute_connected
,
753 no_ipv6_bgp_redistribute_connected_cmd
,
754 "no redistribute connected",
756 "Redistribute information from another routing protocol\n"
759 bgp_redistribute_unset (vty
->index
, AFI_IP6
, ZEBRA_ROUTE_CONNECT
);
763 DEFUN (no_ipv6_bgp_redistribute_connected_routemap
,
764 no_ipv6_bgp_redistribute_connected_routemap_cmd
,
765 "no redistribute connected route-map WORD",
767 "Redistribute information from another routing protocol\n"
769 "Route map reference\n"
770 "Pointer to route-map entries\n")
772 bgp_redistribute_unset (vty
->index
, AFI_IP6
, ZEBRA_ROUTE_CONNECT
);
776 DEFUN (ipv6_bgp_redistribute_ripng
,
777 ipv6_bgp_redistribute_ripng_cmd
,
778 "redistribute ripng",
779 "Redistribute information from another routing protocol\n"
780 "IPv6 Routing Information Protocol (RIPng)\n")
782 bgp_redistribute_set (vty
->index
, AFI_IP6
, ZEBRA_ROUTE_RIPNG
);
786 DEFUN (ipv6_bgp_redistribute_ripng_routemap
,
787 ipv6_bgp_redistribute_ripng_routemap_cmd
,
788 "redistribute ripng route-map WORD",
789 "Redistribute information from another routing protocol\n"
790 "IPv6 Routing Information Protocol (RIPng)\n"
791 "Route map reference\n"
792 "Pointer to route-map entries\n")
794 bgp_redistribute_routemap_set (vty
->index
, AFI_IP6
, ZEBRA_ROUTE_RIPNG
, argv
[0]);
798 DEFUN (no_ipv6_bgp_redistribute_ripng
,
799 no_ipv6_bgp_redistribute_ripng_cmd
,
800 "no redistribute ripng",
802 "Redistribute information from another routing protocol\n"
803 "IPv6 Routing Information Protocol (RIPng)\n")
805 bgp_redistribute_unset (vty
->index
, AFI_IP6
, ZEBRA_ROUTE_RIPNG
);
809 DEFUN (no_ipv6_bgp_redistribute_ripng_routemap
,
810 no_ipv6_bgp_redistribute_ripng_routemap_cmd
,
811 "no redistribute ripng route-map WORD",
813 "Redistribute information from another routing protocol\n"
814 "IPv6 Routing Information Protocol (RIPng)\n"
815 "Route map reference\n"
816 "Pointer to route-map entries\n")
818 bgp_redistribute_unset (vty
->index
, AFI_IP6
, ZEBRA_ROUTE_RIPNG
);
822 DEFUN (ipv6_bgp_redistribute_ospf6
,
823 ipv6_bgp_redistribute_ospf6_cmd
,
824 "redistribute ospf6",
825 "Redistribute information from another routing protocol\n"
826 "IPv6 Open Shortest Path First (OSPFv3)\n")
828 bgp_redistribute_set (vty
->index
, AFI_IP6
, ZEBRA_ROUTE_OSPF6
);
832 DEFUN (ipv6_bgp_redistribute_ospf6_routemap
,
833 ipv6_bgp_redistribute_ospf6_routemap_cmd
,
834 "redistribute ospf6 route-map WORD",
835 "Redistribute information from another routing protocol\n"
836 "IPv6 Open Shortest Path First (OSPFv3)\n"
837 "Route map reference\n"
838 "Pointer to route-map entries\n")
840 bgp_redistribute_routemap_set (vty
->index
, AFI_IP6
, ZEBRA_ROUTE_OSPF6
, argv
[0]);
844 DEFUN (no_ipv6_bgp_redistribute_ospf6
,
845 no_ipv6_bgp_redistribute_ospf6_cmd
,
846 "no redistribute ospf6",
848 "Redistribute information from another routing protocol\n"
849 "IPv6 Open Shortest Path First (OSPFv3)\n")
851 bgp_redistribute_unset (vty
->index
, AFI_IP6
, ZEBRA_ROUTE_OSPF6
);
855 DEFUN (no_ipv6_bgp_redistribute_ospf6_routemap
,
856 no_ipv6_bgp_redistribute_ospf6_routemap_cmd
,
857 "no redistribute ospf6 route-map WORD",
859 "Redistribute information from another routing protocol\n"
860 "IPv6 Open Shortest Path First (OSPFv3)\n"
861 "Route map reference\n"
862 "Pointer to route-map entries\n")
864 bgp_redistribute_unset (vty
->index
, AFI_IP6
, ZEBRA_ROUTE_OSPF6
);
869 ALIAS (ipv6_bgp_redistribute_kernel
,
870 old_ipv6_bgp_redistribute_kernel_cmd
,
871 "ipv6 bgp redistribute kernel",
874 "Redistribute information from another routing protocol\n"
877 ALIAS (ipv6_bgp_redistribute_kernel_routemap
,
878 old_ipv6_bgp_redistribute_kernel_routemap_cmd
,
879 "ipv6 bgp redistribute kernel route-map WORD",
882 "Redistribute information from another routing protocol\n"
884 "Route map reference\n"
885 "Pointer to route-map entries\n")
887 ALIAS (no_ipv6_bgp_redistribute_kernel
,
888 old_no_ipv6_bgp_redistribute_kernel_cmd
,
889 "no ipv6 bgp redistribute kernel",
893 "Redistribute information from another routing protocol\n"
896 ALIAS (no_ipv6_bgp_redistribute_kernel_routemap
,
897 old_no_ipv6_bgp_redistribute_kernel_routemap_cmd
,
898 "no ipv6 bgp redistribute kernel route-map WORD",
902 "Redistribute information from another routing protocol\n"
904 "Route map reference\n"
905 "Pointer to route-map entries\n")
907 ALIAS (ipv6_bgp_redistribute_static
,
908 old_ipv6_bgp_redistribute_static_cmd
,
909 "ipv6 bgp redistribute static",
912 "Redistribute information from another routing protocol\n"
915 ALIAS (ipv6_bgp_redistribute_static_routemap
,
916 old_ipv6_bgp_redistribute_static_routemap_cmd
,
917 "ipv6 bgp redistribute static route-map WORD",
920 "Redistribute information from another routing protocol\n"
922 "Route map reference\n"
923 "Pointer to route-map entries\n")
925 ALIAS (no_ipv6_bgp_redistribute_static
,
926 old_no_ipv6_bgp_redistribute_static_cmd
,
927 "no ipv6 bgp redistribute static",
931 "Redistribute information from another routing protocol\n"
934 ALIAS (no_ipv6_bgp_redistribute_static_routemap
,
935 old_no_ipv6_bgp_redistribute_static_routemap_cmd
,
936 "no ipv6 bgp redistribute static route-map WORD",
940 "Redistribute information from another routing protocol\n"
942 "Route map reference\n"
943 "Pointer to route-map entries\n")
945 ALIAS (ipv6_bgp_redistribute_connected
,
946 old_ipv6_bgp_redistribute_connected_cmd
,
947 "ipv6 bgp redistribute connected",
950 "Redistribute information from another routing protocol\n"
953 ALIAS (ipv6_bgp_redistribute_connected_routemap
,
954 old_ipv6_bgp_redistribute_connected_routemap_cmd
,
955 "ipv6 bgp redistribute connected route-map WORD",
958 "Redistribute information from another routing protocol\n"
960 "Route map reference\n"
961 "Pointer to route-map entries\n")
963 ALIAS (no_ipv6_bgp_redistribute_connected
,
964 old_no_ipv6_bgp_redistribute_connected_cmd
,
965 "no ipv6 bgp redistribute connected",
969 "Redistribute information from another routing protocol\n"
972 ALIAS (no_ipv6_bgp_redistribute_connected_routemap
,
973 old_no_ipv6_bgp_redistribute_connected_routemap_cmd
,
974 "no ipv6 bgp redistribute connected route-map WORD",
978 "Redistribute information from another routing protocol\n"
980 "Route map reference\n"
981 "Pointer to route-map entries\n")
983 ALIAS (ipv6_bgp_redistribute_ripng
,
984 old_ipv6_bgp_redistribute_ripng_cmd
,
985 "ipv6 bgp redistribute ripng",
988 "Redistribute information from another routing protocol\n"
989 "IPv6 Routing Information Protocol (RIPng)\n")
991 ALIAS (ipv6_bgp_redistribute_ripng_routemap
,
992 old_ipv6_bgp_redistribute_ripng_routemap_cmd
,
993 "ipv6 bgp redistribute ripng route-map WORD",
996 "Redistribute information from another routing protocol\n"
997 "IPv6 Routing Information Protocol (RIPng)\n"
998 "Route map reference\n"
999 "Pointer to route-map entries\n")
1001 ALIAS (no_ipv6_bgp_redistribute_ripng
,
1002 old_no_ipv6_bgp_redistribute_ripng_cmd
,
1003 "no ipv6 bgp redistribute ripng",
1007 "Redistribute information from another routing protocol\n"
1008 "IPv6 Routing Information Protocol (RIPng)\n")
1010 ALIAS (no_ipv6_bgp_redistribute_ripng_routemap
,
1011 old_no_ipv6_bgp_redistribute_ripng_routemap_cmd
,
1012 "no ipv6 bgp redistribute ripng route-map WORD",
1016 "Redistribute information from another routing protocol\n"
1017 "IPv6 Routing Information Protocol (RIPng)\n"
1018 "Route map reference\n"
1019 "Pointer to route-map entries\n")
1021 ALIAS (ipv6_bgp_redistribute_ospf6
,
1022 old_ipv6_bgp_redistribute_ospf6_cmd
,
1023 "ipv6 bgp redistribute ospf6",
1026 "Redistribute information from another routing protocol\n"
1027 "IPv6 Open Shortest Path First (OSPFv3)\n")
1029 ALIAS (ipv6_bgp_redistribute_ospf6_routemap
,
1030 old_ipv6_bgp_redistribute_ospf6_routemap_cmd
,
1031 "ipv6 bgp redistribute ospf6 route-map WORD",
1034 "Redistribute information from another routing protocol\n"
1035 "IPv6 Open Shortest Path First (OSPFv3)\n"
1036 "Route map reference\n"
1037 "Pointer to route-map entries\n")
1039 ALIAS (no_ipv6_bgp_redistribute_ospf6
,
1040 old_no_ipv6_bgp_redistribute_ospf6_cmd
,
1041 "no ipv6 bgp redistribute ospf6",
1045 "Redistribute information from another routing protocol\n"
1046 "IPv6 Open Shortest Path First (OSPFv3)\n")
1048 ALIAS (no_ipv6_bgp_redistribute_ospf6_routemap
,
1049 old_no_ipv6_bgp_redistribute_ospf6_routemap_cmd
,
1050 "no ipv6 bgp redistribute ospf6 route-map WORD",
1054 "Redistribute information from another routing protocol\n"
1055 "IPv6 Open Shortest Path First (OSPFv3)\n"
1056 "Route map reference\n"
1057 "Pointer to route-map entries\n")
1058 #endif /* HAVE_IPV6 */
1061 if_lookup_by_ipv4 (struct in_addr
*addr
)
1065 struct interface
*ifp
;
1066 struct connected
*connected
;
1067 struct prefix_ipv4 p
;
1072 p
.prefixlen
= IPV4_MAX_BITLEN
;
1074 for (ifnode
= listhead (iflist
); ifnode
; nextnode (ifnode
))
1076 ifp
= getdata (ifnode
);
1078 for (cnode
= listhead (ifp
->connected
); cnode
; nextnode (cnode
))
1080 connected
= getdata (cnode
);
1081 cp
= connected
->address
;
1083 if (cp
->family
== AF_INET
)
1084 if (prefix_match (cp
, (struct prefix
*)&p
))
1093 if_lookup_by_ipv6 (struct in6_addr
*addr
)
1097 struct interface
*ifp
;
1098 struct connected
*connected
;
1099 struct prefix_ipv6 p
;
1102 p
.family
= AF_INET6
;
1104 p
.prefixlen
= IPV6_MAX_BITLEN
;
1106 for (ifnode
= listhead (iflist
); ifnode
; nextnode (ifnode
))
1108 ifp
= getdata (ifnode
);
1110 for (cnode
= listhead (ifp
->connected
); cnode
; nextnode (cnode
))
1112 connected
= getdata (cnode
);
1113 cp
= connected
->address
;
1115 if (cp
->family
== AF_INET6
)
1116 if (prefix_match (cp
, (struct prefix
*)&p
))
1122 #endif /* HAVE_IPV6 */
1126 if_get_ipv6_global (struct interface
*ifp
, struct in6_addr
*addr
)
1129 struct connected
*connected
;
1132 for (cnode
= listhead (ifp
->connected
); cnode
; nextnode (cnode
))
1134 connected
= getdata (cnode
);
1135 cp
= connected
->address
;
1137 if (cp
->family
== AF_INET6
)
1138 if (! IN6_IS_ADDR_LINKLOCAL (&cp
->u
.prefix6
))
1140 memcpy (addr
, &cp
->u
.prefix6
, IPV6_MAX_BYTELEN
);
1148 if_get_ipv6_local (struct interface
*ifp
, struct in6_addr
*addr
)
1151 struct connected
*connected
;
1154 for (cnode
= listhead (ifp
->connected
); cnode
; nextnode (cnode
))
1156 connected
= getdata (cnode
);
1157 cp
= connected
->address
;
1159 if (cp
->family
== AF_INET6
)
1160 if (IN6_IS_ADDR_LINKLOCAL (&cp
->u
.prefix6
))
1162 memcpy (addr
, &cp
->u
.prefix6
, IPV6_MAX_BYTELEN
);
1168 #endif /* HAVE_IPV6 */
1171 bgp_nexthop_set (union sockunion
*local
, union sockunion
*remote
,
1172 struct bgp_nexthop
*nexthop
, struct peer
*peer
)
1175 struct interface
*ifp
= NULL
;
1177 memset (nexthop
, 0, sizeof (struct bgp_nexthop
));
1184 if (local
->sa
.sa_family
== AF_INET
)
1186 nexthop
->v4
= local
->sin
.sin_addr
;
1187 ifp
= if_lookup_by_ipv4 (&local
->sin
.sin_addr
);
1190 if (local
->sa
.sa_family
== AF_INET6
)
1192 if (IN6_IS_ADDR_LINKLOCAL (&local
->sin6
.sin6_addr
))
1195 ifp
= if_lookup_by_index (if_nametoindex (peer
->ifname
));
1198 ifp
= if_lookup_by_ipv6 (&local
->sin6
.sin6_addr
);
1200 #endif /* HAVE_IPV6 */
1207 /* IPv4 connection. */
1208 if (local
->sa
.sa_family
== AF_INET
)
1212 ret
= if_get_ipv6_global (ifp
, &nexthop
->v6_global
);
1214 /* There is no global nexthop. */
1216 if_get_ipv6_local (ifp
, &nexthop
->v6_global
);
1218 if_get_ipv6_local (ifp
, &nexthop
->v6_local
);
1219 #endif /* HAVE_IPV6 */
1223 /* IPv6 connection. */
1224 if (local
->sa
.sa_family
== AF_INET6
)
1226 struct interface
*direct
= NULL
;
1228 /* IPv4 nexthop. I don't care about it. */
1229 if (peer
->local_id
.s_addr
)
1230 nexthop
->v4
= peer
->local_id
;
1233 if (! IN6_IS_ADDR_LINKLOCAL (&local
->sin6
.sin6_addr
))
1235 memcpy (&nexthop
->v6_global
, &local
->sin6
.sin6_addr
,
1238 /* If directory connected set link-local address. */
1239 direct
= if_lookup_by_ipv6 (&remote
->sin6
.sin6_addr
);
1241 if_get_ipv6_local (ifp
, &nexthop
->v6_local
);
1244 /* Link-local address. */
1246 ret
= if_get_ipv6_global (ifp
, &nexthop
->v6_global
);
1248 /* If there is no global address. Set link-local address as
1249 global. I know this break RFC specification... */
1251 memcpy (&nexthop
->v6_global
, &local
->sin6
.sin6_addr
,
1254 memcpy (&nexthop
->v6_local
, &local
->sin6
.sin6_addr
,
1259 if (IN6_IS_ADDR_LINKLOCAL (&local
->sin6
.sin6_addr
) ||
1260 if_lookup_by_ipv6 (&remote
->sin6
.sin6_addr
))
1261 peer
->shared_network
= 1;
1263 peer
->shared_network
= 0;
1265 /* KAME stack specific treatment. */
1267 if (IN6_IS_ADDR_LINKLOCAL (&nexthop
->v6_global
)
1268 && IN6_LINKLOCAL_IFINDEX (nexthop
->v6_global
))
1270 SET_IN6_LINKLOCAL_IFINDEX (nexthop
->v6_global
, 0);
1272 if (IN6_IS_ADDR_LINKLOCAL (&nexthop
->v6_local
)
1273 && IN6_LINKLOCAL_IFINDEX (nexthop
->v6_local
))
1275 SET_IN6_LINKLOCAL_IFINDEX (nexthop
->v6_local
, 0);
1278 #endif /* HAVE_IPV6 */
1284 bgp_ifindex_by_nexthop (struct in6_addr
*addr
)
1288 struct interface
*ifp
;
1289 struct connected
*connected
;
1290 struct prefix_ipv6 p
;
1292 p
.family
= AF_INET6
;
1294 p
.prefixlen
= IPV6_MAX_BITLEN
;
1296 for (ifnode
= listhead (iflist
); ifnode
; nextnode (ifnode
))
1298 ifp
= getdata (ifnode
);
1300 for (cnode
= listhead (ifp
->connected
); cnode
; nextnode (cnode
))
1304 connected
= getdata (cnode
);
1305 cp
= connected
->address
;
1307 if (cp
->family
== AF_INET6
)
1309 if (prefix_match (cp
, (struct prefix
*)&p
))
1310 return ifp
->ifindex
;
1316 #endif /* HAVE_IPV6 */
1319 bgp_zebra_announce (struct prefix
*p
, struct bgp_info
*info
, struct bgp
*bgp
)
1325 if (zclient
->sock
< 0)
1328 if (! zclient
->redist
[ZEBRA_ROUTE_BGP
])
1334 if (peer_sort (peer
) == BGP_PEER_IBGP
|| peer_sort (peer
) == BGP_PEER_CONFED
)
1336 SET_FLAG (flags
, ZEBRA_FLAG_IBGP
);
1337 SET_FLAG (flags
, ZEBRA_FLAG_INTERNAL
);
1340 if (peer_sort (peer
) == BGP_PEER_EBGP
&& peer
->ttl
!= 1)
1341 SET_FLAG (flags
, ZEBRA_FLAG_INTERNAL
);
1343 if (p
->family
== AF_INET
)
1345 struct zapi_ipv4 api
;
1346 struct in_addr
*nexthop
;
1349 nexthop
= &info
->attr
->nexthop
;
1351 api
.type
= ZEBRA_ROUTE_BGP
;
1353 SET_FLAG (api
.message
, ZAPI_MESSAGE_NEXTHOP
);
1354 api
.nexthop_num
= 1;
1355 api
.nexthop
= &nexthop
;
1356 api
.ifindex_num
= 0;
1357 SET_FLAG (api
.message
, ZAPI_MESSAGE_METRIC
);
1358 api
.metric
= info
->attr
->med
;
1360 distance
= bgp_distance_apply (p
, info
, bgp
);
1364 SET_FLAG (api
.message
, ZAPI_MESSAGE_DISTANCE
);
1365 api
.distance
= distance
;
1367 zapi_ipv4_add (zclient
, (struct prefix_ipv4
*) p
, &api
);
1370 /* We have to think about a IPv6 link-local address curse. */
1371 if (p
->family
== AF_INET6
)
1373 unsigned int ifindex
;
1374 struct in6_addr
*nexthop
;
1375 struct zapi_ipv6 api
;
1380 /* Only global address nexthop exists. */
1381 if (info
->attr
->mp_nexthop_len
== 16)
1382 nexthop
= &info
->attr
->mp_nexthop_global
;
1384 /* If both global and link-local address present. */
1385 if (info
->attr
->mp_nexthop_len
== 32)
1387 /* Workaround for Cisco's nexthop bug. */
1388 if (IN6_IS_ADDR_UNSPECIFIED (&info
->attr
->mp_nexthop_global
)
1389 && peer
->su_remote
->sa
.sa_family
== AF_INET6
)
1390 nexthop
= &peer
->su_remote
->sin6
.sin6_addr
;
1392 nexthop
= &info
->attr
->mp_nexthop_local
;
1394 if (info
->peer
->nexthop
.ifp
)
1395 ifindex
= info
->peer
->nexthop
.ifp
->ifindex
;
1398 if (nexthop
== NULL
)
1401 if (IN6_IS_ADDR_LINKLOCAL (nexthop
) && ! ifindex
)
1403 if (info
->peer
->ifname
)
1404 ifindex
= if_nametoindex (info
->peer
->ifname
);
1405 else if (info
->peer
->nexthop
.ifp
)
1406 ifindex
= info
->peer
->nexthop
.ifp
->ifindex
;
1409 /* Make Zebra API structure. */
1411 api
.type
= ZEBRA_ROUTE_BGP
;
1413 SET_FLAG (api
.message
, ZAPI_MESSAGE_NEXTHOP
);
1414 api
.nexthop_num
= 1;
1415 api
.nexthop
= &nexthop
;
1416 SET_FLAG (api
.message
, ZAPI_MESSAGE_IFINDEX
);
1417 api
.ifindex_num
= 1;
1418 api
.ifindex
= &ifindex
;
1419 SET_FLAG (api
.message
, ZAPI_MESSAGE_METRIC
);
1420 api
.metric
= info
->attr
->med
;
1422 zapi_ipv6_add (zclient
, (struct prefix_ipv6
*) p
, &api
);
1424 #endif /* HAVE_IPV6 */
1428 bgp_zebra_withdraw (struct prefix
*p
, struct bgp_info
*info
)
1433 if (zclient
->sock
< 0)
1436 if (! zclient
->redist
[ZEBRA_ROUTE_BGP
])
1442 if (peer_sort (peer
) == BGP_PEER_IBGP
)
1444 SET_FLAG (flags
, ZEBRA_FLAG_INTERNAL
);
1445 SET_FLAG (flags
, ZEBRA_FLAG_IBGP
);
1448 if (peer_sort (peer
) == BGP_PEER_EBGP
&& peer
->ttl
!= 1)
1449 SET_FLAG (flags
, ZEBRA_FLAG_INTERNAL
);
1451 if (p
->family
== AF_INET
)
1453 struct zapi_ipv4 api
;
1454 struct in_addr
*nexthop
;
1457 nexthop
= &info
->attr
->nexthop
;
1459 api
.type
= ZEBRA_ROUTE_BGP
;
1461 SET_FLAG (api
.message
, ZAPI_MESSAGE_NEXTHOP
);
1462 api
.nexthop_num
= 1;
1463 api
.nexthop
= &nexthop
;
1464 api
.ifindex_num
= 0;
1465 SET_FLAG (api
.message
, ZAPI_MESSAGE_METRIC
);
1466 api
.metric
= info
->attr
->med
;
1468 zapi_ipv4_delete (zclient
, (struct prefix_ipv4
*) p
, &api
);
1471 /* We have to think about a IPv6 link-local address curse. */
1472 if (p
->family
== AF_INET6
)
1474 struct zapi_ipv6 api
;
1475 unsigned int ifindex
;
1476 struct in6_addr
*nexthop
;
1481 /* Only global address nexthop exists. */
1482 if (info
->attr
->mp_nexthop_len
== 16)
1483 nexthop
= &info
->attr
->mp_nexthop_global
;
1485 /* If both global and link-local address present. */
1486 if (info
->attr
->mp_nexthop_len
== 32)
1488 nexthop
= &info
->attr
->mp_nexthop_local
;
1489 if (info
->peer
->nexthop
.ifp
)
1490 ifindex
= info
->peer
->nexthop
.ifp
->ifindex
;
1493 if (nexthop
== NULL
)
1496 if (IN6_IS_ADDR_LINKLOCAL (nexthop
) && ! ifindex
)
1497 if (info
->peer
->ifname
)
1498 ifindex
= if_nametoindex (info
->peer
->ifname
);
1501 api
.type
= ZEBRA_ROUTE_BGP
;
1503 SET_FLAG (api
.message
, ZAPI_MESSAGE_NEXTHOP
);
1504 api
.nexthop_num
= 1;
1505 api
.nexthop
= &nexthop
;
1506 SET_FLAG (api
.message
, ZAPI_MESSAGE_IFINDEX
);
1507 api
.ifindex_num
= 1;
1508 api
.ifindex
= &ifindex
;
1509 SET_FLAG (api
.message
, ZAPI_MESSAGE_METRIC
);
1510 api
.metric
= info
->attr
->med
;
1512 zapi_ipv6_delete (zclient
, (struct prefix_ipv6
*) p
, &api
);
1514 #endif /* HAVE_IPV6 */
1517 DEFUN (router_zebra
,
1520 "Enable a routing process\n"
1521 "Make connection to zebra daemon\n")
1523 vty
->node
= ZEBRA_NODE
;
1524 zclient
->enable
= 1;
1525 zclient_start (zclient
);
1529 DEFUN (no_router_zebra
,
1530 no_router_zebra_cmd
,
1533 "Configure routing process\n"
1534 "Disable connection to zebra daemon\n")
1536 zclient
->enable
= 0;
1537 zclient_stop (zclient
);
1541 DEFUN (redistribute_bgp
,
1542 redistribute_bgp_cmd
,
1544 "Redistribute control\n"
1547 zclient
->redist
[ZEBRA_ROUTE_BGP
] = 1;
1551 DEFUN (no_redistribute_bgp
,
1552 no_redistribute_bgp_cmd
,
1553 "no redistribute bgp",
1555 "Redistribute control\n"
1558 zclient
->redist
[ZEBRA_ROUTE_BGP
] = 0;
1562 /* Zebra configuration write function. */
1564 zebra_config_write (struct vty
*vty
)
1566 if (! zclient
->enable
)
1568 vty_out (vty
, "no router zebra%s", VTY_NEWLINE
);
1571 else if (! zclient
->redist
[ZEBRA_ROUTE_BGP
])
1573 vty_out (vty
, "router zebra%s", VTY_NEWLINE
);
1574 vty_out (vty
, " no redistribute bgp%s", VTY_NEWLINE
);
1580 /* Redistribute configuration. */
1582 bgp_config_write_redistribute (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
1583 safi_t safi
, int *write
)
1586 char *str
[] = { "system", "kernel", "connected", "static", "rip",
1587 "ripng", "ospf", "ospf6", "bgp"};
1589 if (safi
!= SAFI_UNICAST
)
1592 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++)
1594 if (i
!= ZEBRA_ROUTE_BGP
&& bgp
->redist
[afi
][i
])
1596 /* "address-family" display. */
1597 bgp_config_write_family_header (vty
, afi
, safi
, write
);
1599 if (bgp
->rmap
[afi
][i
].name
)
1600 vty_out (vty
, "%sredistribute %s route-map %s%s",
1601 afi
== AFI_IP
? " " : " ",
1602 str
[i
], bgp
->rmap
[afi
][i
].name
, VTY_NEWLINE
);
1604 vty_out (vty
, "%sredistribute %s%s",
1605 afi
== AFI_IP
? " " : " ",
1606 str
[i
], VTY_NEWLINE
);
1612 /* Zebra node structure. */
1613 struct cmd_node zebra_node
=
1616 "%s(config-router)# ",
1620 bgp_zclient_reset ()
1622 zclient_reset (zclient
);
1626 zebra_init (int enable
)
1628 /* Set default values. */
1629 zclient
= zclient_new ();
1630 zclient_init (zclient
, ZEBRA_ROUTE_BGP
);
1631 zclient
->interface_add
= bgp_interface_add
;
1632 zclient
->interface_delete
= bgp_interface_delete
;
1633 zclient
->interface_address_add
= bgp_interface_address_add
;
1634 zclient
->interface_address_delete
= bgp_interface_address_delete
;
1635 zclient
->ipv4_route_add
= zebra_read_ipv4
;
1636 zclient
->ipv4_route_delete
= zebra_read_ipv4
;
1637 zclient
->interface_up
= bgp_interface_up
;
1638 zclient
->interface_down
= bgp_interface_down
;
1640 zclient
->ipv6_route_add
= zebra_read_ipv6
;
1641 zclient
->ipv6_route_delete
= zebra_read_ipv6
;
1642 #endif /* HAVE_IPV6 */
1644 /* Install zebra node. */
1645 install_node (&zebra_node
, zebra_config_write
);
1647 install_element (CONFIG_NODE
, &router_zebra_cmd
);
1648 install_element (CONFIG_NODE
, &no_router_zebra_cmd
);
1649 install_default (ZEBRA_NODE
);
1650 install_element (ZEBRA_NODE
, &redistribute_bgp_cmd
);
1651 install_element (ZEBRA_NODE
, &no_redistribute_bgp_cmd
);
1653 install_element (BGP_NODE
, &bgp_redistribute_kernel_cmd
);
1654 install_element (BGP_NODE
, &bgp_redistribute_kernel_routemap_cmd
);
1655 install_element (BGP_NODE
, &no_bgp_redistribute_kernel_cmd
);
1656 install_element (BGP_NODE
, &no_bgp_redistribute_kernel_routemap_cmd
);
1657 install_element (BGP_NODE
, &bgp_redistribute_static_cmd
);
1658 install_element (BGP_NODE
, &bgp_redistribute_static_routemap_cmd
);
1659 install_element (BGP_NODE
, &no_bgp_redistribute_static_cmd
);
1660 install_element (BGP_NODE
, &no_bgp_redistribute_static_routemap_cmd
);
1661 install_element (BGP_NODE
, &bgp_redistribute_connected_cmd
);
1662 install_element (BGP_NODE
, &bgp_redistribute_connected_routemap_cmd
);
1663 install_element (BGP_NODE
, &no_bgp_redistribute_connected_cmd
);
1664 install_element (BGP_NODE
, &no_bgp_redistribute_connected_routemap_cmd
);
1665 install_element (BGP_NODE
, &bgp_redistribute_rip_cmd
);
1666 install_element (BGP_NODE
, &bgp_redistribute_rip_routemap_cmd
);
1667 install_element (BGP_NODE
, &no_bgp_redistribute_rip_cmd
);
1668 install_element (BGP_NODE
, &no_bgp_redistribute_rip_routemap_cmd
);
1669 install_element (BGP_NODE
, &bgp_redistribute_ospf_cmd
);
1670 install_element (BGP_NODE
, &bgp_redistribute_ospf_routemap_cmd
);
1671 install_element (BGP_NODE
, &no_bgp_redistribute_ospf_cmd
);
1672 install_element (BGP_NODE
, &no_bgp_redistribute_ospf_routemap_cmd
);
1675 install_element (BGP_IPV6_NODE
, &ipv6_bgp_redistribute_kernel_cmd
);
1676 install_element (BGP_IPV6_NODE
, &ipv6_bgp_redistribute_kernel_routemap_cmd
);
1677 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_redistribute_kernel_cmd
);
1678 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_redistribute_kernel_routemap_cmd
);
1679 install_element (BGP_IPV6_NODE
, &ipv6_bgp_redistribute_static_cmd
);
1680 install_element (BGP_IPV6_NODE
, &ipv6_bgp_redistribute_static_routemap_cmd
);
1681 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_redistribute_static_cmd
);
1682 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_redistribute_static_routemap_cmd
);
1683 install_element (BGP_IPV6_NODE
, &ipv6_bgp_redistribute_connected_cmd
);
1684 install_element (BGP_IPV6_NODE
, &ipv6_bgp_redistribute_connected_routemap_cmd
);
1685 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_redistribute_connected_cmd
);
1686 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_redistribute_connected_routemap_cmd
);
1687 install_element (BGP_IPV6_NODE
, &ipv6_bgp_redistribute_ripng_cmd
);
1688 install_element (BGP_IPV6_NODE
, &ipv6_bgp_redistribute_ripng_routemap_cmd
);
1689 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_redistribute_ripng_cmd
);
1690 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_redistribute_ripng_routemap_cmd
);
1691 install_element (BGP_IPV6_NODE
, &ipv6_bgp_redistribute_ospf6_cmd
);
1692 install_element (BGP_IPV6_NODE
, &ipv6_bgp_redistribute_ospf6_routemap_cmd
);
1693 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_redistribute_ospf6_cmd
);
1694 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_redistribute_ospf6_routemap_cmd
);
1696 install_element (BGP_NODE
, &old_ipv6_bgp_redistribute_kernel_cmd
);
1697 install_element (BGP_NODE
, &old_ipv6_bgp_redistribute_kernel_routemap_cmd
);
1698 install_element (BGP_NODE
, &old_no_ipv6_bgp_redistribute_kernel_cmd
);
1699 install_element (BGP_NODE
, &old_no_ipv6_bgp_redistribute_kernel_routemap_cmd
);
1700 install_element (BGP_NODE
, &old_ipv6_bgp_redistribute_static_cmd
);
1701 install_element (BGP_NODE
, &old_ipv6_bgp_redistribute_static_routemap_cmd
);
1702 install_element (BGP_NODE
, &old_no_ipv6_bgp_redistribute_static_cmd
);
1703 install_element (BGP_NODE
, &old_no_ipv6_bgp_redistribute_static_routemap_cmd
);
1704 install_element (BGP_NODE
, &old_ipv6_bgp_redistribute_connected_cmd
);
1705 install_element (BGP_NODE
, &old_ipv6_bgp_redistribute_connected_routemap_cmd
);
1706 install_element (BGP_NODE
, &old_no_ipv6_bgp_redistribute_connected_cmd
);
1707 install_element (BGP_NODE
, &old_no_ipv6_bgp_redistribute_connected_routemap_cmd
);
1708 install_element (BGP_NODE
, &old_ipv6_bgp_redistribute_ripng_cmd
);
1709 install_element (BGP_NODE
, &old_ipv6_bgp_redistribute_ripng_routemap_cmd
);
1710 install_element (BGP_NODE
, &old_no_ipv6_bgp_redistribute_ripng_cmd
);
1711 install_element (BGP_NODE
, &old_no_ipv6_bgp_redistribute_ripng_routemap_cmd
);
1712 install_element (BGP_NODE
, &old_ipv6_bgp_redistribute_ospf6_cmd
);
1713 install_element (BGP_NODE
, &old_ipv6_bgp_redistribute_ospf6_routemap_cmd
);
1714 install_element (BGP_NODE
, &old_no_ipv6_bgp_redistribute_ospf6_cmd
);
1715 install_element (BGP_NODE
, &old_no_ipv6_bgp_redistribute_ospf6_routemap_cmd
);
1716 #endif /* HAVE_IPV6 */
1718 /* Interface related init. */