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 struct ripng_interface
*ri
= c
->ifp
->info
;
440 if (IS_RIPNG_DEBUG_ZEBRA
)
441 zlog_debug ("RIPng connected address %s/%d add",
442 inet6_ntoa(p
->u
.prefix6
),
445 /* Check is this prefix needs to be redistributed. */
446 ripng_apply_address_add(c
);
448 /* Let's try once again whether the interface could be activated */
450 /* Check if this interface is RIP enabled or not.*/
451 ripng_enable_apply (c
->ifp
);
453 /* Apply distribute list to the interface. */
454 ripng_distribute_update_interface (c
->ifp
);
456 /* Check interface routemap. */
457 ripng_if_rmap_update_interface (c
->ifp
);
466 ripng_apply_address_del (struct connected
*ifc
) {
467 struct prefix_ipv6 address
;
473 if (! if_is_up(ifc
->ifp
))
478 memset (&address
, 0, sizeof (address
));
479 address
.family
= p
->family
;
480 address
.prefix
= p
->u
.prefix6
;
481 address
.prefixlen
= p
->prefixlen
;
482 apply_mask_ipv6(&address
);
484 ripng_redistribute_delete(ZEBRA_ROUTE_CONNECT
, RIPNG_ROUTE_INTERFACE
,
485 &address
, ifc
->ifp
->ifindex
);
489 ripng_interface_address_delete (int command
, struct zclient
*zclient
,
492 struct connected
*ifc
;
494 char buf
[INET6_ADDRSTRLEN
];
496 ifc
= zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_DELETE
,
503 if (p
->family
== AF_INET6
)
505 if (IS_RIPNG_DEBUG_ZEBRA
)
506 zlog_debug ("RIPng connected address %s/%d delete",
507 inet_ntop (AF_INET6
, &p
->u
.prefix6
, buf
,
511 /* Check wether this prefix needs to be removed. */
512 ripng_apply_address_del(ifc
);
514 connected_free (ifc
);
520 /* RIPng enable interface vector. */
521 vector ripng_enable_if
;
523 /* RIPng enable network table. */
524 struct route_table
*ripng_enable_network
;
526 /* Lookup RIPng enable network. */
527 /* Check wether the interface has at least a connected prefix that
528 * is within the ripng_enable_network table. */
530 ripng_enable_network_lookup_if (struct interface
*ifp
)
532 struct listnode
*node
;
533 struct connected
*connected
;
534 struct prefix_ipv6 address
;
536 for (ALL_LIST_ELEMENTS_RO (ifp
->connected
, node
, connected
))
539 struct route_node
*node
;
541 p
= connected
->address
;
543 if (p
->family
== AF_INET6
)
545 address
.family
= AF_INET6
;
546 address
.prefix
= p
->u
.prefix6
;
547 address
.prefixlen
= IPV6_MAX_BITLEN
;
549 node
= route_node_match (ripng_enable_network
,
550 (struct prefix
*)&address
);
553 route_unlock_node (node
);
561 /* Check wether connected is within the ripng_enable_network table. */
563 ripng_enable_network_lookup2 (struct connected
*connected
)
565 struct prefix_ipv6 address
;
568 p
= connected
->address
;
570 if (p
->family
== AF_INET6
) {
571 struct route_node
*node
;
573 address
.family
= p
->family
;
574 address
.prefix
= p
->u
.prefix6
;
575 address
.prefixlen
= IPV6_MAX_BITLEN
;
577 /* LPM on p->family, p->u.prefix6/IPV6_MAX_BITLEN within ripng_enable_network */
578 node
= route_node_match (ripng_enable_network
,
579 (struct prefix
*)&address
);
582 route_unlock_node (node
);
590 /* Add RIPng enable network. */
592 ripng_enable_network_add (struct prefix
*p
)
594 struct route_node
*node
;
596 node
= route_node_get (ripng_enable_network
, p
);
600 route_unlock_node (node
);
604 node
->info
= (char *) "enabled";
606 /* XXX: One should find a better solution than a generic one */
607 ripng_enable_apply_all();
612 /* Delete RIPng enable network. */
614 ripng_enable_network_delete (struct prefix
*p
)
616 struct route_node
*node
;
618 node
= route_node_lookup (ripng_enable_network
, p
);
623 /* Unlock info lock. */
624 route_unlock_node (node
);
626 /* Unlock lookup lock. */
627 route_unlock_node (node
);
634 /* Lookup function. */
636 ripng_enable_if_lookup (const char *ifname
)
641 for (i
= 0; i
< vector_active (ripng_enable_if
); i
++)
642 if ((str
= vector_slot (ripng_enable_if
, i
)) != NULL
)
643 if (strcmp (str
, ifname
) == 0)
648 /* Add interface to ripng_enable_if. */
650 ripng_enable_if_add (const char *ifname
)
654 ret
= ripng_enable_if_lookup (ifname
);
658 vector_set (ripng_enable_if
, strdup (ifname
));
660 ripng_enable_apply_all();
665 /* Delete interface from ripng_enable_if. */
667 ripng_enable_if_delete (const char *ifname
)
672 index
= ripng_enable_if_lookup (ifname
);
676 str
= vector_slot (ripng_enable_if
, index
);
678 vector_unset (ripng_enable_if
, index
);
680 ripng_enable_apply_all();
685 /* Wake up interface. */
687 ripng_interface_wakeup (struct thread
*t
)
689 struct interface
*ifp
;
690 struct ripng_interface
*ri
;
693 ifp
= THREAD_ARG (t
);
698 /* Join to multicast group. */
699 if (ripng_multicast_join (ifp
) < 0) {
700 zlog_err ("multicast join failed, interface %s not running", ifp
->name
);
704 /* Set running flag. */
707 /* Send RIP request to the interface. */
713 int ripng_redistribute_check (int);
716 ripng_connect_set (struct interface
*ifp
, int set
)
718 struct listnode
*node
, *nnode
;
719 struct connected
*connected
;
720 struct prefix_ipv6 address
;
722 for (ALL_LIST_ELEMENTS (ifp
->connected
, node
, nnode
, connected
))
725 p
= connected
->address
;
727 if (p
->family
!= AF_INET6
)
730 address
.family
= AF_INET6
;
731 address
.prefix
= p
->u
.prefix6
;
732 address
.prefixlen
= p
->prefixlen
;
733 apply_mask_ipv6 (&address
);
736 /* Check once more wether this prefix is within a "network IF_OR_PREF" one */
737 if ((ripng_enable_if_lookup(connected
->ifp
->name
) >= 0) ||
738 (ripng_enable_network_lookup2(connected
) >= 0))
739 ripng_redistribute_add (ZEBRA_ROUTE_CONNECT
, RIPNG_ROUTE_INTERFACE
,
740 &address
, connected
->ifp
->ifindex
, NULL
);
742 ripng_redistribute_delete (ZEBRA_ROUTE_CONNECT
, RIPNG_ROUTE_INTERFACE
,
743 &address
, connected
->ifp
->ifindex
);
744 if (ripng_redistribute_check (ZEBRA_ROUTE_CONNECT
))
745 ripng_redistribute_add (ZEBRA_ROUTE_CONNECT
, RIPNG_ROUTE_REDISTRIBUTE
,
746 &address
, connected
->ifp
->ifindex
, NULL
);
751 /* Check RIPng is enabed on this interface. */
753 ripng_enable_apply (struct interface
*ifp
)
756 struct ripng_interface
*ri
= NULL
;
758 /* Check interface. */
759 if (! if_is_up (ifp
))
764 /* Is this interface a candidate for RIPng ? */
765 ret
= ripng_enable_network_lookup_if (ifp
);
767 /* If the interface is matched. */
769 ri
->enable_network
= 1;
771 ri
->enable_network
= 0;
773 /* Check interface name configuration. */
774 ret
= ripng_enable_if_lookup (ifp
->name
);
776 ri
->enable_interface
= 1;
778 ri
->enable_interface
= 0;
780 /* any candidate interface MUST have a link-local IPv6 address */
781 if ((! ripng_if_ipv6_lladdress_check (ifp
)) &&
782 (ri
->enable_network
|| ri
->enable_interface
)) {
783 ri
->enable_network
= 0;
784 ri
->enable_interface
= 0;
785 zlog_warn("Interface %s does not have any link-local address",
789 /* Update running status of the interface. */
790 if (ri
->enable_network
|| ri
->enable_interface
)
793 if (IS_RIPNG_DEBUG_EVENT
)
794 zlog_debug ("RIPng turn on %s", ifp
->name
);
796 /* Add interface wake up thread. */
798 ri
->t_wakeup
= thread_add_timer (master
, ripng_interface_wakeup
,
801 ripng_connect_set (ifp
, 1);
808 /* Might as well clean up the route table as well
809 * ripng_if_down sets to 0 ri->running, and displays "turn off %s"
813 ripng_connect_set (ifp
, 0);
818 /* Set distribute list to all interfaces. */
820 ripng_enable_apply_all ()
822 struct interface
*ifp
;
823 struct listnode
*node
;
825 for (ALL_LIST_ELEMENTS_RO (iflist
, node
, ifp
))
826 ripng_enable_apply (ifp
);
829 /* Clear all network and neighbor configuration */
831 ripng_clean_network ()
835 struct route_node
*rn
;
837 /* ripng_enable_network */
838 for (rn
= route_top (ripng_enable_network
); rn
; rn
= route_next (rn
))
841 route_unlock_node(rn
);
844 /* ripng_enable_if */
845 for (i
= 0; i
< vector_active (ripng_enable_if
); i
++)
846 if ((str
= vector_slot (ripng_enable_if
, i
)) != NULL
) {
848 vector_slot (ripng_enable_if
, i
) = NULL
;
852 /* Vector to store passive-interface name. */
853 vector Vripng_passive_interface
;
855 /* Utility function for looking up passive interface settings. */
857 ripng_passive_interface_lookup (const char *ifname
)
862 for (i
= 0; i
< vector_active (Vripng_passive_interface
); i
++)
863 if ((str
= vector_slot (Vripng_passive_interface
, i
)) != NULL
)
864 if (strcmp (str
, ifname
) == 0)
870 ripng_passive_interface_apply (struct interface
*ifp
)
873 struct ripng_interface
*ri
;
877 ret
= ripng_passive_interface_lookup (ifp
->name
);
885 ripng_passive_interface_apply_all (void)
887 struct interface
*ifp
;
888 struct listnode
*node
;
890 for (ALL_LIST_ELEMENTS_RO (iflist
, node
, ifp
))
891 ripng_passive_interface_apply (ifp
);
894 /* Passive interface. */
896 ripng_passive_interface_set (struct vty
*vty
, const char *ifname
)
898 if (ripng_passive_interface_lookup (ifname
) >= 0)
901 vector_set (Vripng_passive_interface
, strdup (ifname
));
903 ripng_passive_interface_apply_all ();
909 ripng_passive_interface_unset (struct vty
*vty
, const char *ifname
)
914 i
= ripng_passive_interface_lookup (ifname
);
918 str
= vector_slot (Vripng_passive_interface
, i
);
920 vector_unset (Vripng_passive_interface
, i
);
922 ripng_passive_interface_apply_all ();
927 /* Free all configured RIP passive-interface settings. */
929 ripng_passive_interface_clean (void)
934 for (i
= 0; i
< vector_active (Vripng_passive_interface
); i
++)
935 if ((str
= vector_slot (Vripng_passive_interface
, i
)) != NULL
)
938 vector_slot (Vripng_passive_interface
, i
) = NULL
;
940 ripng_passive_interface_apply_all ();
943 /* Write RIPng enable network and interface to the vty. */
945 ripng_network_write (struct vty
*vty
, int config_mode
)
949 struct route_node
*node
;
952 /* Write enable network. */
953 for (node
= route_top (ripng_enable_network
); node
; node
= route_next (node
))
956 struct prefix
*p
= &node
->p
;
957 vty_out (vty
, "%s%s/%d%s",
958 config_mode
? " network " : " ",
959 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
965 /* Write enable interface. */
966 for (i
= 0; i
< vector_active (ripng_enable_if
); i
++)
967 if ((ifname
= vector_slot (ripng_enable_if
, i
)) != NULL
)
968 vty_out (vty
, "%s%s%s",
969 config_mode
? " network " : " ",
973 /* Write passive interface. */
975 for (i
= 0; i
< vector_active (Vripng_passive_interface
); i
++)
976 if ((ifname
= vector_slot (Vripng_passive_interface
, i
)) != NULL
)
977 vty_out (vty
, " passive-interface %s%s", ifname
, VTY_NEWLINE
);
982 /* RIPng enable on specified interface or matched network. */
983 DEFUN (ripng_network
,
985 "network IF_OR_ADDR",
986 "RIPng enable on specified interface or network.\n"
987 "Interface or address")
992 ret
= str2prefix (argv
[0], &p
);
994 /* Given string is IPv6 network or interface name. */
996 ret
= ripng_enable_network_add (&p
);
998 ret
= ripng_enable_if_add (argv
[0]);
1002 vty_out (vty
, "There is same network configuration %s%s", argv
[0],
1010 /* RIPng enable on specified interface or matched network. */
1011 DEFUN (no_ripng_network
,
1012 no_ripng_network_cmd
,
1013 "no network IF_OR_ADDR",
1015 "RIPng enable on specified interface or network.\n"
1016 "Interface or address")
1021 ret
= str2prefix (argv
[0], &p
);
1023 /* Given string is interface name. */
1025 ret
= ripng_enable_network_delete (&p
);
1027 ret
= ripng_enable_if_delete (argv
[0]);
1031 vty_out (vty
, "can't find network %s%s", argv
[0],
1039 DEFUN (ipv6_ripng_split_horizon
,
1040 ipv6_ripng_split_horizon_cmd
,
1041 "ipv6 ripng split-horizon",
1043 "Routing Information Protocol\n"
1044 "Perform split horizon\n")
1046 struct interface
*ifp
;
1047 struct ripng_interface
*ri
;
1052 ri
->split_horizon
= RIPNG_SPLIT_HORIZON
;
1056 DEFUN (ipv6_ripng_split_horizon_poisoned_reverse
,
1057 ipv6_ripng_split_horizon_poisoned_reverse_cmd
,
1058 "ipv6 ripng split-horizon poisoned-reverse",
1060 "Routing Information Protocol\n"
1061 "Perform split horizon\n"
1062 "With poisoned-reverse\n")
1064 struct interface
*ifp
;
1065 struct ripng_interface
*ri
;
1070 ri
->split_horizon
= RIPNG_SPLIT_HORIZON_POISONED_REVERSE
;
1074 DEFUN (no_ipv6_ripng_split_horizon
,
1075 no_ipv6_ripng_split_horizon_cmd
,
1076 "no ipv6 ripng split-horizon",
1079 "Routing Information Protocol\n"
1080 "Perform split horizon\n")
1082 struct interface
*ifp
;
1083 struct ripng_interface
*ri
;
1088 ri
->split_horizon
= RIPNG_NO_SPLIT_HORIZON
;
1092 ALIAS (no_ipv6_ripng_split_horizon
,
1093 no_ipv6_ripng_split_horizon_poisoned_reverse_cmd
,
1094 "no ipv6 ripng split-horizon poisoned-reverse",
1097 "Routing Information Protocol\n"
1098 "Perform split horizon\n"
1099 "With poisoned-reverse\n")
1101 DEFUN (ripng_passive_interface
,
1102 ripng_passive_interface_cmd
,
1103 "passive-interface IFNAME",
1104 "Suppress routing updates on an interface\n"
1107 return ripng_passive_interface_set (vty
, argv
[0]);
1110 DEFUN (no_ripng_passive_interface
,
1111 no_ripng_passive_interface_cmd
,
1112 "no passive-interface IFNAME",
1114 "Suppress routing updates on an interface\n"
1117 return ripng_passive_interface_unset (vty
, argv
[0]);
1120 struct ripng_interface
*
1123 struct ripng_interface
*ri
;
1124 ri
= XCALLOC (MTYPE_IF
, sizeof (struct ripng_interface
));
1126 /* Set default split-horizon behavior. If the interface is Frame
1127 Relay or SMDS is enabled, the default value for split-horizon is
1128 off. But currently Zebra does detect Frame Relay or SMDS
1129 interface. So all interface is set to split horizon. */
1130 ri
->split_horizon_default
= RIPNG_SPLIT_HORIZON
;
1131 ri
->split_horizon
= ri
->split_horizon_default
;
1137 ripng_if_new_hook (struct interface
*ifp
)
1139 ifp
->info
= ri_new ();
1143 /* Called when interface structure deleted. */
1145 ripng_if_delete_hook (struct interface
*ifp
)
1147 XFREE (MTYPE_IF
, ifp
->info
);
1152 /* Configuration write function for ripngd. */
1154 interface_config_write (struct vty
*vty
)
1156 struct listnode
*node
;
1157 struct interface
*ifp
;
1158 struct ripng_interface
*ri
;
1161 for (ALL_LIST_ELEMENTS_RO (iflist
, node
, ifp
))
1165 /* Do not display the interface if there is no
1166 * configuration about it.
1169 (ri
->split_horizon
== ri
->split_horizon_default
))
1172 vty_out (vty
, "interface %s%s", ifp
->name
,
1175 vty_out (vty
, " description %s%s", ifp
->desc
,
1178 /* Split horizon. */
1179 if (ri
->split_horizon
!= ri
->split_horizon_default
)
1181 switch (ri
->split_horizon
) {
1182 case RIPNG_SPLIT_HORIZON
:
1183 vty_out (vty
, " ipv6 ripng split-horizon%s", VTY_NEWLINE
);
1185 case RIPNG_SPLIT_HORIZON_POISONED_REVERSE
:
1186 vty_out (vty
, " ipv6 ripng split-horizon poisoned-reverse%s",
1189 case RIPNG_NO_SPLIT_HORIZON
:
1191 vty_out (vty
, " no ipv6 ripng split-horizon%s", VTY_NEWLINE
);
1196 vty_out (vty
, "!%s", VTY_NEWLINE
);
1203 /* ripngd's interface node. */
1204 struct cmd_node interface_node
=
1211 /* Initialization of interface. */
1215 /* Interface initialize. */
1216 iflist
= list_new ();
1217 if_add_hook (IF_NEW_HOOK
, ripng_if_new_hook
);
1218 if_add_hook (IF_DELETE_HOOK
, ripng_if_delete_hook
);
1220 /* RIPng enable network init. */
1221 ripng_enable_network
= route_table_init ();
1223 /* RIPng enable interface init. */
1224 ripng_enable_if
= vector_init (1);
1226 /* RIPng passive interface. */
1227 Vripng_passive_interface
= vector_init (1);
1229 /* Install interface node. */
1230 install_node (&interface_node
, interface_config_write
);
1232 /* Install commands. */
1233 install_element (CONFIG_NODE
, &interface_cmd
);
1234 install_element (CONFIG_NODE
, &no_interface_cmd
);
1235 install_default (INTERFACE_NODE
);
1236 install_element (INTERFACE_NODE
, &interface_desc_cmd
);
1237 install_element (INTERFACE_NODE
, &no_interface_desc_cmd
);
1239 install_element (RIPNG_NODE
, &ripng_network_cmd
);
1240 install_element (RIPNG_NODE
, &no_ripng_network_cmd
);
1241 install_element (RIPNG_NODE
, &ripng_passive_interface_cmd
);
1242 install_element (RIPNG_NODE
, &no_ripng_passive_interface_cmd
);
1244 install_element (INTERFACE_NODE
, &ipv6_ripng_split_horizon_cmd
);
1245 install_element (INTERFACE_NODE
, &ipv6_ripng_split_horizon_poisoned_reverse_cmd
);
1246 install_element (INTERFACE_NODE
, &no_ipv6_ripng_split_horizon_cmd
);
1247 install_element (INTERFACE_NODE
, &no_ipv6_ripng_split_horizon_poisoned_reverse_cmd
);