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 along
18 * with this program; see the file COPYING; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
34 #include "agg_table.h"
38 #include "lib_errors.h"
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 /* Static utility function. */
52 static void ripng_enable_apply(struct interface
*);
53 static void ripng_passive_interface_apply(struct interface
*);
54 static int ripng_enable_if_lookup(const char *);
55 static int ripng_enable_network_lookup2(struct connected
*);
56 static void ripng_enable_apply_all(void);
58 /* Join to the all rip routers multicast group. */
59 static int ripng_multicast_join(struct interface
*ifp
)
62 struct ipv6_mreq mreq
;
65 if (if_is_multicast(ifp
)) {
66 memset(&mreq
, 0, sizeof(mreq
));
67 inet_pton(AF_INET6
, RIPNG_GROUP
, &mreq
.ipv6mr_multiaddr
);
68 mreq
.ipv6mr_interface
= ifp
->ifindex
;
71 * NetBSD 1.6.2 requires root to join groups on gif(4).
72 * While this is bogus, privs are available and easy to use
73 * for this call as a workaround.
75 frr_elevate_privs(&ripngd_privs
) {
77 ret
= setsockopt(ripng
->sock
, IPPROTO_IPV6
,
79 (char *)&mreq
, sizeof(mreq
));
84 if (ret
< 0 && save_errno
== EADDRINUSE
) {
86 * Group is already joined. This occurs due to sloppy
88 * management, in particular declining to leave the
90 * an interface that has just gone down.
92 zlog_warn("ripng join on %s EADDRINUSE (ignoring)\n",
94 return 0; /* not an error */
98 zlog_warn("can't setsockopt IPV6_JOIN_GROUP: %s",
99 safe_strerror(save_errno
));
101 if (IS_RIPNG_DEBUG_EVENT
)
103 "RIPng %s join to all-rip-routers multicast group",
112 /* Leave from the all rip routers multicast group. */
113 static int ripng_multicast_leave(struct interface
*ifp
)
116 struct ipv6_mreq mreq
;
118 if (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",
127 safe_strerror(errno
));
129 if (IS_RIPNG_DEBUG_EVENT
)
131 "RIPng %s leave from all-rip-routers multicast group",
141 /* How many link local IPv6 address could be used on the interface ? */
142 static int ripng_if_ipv6_lladdress_check(struct interface
*ifp
)
145 struct connected
*connected
;
148 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 static int ripng_if_down(struct interface
*ifp
)
163 struct ripng_info
*rinfo
;
164 struct ripng_interface
*ri
;
165 struct list
*list
= NULL
;
166 struct listnode
*listnode
= NULL
, *nextnode
= NULL
;
169 for (rp
= agg_route_top(ripng
->table
); rp
;
170 rp
= agg_route_next(rp
))
171 if ((list
= rp
->info
) != NULL
)
172 for (ALL_LIST_ELEMENTS(list
, listnode
, nextnode
,
174 if (rinfo
->ifindex
== ifp
->ifindex
)
175 ripng_ecmp_delete(rinfo
);
180 if (IS_RIPNG_DEBUG_EVENT
)
181 zlog_debug("turn off %s", ifp
->name
);
183 /* Leave from multicast group. */
184 ripng_multicast_leave(ifp
);
192 /* Inteface link up message processing. */
193 int ripng_interface_up(int command
, struct zclient
*zclient
,
194 zebra_size_t length
, vrf_id_t vrf_id
)
197 struct interface
*ifp
;
199 /* zebra_interface_state_read() updates interface structure in iflist.
202 ifp
= zebra_interface_state_read(s
, vrf_id
);
207 if (IS_RIPNG_DEBUG_ZEBRA
)
209 "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. */
226 int ripng_interface_down(int command
, struct zclient
*zclient
,
227 zebra_size_t length
, vrf_id_t vrf_id
)
230 struct interface
*ifp
;
232 /* zebra_interface_state_read() updates interface structure in iflist.
235 ifp
= zebra_interface_state_read(s
, vrf_id
);
242 if (IS_RIPNG_DEBUG_ZEBRA
)
244 "interface down %s index %d flags %#llx metric %d mtu %d",
245 ifp
->name
, ifp
->ifindex
, (unsigned long long)ifp
->flags
,
246 ifp
->metric
, ifp
->mtu6
);
251 /* Inteface addition message from zebra. */
252 int ripng_interface_add(int command
, struct zclient
*zclient
,
253 zebra_size_t length
, vrf_id_t vrf_id
)
255 struct interface
*ifp
;
257 ifp
= zebra_interface_add_read(zclient
->ibuf
, vrf_id
);
259 if (IS_RIPNG_DEBUG_ZEBRA
)
261 "RIPng interface add %s index %d flags %#llx metric %d mtu %d",
262 ifp
->name
, ifp
->ifindex
, (unsigned long long)ifp
->flags
,
263 ifp
->metric
, ifp
->mtu6
);
265 /* Check is this interface is RIP enabled or not.*/
266 ripng_enable_apply(ifp
);
268 /* Apply distribute list to the interface. */
269 ripng_distribute_update_interface(ifp
);
271 /* Check interface routemap. */
272 ripng_if_rmap_update_interface(ifp
);
277 int 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
286 ifp
= zebra_interface_state_read(s
, vrf_id
);
295 zlog_info("interface delete %s index %d flags %#llx metric %d mtu %d",
296 ifp
->name
, ifp
->ifindex
, (unsigned long long)ifp
->flags
,
297 ifp
->metric
, ifp
->mtu6
);
299 /* To support pseudo interface do not free interface structure. */
300 /* if_delete(ifp); */
301 if_set_index(ifp
, IFINDEX_INTERNAL
);
306 void ripng_interface_clean(void)
308 struct vrf
*vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
309 struct interface
*ifp
;
310 struct ripng_interface
*ri
;
312 FOR_ALL_INTERFACES (vrf
, ifp
) {
315 ri
->enable_network
= 0;
316 ri
->enable_interface
= 0;
320 thread_cancel(ri
->t_wakeup
);
326 void ripng_interface_reset(void)
328 struct vrf
*vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
329 struct interface
*ifp
;
330 struct ripng_interface
*ri
;
332 FOR_ALL_INTERFACES (vrf
, ifp
) {
335 ri
->enable_network
= 0;
336 ri
->enable_interface
= 0;
339 ri
->split_horizon
= RIPNG_NO_SPLIT_HORIZON
;
340 ri
->split_horizon_default
= RIPNG_NO_SPLIT_HORIZON
;
342 ri
->list
[RIPNG_FILTER_IN
] = NULL
;
343 ri
->list
[RIPNG_FILTER_OUT
] = NULL
;
345 ri
->prefix
[RIPNG_FILTER_IN
] = NULL
;
346 ri
->prefix
[RIPNG_FILTER_OUT
] = NULL
;
349 thread_cancel(ri
->t_wakeup
);
357 static void ripng_apply_address_add(struct connected
*ifc
)
359 struct prefix_ipv6 address
;
365 if (!if_is_up(ifc
->ifp
))
370 memset(&address
, 0, sizeof(address
));
371 address
.family
= p
->family
;
372 address
.prefix
= p
->u
.prefix6
;
373 address
.prefixlen
= p
->prefixlen
;
374 apply_mask_ipv6(&address
);
376 /* Check if this interface is RIP enabled or not
377 or Check if this address's prefix is RIP enabled */
378 if ((ripng_enable_if_lookup(ifc
->ifp
->name
) >= 0)
379 || (ripng_enable_network_lookup2(ifc
) >= 0))
380 ripng_redistribute_add(ZEBRA_ROUTE_CONNECT
,
381 RIPNG_ROUTE_INTERFACE
, &address
,
382 ifc
->ifp
->ifindex
, NULL
, 0);
385 int ripng_interface_address_add(int command
, struct zclient
*zclient
,
386 zebra_size_t length
, vrf_id_t vrf_id
)
391 c
= zebra_interface_address_read(ZEBRA_INTERFACE_ADDRESS_ADD
,
392 zclient
->ibuf
, vrf_id
);
399 if (p
->family
== AF_INET6
) {
400 struct ripng_interface
*ri
= c
->ifp
->info
;
402 if (IS_RIPNG_DEBUG_ZEBRA
)
403 zlog_debug("RIPng connected address %s/%d add",
404 inet6_ntoa(p
->u
.prefix6
), p
->prefixlen
);
406 /* Check is this prefix needs to be redistributed. */
407 ripng_apply_address_add(c
);
409 /* Let's try once again whether the interface could be activated
412 /* Check if this interface is RIP enabled or not.*/
413 ripng_enable_apply(c
->ifp
);
415 /* Apply distribute list to the interface. */
416 ripng_distribute_update_interface(c
->ifp
);
418 /* Check interface routemap. */
419 ripng_if_rmap_update_interface(c
->ifp
);
426 static void ripng_apply_address_del(struct connected
*ifc
)
428 struct prefix_ipv6 address
;
434 if (!if_is_up(ifc
->ifp
))
439 memset(&address
, 0, sizeof(address
));
440 address
.family
= p
->family
;
441 address
.prefix
= p
->u
.prefix6
;
442 address
.prefixlen
= p
->prefixlen
;
443 apply_mask_ipv6(&address
);
445 ripng_redistribute_delete(ZEBRA_ROUTE_CONNECT
, RIPNG_ROUTE_INTERFACE
,
446 &address
, ifc
->ifp
->ifindex
);
449 int ripng_interface_address_delete(int command
, struct zclient
*zclient
,
450 zebra_size_t length
, vrf_id_t vrf_id
)
452 struct connected
*ifc
;
454 char buf
[INET6_ADDRSTRLEN
];
456 ifc
= zebra_interface_address_read(ZEBRA_INTERFACE_ADDRESS_DELETE
,
457 zclient
->ibuf
, vrf_id
);
462 if (p
->family
== AF_INET6
) {
463 if (IS_RIPNG_DEBUG_ZEBRA
)
465 "RIPng connected address %s/%d delete",
466 inet_ntop(AF_INET6
, &p
->u
.prefix6
, buf
,
470 /* Check wether this prefix needs to be removed. */
471 ripng_apply_address_del(ifc
);
479 /* RIPng enable interface vector. */
480 vector ripng_enable_if
;
482 /* RIPng enable network table. */
483 struct agg_table
*ripng_enable_network
;
485 /* Lookup RIPng enable network. */
486 /* Check wether the interface has at least a connected prefix that
487 * is within the ripng_enable_network table. */
488 static int ripng_enable_network_lookup_if(struct interface
*ifp
)
490 struct listnode
*node
;
491 struct connected
*connected
;
492 struct prefix_ipv6 address
;
494 for (ALL_LIST_ELEMENTS_RO(ifp
->connected
, node
, connected
)) {
498 p
= connected
->address
;
500 if (p
->family
== AF_INET6
) {
501 address
.family
= AF_INET6
;
502 address
.prefix
= p
->u
.prefix6
;
503 address
.prefixlen
= IPV6_MAX_BITLEN
;
505 n
= agg_node_match(ripng_enable_network
,
506 (struct prefix
*)&address
);
516 /* Check wether connected is within the ripng_enable_network table. */
517 static int ripng_enable_network_lookup2(struct connected
*connected
)
519 struct prefix_ipv6 address
;
522 p
= connected
->address
;
524 if (p
->family
== AF_INET6
) {
525 struct agg_node
*node
;
527 address
.family
= p
->family
;
528 address
.prefix
= p
->u
.prefix6
;
529 address
.prefixlen
= IPV6_MAX_BITLEN
;
531 /* LPM on p->family, p->u.prefix6/IPV6_MAX_BITLEN within
532 * ripng_enable_network */
533 node
= agg_node_match(ripng_enable_network
,
534 (struct prefix
*)&address
);
537 agg_unlock_node(node
);
545 /* Add RIPng enable network. */
546 static int ripng_enable_network_add(struct prefix
*p
)
548 struct agg_node
*node
;
550 node
= agg_node_get(ripng_enable_network
, p
);
553 agg_unlock_node(node
);
556 node
->info
= (void *)1;
558 /* XXX: One should find a better solution than a generic one */
559 ripng_enable_apply_all();
564 /* Delete RIPng enable network. */
565 static int ripng_enable_network_delete(struct prefix
*p
)
567 struct agg_node
*node
;
569 node
= agg_node_lookup(ripng_enable_network
, p
);
573 /* Unlock info lock. */
574 agg_unlock_node(node
);
576 /* Unlock lookup lock. */
577 agg_unlock_node(node
);
584 /* Lookup function. */
585 static int ripng_enable_if_lookup(const char *ifname
)
590 for (i
= 0; i
< vector_active(ripng_enable_if
); i
++)
591 if ((str
= vector_slot(ripng_enable_if
, i
)) != NULL
)
592 if (strcmp(str
, ifname
) == 0)
597 /* Add interface to ripng_enable_if. */
598 static int ripng_enable_if_add(const char *ifname
)
602 ret
= ripng_enable_if_lookup(ifname
);
606 vector_set(ripng_enable_if
, strdup(ifname
));
608 ripng_enable_apply_all();
613 /* Delete interface from ripng_enable_if. */
614 static int ripng_enable_if_delete(const char *ifname
)
619 index
= ripng_enable_if_lookup(ifname
);
623 str
= vector_slot(ripng_enable_if
, index
);
625 vector_unset(ripng_enable_if
, index
);
627 ripng_enable_apply_all();
632 /* Wake up interface. */
633 static int ripng_interface_wakeup(struct thread
*t
)
635 struct interface
*ifp
;
636 struct ripng_interface
*ri
;
644 /* Join to multicast group. */
645 if (ripng_multicast_join(ifp
) < 0) {
646 flog_err_sys(EC_LIB_SOCKET
,
647 "multicast join failed, interface %s not running",
652 /* Set running flag. */
655 /* Send RIP request to the interface. */
661 static void ripng_connect_set(struct interface
*ifp
, int set
)
663 struct listnode
*node
, *nnode
;
664 struct connected
*connected
;
665 struct prefix_ipv6 address
;
667 for (ALL_LIST_ELEMENTS(ifp
->connected
, node
, nnode
, connected
)) {
669 p
= connected
->address
;
671 if (p
->family
!= AF_INET6
)
674 address
.family
= AF_INET6
;
675 address
.prefix
= p
->u
.prefix6
;
676 address
.prefixlen
= p
->prefixlen
;
677 apply_mask_ipv6(&address
);
680 /* Check once more wether this prefix is within a
681 * "network IF_OR_PREF" one */
682 if ((ripng_enable_if_lookup(connected
->ifp
->name
) >= 0)
683 || (ripng_enable_network_lookup2(connected
) >= 0))
684 ripng_redistribute_add(
686 RIPNG_ROUTE_INTERFACE
, &address
,
687 connected
->ifp
->ifindex
, NULL
, 0);
689 ripng_redistribute_delete(
690 ZEBRA_ROUTE_CONNECT
, RIPNG_ROUTE_INTERFACE
,
691 &address
, connected
->ifp
->ifindex
);
692 if (ripng_redistribute_check(ZEBRA_ROUTE_CONNECT
))
693 ripng_redistribute_add(
695 RIPNG_ROUTE_REDISTRIBUTE
, &address
,
696 connected
->ifp
->ifindex
, NULL
, 0);
701 /* Check RIPng is enabed on this interface. */
702 void ripng_enable_apply(struct interface
*ifp
)
705 struct ripng_interface
*ri
= NULL
;
707 /* Check interface. */
713 /* Is this interface a candidate for RIPng ? */
714 ret
= ripng_enable_network_lookup_if(ifp
);
716 /* If the interface is matched. */
718 ri
->enable_network
= 1;
720 ri
->enable_network
= 0;
722 /* Check interface name configuration. */
723 ret
= ripng_enable_if_lookup(ifp
->name
);
725 ri
->enable_interface
= 1;
727 ri
->enable_interface
= 0;
729 /* any candidate interface MUST have a link-local IPv6 address */
730 if ((!ripng_if_ipv6_lladdress_check(ifp
))
731 && (ri
->enable_network
|| ri
->enable_interface
)) {
732 ri
->enable_network
= 0;
733 ri
->enable_interface
= 0;
734 zlog_warn("Interface %s does not have any link-local address",
738 /* Update running status of the interface. */
739 if (ri
->enable_network
|| ri
->enable_interface
) {
740 zlog_info("RIPng INTERFACE ON %s", ifp
->name
);
742 /* Add interface wake up thread. */
743 thread_add_timer(master
, ripng_interface_wakeup
, ifp
, 1,
746 ripng_connect_set(ifp
, 1);
749 /* Might as well clean up the route table as well
750 * ripng_if_down sets to 0 ri->running, and displays
755 ripng_connect_set(ifp
, 0);
760 /* Set distribute list to all interfaces. */
761 static void ripng_enable_apply_all(void)
763 struct vrf
*vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
764 struct interface
*ifp
;
766 FOR_ALL_INTERFACES (vrf
, ifp
)
767 ripng_enable_apply(ifp
);
770 /* Clear all network and neighbor configuration */
771 void ripng_clean_network()
777 /* ripng_enable_network */
778 for (rn
= agg_route_top(ripng_enable_network
); rn
;
779 rn
= agg_route_next(rn
))
785 /* ripng_enable_if */
786 for (i
= 0; i
< vector_active(ripng_enable_if
); i
++)
787 if ((str
= vector_slot(ripng_enable_if
, i
)) != NULL
) {
789 vector_slot(ripng_enable_if
, i
) = NULL
;
793 /* Vector to store passive-interface name. */
794 vector Vripng_passive_interface
;
796 /* Utility function for looking up passive interface settings. */
797 static int ripng_passive_interface_lookup(const char *ifname
)
802 for (i
= 0; i
< vector_active(Vripng_passive_interface
); i
++)
803 if ((str
= vector_slot(Vripng_passive_interface
, i
)) != NULL
)
804 if (strcmp(str
, ifname
) == 0)
809 void ripng_passive_interface_apply(struct interface
*ifp
)
812 struct ripng_interface
*ri
;
816 ret
= ripng_passive_interface_lookup(ifp
->name
);
823 static void ripng_passive_interface_apply_all(void)
825 struct vrf
*vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
826 struct interface
*ifp
;
828 FOR_ALL_INTERFACES (vrf
, ifp
)
829 ripng_passive_interface_apply(ifp
);
832 /* Passive interface. */
833 static int ripng_passive_interface_set(struct vty
*vty
, const char *ifname
)
835 if (ripng_passive_interface_lookup(ifname
) >= 0)
836 return CMD_WARNING_CONFIG_FAILED
;
838 vector_set(Vripng_passive_interface
, strdup(ifname
));
840 ripng_passive_interface_apply_all();
845 static int ripng_passive_interface_unset(struct vty
*vty
, const char *ifname
)
850 i
= ripng_passive_interface_lookup(ifname
);
852 return CMD_WARNING_CONFIG_FAILED
;
854 str
= vector_slot(Vripng_passive_interface
, i
);
856 vector_unset(Vripng_passive_interface
, i
);
858 ripng_passive_interface_apply_all();
863 /* Free all configured RIP passive-interface settings. */
864 void ripng_passive_interface_clean(void)
869 for (i
= 0; i
< vector_active(Vripng_passive_interface
); i
++)
870 if ((str
= vector_slot(Vripng_passive_interface
, i
)) != NULL
) {
872 vector_slot(Vripng_passive_interface
, i
) = NULL
;
874 ripng_passive_interface_apply_all();
877 /* Write RIPng enable network and interface to the vty. */
878 int ripng_network_write(struct vty
*vty
, int config_mode
)
882 struct agg_node
*node
;
885 /* Write enable network. */
886 for (node
= agg_route_top(ripng_enable_network
); node
;
887 node
= agg_route_next(node
))
889 struct prefix
*p
= &node
->p
;
890 vty_out(vty
, "%s%s/%d\n",
891 config_mode
? " network " : " ",
892 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
896 /* Write enable interface. */
897 for (i
= 0; i
< vector_active(ripng_enable_if
); i
++)
898 if ((ifname
= vector_slot(ripng_enable_if
, i
)) != NULL
)
899 vty_out(vty
, "%s%s\n",
900 config_mode
? " network " : " ", ifname
);
902 /* Write passive interface. */
904 for (i
= 0; i
< vector_active(Vripng_passive_interface
); i
++)
905 if ((ifname
= vector_slot(Vripng_passive_interface
, i
))
907 vty_out(vty
, " passive-interface %s\n", ifname
);
912 /* RIPng enable on specified interface or matched network. */
913 DEFUN (ripng_network
,
915 "network IF_OR_ADDR",
916 "RIPng enable on specified interface or network.\n"
917 "Interface or address\n")
919 int idx_if_or_addr
= 1;
923 ret
= str2prefix(argv
[idx_if_or_addr
]->arg
, &p
);
925 /* Given string is IPv6 network or interface name. */
927 ret
= ripng_enable_network_add(&p
);
929 ret
= ripng_enable_if_add(argv
[idx_if_or_addr
]->arg
);
932 vty_out(vty
, "There is same network configuration %s\n",
933 argv
[idx_if_or_addr
]->arg
);
934 return CMD_WARNING_CONFIG_FAILED
;
940 /* RIPng enable on specified interface or matched network. */
941 DEFUN (no_ripng_network
,
942 no_ripng_network_cmd
,
943 "no network IF_OR_ADDR",
945 "RIPng enable on specified interface or network.\n"
946 "Interface or address\n")
948 int idx_if_or_addr
= 2;
952 ret
= str2prefix(argv
[idx_if_or_addr
]->arg
, &p
);
954 /* Given string is interface name. */
956 ret
= ripng_enable_network_delete(&p
);
958 ret
= ripng_enable_if_delete(argv
[idx_if_or_addr
]->arg
);
961 vty_out(vty
, "can't find network %s\n",
962 argv
[idx_if_or_addr
]->arg
);
963 return CMD_WARNING_CONFIG_FAILED
;
969 DEFUN (ipv6_ripng_split_horizon
,
970 ipv6_ripng_split_horizon_cmd
,
971 "ipv6 ripng split-horizon",
973 "Routing Information Protocol\n"
974 "Perform split horizon\n")
976 VTY_DECLVAR_CONTEXT(interface
, ifp
);
977 struct ripng_interface
*ri
;
981 ri
->split_horizon
= RIPNG_SPLIT_HORIZON
;
985 DEFUN (ipv6_ripng_split_horizon_poisoned_reverse
,
986 ipv6_ripng_split_horizon_poisoned_reverse_cmd
,
987 "ipv6 ripng split-horizon poisoned-reverse",
989 "Routing Information Protocol\n"
990 "Perform split horizon\n"
991 "With poisoned-reverse\n")
993 VTY_DECLVAR_CONTEXT(interface
, ifp
);
994 struct ripng_interface
*ri
;
998 ri
->split_horizon
= RIPNG_SPLIT_HORIZON_POISONED_REVERSE
;
1002 DEFUN (no_ipv6_ripng_split_horizon
,
1003 no_ipv6_ripng_split_horizon_cmd
,
1004 "no ipv6 ripng split-horizon [poisoned-reverse]",
1007 "Routing Information Protocol\n"
1008 "Perform split horizon\n"
1009 "With poisoned-reverse\n")
1011 VTY_DECLVAR_CONTEXT(interface
, ifp
);
1012 struct ripng_interface
*ri
;
1016 ri
->split_horizon
= RIPNG_NO_SPLIT_HORIZON
;
1020 DEFUN (ripng_passive_interface
,
1021 ripng_passive_interface_cmd
,
1022 "passive-interface IFNAME",
1023 "Suppress routing updates on an interface\n"
1027 return ripng_passive_interface_set(vty
, argv
[idx_ifname
]->arg
);
1030 DEFUN (no_ripng_passive_interface
,
1031 no_ripng_passive_interface_cmd
,
1032 "no passive-interface IFNAME",
1034 "Suppress routing updates on an interface\n"
1038 return ripng_passive_interface_unset(vty
, argv
[idx_ifname
]->arg
);
1041 static struct ripng_interface
*ri_new(void)
1043 struct ripng_interface
*ri
;
1044 ri
= XCALLOC(MTYPE_IF
, sizeof(struct ripng_interface
));
1046 /* Set default split-horizon behavior. If the interface is Frame
1047 Relay or SMDS is enabled, the default value for split-horizon is
1048 off. But currently Zebra does detect Frame Relay or SMDS
1049 interface. So all interface is set to split horizon. */
1050 ri
->split_horizon_default
= RIPNG_SPLIT_HORIZON
;
1051 ri
->split_horizon
= ri
->split_horizon_default
;
1056 static int ripng_if_new_hook(struct interface
*ifp
)
1058 ifp
->info
= ri_new();
1062 /* Called when interface structure deleted. */
1063 static int ripng_if_delete_hook(struct interface
*ifp
)
1065 XFREE(MTYPE_IF
, ifp
->info
);
1070 /* Configuration write function for ripngd. */
1071 static int interface_config_write(struct vty
*vty
)
1073 struct vrf
*vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
1074 struct interface
*ifp
;
1075 struct ripng_interface
*ri
;
1078 FOR_ALL_INTERFACES (vrf
, ifp
) {
1081 /* Do not display the interface if there is no
1082 * configuration about it.
1085 && (ri
->split_horizon
== ri
->split_horizon_default
))
1088 vty_frame(vty
, "interface %s\n", ifp
->name
);
1090 vty_out(vty
, " description %s\n", ifp
->desc
);
1092 /* Split horizon. */
1093 if (ri
->split_horizon
!= ri
->split_horizon_default
) {
1094 switch (ri
->split_horizon
) {
1095 case RIPNG_SPLIT_HORIZON
:
1096 vty_out(vty
, " ipv6 ripng split-horizon\n");
1098 case RIPNG_SPLIT_HORIZON_POISONED_REVERSE
:
1100 " ipv6 ripng split-horizon poisoned-reverse\n");
1102 case RIPNG_NO_SPLIT_HORIZON
:
1104 vty_out(vty
, " no ipv6 ripng split-horizon\n");
1109 vty_endframe(vty
, "!\n");
1116 /* ripngd's interface node. */
1117 static struct cmd_node interface_node
= {
1118 INTERFACE_NODE
, "%s(config-if)# ", 1 /* VTYSH */
1121 /* Initialization of interface. */
1122 void ripng_if_init()
1124 /* Interface initialize. */
1125 hook_register_prio(if_add
, 0, ripng_if_new_hook
);
1126 hook_register_prio(if_del
, 0, ripng_if_delete_hook
);
1128 /* RIPng enable network init. */
1129 ripng_enable_network
= agg_table_init();
1131 /* RIPng enable interface init. */
1132 ripng_enable_if
= vector_init(1);
1134 /* RIPng passive interface. */
1135 Vripng_passive_interface
= vector_init(1);
1137 /* Install interface node. */
1138 install_node(&interface_node
, interface_config_write
);
1141 install_element(RIPNG_NODE
, &ripng_network_cmd
);
1142 install_element(RIPNG_NODE
, &no_ripng_network_cmd
);
1143 install_element(RIPNG_NODE
, &ripng_passive_interface_cmd
);
1144 install_element(RIPNG_NODE
, &no_ripng_passive_interface_cmd
);
1146 install_element(INTERFACE_NODE
, &ipv6_ripng_split_horizon_cmd
);
1147 install_element(INTERFACE_NODE
,
1148 &ipv6_ripng_split_horizon_poisoned_reverse_cmd
);
1149 install_element(INTERFACE_NODE
, &no_ipv6_ripng_split_horizon_cmd
);