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 int ripng_enable_if_lookup (const char *ifname
);
56 int ripng_enable_network_lookup2 (struct connected
*connected
);
57 void ripng_enable_apply_all ();
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 ()
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 ()
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 () {
362 struct listnode
*node
;
363 struct interface
*ifp
;
364 struct ripng_interface
*ri
;
366 for (ALL_LIST_ELEMENTS_RO (iflist
, node
, ifp
))
370 ri
->enable_network
= 0;
371 ri
->enable_interface
= 0;
374 ri
->split_horizon
= RIPNG_NO_SPLIT_HORIZON
;
375 ri
->split_horizon_default
= RIPNG_NO_SPLIT_HORIZON
;
377 ri
->list
[RIPNG_FILTER_IN
] = NULL
;
378 ri
->list
[RIPNG_FILTER_OUT
] = NULL
;
380 ri
->prefix
[RIPNG_FILTER_IN
] = NULL
;
381 ri
->prefix
[RIPNG_FILTER_OUT
] = NULL
;
385 thread_cancel (ri
->t_wakeup
);
394 ripng_apply_address_add (struct connected
*ifc
) {
395 struct prefix_ipv6 address
;
401 if (! if_is_up(ifc
->ifp
))
406 memset (&address
, 0, sizeof (address
));
407 address
.family
= p
->family
;
408 address
.prefix
= p
->u
.prefix6
;
409 address
.prefixlen
= p
->prefixlen
;
410 apply_mask_ipv6(&address
);
412 /* Check if this interface is RIP enabled or not
413 or Check if this address's prefix is RIP enabled */
414 if ((ripng_enable_if_lookup(ifc
->ifp
->name
) >= 0) ||
415 (ripng_enable_network_lookup2(ifc
) >= 0))
416 ripng_redistribute_add(ZEBRA_ROUTE_CONNECT
, RIPNG_ROUTE_INTERFACE
,
417 &address
, ifc
->ifp
->ifindex
, NULL
);
422 ripng_interface_address_add (int command
, struct zclient
*zclient
,
428 c
= zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_ADD
,
436 if (p
->family
== AF_INET6
)
438 if (IS_RIPNG_DEBUG_ZEBRA
)
439 zlog_debug ("RIPng connected address %s/%d add",
440 inet6_ntoa(&p
->u
.prefix6
),
443 /* Check is this prefix needs to be redistributed. */
444 ripng_apply_address_add(c
);
446 /* Let's try once again whether the interface could be activated */
448 struct ripng_interface
*ri
= c
->ifp
->info
;
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
);
468 ripng_apply_address_del (struct connected
*ifc
) {
469 struct prefix_ipv6 address
;
475 if (! if_is_up(ifc
->ifp
))
480 memset (&address
, 0, sizeof (address
));
481 address
.family
= p
->family
;
482 address
.prefix
= p
->u
.prefix6
;
483 address
.prefixlen
= p
->prefixlen
;
484 apply_mask_ipv6(&address
);
486 ripng_redistribute_delete(ZEBRA_ROUTE_CONNECT
, RIPNG_ROUTE_INTERFACE
,
487 &address
, ifc
->ifp
->ifindex
);
491 ripng_interface_address_delete (int command
, struct zclient
*zclient
,
494 struct connected
*ifc
;
496 char buf
[INET6_ADDRSTRLEN
];
498 ifc
= zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_DELETE
,
505 if (p
->family
== AF_INET6
)
507 if (IS_RIPNG_DEBUG_ZEBRA
)
508 zlog_debug ("RIPng connected address %s/%d delete",
509 inet_ntop (AF_INET6
, &p
->u
.prefix6
, buf
,
513 /* Check wether this prefix needs to be removed. */
514 ripng_apply_address_del(ifc
);
516 connected_free (ifc
);
522 /* RIPng enable interface vector. */
523 vector ripng_enable_if
;
525 /* RIPng enable network table. */
526 struct route_table
*ripng_enable_network
;
528 /* Lookup RIPng enable network. */
529 /* Check wether the interface has at least a connected prefix that
530 * is within the ripng_enable_network table. */
532 ripng_enable_network_lookup_if (struct interface
*ifp
)
534 struct listnode
*node
;
535 struct connected
*connected
;
536 struct prefix_ipv6 address
;
538 for (ALL_LIST_ELEMENTS_RO (ifp
->connected
, node
, connected
))
541 struct route_node
*node
;
543 p
= connected
->address
;
545 if (p
->family
== AF_INET6
)
547 address
.family
= AF_INET6
;
548 address
.prefix
= p
->u
.prefix6
;
549 address
.prefixlen
= IPV6_MAX_BITLEN
;
551 node
= route_node_match (ripng_enable_network
,
552 (struct prefix
*)&address
);
555 route_unlock_node (node
);
563 /* Check wether connected is within the ripng_enable_network table. */
565 ripng_enable_network_lookup2 (struct connected
*connected
)
567 struct prefix_ipv6 address
;
570 p
= connected
->address
;
572 if (p
->family
== AF_INET6
) {
573 struct route_node
*node
;
575 address
.family
= p
->family
;
576 address
.prefix
= p
->u
.prefix6
;
577 address
.prefixlen
= IPV6_MAX_BITLEN
;
579 /* LPM on p->family, p->u.prefix6/IPV6_MAX_BITLEN within ripng_enable_network */
580 node
= route_node_match (ripng_enable_network
,
581 (struct prefix
*)&address
);
584 route_unlock_node (node
);
592 /* Add RIPng enable network. */
594 ripng_enable_network_add (struct prefix
*p
)
596 struct route_node
*node
;
598 node
= route_node_get (ripng_enable_network
, p
);
602 route_unlock_node (node
);
606 node
->info
= (char *) "enabled";
608 /* XXX: One should find a better solution than a generic one */
609 ripng_enable_apply_all();
614 /* Delete RIPng enable network. */
616 ripng_enable_network_delete (struct prefix
*p
)
618 struct route_node
*node
;
620 node
= route_node_lookup (ripng_enable_network
, p
);
625 /* Unlock info lock. */
626 route_unlock_node (node
);
628 /* Unlock lookup lock. */
629 route_unlock_node (node
);
636 /* Lookup function. */
638 ripng_enable_if_lookup (const char *ifname
)
643 for (i
= 0; i
< vector_active (ripng_enable_if
); i
++)
644 if ((str
= vector_slot (ripng_enable_if
, i
)) != NULL
)
645 if (strcmp (str
, ifname
) == 0)
650 /* Add interface to ripng_enable_if. */
652 ripng_enable_if_add (const char *ifname
)
656 ret
= ripng_enable_if_lookup (ifname
);
660 vector_set (ripng_enable_if
, strdup (ifname
));
662 ripng_enable_apply_all();
667 /* Delete interface from ripng_enable_if. */
669 ripng_enable_if_delete (const char *ifname
)
674 index
= ripng_enable_if_lookup (ifname
);
678 str
= vector_slot (ripng_enable_if
, index
);
680 vector_unset (ripng_enable_if
, index
);
682 ripng_enable_apply_all();
687 /* Wake up interface. */
689 ripng_interface_wakeup (struct thread
*t
)
691 struct interface
*ifp
;
692 struct ripng_interface
*ri
;
695 ifp
= THREAD_ARG (t
);
700 /* Join to multicast group. */
701 if (ripng_multicast_join (ifp
) < 0) {
702 zlog_err ("multicast join failed, interface %s not running", ifp
->name
);
706 /* Set running flag. */
709 /* Send RIP request to the interface. */
715 int ripng_redistribute_check (int);
718 ripng_connect_set (struct interface
*ifp
, int set
)
720 struct listnode
*node
, *nnode
;
721 struct connected
*connected
;
722 struct prefix_ipv6 address
;
724 for (ALL_LIST_ELEMENTS (ifp
->connected
, node
, nnode
, connected
))
727 p
= connected
->address
;
729 if (p
->family
!= AF_INET6
)
732 address
.family
= AF_INET6
;
733 address
.prefix
= p
->u
.prefix6
;
734 address
.prefixlen
= p
->prefixlen
;
735 apply_mask_ipv6 (&address
);
738 /* Check once more wether this prefix is within a "network IF_OR_PREF" one */
739 if ((ripng_enable_if_lookup(connected
->ifp
->name
) >= 0) ||
740 (ripng_enable_network_lookup2(connected
) >= 0))
741 ripng_redistribute_add (ZEBRA_ROUTE_CONNECT
, RIPNG_ROUTE_INTERFACE
,
742 &address
, connected
->ifp
->ifindex
, NULL
);
744 ripng_redistribute_delete (ZEBRA_ROUTE_CONNECT
, RIPNG_ROUTE_INTERFACE
,
745 &address
, connected
->ifp
->ifindex
);
746 if (ripng_redistribute_check (ZEBRA_ROUTE_CONNECT
))
747 ripng_redistribute_add (ZEBRA_ROUTE_CONNECT
, RIPNG_ROUTE_REDISTRIBUTE
,
748 &address
, connected
->ifp
->ifindex
, NULL
);
753 /* Check RIPng is enabed on this interface. */
755 ripng_enable_apply (struct interface
*ifp
)
758 struct ripng_interface
*ri
= NULL
;
760 /* Check interface. */
761 if (! if_is_up (ifp
))
766 /* Is this interface a candidate for RIPng ? */
767 ret
= ripng_enable_network_lookup_if (ifp
);
769 /* If the interface is matched. */
771 ri
->enable_network
= 1;
773 ri
->enable_network
= 0;
775 /* Check interface name configuration. */
776 ret
= ripng_enable_if_lookup (ifp
->name
);
778 ri
->enable_interface
= 1;
780 ri
->enable_interface
= 0;
782 /* any candidate interface MUST have a link-local IPv6 address */
783 if ((! ripng_if_ipv6_lladdress_check (ifp
)) &&
784 (ri
->enable_network
|| ri
->enable_interface
)) {
785 ri
->enable_network
= 0;
786 ri
->enable_interface
= 0;
787 zlog_warn("Interface %s does not have any link-local address",
791 /* Update running status of the interface. */
792 if (ri
->enable_network
|| ri
->enable_interface
)
795 if (IS_RIPNG_DEBUG_EVENT
)
796 zlog_debug ("RIPng turn on %s", ifp
->name
);
798 /* Add interface wake up thread. */
800 ri
->t_wakeup
= thread_add_timer (master
, ripng_interface_wakeup
,
803 ripng_connect_set (ifp
, 1);
810 /* Might as well clean up the route table as well
811 * ripng_if_down sets to 0 ri->running, and displays "turn off %s"
815 ripng_connect_set (ifp
, 0);
820 /* Set distribute list to all interfaces. */
822 ripng_enable_apply_all ()
824 struct interface
*ifp
;
825 struct listnode
*node
;
827 for (ALL_LIST_ELEMENTS_RO (iflist
, node
, ifp
))
828 ripng_enable_apply (ifp
);
831 /* Clear all network and neighbor configuration */
833 ripng_clean_network ()
837 struct route_node
*rn
;
839 /* ripng_enable_network */
840 for (rn
= route_top (ripng_enable_network
); rn
; rn
= route_next (rn
))
843 route_unlock_node(rn
);
846 /* ripng_enable_if */
847 for (i
= 0; i
< vector_active (ripng_enable_if
); i
++)
848 if ((str
= vector_slot (ripng_enable_if
, i
)) != NULL
) {
850 vector_slot (ripng_enable_if
, i
) = NULL
;
854 /* Vector to store passive-interface name. */
855 vector Vripng_passive_interface
;
857 /* Utility function for looking up passive interface settings. */
859 ripng_passive_interface_lookup (const char *ifname
)
864 for (i
= 0; i
< vector_active (Vripng_passive_interface
); i
++)
865 if ((str
= vector_slot (Vripng_passive_interface
, i
)) != NULL
)
866 if (strcmp (str
, ifname
) == 0)
872 ripng_passive_interface_apply (struct interface
*ifp
)
875 struct ripng_interface
*ri
;
879 ret
= ripng_passive_interface_lookup (ifp
->name
);
887 ripng_passive_interface_apply_all (void)
889 struct interface
*ifp
;
890 struct listnode
*node
;
892 for (ALL_LIST_ELEMENTS_RO (iflist
, node
, ifp
))
893 ripng_passive_interface_apply (ifp
);
896 /* Passive interface. */
898 ripng_passive_interface_set (struct vty
*vty
, const char *ifname
)
900 if (ripng_passive_interface_lookup (ifname
) >= 0)
903 vector_set (Vripng_passive_interface
, strdup (ifname
));
905 ripng_passive_interface_apply_all ();
911 ripng_passive_interface_unset (struct vty
*vty
, const char *ifname
)
916 i
= ripng_passive_interface_lookup (ifname
);
920 str
= vector_slot (Vripng_passive_interface
, i
);
922 vector_unset (Vripng_passive_interface
, i
);
924 ripng_passive_interface_apply_all ();
929 /* Free all configured RIP passive-interface settings. */
931 ripng_passive_interface_clean (void)
936 for (i
= 0; i
< vector_active (Vripng_passive_interface
); i
++)
937 if ((str
= vector_slot (Vripng_passive_interface
, i
)) != NULL
)
940 vector_slot (Vripng_passive_interface
, i
) = NULL
;
942 ripng_passive_interface_apply_all ();
945 /* Write RIPng enable network and interface to the vty. */
947 ripng_network_write (struct vty
*vty
, int config_mode
)
951 struct route_node
*node
;
954 /* Write enable network. */
955 for (node
= route_top (ripng_enable_network
); node
; node
= route_next (node
))
958 struct prefix
*p
= &node
->p
;
959 vty_out (vty
, "%s%s/%d%s",
960 config_mode
? " network " : " ",
961 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
967 /* Write enable interface. */
968 for (i
= 0; i
< vector_active (ripng_enable_if
); i
++)
969 if ((ifname
= vector_slot (ripng_enable_if
, i
)) != NULL
)
970 vty_out (vty
, "%s%s%s",
971 config_mode
? " network " : " ",
975 /* Write passive interface. */
977 for (i
= 0; i
< vector_active (Vripng_passive_interface
); i
++)
978 if ((ifname
= vector_slot (Vripng_passive_interface
, i
)) != NULL
)
979 vty_out (vty
, " passive-interface %s%s", ifname
, VTY_NEWLINE
);
984 /* RIPng enable on specified interface or matched network. */
985 DEFUN (ripng_network
,
987 "network IF_OR_ADDR",
988 "RIPng enable on specified interface or network.\n"
989 "Interface or address")
994 ret
= str2prefix (argv
[0], &p
);
996 /* Given string is IPv6 network or interface name. */
998 ret
= ripng_enable_network_add (&p
);
1000 ret
= ripng_enable_if_add (argv
[0]);
1004 vty_out (vty
, "There is same network configuration %s%s", argv
[0],
1012 /* RIPng enable on specified interface or matched network. */
1013 DEFUN (no_ripng_network
,
1014 no_ripng_network_cmd
,
1015 "no network IF_OR_ADDR",
1017 "RIPng enable on specified interface or network.\n"
1018 "Interface or address")
1023 ret
= str2prefix (argv
[0], &p
);
1025 /* Given string is interface name. */
1027 ret
= ripng_enable_network_delete (&p
);
1029 ret
= ripng_enable_if_delete (argv
[0]);
1033 vty_out (vty
, "can't find network %s%s", argv
[0],
1041 DEFUN (ipv6_ripng_split_horizon
,
1042 ipv6_ripng_split_horizon_cmd
,
1043 "ipv6 ripng split-horizon",
1045 "Routing Information Protocol\n"
1046 "Perform split horizon\n")
1048 struct interface
*ifp
;
1049 struct ripng_interface
*ri
;
1054 ri
->split_horizon
= RIPNG_SPLIT_HORIZON
;
1058 DEFUN (ipv6_ripng_split_horizon_poisoned_reverse
,
1059 ipv6_ripng_split_horizon_poisoned_reverse_cmd
,
1060 "ipv6 ripng split-horizon poisoned-reverse",
1062 "Routing Information Protocol\n"
1063 "Perform split horizon\n"
1064 "With poisoned-reverse\n")
1066 struct interface
*ifp
;
1067 struct ripng_interface
*ri
;
1072 ri
->split_horizon
= RIPNG_SPLIT_HORIZON_POISONED_REVERSE
;
1076 DEFUN (no_ipv6_ripng_split_horizon
,
1077 no_ipv6_ripng_split_horizon_cmd
,
1078 "no ipv6 ripng split-horizon",
1081 "Routing Information Protocol\n"
1082 "Perform split horizon\n")
1084 struct interface
*ifp
;
1085 struct ripng_interface
*ri
;
1090 ri
->split_horizon
= RIPNG_NO_SPLIT_HORIZON
;
1094 ALIAS (no_ipv6_ripng_split_horizon
,
1095 no_ipv6_ripng_split_horizon_poisoned_reverse_cmd
,
1096 "no ipv6 ripng split-horizon poisoned-reverse",
1099 "Routing Information Protocol\n"
1100 "Perform split horizon\n"
1101 "With poisoned-reverse\n")
1103 DEFUN (ripng_passive_interface
,
1104 ripng_passive_interface_cmd
,
1105 "passive-interface IFNAME",
1106 "Suppress routing updates on an interface\n"
1109 return ripng_passive_interface_set (vty
, argv
[0]);
1112 DEFUN (no_ripng_passive_interface
,
1113 no_ripng_passive_interface_cmd
,
1114 "no passive-interface IFNAME",
1116 "Suppress routing updates on an interface\n"
1119 return ripng_passive_interface_unset (vty
, argv
[0]);
1122 struct ripng_interface
*
1125 struct ripng_interface
*ri
;
1126 ri
= XCALLOC (MTYPE_IF
, sizeof (struct ripng_interface
));
1128 /* Set default split-horizon behavior. If the interface is Frame
1129 Relay or SMDS is enabled, the default value for split-horizon is
1130 off. But currently Zebra does detect Frame Relay or SMDS
1131 interface. So all interface is set to split horizon. */
1132 ri
->split_horizon_default
= RIPNG_SPLIT_HORIZON
;
1133 ri
->split_horizon
= ri
->split_horizon_default
;
1139 ripng_if_new_hook (struct interface
*ifp
)
1141 ifp
->info
= ri_new ();
1145 /* Called when interface structure deleted. */
1147 ripng_if_delete_hook (struct interface
*ifp
)
1149 XFREE (MTYPE_IF
, ifp
->info
);
1154 /* Configuration write function for ripngd. */
1156 interface_config_write (struct vty
*vty
)
1158 struct listnode
*node
;
1159 struct interface
*ifp
;
1160 struct ripng_interface
*ri
;
1163 for (ALL_LIST_ELEMENTS_RO (iflist
, node
, ifp
))
1167 /* Do not display the interface if there is no
1168 * configuration about it.
1171 (ri
->split_horizon
== ri
->split_horizon_default
))
1174 vty_out (vty
, "interface %s%s", ifp
->name
,
1177 vty_out (vty
, " description %s%s", ifp
->desc
,
1180 /* Split horizon. */
1181 if (ri
->split_horizon
!= ri
->split_horizon_default
)
1183 switch (ri
->split_horizon
) {
1184 case RIPNG_SPLIT_HORIZON
:
1185 vty_out (vty
, " ipv6 ripng split-horizon%s", VTY_NEWLINE
);
1187 case RIPNG_SPLIT_HORIZON_POISONED_REVERSE
:
1188 vty_out (vty
, " ipv6 ripng split-horizon poisoned-reverse%s",
1191 case RIPNG_NO_SPLIT_HORIZON
:
1193 vty_out (vty
, " no ipv6 ripng split-horizon%s", VTY_NEWLINE
);
1198 vty_out (vty
, "!%s", VTY_NEWLINE
);
1205 /* ripngd's interface node. */
1206 struct cmd_node interface_node
=
1213 /* Initialization of interface. */
1217 /* Interface initialize. */
1218 iflist
= list_new ();
1219 if_add_hook (IF_NEW_HOOK
, ripng_if_new_hook
);
1220 if_add_hook (IF_DELETE_HOOK
, ripng_if_delete_hook
);
1222 /* RIPng enable network init. */
1223 ripng_enable_network
= route_table_init ();
1225 /* RIPng enable interface init. */
1226 ripng_enable_if
= vector_init (1);
1228 /* RIPng passive interface. */
1229 Vripng_passive_interface
= vector_init (1);
1231 /* Install interface node. */
1232 install_node (&interface_node
, interface_config_write
);
1234 /* Install commands. */
1235 install_element (CONFIG_NODE
, &interface_cmd
);
1236 install_element (CONFIG_NODE
, &no_interface_cmd
);
1237 install_default (INTERFACE_NODE
);
1238 install_element (INTERFACE_NODE
, &interface_desc_cmd
);
1239 install_element (INTERFACE_NODE
, &no_interface_desc_cmd
);
1241 install_element (RIPNG_NODE
, &ripng_network_cmd
);
1242 install_element (RIPNG_NODE
, &no_ripng_network_cmd
);
1243 install_element (RIPNG_NODE
, &ripng_passive_interface_cmd
);
1244 install_element (RIPNG_NODE
, &no_ripng_passive_interface_cmd
);
1246 install_element (INTERFACE_NODE
, &ipv6_ripng_split_horizon_cmd
);
1247 install_element (INTERFACE_NODE
, &ipv6_ripng_split_horizon_poisoned_reverse_cmd
);
1248 install_element (INTERFACE_NODE
, &no_ipv6_ripng_split_horizon_cmd
);
1249 install_element (INTERFACE_NODE
, &no_ipv6_ripng_split_horizon_poisoned_reverse_cmd
);