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
40 #include "ripngd/ripngd.h"
41 #include "ripngd/ripng_debug.h"
43 /* If RFC2133 definition is used. */
44 #ifndef IPV6_JOIN_GROUP
45 #define IPV6_JOIN_GROUP IPV6_ADD_MEMBERSHIP
47 #ifndef IPV6_LEAVE_GROUP
48 #define IPV6_LEAVE_GROUP IPV6_DROP_MEMBERSHIP
51 extern struct zebra_privs_t ripngd_privs;
53 /* Static utility function. */
54 static void ripng_enable_apply (struct interface *);
55 static void ripng_passive_interface_apply (struct interface *);
56 static int ripng_enable_if_lookup (const char *);
57 static int ripng_enable_network_lookup2 (struct connected *);
58 static void ripng_enable_apply_all (void);
60 /* Join to the all rip routers multicast group. */
62 ripng_multicast_join (struct interface *ifp)
65 struct ipv6_mreq mreq;
68 if (if_is_up (ifp) && if_is_multicast (ifp)) {
69 memset (&mreq, 0, sizeof (mreq));
70 inet_pton(AF_INET6, RIPNG_GROUP, &mreq.ipv6mr_multiaddr);
71 mreq.ipv6mr_interface = ifp->ifindex;
74 * NetBSD 1.6.2 requires root to join groups on gif(4).
75 * While this is bogus, privs are available and easy to use
76 * for this call as a workaround.
78 if (ripngd_privs.change (ZPRIVS_RAISE))
79 zlog_err ("ripng_multicast_join: could not raise privs");
81 ret = setsockopt (ripng->sock, IPPROTO_IPV6, IPV6_JOIN_GROUP,
82 (char *) &mreq, sizeof (mreq));
85 if (ripngd_privs.change (ZPRIVS_LOWER))
86 zlog_err ("ripng_multicast_join: could not lower privs");
88 if (ret < 0 && save_errno == EADDRINUSE)
91 * Group is already joined. This occurs due to sloppy group
92 * management, in particular declining to leave the group on
93 * an interface that has just gone down.
95 zlog_warn ("ripng join on %s EADDRINUSE (ignoring)\n", ifp->name);
96 return 0; /* not an error */
100 zlog_warn ("can't setsockopt IPV6_JOIN_GROUP: %s",
101 safe_strerror (save_errno));
103 if (IS_RIPNG_DEBUG_EVENT)
104 zlog_debug ("RIPng %s join to all-rip-routers multicast group", ifp->name);
112 /* Leave from the all rip routers multicast group. */
114 ripng_multicast_leave (struct interface *ifp)
117 struct ipv6_mreq mreq;
119 if (if_is_up (ifp) && if_is_multicast (ifp)) {
120 memset (&mreq, 0, sizeof (mreq));
121 inet_pton(AF_INET6, RIPNG_GROUP, &mreq.ipv6mr_multiaddr);
122 mreq.ipv6mr_interface = ifp->ifindex;
124 ret = setsockopt (ripng->sock, IPPROTO_IPV6, IPV6_LEAVE_GROUP,
125 (char *) &mreq, sizeof (mreq));
127 zlog_warn ("can't setsockopt IPV6_LEAVE_GROUP: %s\n", safe_strerror (errno));
129 if (IS_RIPNG_DEBUG_EVENT)
130 zlog_debug ("RIPng %s leave from all-rip-routers multicast group",
140 /* How many link local IPv6 address could be used on the interface ? */
142 ripng_if_ipv6_lladdress_check (struct interface *ifp)
145 struct connected *connected;
148 for (ALL_LIST_ELEMENTS_RO (ifp->connected, nn, connected))
151 p = connected->address;
153 if ((p->family == AF_INET6) &&
154 IN6_IS_ADDR_LINKLOCAL (&p->u.prefix6))
162 ripng_if_down (struct interface *ifp)
164 struct route_node *rp;
165 struct ripng_info *rinfo;
166 struct ripng_interface *ri;
167 struct list *list = NULL;
168 struct listnode *listnode = NULL, *nextnode = NULL;
171 for (rp = route_top (ripng->table); rp; rp = route_next (rp))
172 if ((list = rp->info) != NULL)
173 for (ALL_LIST_ELEMENTS (list, listnode, nextnode, rinfo))
174 if (rinfo->ifindex == ifp->ifindex)
175 ripng_ecmp_delete (rinfo);
181 if (IS_RIPNG_DEBUG_EVENT)
182 zlog_debug ("turn off %s", ifp->name);
184 /* Leave from multicast group. */
185 ripng_multicast_leave (ifp);
193 /* Inteface link up message processing. */
195 ripng_interface_up (int command, struct zclient *zclient, zebra_size_t length,
199 struct interface *ifp;
201 /* zebra_interface_state_read() updates interface structure in iflist. */
203 ifp = zebra_interface_state_read (s, vrf_id);
208 if (IS_RIPNG_DEBUG_ZEBRA)
209 zlog_debug ("interface up %s index %d flags %llx metric %d mtu %d",
210 ifp->name, ifp->ifindex, (unsigned long long)ifp->flags,
211 ifp->metric, ifp->mtu6);
213 /* Check if this interface is RIPng enabled or not. */
214 ripng_enable_apply (ifp);
216 /* Check for a passive interface. */
217 ripng_passive_interface_apply (ifp);
219 /* Apply distribute list to the all interface. */
220 ripng_distribute_update_interface (ifp);
225 /* Inteface link down message processing. */
227 ripng_interface_down (int command, struct zclient *zclient,
228 zebra_size_t length, vrf_id_t vrf_id)
231 struct interface *ifp;
233 /* zebra_interface_state_read() updates interface structure in iflist. */
235 ifp = zebra_interface_state_read (s, vrf_id);
242 if (IS_RIPNG_DEBUG_ZEBRA)
243 zlog_debug ("interface down %s index %d flags %#llx metric %d mtu %d",
244 ifp->name, ifp->ifindex,
245 (unsigned long long) ifp->flags, ifp->metric, ifp->mtu6);
250 /* Inteface addition message from zebra. */
252 ripng_interface_add (int command, struct zclient *zclient, zebra_size_t length,
255 struct interface *ifp;
257 ifp = zebra_interface_add_read (zclient->ibuf, vrf_id);
259 if (IS_RIPNG_DEBUG_ZEBRA)
260 zlog_debug ("RIPng interface add %s index %d flags %#llx metric %d mtu %d",
261 ifp->name, ifp->ifindex, (unsigned long long) ifp->flags,
262 ifp->metric, ifp->mtu6);
264 /* Check is this interface is RIP enabled or not.*/
265 ripng_enable_apply (ifp);
267 /* Apply distribute list to the interface. */
268 ripng_distribute_update_interface (ifp);
270 /* Check interface routemap. */
271 ripng_if_rmap_update_interface (ifp);
277 ripng_interface_delete (int command, struct zclient *zclient,
278 zebra_size_t length, vrf_id_t vrf_id)
280 struct interface *ifp;
284 /* zebra_interface_state_read() updates interface structure in iflist */
285 ifp = zebra_interface_state_read (s, vrf_id);
290 if (if_is_up (ifp)) {
294 zlog_info("interface delete %s index %d flags %#llx metric %d mtu %d",
295 ifp->name, ifp->ifindex, (unsigned long long) ifp->flags,
296 ifp->metric, ifp->mtu6);
298 /* To support pseudo interface do not free interface structure. */
299 /* if_delete(ifp); */
300 ifp->ifindex = IFINDEX_INTERNAL;
306 ripng_interface_clean (void)
308 struct listnode *node, *nnode;
309 struct interface *ifp;
310 struct ripng_interface *ri;
312 for (ALL_LIST_ELEMENTS (iflist, node, nnode, ifp))
316 ri->enable_network = 0;
317 ri->enable_interface = 0;
322 thread_cancel (ri->t_wakeup);
329 ripng_interface_reset (void)
331 struct listnode *node;
332 struct interface *ifp;
333 struct ripng_interface *ri;
335 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
339 ri->enable_network = 0;
340 ri->enable_interface = 0;
343 ri->split_horizon = RIPNG_NO_SPLIT_HORIZON;
344 ri->split_horizon_default = RIPNG_NO_SPLIT_HORIZON;
346 ri->list[RIPNG_FILTER_IN] = NULL;
347 ri->list[RIPNG_FILTER_OUT] = NULL;
349 ri->prefix[RIPNG_FILTER_IN] = NULL;
350 ri->prefix[RIPNG_FILTER_OUT] = NULL;
354 thread_cancel (ri->t_wakeup);
363 ripng_apply_address_add (struct connected *ifc) {
364 struct prefix_ipv6 address;
370 if (! if_is_up(ifc->ifp))
375 memset (&address, 0, sizeof (address));
376 address.family = p->family;
377 address.prefix = p->u.prefix6;
378 address.prefixlen = p->prefixlen;
379 apply_mask_ipv6(&address);
381 /* Check if this interface is RIP enabled or not
382 or Check if this address's prefix is RIP enabled */
383 if ((ripng_enable_if_lookup(ifc->ifp->name) >= 0) ||
384 (ripng_enable_network_lookup2(ifc) >= 0))
385 ripng_redistribute_add(ZEBRA_ROUTE_CONNECT, RIPNG_ROUTE_INTERFACE,
386 &address, ifc->ifp->ifindex, NULL, 0);
391 ripng_interface_address_add (int command, struct zclient *zclient,
392 zebra_size_t length, vrf_id_t vrf_id)
397 c = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_ADD,
398 zclient->ibuf, vrf_id);
405 if (p->family == AF_INET6)
407 struct ripng_interface *ri = c->ifp->info;
409 if (IS_RIPNG_DEBUG_ZEBRA)
410 zlog_debug ("RIPng connected address %s/%d add",
411 inet6_ntoa(p->u.prefix6),
414 /* Check is this prefix needs to be redistributed. */
415 ripng_apply_address_add(c);
417 /* Let's try once again whether the interface could be activated */
419 /* Check if this interface is RIP enabled or not.*/
420 ripng_enable_apply (c->ifp);
422 /* Apply distribute list to the interface. */
423 ripng_distribute_update_interface (c->ifp);
425 /* Check interface routemap. */
426 ripng_if_rmap_update_interface (c->ifp);
435 ripng_apply_address_del (struct connected *ifc) {
436 struct prefix_ipv6 address;
442 if (! if_is_up(ifc->ifp))
447 memset (&address, 0, sizeof (address));
448 address.family = p->family;
449 address.prefix = p->u.prefix6;
450 address.prefixlen = p->prefixlen;
451 apply_mask_ipv6(&address);
453 ripng_redistribute_delete(ZEBRA_ROUTE_CONNECT, RIPNG_ROUTE_INTERFACE,
454 &address, ifc->ifp->ifindex);
458 ripng_interface_address_delete (int command, struct zclient *zclient,
459 zebra_size_t length, vrf_id_t vrf_id)
461 struct connected *ifc;
463 char buf[INET6_ADDRSTRLEN];
465 ifc = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_DELETE,
466 zclient->ibuf, vrf_id);
472 if (p->family == AF_INET6)
474 if (IS_RIPNG_DEBUG_ZEBRA)
475 zlog_debug ("RIPng connected address %s/%d delete",
476 inet_ntop (AF_INET6, &p->u.prefix6, buf,
480 /* Check wether this prefix needs to be removed. */
481 ripng_apply_address_del(ifc);
483 connected_free (ifc);
489 /* RIPng enable interface vector. */
490 vector ripng_enable_if;
492 /* RIPng enable network table. */
493 struct route_table *ripng_enable_network;
495 /* Lookup RIPng enable network. */
496 /* Check wether the interface has at least a connected prefix that
497 * is within the ripng_enable_network table. */
499 ripng_enable_network_lookup_if (struct interface *ifp)
501 struct listnode *node;
502 struct connected *connected;
503 struct prefix_ipv6 address;
505 for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, connected))
508 struct route_node *node;
510 p = connected->address;
512 if (p->family == AF_INET6)
514 address.family = AF_INET6;
515 address.prefix = p->u.prefix6;
516 address.prefixlen = IPV6_MAX_BITLEN;
518 node = route_node_match (ripng_enable_network,
519 (struct prefix *)&address);
522 route_unlock_node (node);
530 /* Check wether connected is within the ripng_enable_network table. */
532 ripng_enable_network_lookup2 (struct connected *connected)
534 struct prefix_ipv6 address;
537 p = connected->address;
539 if (p->family == AF_INET6) {
540 struct route_node *node;
542 address.family = p->family;
543 address.prefix = p->u.prefix6;
544 address.prefixlen = IPV6_MAX_BITLEN;
546 /* LPM on p->family, p->u.prefix6/IPV6_MAX_BITLEN within ripng_enable_network */
547 node = route_node_match (ripng_enable_network,
548 (struct prefix *)&address);
551 route_unlock_node (node);
559 /* Add RIPng enable network. */
561 ripng_enable_network_add (struct prefix *p)
563 struct route_node *node;
565 node = route_node_get (ripng_enable_network, p);
569 route_unlock_node (node);
573 node->info = (char *) "enabled";
575 /* XXX: One should find a better solution than a generic one */
576 ripng_enable_apply_all();
581 /* Delete RIPng enable network. */
583 ripng_enable_network_delete (struct prefix *p)
585 struct route_node *node;
587 node = route_node_lookup (ripng_enable_network, p);
592 /* Unlock info lock. */
593 route_unlock_node (node);
595 /* Unlock lookup lock. */
596 route_unlock_node (node);
603 /* Lookup function. */
605 ripng_enable_if_lookup (const char *ifname)
610 for (i = 0; i < vector_active (ripng_enable_if); i++)
611 if ((str = vector_slot (ripng_enable_if, i)) != NULL)
612 if (strcmp (str, ifname) == 0)
617 /* Add interface to ripng_enable_if. */
619 ripng_enable_if_add (const char *ifname)
623 ret = ripng_enable_if_lookup (ifname);
627 vector_set (ripng_enable_if, strdup (ifname));
629 ripng_enable_apply_all();
634 /* Delete interface from ripng_enable_if. */
636 ripng_enable_if_delete (const char *ifname)
641 index = ripng_enable_if_lookup (ifname);
645 str = vector_slot (ripng_enable_if, index);
647 vector_unset (ripng_enable_if, index);
649 ripng_enable_apply_all();
654 /* Wake up interface. */
656 ripng_interface_wakeup (struct thread *t)
658 struct interface *ifp;
659 struct ripng_interface *ri;
662 ifp = THREAD_ARG (t);
667 /* Join to multicast group. */
668 if (ripng_multicast_join (ifp) < 0) {
669 zlog_err ("multicast join failed, interface %s not running", ifp->name);
673 /* Set running flag. */
676 /* Send RIP request to the interface. */
683 ripng_connect_set (struct interface *ifp, int set)
685 struct listnode *node, *nnode;
686 struct connected *connected;
687 struct prefix_ipv6 address;
689 for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, connected))
692 p = connected->address;
694 if (p->family != AF_INET6)
697 address.family = AF_INET6;
698 address.prefix = p->u.prefix6;
699 address.prefixlen = p->prefixlen;
700 apply_mask_ipv6 (&address);
703 /* Check once more wether this prefix is within a "network IF_OR_PREF" one */
704 if ((ripng_enable_if_lookup(connected->ifp->name) >= 0) ||
705 (ripng_enable_network_lookup2(connected) >= 0))
706 ripng_redistribute_add (ZEBRA_ROUTE_CONNECT, RIPNG_ROUTE_INTERFACE,
707 &address, connected->ifp->ifindex, NULL, 0);
709 ripng_redistribute_delete (ZEBRA_ROUTE_CONNECT, RIPNG_ROUTE_INTERFACE,
710 &address, connected->ifp->ifindex);
711 if (ripng_redistribute_check (ZEBRA_ROUTE_CONNECT))
712 ripng_redistribute_add (ZEBRA_ROUTE_CONNECT, RIPNG_ROUTE_REDISTRIBUTE,
713 &address, connected->ifp->ifindex, NULL, 0);
718 /* Check RIPng is enabed on this interface. */
720 ripng_enable_apply (struct interface *ifp)
723 struct ripng_interface *ri = NULL;
725 /* Check interface. */
726 if (! if_is_up (ifp))
731 /* Is this interface a candidate for RIPng ? */
732 ret = ripng_enable_network_lookup_if (ifp);
734 /* If the interface is matched. */
736 ri->enable_network = 1;
738 ri->enable_network = 0;
740 /* Check interface name configuration. */
741 ret = ripng_enable_if_lookup (ifp->name);
743 ri->enable_interface = 1;
745 ri->enable_interface = 0;
747 /* any candidate interface MUST have a link-local IPv6 address */
748 if ((! ripng_if_ipv6_lladdress_check (ifp)) &&
749 (ri->enable_network || ri->enable_interface)) {
750 ri->enable_network = 0;
751 ri->enable_interface = 0;
752 zlog_warn("Interface %s does not have any link-local address",
756 /* Update running status of the interface. */
757 if (ri->enable_network || ri->enable_interface)
760 if (IS_RIPNG_DEBUG_EVENT)
761 zlog_debug ("RIPng turn on %s", ifp->name);
763 /* Add interface wake up thread. */
765 ri->t_wakeup = thread_add_timer (master, ripng_interface_wakeup,
768 ripng_connect_set (ifp, 1);
775 /* Might as well clean up the route table as well
776 * ripng_if_down sets to 0 ri->running, and displays "turn off %s"
780 ripng_connect_set (ifp, 0);
785 /* Set distribute list to all interfaces. */
787 ripng_enable_apply_all (void)
789 struct interface *ifp;
790 struct listnode *node;
792 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
793 ripng_enable_apply (ifp);
796 /* Clear all network and neighbor configuration */
798 ripng_clean_network ()
802 struct route_node *rn;
804 /* ripng_enable_network */
805 for (rn = route_top (ripng_enable_network); rn; rn = route_next (rn))
808 route_unlock_node(rn);
811 /* ripng_enable_if */
812 for (i = 0; i < vector_active (ripng_enable_if); i++)
813 if ((str = vector_slot (ripng_enable_if, i)) != NULL) {
815 vector_slot (ripng_enable_if, i) = NULL;
819 /* Vector to store passive-interface name. */
820 vector Vripng_passive_interface;
822 /* Utility function for looking up passive interface settings. */
824 ripng_passive_interface_lookup (const char *ifname)
829 for (i = 0; i < vector_active (Vripng_passive_interface); i++)
830 if ((str = vector_slot (Vripng_passive_interface, i)) != NULL)
831 if (strcmp (str, ifname) == 0)
837 ripng_passive_interface_apply (struct interface *ifp)
840 struct ripng_interface *ri;
844 ret = ripng_passive_interface_lookup (ifp->name);
852 ripng_passive_interface_apply_all (void)
854 struct interface *ifp;
855 struct listnode *node;
857 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
858 ripng_passive_interface_apply (ifp);
861 /* Passive interface. */
863 ripng_passive_interface_set (struct vty *vty, const char *ifname)
865 if (ripng_passive_interface_lookup (ifname) >= 0)
868 vector_set (Vripng_passive_interface, strdup (ifname));
870 ripng_passive_interface_apply_all ();
876 ripng_passive_interface_unset (struct vty *vty, const char *ifname)
881 i = ripng_passive_interface_lookup (ifname);
885 str = vector_slot (Vripng_passive_interface, i);
887 vector_unset (Vripng_passive_interface, i);
889 ripng_passive_interface_apply_all ();
894 /* Free all configured RIP passive-interface settings. */
896 ripng_passive_interface_clean (void)
901 for (i = 0; i < vector_active (Vripng_passive_interface); i++)
902 if ((str = vector_slot (Vripng_passive_interface, i)) != NULL)
905 vector_slot (Vripng_passive_interface, i) = NULL;
907 ripng_passive_interface_apply_all ();
910 /* Write RIPng enable network and interface to the vty. */
912 ripng_network_write (struct vty *vty, int config_mode)
916 struct route_node *node;
919 /* Write enable network. */
920 for (node = route_top (ripng_enable_network); node; node = route_next (node))
923 struct prefix *p = &node->p;
924 vty_out (vty, "%s%s/%d%s",
925 config_mode ? " network " : " ",
926 inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ),
932 /* Write enable interface. */
933 for (i = 0; i < vector_active (ripng_enable_if); i++)
934 if ((ifname = vector_slot (ripng_enable_if, i)) != NULL)
935 vty_out (vty, "%s%s%s",
936 config_mode ? " network " : " ",
940 /* Write passive interface. */
942 for (i = 0; i < vector_active (Vripng_passive_interface); i++)
943 if ((ifname = vector_slot (Vripng_passive_interface, i)) != NULL)
944 vty_out (vty, " passive-interface %s%s", ifname, VTY_NEWLINE);
949 /* RIPng enable on specified interface or matched network. */
950 DEFUN (ripng_network,
952 "network IF_OR_ADDR",
953 "RIPng enable on specified interface or network.\n"
954 "Interface or address")
959 ret = str2prefix (argv[0], &p);
961 /* Given string is IPv6 network or interface name. */
963 ret = ripng_enable_network_add (&p);
965 ret = ripng_enable_if_add (argv[0]);
969 vty_out (vty, "There is same network configuration %s%s", argv[0],
977 /* RIPng enable on specified interface or matched network. */
978 DEFUN (no_ripng_network,
979 no_ripng_network_cmd,
980 "no network IF_OR_ADDR",
982 "RIPng enable on specified interface or network.\n"
983 "Interface or address")
988 ret = str2prefix (argv[0], &p);
990 /* Given string is interface name. */
992 ret = ripng_enable_network_delete (&p);
994 ret = ripng_enable_if_delete (argv[0]);
998 vty_out (vty, "can't find network %s%s", argv[0],
1006 DEFUN (ipv6_ripng_split_horizon,
1007 ipv6_ripng_split_horizon_cmd,
1008 "ipv6 ripng split-horizon",
1010 "Routing Information Protocol\n"
1011 "Perform split horizon\n")
1013 struct interface *ifp;
1014 struct ripng_interface *ri;
1019 ri->split_horizon = RIPNG_SPLIT_HORIZON;
1023 DEFUN (ipv6_ripng_split_horizon_poisoned_reverse,
1024 ipv6_ripng_split_horizon_poisoned_reverse_cmd,
1025 "ipv6 ripng split-horizon poisoned-reverse",
1027 "Routing Information Protocol\n"
1028 "Perform split horizon\n"
1029 "With poisoned-reverse\n")
1031 struct interface *ifp;
1032 struct ripng_interface *ri;
1037 ri->split_horizon = RIPNG_SPLIT_HORIZON_POISONED_REVERSE;
1041 DEFUN (no_ipv6_ripng_split_horizon,
1042 no_ipv6_ripng_split_horizon_cmd,
1043 "no ipv6 ripng split-horizon",
1046 "Routing Information Protocol\n"
1047 "Perform split horizon\n")
1049 struct interface *ifp;
1050 struct ripng_interface *ri;
1055 ri->split_horizon = RIPNG_NO_SPLIT_HORIZON;
1059 ALIAS (no_ipv6_ripng_split_horizon,
1060 no_ipv6_ripng_split_horizon_poisoned_reverse_cmd,
1061 "no ipv6 ripng split-horizon poisoned-reverse",
1064 "Routing Information Protocol\n"
1065 "Perform split horizon\n"
1066 "With poisoned-reverse\n")
1068 DEFUN (ripng_passive_interface,
1069 ripng_passive_interface_cmd,
1070 "passive-interface IFNAME",
1071 "Suppress routing updates on an interface\n"
1074 return ripng_passive_interface_set (vty, argv[0]);
1077 DEFUN (no_ripng_passive_interface,
1078 no_ripng_passive_interface_cmd,
1079 "no passive-interface IFNAME",
1081 "Suppress routing updates on an interface\n"
1084 return ripng_passive_interface_unset (vty, argv[0]);
1087 static struct ripng_interface *
1090 struct ripng_interface *ri;
1091 ri = XCALLOC (MTYPE_IF, sizeof (struct ripng_interface));
1093 /* Set default split-horizon behavior. If the interface is Frame
1094 Relay or SMDS is enabled, the default value for split-horizon is
1095 off. But currently Zebra does detect Frame Relay or SMDS
1096 interface. So all interface is set to split horizon. */
1097 ri->split_horizon_default = RIPNG_SPLIT_HORIZON;
1098 ri->split_horizon = ri->split_horizon_default;
1104 ripng_if_new_hook (struct interface *ifp)
1106 ifp->info = ri_new ();
1110 /* Called when interface structure deleted. */
1112 ripng_if_delete_hook (struct interface *ifp)
1114 XFREE (MTYPE_IF, ifp->info);
1119 /* Configuration write function for ripngd. */
1121 interface_config_write (struct vty *vty)
1123 struct listnode *node;
1124 struct interface *ifp;
1125 struct ripng_interface *ri;
1128 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
1132 /* Do not display the interface if there is no
1133 * configuration about it.
1136 (ri->split_horizon == ri->split_horizon_default))
1139 vty_out (vty, "interface %s%s", ifp->name,
1142 vty_out (vty, " description %s%s", ifp->desc,
1145 /* Split horizon. */
1146 if (ri->split_horizon != ri->split_horizon_default)
1148 switch (ri->split_horizon) {
1149 case RIPNG_SPLIT_HORIZON:
1150 vty_out (vty, " ipv6 ripng split-horizon%s", VTY_NEWLINE);
1152 case RIPNG_SPLIT_HORIZON_POISONED_REVERSE:
1153 vty_out (vty, " ipv6 ripng split-horizon poisoned-reverse%s",
1156 case RIPNG_NO_SPLIT_HORIZON:
1158 vty_out (vty, " no ipv6 ripng split-horizon%s", VTY_NEWLINE);
1163 vty_out (vty, "!%s", VTY_NEWLINE);
1170 /* ripngd's interface node. */
1171 static struct cmd_node interface_node =
1178 /* Initialization of interface. */
1182 /* Interface initialize. */
1183 if_add_hook (IF_NEW_HOOK, ripng_if_new_hook);
1184 if_add_hook (IF_DELETE_HOOK, ripng_if_delete_hook);
1186 /* RIPng enable network init. */
1187 ripng_enable_network = route_table_init ();
1189 /* RIPng enable interface init. */
1190 ripng_enable_if = vector_init (1);
1192 /* RIPng passive interface. */
1193 Vripng_passive_interface = vector_init (1);
1195 /* Install interface node. */
1196 install_node (&interface_node, interface_config_write);
1198 /* Install commands. */
1199 install_element (CONFIG_NODE, &interface_cmd);
1200 install_element (CONFIG_NODE, &no_interface_cmd);
1201 install_default (INTERFACE_NODE);
1202 install_element (INTERFACE_NODE, &interface_desc_cmd);
1203 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
1205 install_element (RIPNG_NODE, &ripng_network_cmd);
1206 install_element (RIPNG_NODE, &no_ripng_network_cmd);
1207 install_element (RIPNG_NODE, &ripng_passive_interface_cmd);
1208 install_element (RIPNG_NODE, &no_ripng_passive_interface_cmd);
1210 install_element (INTERFACE_NODE, &ipv6_ripng_split_horizon_cmd);
1211 install_element (INTERFACE_NODE, &ipv6_ripng_split_horizon_poisoned_reverse_cmd);
1212 install_element (INTERFACE_NODE, &no_ipv6_ripng_split_horizon_cmd);
1213 install_element (INTERFACE_NODE, &no_ipv6_ripng_split_horizon_poisoned_reverse_cmd);