2 * Interface related function for RIPng.
3 * Copyright (C) 1998 Kunihiro Ishiguro
5 * This file is part of GNU Zebra.
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Zebra; see the file COPYING. If not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
39 #include "ripngd/ripngd.h"
40 #include "ripngd/ripng_debug.h"
42 /* If RFC2133 definition is used. */
43 #ifndef IPV6_JOIN_GROUP
44 #define IPV6_JOIN_GROUP IPV6_ADD_MEMBERSHIP
46 #ifndef IPV6_LEAVE_GROUP
47 #define IPV6_LEAVE_GROUP IPV6_DROP_MEMBERSHIP
50 extern struct zebra_privs_t ripngd_privs
;
52 /* Static utility function. */
53 static void ripng_enable_apply (struct interface
*);
54 static void ripng_passive_interface_apply (struct interface
*);
55 static int ripng_enable_if_lookup (const char *);
56 static int ripng_enable_network_lookup2 (struct connected
*);
57 static void ripng_enable_apply_all (void);
59 /* Join to the all rip routers multicast group. */
61 ripng_multicast_join (struct interface
*ifp
)
64 struct ipv6_mreq mreq
;
67 if (if_is_up (ifp
) && if_is_multicast (ifp
)) {
68 memset (&mreq
, 0, sizeof (mreq
));
69 inet_pton(AF_INET6
, RIPNG_GROUP
, &mreq
.ipv6mr_multiaddr
);
70 mreq
.ipv6mr_interface
= ifp
->ifindex
;
73 * NetBSD 1.6.2 requires root to join groups on gif(4).
74 * While this is bogus, privs are available and easy to use
75 * for this call as a workaround.
77 if (ripngd_privs
.change (ZPRIVS_RAISE
))
78 zlog_err ("ripng_multicast_join: could not raise privs");
80 ret
= setsockopt (ripng
->sock
, IPPROTO_IPV6
, IPV6_JOIN_GROUP
,
81 (char *) &mreq
, sizeof (mreq
));
84 if (ripngd_privs
.change (ZPRIVS_LOWER
))
85 zlog_err ("ripng_multicast_join: could not lower privs");
87 if (ret
< 0 && save_errno
== EADDRINUSE
)
90 * Group is already joined. This occurs due to sloppy group
91 * management, in particular declining to leave the group on
92 * an interface that has just gone down.
94 zlog_warn ("ripng join on %s EADDRINUSE (ignoring)\n", ifp
->name
);
95 return 0; /* not an error */
99 zlog_warn ("can't setsockopt IPV6_JOIN_GROUP: %s",
100 safe_strerror (save_errno
));
102 if (IS_RIPNG_DEBUG_EVENT
)
103 zlog_debug ("RIPng %s join to all-rip-routers multicast group", ifp
->name
);
111 /* Leave from the all rip routers multicast group. */
113 ripng_multicast_leave (struct interface
*ifp
)
116 struct ipv6_mreq mreq
;
118 if (if_is_up (ifp
) && if_is_multicast (ifp
)) {
119 memset (&mreq
, 0, sizeof (mreq
));
120 inet_pton(AF_INET6
, RIPNG_GROUP
, &mreq
.ipv6mr_multiaddr
);
121 mreq
.ipv6mr_interface
= ifp
->ifindex
;
123 ret
= setsockopt (ripng
->sock
, IPPROTO_IPV6
, IPV6_LEAVE_GROUP
,
124 (char *) &mreq
, sizeof (mreq
));
126 zlog_warn ("can't setsockopt IPV6_LEAVE_GROUP: %s\n", safe_strerror (errno
));
128 if (IS_RIPNG_DEBUG_EVENT
)
129 zlog_debug ("RIPng %s leave from all-rip-routers multicast group",
139 /* How many link local IPv6 address could be used on the interface ? */
141 ripng_if_ipv6_lladdress_check (struct interface
*ifp
)
144 struct connected
*connected
;
147 for (ALL_LIST_ELEMENTS_RO (ifp
->connected
, nn
, connected
))
150 p
= connected
->address
;
152 if ((p
->family
== AF_INET6
) &&
153 IN6_IS_ADDR_LINKLOCAL (&p
->u
.prefix6
))
160 /* Check max mtu size. */
162 ripng_check_max_mtu (void)
164 struct listnode
*node
;
165 struct interface
*ifp
;
169 for (ALL_LIST_ELEMENTS_RO (iflist
, node
, ifp
))
177 ripng_if_down (struct interface
*ifp
)
179 struct route_node
*rp
;
180 struct ripng_info
*rinfo
;
181 struct ripng_interface
*ri
;
185 for (rp
= route_top (ripng
->table
); rp
; rp
= route_next (rp
))
186 if ((rinfo
= rp
->info
) != NULL
)
188 /* Routes got through this interface. */
189 if (rinfo
->ifindex
== ifp
->ifindex
190 && rinfo
->type
== ZEBRA_ROUTE_RIPNG
191 && rinfo
->sub_type
== RIPNG_ROUTE_RTE
)
193 ripng_zebra_ipv6_delete ((struct prefix_ipv6
*) &rp
->p
,
197 ripng_redistribute_delete (rinfo
->type
, rinfo
->sub_type
,
198 (struct prefix_ipv6
*)&rp
->p
,
203 /* All redistributed routes got through this interface,
204 * but the static and system ones are kept. */
205 if ((rinfo
->ifindex
== ifp
->ifindex
) &&
206 (rinfo
->type
!= ZEBRA_ROUTE_STATIC
) &&
207 (rinfo
->type
!= ZEBRA_ROUTE_SYSTEM
))
208 ripng_redistribute_delete (rinfo
->type
, rinfo
->sub_type
,
209 (struct prefix_ipv6
*) &rp
->p
,
219 if (IS_RIPNG_DEBUG_EVENT
)
220 zlog_debug ("turn off %s", ifp
->name
);
222 /* Leave from multicast group. */
223 ripng_multicast_leave (ifp
);
231 /* Inteface link up message processing. */
233 ripng_interface_up (int command
, struct zclient
*zclient
, zebra_size_t length
)
236 struct interface
*ifp
;
238 /* zebra_interface_state_read() updates interface structure in iflist. */
240 ifp
= zebra_interface_state_read (s
);
245 if (IS_RIPNG_DEBUG_ZEBRA
)
246 zlog_debug ("interface up %s index %d flags %ld metric %d mtu %d",
247 ifp
->name
, ifp
->ifindex
, ifp
->flags
, ifp
->metric
, ifp
->mtu6
);
249 /* Check if this interface is RIPng enabled or not. */
250 ripng_enable_apply (ifp
);
252 /* Check for a passive interface. */
253 ripng_passive_interface_apply (ifp
);
255 /* Apply distribute list to the all interface. */
256 ripng_distribute_update_interface (ifp
);
261 /* Inteface link down message processing. */
263 ripng_interface_down (int command
, struct zclient
*zclient
,
267 struct interface
*ifp
;
269 /* zebra_interface_state_read() updates interface structure in iflist. */
271 ifp
= zebra_interface_state_read (s
);
278 if (IS_RIPNG_DEBUG_ZEBRA
)
279 zlog_debug ("interface down %s index %d flags %ld metric %d mtu %d",
280 ifp
->name
, ifp
->ifindex
, ifp
->flags
, ifp
->metric
, ifp
->mtu6
);
285 /* Inteface addition message from zebra. */
287 ripng_interface_add (int command
, struct zclient
*zclient
, zebra_size_t length
)
289 struct interface
*ifp
;
291 ifp
= zebra_interface_add_read (zclient
->ibuf
);
293 if (IS_RIPNG_DEBUG_ZEBRA
)
294 zlog_debug ("RIPng interface add %s index %d flags %ld metric %d mtu %d",
295 ifp
->name
, ifp
->ifindex
, ifp
->flags
, ifp
->metric
, ifp
->mtu6
);
297 /* Check is this interface is RIP enabled or not.*/
298 ripng_enable_apply (ifp
);
300 /* Apply distribute list to the interface. */
301 ripng_distribute_update_interface (ifp
);
303 /* Check interface routemap. */
304 ripng_if_rmap_update_interface (ifp
);
310 ripng_interface_delete (int command
, struct zclient
*zclient
,
313 struct interface
*ifp
;
317 /* zebra_interface_state_read() updates interface structure in iflist */
318 ifp
= zebra_interface_state_read(s
);
323 if (if_is_up (ifp
)) {
327 zlog_info("interface delete %s index %d flags %ld metric %d mtu %d",
328 ifp
->name
, ifp
->ifindex
, ifp
->flags
, ifp
->metric
, ifp
->mtu6
);
330 /* To support pseudo interface do not free interface structure. */
331 /* if_delete(ifp); */
332 ifp
->ifindex
= IFINDEX_INTERNAL
;
338 ripng_interface_clean (void)
340 struct listnode
*node
, *nnode
;
341 struct interface
*ifp
;
342 struct ripng_interface
*ri
;
344 for (ALL_LIST_ELEMENTS (iflist
, node
, nnode
, ifp
))
348 ri
->enable_network
= 0;
349 ri
->enable_interface
= 0;
354 thread_cancel (ri
->t_wakeup
);
361 ripng_interface_reset (void)
363 struct listnode
*node
;
364 struct interface
*ifp
;
365 struct ripng_interface
*ri
;
367 for (ALL_LIST_ELEMENTS_RO (iflist
, node
, ifp
))
371 ri
->enable_network
= 0;
372 ri
->enable_interface
= 0;
375 ri
->split_horizon
= RIPNG_NO_SPLIT_HORIZON
;
376 ri
->split_horizon_default
= RIPNG_NO_SPLIT_HORIZON
;
378 ri
->list
[RIPNG_FILTER_IN
] = NULL
;
379 ri
->list
[RIPNG_FILTER_OUT
] = NULL
;
381 ri
->prefix
[RIPNG_FILTER_IN
] = NULL
;
382 ri
->prefix
[RIPNG_FILTER_OUT
] = NULL
;
386 thread_cancel (ri
->t_wakeup
);
395 ripng_apply_address_add (struct connected
*ifc
) {
396 struct prefix_ipv6 address
;
402 if (! if_is_up(ifc
->ifp
))
407 memset (&address
, 0, sizeof (address
));
408 address
.family
= p
->family
;
409 address
.prefix
= p
->u
.prefix6
;
410 address
.prefixlen
= p
->prefixlen
;
411 apply_mask_ipv6(&address
);
413 /* Check if this interface is RIP enabled or not
414 or Check if this address's prefix is RIP enabled */
415 if ((ripng_enable_if_lookup(ifc
->ifp
->name
) >= 0) ||
416 (ripng_enable_network_lookup2(ifc
) >= 0))
417 ripng_redistribute_add(ZEBRA_ROUTE_CONNECT
, RIPNG_ROUTE_INTERFACE
,
418 &address
, ifc
->ifp
->ifindex
, NULL
);
423 ripng_interface_address_add (int command
, struct zclient
*zclient
,
429 c
= zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_ADD
,
437 if (p
->family
== AF_INET6
)
439 struct ripng_interface
*ri
= c
->ifp
->info
;
441 if (IS_RIPNG_DEBUG_ZEBRA
)
442 zlog_debug ("RIPng connected address %s/%d add",
443 inet6_ntoa(p
->u
.prefix6
),
446 /* Check is this prefix needs to be redistributed. */
447 ripng_apply_address_add(c
);
449 /* Let's try once again whether the interface could be activated */
451 /* Check if this interface is RIP enabled or not.*/
452 ripng_enable_apply (c
->ifp
);
454 /* Apply distribute list to the interface. */
455 ripng_distribute_update_interface (c
->ifp
);
457 /* Check interface routemap. */
458 ripng_if_rmap_update_interface (c
->ifp
);
467 ripng_apply_address_del (struct connected
*ifc
) {
468 struct prefix_ipv6 address
;
474 if (! if_is_up(ifc
->ifp
))
479 memset (&address
, 0, sizeof (address
));
480 address
.family
= p
->family
;
481 address
.prefix
= p
->u
.prefix6
;
482 address
.prefixlen
= p
->prefixlen
;
483 apply_mask_ipv6(&address
);
485 ripng_redistribute_delete(ZEBRA_ROUTE_CONNECT
, RIPNG_ROUTE_INTERFACE
,
486 &address
, ifc
->ifp
->ifindex
);
490 ripng_interface_address_delete (int command
, struct zclient
*zclient
,
493 struct connected
*ifc
;
495 char buf
[INET6_ADDRSTRLEN
];
497 ifc
= zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_DELETE
,
504 if (p
->family
== AF_INET6
)
506 if (IS_RIPNG_DEBUG_ZEBRA
)
507 zlog_debug ("RIPng connected address %s/%d delete",
508 inet_ntop (AF_INET6
, &p
->u
.prefix6
, buf
,
512 /* Check wether this prefix needs to be removed. */
513 ripng_apply_address_del(ifc
);
515 connected_free (ifc
);
521 /* RIPng enable interface vector. */
522 vector ripng_enable_if
;
524 /* RIPng enable network table. */
525 struct route_table
*ripng_enable_network
;
527 /* Lookup RIPng enable network. */
528 /* Check wether the interface has at least a connected prefix that
529 * is within the ripng_enable_network table. */
531 ripng_enable_network_lookup_if (struct interface
*ifp
)
533 struct listnode
*node
;
534 struct connected
*connected
;
535 struct prefix_ipv6 address
;
537 for (ALL_LIST_ELEMENTS_RO (ifp
->connected
, node
, connected
))
540 struct route_node
*node
;
542 p
= connected
->address
;
544 if (p
->family
== AF_INET6
)
546 address
.family
= AF_INET6
;
547 address
.prefix
= p
->u
.prefix6
;
548 address
.prefixlen
= IPV6_MAX_BITLEN
;
550 node
= route_node_match (ripng_enable_network
,
551 (struct prefix
*)&address
);
554 route_unlock_node (node
);
562 /* Check wether connected is within the ripng_enable_network table. */
564 ripng_enable_network_lookup2 (struct connected
*connected
)
566 struct prefix_ipv6 address
;
569 p
= connected
->address
;
571 if (p
->family
== AF_INET6
) {
572 struct route_node
*node
;
574 address
.family
= p
->family
;
575 address
.prefix
= p
->u
.prefix6
;
576 address
.prefixlen
= IPV6_MAX_BITLEN
;
578 /* LPM on p->family, p->u.prefix6/IPV6_MAX_BITLEN within ripng_enable_network */
579 node
= route_node_match (ripng_enable_network
,
580 (struct prefix
*)&address
);
583 route_unlock_node (node
);
591 /* Add RIPng enable network. */
593 ripng_enable_network_add (struct prefix
*p
)
595 struct route_node
*node
;
597 node
= route_node_get (ripng_enable_network
, p
);
601 route_unlock_node (node
);
605 node
->info
= (char *) "enabled";
607 /* XXX: One should find a better solution than a generic one */
608 ripng_enable_apply_all();
613 /* Delete RIPng enable network. */
615 ripng_enable_network_delete (struct prefix
*p
)
617 struct route_node
*node
;
619 node
= route_node_lookup (ripng_enable_network
, p
);
624 /* Unlock info lock. */
625 route_unlock_node (node
);
627 /* Unlock lookup lock. */
628 route_unlock_node (node
);
635 /* Lookup function. */
637 ripng_enable_if_lookup (const char *ifname
)
642 for (i
= 0; i
< vector_active (ripng_enable_if
); i
++)
643 if ((str
= vector_slot (ripng_enable_if
, i
)) != NULL
)
644 if (strcmp (str
, ifname
) == 0)
649 /* Add interface to ripng_enable_if. */
651 ripng_enable_if_add (const char *ifname
)
655 ret
= ripng_enable_if_lookup (ifname
);
659 vector_set (ripng_enable_if
, strdup (ifname
));
661 ripng_enable_apply_all();
666 /* Delete interface from ripng_enable_if. */
668 ripng_enable_if_delete (const char *ifname
)
673 index
= ripng_enable_if_lookup (ifname
);
677 str
= vector_slot (ripng_enable_if
, index
);
679 vector_unset (ripng_enable_if
, index
);
681 ripng_enable_apply_all();
686 /* Wake up interface. */
688 ripng_interface_wakeup (struct thread
*t
)
690 struct interface
*ifp
;
691 struct ripng_interface
*ri
;
694 ifp
= THREAD_ARG (t
);
699 /* Join to multicast group. */
700 if (ripng_multicast_join (ifp
) < 0) {
701 zlog_err ("multicast join failed, interface %s not running", ifp
->name
);
705 /* Set running flag. */
708 /* Send RIP request to the interface. */
715 ripng_connect_set (struct interface
*ifp
, int set
)
717 struct listnode
*node
, *nnode
;
718 struct connected
*connected
;
719 struct prefix_ipv6 address
;
721 for (ALL_LIST_ELEMENTS (ifp
->connected
, node
, nnode
, connected
))
724 p
= connected
->address
;
726 if (p
->family
!= AF_INET6
)
729 address
.family
= AF_INET6
;
730 address
.prefix
= p
->u
.prefix6
;
731 address
.prefixlen
= p
->prefixlen
;
732 apply_mask_ipv6 (&address
);
735 /* Check once more wether this prefix is within a "network IF_OR_PREF" one */
736 if ((ripng_enable_if_lookup(connected
->ifp
->name
) >= 0) ||
737 (ripng_enable_network_lookup2(connected
) >= 0))
738 ripng_redistribute_add (ZEBRA_ROUTE_CONNECT
, RIPNG_ROUTE_INTERFACE
,
739 &address
, connected
->ifp
->ifindex
, NULL
);
741 ripng_redistribute_delete (ZEBRA_ROUTE_CONNECT
, RIPNG_ROUTE_INTERFACE
,
742 &address
, connected
->ifp
->ifindex
);
743 if (ripng_redistribute_check (ZEBRA_ROUTE_CONNECT
))
744 ripng_redistribute_add (ZEBRA_ROUTE_CONNECT
, RIPNG_ROUTE_REDISTRIBUTE
,
745 &address
, connected
->ifp
->ifindex
, NULL
);
750 /* Check RIPng is enabed on this interface. */
752 ripng_enable_apply (struct interface
*ifp
)
755 struct ripng_interface
*ri
= NULL
;
757 /* Check interface. */
758 if (! if_is_up (ifp
))
763 /* Is this interface a candidate for RIPng ? */
764 ret
= ripng_enable_network_lookup_if (ifp
);
766 /* If the interface is matched. */
768 ri
->enable_network
= 1;
770 ri
->enable_network
= 0;
772 /* Check interface name configuration. */
773 ret
= ripng_enable_if_lookup (ifp
->name
);
775 ri
->enable_interface
= 1;
777 ri
->enable_interface
= 0;
779 /* any candidate interface MUST have a link-local IPv6 address */
780 if ((! ripng_if_ipv6_lladdress_check (ifp
)) &&
781 (ri
->enable_network
|| ri
->enable_interface
)) {
782 ri
->enable_network
= 0;
783 ri
->enable_interface
= 0;
784 zlog_warn("Interface %s does not have any link-local address",
788 /* Update running status of the interface. */
789 if (ri
->enable_network
|| ri
->enable_interface
)
792 if (IS_RIPNG_DEBUG_EVENT
)
793 zlog_debug ("RIPng turn on %s", ifp
->name
);
795 /* Add interface wake up thread. */
797 ri
->t_wakeup
= thread_add_timer (master
, ripng_interface_wakeup
,
800 ripng_connect_set (ifp
, 1);
807 /* Might as well clean up the route table as well
808 * ripng_if_down sets to 0 ri->running, and displays "turn off %s"
812 ripng_connect_set (ifp
, 0);
817 /* Set distribute list to all interfaces. */
819 ripng_enable_apply_all (void)
821 struct interface
*ifp
;
822 struct listnode
*node
;
824 for (ALL_LIST_ELEMENTS_RO (iflist
, node
, ifp
))
825 ripng_enable_apply (ifp
);
828 /* Clear all network and neighbor configuration */
830 ripng_clean_network ()
834 struct route_node
*rn
;
836 /* ripng_enable_network */
837 for (rn
= route_top (ripng_enable_network
); rn
; rn
= route_next (rn
))
840 route_unlock_node(rn
);
843 /* ripng_enable_if */
844 for (i
= 0; i
< vector_active (ripng_enable_if
); i
++)
845 if ((str
= vector_slot (ripng_enable_if
, i
)) != NULL
) {
847 vector_slot (ripng_enable_if
, i
) = NULL
;
851 /* Vector to store passive-interface name. */
852 vector Vripng_passive_interface
;
854 /* Utility function for looking up passive interface settings. */
856 ripng_passive_interface_lookup (const char *ifname
)
861 for (i
= 0; i
< vector_active (Vripng_passive_interface
); i
++)
862 if ((str
= vector_slot (Vripng_passive_interface
, i
)) != NULL
)
863 if (strcmp (str
, ifname
) == 0)
869 ripng_passive_interface_apply (struct interface
*ifp
)
872 struct ripng_interface
*ri
;
876 ret
= ripng_passive_interface_lookup (ifp
->name
);
884 ripng_passive_interface_apply_all (void)
886 struct interface
*ifp
;
887 struct listnode
*node
;
889 for (ALL_LIST_ELEMENTS_RO (iflist
, node
, ifp
))
890 ripng_passive_interface_apply (ifp
);
893 /* Passive interface. */
895 ripng_passive_interface_set (struct vty
*vty
, const char *ifname
)
897 if (ripng_passive_interface_lookup (ifname
) >= 0)
900 vector_set (Vripng_passive_interface
, strdup (ifname
));
902 ripng_passive_interface_apply_all ();
908 ripng_passive_interface_unset (struct vty
*vty
, const char *ifname
)
913 i
= ripng_passive_interface_lookup (ifname
);
917 str
= vector_slot (Vripng_passive_interface
, i
);
919 vector_unset (Vripng_passive_interface
, i
);
921 ripng_passive_interface_apply_all ();
926 /* Free all configured RIP passive-interface settings. */
928 ripng_passive_interface_clean (void)
933 for (i
= 0; i
< vector_active (Vripng_passive_interface
); i
++)
934 if ((str
= vector_slot (Vripng_passive_interface
, i
)) != NULL
)
937 vector_slot (Vripng_passive_interface
, i
) = NULL
;
939 ripng_passive_interface_apply_all ();
942 /* Write RIPng enable network and interface to the vty. */
944 ripng_network_write (struct vty
*vty
, int config_mode
)
948 struct route_node
*node
;
951 /* Write enable network. */
952 for (node
= route_top (ripng_enable_network
); node
; node
= route_next (node
))
955 struct prefix
*p
= &node
->p
;
956 vty_out (vty
, "%s%s/%d%s",
957 config_mode
? " network " : " ",
958 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
964 /* Write enable interface. */
965 for (i
= 0; i
< vector_active (ripng_enable_if
); i
++)
966 if ((ifname
= vector_slot (ripng_enable_if
, i
)) != NULL
)
967 vty_out (vty
, "%s%s%s",
968 config_mode
? " network " : " ",
972 /* Write passive interface. */
974 for (i
= 0; i
< vector_active (Vripng_passive_interface
); i
++)
975 if ((ifname
= vector_slot (Vripng_passive_interface
, i
)) != NULL
)
976 vty_out (vty
, " passive-interface %s%s", ifname
, VTY_NEWLINE
);
981 /* RIPng enable on specified interface or matched network. */
982 DEFUN (ripng_network
,
984 "network IF_OR_ADDR",
985 "RIPng enable on specified interface or network.\n"
986 "Interface or address")
991 ret
= str2prefix (argv
[0], &p
);
993 /* Given string is IPv6 network or interface name. */
995 ret
= ripng_enable_network_add (&p
);
997 ret
= ripng_enable_if_add (argv
[0]);
1001 vty_out (vty
, "There is same network configuration %s%s", argv
[0],
1009 /* RIPng enable on specified interface or matched network. */
1010 DEFUN (no_ripng_network
,
1011 no_ripng_network_cmd
,
1012 "no network IF_OR_ADDR",
1014 "RIPng enable on specified interface or network.\n"
1015 "Interface or address")
1020 ret
= str2prefix (argv
[0], &p
);
1022 /* Given string is interface name. */
1024 ret
= ripng_enable_network_delete (&p
);
1026 ret
= ripng_enable_if_delete (argv
[0]);
1030 vty_out (vty
, "can't find network %s%s", argv
[0],
1038 DEFUN (ipv6_ripng_split_horizon
,
1039 ipv6_ripng_split_horizon_cmd
,
1040 "ipv6 ripng split-horizon",
1042 "Routing Information Protocol\n"
1043 "Perform split horizon\n")
1045 struct interface
*ifp
;
1046 struct ripng_interface
*ri
;
1051 ri
->split_horizon
= RIPNG_SPLIT_HORIZON
;
1055 DEFUN (ipv6_ripng_split_horizon_poisoned_reverse
,
1056 ipv6_ripng_split_horizon_poisoned_reverse_cmd
,
1057 "ipv6 ripng split-horizon poisoned-reverse",
1059 "Routing Information Protocol\n"
1060 "Perform split horizon\n"
1061 "With poisoned-reverse\n")
1063 struct interface
*ifp
;
1064 struct ripng_interface
*ri
;
1069 ri
->split_horizon
= RIPNG_SPLIT_HORIZON_POISONED_REVERSE
;
1073 DEFUN (no_ipv6_ripng_split_horizon
,
1074 no_ipv6_ripng_split_horizon_cmd
,
1075 "no ipv6 ripng split-horizon",
1078 "Routing Information Protocol\n"
1079 "Perform split horizon\n")
1081 struct interface
*ifp
;
1082 struct ripng_interface
*ri
;
1087 ri
->split_horizon
= RIPNG_NO_SPLIT_HORIZON
;
1091 ALIAS (no_ipv6_ripng_split_horizon
,
1092 no_ipv6_ripng_split_horizon_poisoned_reverse_cmd
,
1093 "no ipv6 ripng split-horizon poisoned-reverse",
1096 "Routing Information Protocol\n"
1097 "Perform split horizon\n"
1098 "With poisoned-reverse\n")
1100 DEFUN (ripng_passive_interface
,
1101 ripng_passive_interface_cmd
,
1102 "passive-interface IFNAME",
1103 "Suppress routing updates on an interface\n"
1106 return ripng_passive_interface_set (vty
, argv
[0]);
1109 DEFUN (no_ripng_passive_interface
,
1110 no_ripng_passive_interface_cmd
,
1111 "no passive-interface IFNAME",
1113 "Suppress routing updates on an interface\n"
1116 return ripng_passive_interface_unset (vty
, argv
[0]);
1119 static struct ripng_interface
*
1122 struct ripng_interface
*ri
;
1123 ri
= XCALLOC (MTYPE_IF
, sizeof (struct ripng_interface
));
1125 /* Set default split-horizon behavior. If the interface is Frame
1126 Relay or SMDS is enabled, the default value for split-horizon is
1127 off. But currently Zebra does detect Frame Relay or SMDS
1128 interface. So all interface is set to split horizon. */
1129 ri
->split_horizon_default
= RIPNG_SPLIT_HORIZON
;
1130 ri
->split_horizon
= ri
->split_horizon_default
;
1136 ripng_if_new_hook (struct interface
*ifp
)
1138 ifp
->info
= ri_new ();
1142 /* Called when interface structure deleted. */
1144 ripng_if_delete_hook (struct interface
*ifp
)
1146 XFREE (MTYPE_IF
, ifp
->info
);
1151 /* Configuration write function for ripngd. */
1153 interface_config_write (struct vty
*vty
)
1155 struct listnode
*node
;
1156 struct interface
*ifp
;
1157 struct ripng_interface
*ri
;
1160 for (ALL_LIST_ELEMENTS_RO (iflist
, node
, ifp
))
1164 /* Do not display the interface if there is no
1165 * configuration about it.
1168 (ri
->split_horizon
== ri
->split_horizon_default
))
1171 vty_out (vty
, "interface %s%s", ifp
->name
,
1174 vty_out (vty
, " description %s%s", ifp
->desc
,
1177 /* Split horizon. */
1178 if (ri
->split_horizon
!= ri
->split_horizon_default
)
1180 switch (ri
->split_horizon
) {
1181 case RIPNG_SPLIT_HORIZON
:
1182 vty_out (vty
, " ipv6 ripng split-horizon%s", VTY_NEWLINE
);
1184 case RIPNG_SPLIT_HORIZON_POISONED_REVERSE
:
1185 vty_out (vty
, " ipv6 ripng split-horizon poisoned-reverse%s",
1188 case RIPNG_NO_SPLIT_HORIZON
:
1190 vty_out (vty
, " no ipv6 ripng split-horizon%s", VTY_NEWLINE
);
1195 vty_out (vty
, "!%s", VTY_NEWLINE
);
1202 /* ripngd's interface node. */
1203 static struct cmd_node interface_node
=
1210 /* Initialization of interface. */
1214 /* Interface initialize. */
1215 iflist
= list_new ();
1216 if_add_hook (IF_NEW_HOOK
, ripng_if_new_hook
);
1217 if_add_hook (IF_DELETE_HOOK
, ripng_if_delete_hook
);
1219 /* RIPng enable network init. */
1220 ripng_enable_network
= route_table_init ();
1222 /* RIPng enable interface init. */
1223 ripng_enable_if
= vector_init (1);
1225 /* RIPng passive interface. */
1226 Vripng_passive_interface
= vector_init (1);
1228 /* Install interface node. */
1229 install_node (&interface_node
, interface_config_write
);
1231 /* Install commands. */
1232 install_element (CONFIG_NODE
, &interface_cmd
);
1233 install_element (CONFIG_NODE
, &no_interface_cmd
);
1234 install_default (INTERFACE_NODE
);
1235 install_element (INTERFACE_NODE
, &interface_desc_cmd
);
1236 install_element (INTERFACE_NODE
, &no_interface_desc_cmd
);
1238 install_element (RIPNG_NODE
, &ripng_network_cmd
);
1239 install_element (RIPNG_NODE
, &no_ripng_network_cmd
);
1240 install_element (RIPNG_NODE
, &ripng_passive_interface_cmd
);
1241 install_element (RIPNG_NODE
, &no_ripng_passive_interface_cmd
);
1243 install_element (INTERFACE_NODE
, &ipv6_ripng_split_horizon_cmd
);
1244 install_element (INTERFACE_NODE
, &ipv6_ripng_split_horizon_poisoned_reverse_cmd
);
1245 install_element (INTERFACE_NODE
, &no_ipv6_ripng_split_horizon_cmd
);
1246 install_element (INTERFACE_NODE
, &no_ipv6_ripng_split_horizon_poisoned_reverse_cmd
);