2 * Copyright (C) 1998, 1999 Kunihiro Ishiguro
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
33 #include "distribute.h"
38 #include "lib_errors.h"
40 #include "ripngd/ripngd.h"
41 #include "ripngd/ripng_route.h"
42 #include "ripngd/ripng_debug.h"
43 #include "ripngd/ripng_nexthop.h"
45 /* RIPng structure which includes many parameters related to RIPng
46 protocol. If ripng couldn't active or ripng doesn't configured,
47 ripng->fd must be negative value. */
48 struct ripng
*ripng
= NULL
;
50 enum { ripng_all_route
,
55 void ripng_output_process(struct interface
*, struct sockaddr_in6
*, int);
57 int ripng_triggered_update(struct thread
*);
59 /* RIPng next hop specification. */
60 struct ripng_nexthop
{
61 enum ripng_nexthop_type
{
65 struct in6_addr address
;
68 static int ripng_route_rte(struct ripng_info
*rinfo
)
70 return (rinfo
->type
== ZEBRA_ROUTE_RIPNG
71 && rinfo
->sub_type
== RIPNG_ROUTE_RTE
);
74 /* Allocate new ripng information. */
75 struct ripng_info
*ripng_info_new()
77 struct ripng_info
*new;
79 new = XCALLOC(MTYPE_RIPNG_ROUTE
, sizeof(struct ripng_info
));
83 /* Free ripng information. */
84 void ripng_info_free(struct ripng_info
*rinfo
)
86 XFREE(MTYPE_RIPNG_ROUTE
, rinfo
);
89 /* Create ripng socket. */
90 static int ripng_make_socket(void)
94 struct sockaddr_in6 ripaddr
;
96 sock
= socket(AF_INET6
, SOCK_DGRAM
, 0);
98 flog_err_sys(LIB_ERR_SOCKET
, "Can't make ripng socket");
102 setsockopt_so_recvbuf(sock
, 8096);
103 ret
= setsockopt_ipv6_pktinfo(sock
, 1);
106 #ifdef IPTOS_PREC_INTERNETCONTROL
107 ret
= setsockopt_ipv6_tclass(sock
, IPTOS_PREC_INTERNETCONTROL
);
111 ret
= setsockopt_ipv6_multicast_hops(sock
, 255);
114 ret
= setsockopt_ipv6_multicast_loop(sock
, 0);
117 ret
= setsockopt_ipv6_hoplimit(sock
, 1);
121 memset(&ripaddr
, 0, sizeof(ripaddr
));
122 ripaddr
.sin6_family
= AF_INET6
;
124 ripaddr
.sin6_len
= sizeof(struct sockaddr_in6
);
125 #endif /* SIN6_LEN */
126 ripaddr
.sin6_port
= htons(RIPNG_PORT_DEFAULT
);
128 frr_elevate_privs(&ripngd_privs
) {
129 ret
= bind(sock
, (struct sockaddr
*)&ripaddr
, sizeof(ripaddr
));
131 zlog_err("Can't bind ripng socket: %s.",
132 safe_strerror(errno
));
143 /* Send RIPng packet. */
144 int ripng_send_packet(caddr_t buf
, int bufsize
, struct sockaddr_in6
*to
,
145 struct interface
*ifp
)
150 struct cmsghdr
*cmsgptr
;
152 struct in6_pktinfo
*pkt
;
153 struct sockaddr_in6 addr
;
155 if (IS_RIPNG_DEBUG_SEND
) {
157 zlog_debug("send to %s", inet6_ntoa(to
->sin6_addr
));
158 zlog_debug(" send interface %s", ifp
->name
);
159 zlog_debug(" send packet size %d", bufsize
);
162 memset(&addr
, 0, sizeof(struct sockaddr_in6
));
163 addr
.sin6_family
= AF_INET6
;
165 addr
.sin6_len
= sizeof(struct sockaddr_in6
);
166 #endif /* SIN6_LEN */
167 addr
.sin6_flowinfo
= htonl(RIPNG_PRIORITY_DEFAULT
);
169 /* When destination is specified. */
171 addr
.sin6_addr
= to
->sin6_addr
;
172 addr
.sin6_port
= to
->sin6_port
;
174 inet_pton(AF_INET6
, RIPNG_GROUP
, &addr
.sin6_addr
);
175 addr
.sin6_port
= htons(RIPNG_PORT_DEFAULT
);
178 memset(&msg
, 0, sizeof(msg
));
179 msg
.msg_name
= (void *)&addr
;
180 msg
.msg_namelen
= sizeof(struct sockaddr_in6
);
183 msg
.msg_control
= (void *)adata
;
184 msg
.msg_controllen
= CMSG_SPACE(sizeof(struct in6_pktinfo
));
187 iov
.iov_len
= bufsize
;
189 cmsgptr
= (struct cmsghdr
*)adata
;
190 cmsgptr
->cmsg_len
= CMSG_LEN(sizeof(struct in6_pktinfo
));
191 cmsgptr
->cmsg_level
= IPPROTO_IPV6
;
192 cmsgptr
->cmsg_type
= IPV6_PKTINFO
;
194 pkt
= (struct in6_pktinfo
*)CMSG_DATA(cmsgptr
);
195 memset(&pkt
->ipi6_addr
, 0, sizeof(struct in6_addr
));
196 pkt
->ipi6_ifindex
= ifp
->ifindex
;
198 ret
= sendmsg(ripng
->sock
, &msg
, 0);
202 flog_err_sys(LIB_ERR_SOCKET
,
203 "RIPng send fail on %s to %s: %s",
204 ifp
->name
, inet6_ntoa(to
->sin6_addr
),
205 safe_strerror(errno
));
207 flog_err_sys(LIB_ERR_SOCKET
,
208 "RIPng send fail on %s: %s", ifp
->name
,
209 safe_strerror(errno
));
215 /* Receive UDP RIPng packet from socket. */
216 static int ripng_recv_packet(int sock
, uint8_t *buf
, int bufsize
,
217 struct sockaddr_in6
*from
, ifindex_t
*ifindex
,
223 struct cmsghdr
*cmsgptr
;
224 struct in6_addr dst
= {.s6_addr
= {0}};
226 memset(&dst
, 0, sizeof(struct in6_addr
));
228 /* Ancillary data. This store cmsghdr and in6_pktinfo. But at this
229 point I can't determine size of cmsghdr */
232 /* Fill in message and iovec. */
233 memset(&msg
, 0, sizeof(msg
));
234 msg
.msg_name
= (void *)from
;
235 msg
.msg_namelen
= sizeof(struct sockaddr_in6
);
238 msg
.msg_control
= (void *)adata
;
239 msg
.msg_controllen
= sizeof adata
;
241 iov
.iov_len
= bufsize
;
243 /* If recvmsg fail return minus value. */
244 ret
= recvmsg(sock
, &msg
, 0);
248 for (cmsgptr
= CMSG_FIRSTHDR(&msg
); cmsgptr
!= NULL
;
249 cmsgptr
= CMSG_NXTHDR(&msg
, cmsgptr
)) {
250 /* I want interface index which this packet comes from. */
251 if (cmsgptr
->cmsg_level
== IPPROTO_IPV6
252 && cmsgptr
->cmsg_type
== IPV6_PKTINFO
) {
253 struct in6_pktinfo
*ptr
;
255 ptr
= (struct in6_pktinfo
*)CMSG_DATA(cmsgptr
);
256 *ifindex
= ptr
->ipi6_ifindex
;
257 dst
= ptr
->ipi6_addr
;
261 "Interface index returned by IPV6_PKTINFO is zero");
264 /* Incoming packet's multicast hop limit. */
265 if (cmsgptr
->cmsg_level
== IPPROTO_IPV6
266 && cmsgptr
->cmsg_type
== IPV6_HOPLIMIT
) {
267 int *phoplimit
= (int *)CMSG_DATA(cmsgptr
);
268 *hoplimit
= *phoplimit
;
272 /* Hoplimit check shold be done when destination address is
273 multicast address. */
274 if (!IN6_IS_ADDR_MULTICAST(&dst
))
280 /* Dump rip packet */
281 void ripng_packet_dump(struct ripng_packet
*packet
, int size
,
286 const char *command_str
;
288 /* Set command string. */
289 if (packet
->command
== RIPNG_REQUEST
)
290 command_str
= "request";
291 else if (packet
->command
== RIPNG_RESPONSE
)
292 command_str
= "response";
294 command_str
= "unknown";
296 /* Dump packet header. */
297 zlog_debug("%s %s version %d packet size %d", sndrcv
, command_str
,
298 packet
->version
, size
);
300 /* Dump each routing table entry. */
303 for (lim
= (caddr_t
)packet
+ size
; (caddr_t
)rte
< lim
; rte
++) {
304 if (rte
->metric
== RIPNG_METRIC_NEXTHOP
)
305 zlog_debug(" nexthop %s/%d", inet6_ntoa(rte
->addr
),
308 zlog_debug(" %s/%d metric %d tag %" ROUTE_TAG_PRI
,
309 inet6_ntoa(rte
->addr
), rte
->prefixlen
,
310 rte
->metric
, (route_tag_t
)ntohs(rte
->tag
));
314 /* RIPng next hop address RTE (Route Table Entry). */
315 static void ripng_nexthop_rte(struct rte
*rte
, struct sockaddr_in6
*from
,
316 struct ripng_nexthop
*nexthop
)
318 char buf
[INET6_BUFSIZ
];
320 /* Logging before checking RTE. */
321 if (IS_RIPNG_DEBUG_RECV
)
322 zlog_debug("RIPng nexthop RTE address %s tag %" ROUTE_TAG_PRI
324 inet6_ntoa(rte
->addr
), (route_tag_t
)ntohs(rte
->tag
),
327 /* RFC2080 2.1.1 Next Hop:
328 The route tag and prefix length in the next hop RTE must be
329 set to zero on sending and ignored on receiption. */
330 if (ntohs(rte
->tag
) != 0)
332 "RIPng nexthop RTE with non zero tag value %" ROUTE_TAG_PRI
334 (route_tag_t
)ntohs(rte
->tag
),
335 inet6_ntoa(from
->sin6_addr
));
337 if (rte
->prefixlen
!= 0)
339 "RIPng nexthop RTE with non zero prefixlen value %d from %s",
340 rte
->prefixlen
, inet6_ntoa(from
->sin6_addr
));
342 /* Specifying a value of 0:0:0:0:0:0:0:0 in the prefix field of a
343 next hop RTE indicates that the next hop address should be the
344 originator of the RIPng advertisement. An address specified as a
345 next hop must be a link-local address. */
346 if (IN6_IS_ADDR_UNSPECIFIED(&rte
->addr
)) {
347 nexthop
->flag
= RIPNG_NEXTHOP_UNSPEC
;
348 memset(&nexthop
->address
, 0, sizeof(struct in6_addr
));
352 if (IN6_IS_ADDR_LINKLOCAL(&rte
->addr
)) {
353 nexthop
->flag
= RIPNG_NEXTHOP_ADDRESS
;
354 IPV6_ADDR_COPY(&nexthop
->address
, &rte
->addr
);
358 /* The purpose of the next hop RTE is to eliminate packets being
359 routed through extra hops in the system. It is particularly useful
360 when RIPng is not being run on all of the routers on a network.
361 Note that next hop RTE is "advisory". That is, if the provided
362 information is ignored, a possibly sub-optimal, but absolutely
363 valid, route may be taken. If the received next hop address is not
364 a link-local address, it should be treated as 0:0:0:0:0:0:0:0. */
365 zlog_warn("RIPng nexthop RTE with non link-local address %s from %s",
366 inet6_ntoa(rte
->addr
),
367 inet_ntop(AF_INET6
, &from
->sin6_addr
, buf
, INET6_BUFSIZ
));
369 nexthop
->flag
= RIPNG_NEXTHOP_UNSPEC
;
370 memset(&nexthop
->address
, 0, sizeof(struct in6_addr
));
375 /* If ifp has same link-local address then return 1. */
376 static int ripng_lladdr_check(struct interface
*ifp
, struct in6_addr
*addr
)
378 struct listnode
*node
;
379 struct connected
*connected
;
382 for (ALL_LIST_ELEMENTS_RO(ifp
->connected
, node
, connected
)) {
383 p
= connected
->address
;
385 if (p
->family
== AF_INET6
386 && IN6_IS_ADDR_LINKLOCAL(&p
->u
.prefix6
)
387 && IN6_ARE_ADDR_EQUAL(&p
->u
.prefix6
, addr
))
393 /* RIPng route garbage collect timer. */
394 static int ripng_garbage_collect(struct thread
*t
)
396 struct ripng_info
*rinfo
;
397 struct route_node
*rp
;
399 rinfo
= THREAD_ARG(t
);
400 rinfo
->t_garbage_collect
= NULL
;
402 /* Off timeout timer. */
403 RIPNG_TIMER_OFF(rinfo
->t_timeout
);
405 /* Get route_node pointer. */
408 /* Unlock route_node. */
409 listnode_delete(rp
->info
, rinfo
);
410 if (list_isempty((struct list
*)rp
->info
)) {
411 list_delete_and_null((struct list
**)&rp
->info
);
412 route_unlock_node(rp
);
415 /* Free RIPng routing information. */
416 ripng_info_free(rinfo
);
421 static void ripng_timeout_update(struct ripng_info
*rinfo
);
423 /* Add new route to the ECMP list.
424 * RETURN: the new entry added in the list, or NULL if it is not the first
425 * entry and ECMP is not allowed.
427 struct ripng_info
*ripng_ecmp_add(struct ripng_info
*rinfo_new
)
429 struct route_node
*rp
= rinfo_new
->rp
;
430 struct ripng_info
*rinfo
= NULL
;
431 struct list
*list
= NULL
;
433 if (rp
->info
== NULL
)
434 rp
->info
= list_new();
435 list
= (struct list
*)rp
->info
;
437 /* If ECMP is not allowed and some entry already exists in the list,
439 if (listcount(list
) && !ripng
->ecmp
)
442 rinfo
= ripng_info_new();
443 memcpy(rinfo
, rinfo_new
, sizeof(struct ripng_info
));
444 listnode_add(list
, rinfo
);
446 if (ripng_route_rte(rinfo
)) {
447 ripng_timeout_update(rinfo
);
448 ripng_zebra_ipv6_add(rp
);
451 ripng_aggregate_increment(rp
, rinfo
);
453 /* Set the route change flag on the first entry. */
454 rinfo
= listgetdata(listhead(list
));
455 SET_FLAG(rinfo
->flags
, RIPNG_RTF_CHANGED
);
457 /* Signal the output process to trigger an update. */
458 ripng_event(RIPNG_TRIGGERED_UPDATE
, 0);
463 /* Replace the ECMP list with the new route.
464 * RETURN: the new entry added in the list
466 struct ripng_info
*ripng_ecmp_replace(struct ripng_info
*rinfo_new
)
468 struct route_node
*rp
= rinfo_new
->rp
;
469 struct list
*list
= (struct list
*)rp
->info
;
470 struct ripng_info
*rinfo
= NULL
, *tmp_rinfo
= NULL
;
471 struct listnode
*node
= NULL
, *nextnode
= NULL
;
473 if (list
== NULL
|| listcount(list
) == 0)
474 return ripng_ecmp_add(rinfo_new
);
476 /* Get the first entry */
477 rinfo
= listgetdata(listhead(list
));
479 /* Learnt route replaced by a local one. Delete it from zebra. */
480 if (ripng_route_rte(rinfo
) && !ripng_route_rte(rinfo_new
))
481 if (CHECK_FLAG(rinfo
->flags
, RIPNG_RTF_FIB
))
482 ripng_zebra_ipv6_delete(rp
);
484 if (rinfo
->metric
!= RIPNG_METRIC_INFINITY
)
485 ripng_aggregate_decrement_list(rp
, list
);
487 /* Re-use the first entry, and delete the others. */
488 for (ALL_LIST_ELEMENTS(list
, node
, nextnode
, tmp_rinfo
))
489 if (tmp_rinfo
!= rinfo
) {
490 RIPNG_TIMER_OFF(tmp_rinfo
->t_timeout
);
491 RIPNG_TIMER_OFF(tmp_rinfo
->t_garbage_collect
);
492 list_delete_node(list
, node
);
493 ripng_info_free(tmp_rinfo
);
496 RIPNG_TIMER_OFF(rinfo
->t_timeout
);
497 RIPNG_TIMER_OFF(rinfo
->t_garbage_collect
);
498 memcpy(rinfo
, rinfo_new
, sizeof(struct ripng_info
));
500 if (ripng_route_rte(rinfo
)) {
501 ripng_timeout_update(rinfo
);
502 /* The ADD message implies an update. */
503 ripng_zebra_ipv6_add(rp
);
506 ripng_aggregate_increment(rp
, rinfo
);
508 /* Set the route change flag. */
509 SET_FLAG(rinfo
->flags
, RIPNG_RTF_CHANGED
);
511 /* Signal the output process to trigger an update. */
512 ripng_event(RIPNG_TRIGGERED_UPDATE
, 0);
517 /* Delete one route from the ECMP list.
519 * null - the entry is freed, and other entries exist in the list
520 * the entry - the entry is the last one in the list; its metric is set
521 * to INFINITY, and the garbage collector is started for it
523 struct ripng_info
*ripng_ecmp_delete(struct ripng_info
*rinfo
)
525 struct route_node
*rp
= rinfo
->rp
;
526 struct list
*list
= (struct list
*)rp
->info
;
528 RIPNG_TIMER_OFF(rinfo
->t_timeout
);
530 if (rinfo
->metric
!= RIPNG_METRIC_INFINITY
)
531 ripng_aggregate_decrement(rp
, rinfo
);
533 if (listcount(list
) > 1) {
534 /* Some other ECMP entries still exist. Just delete this entry.
536 RIPNG_TIMER_OFF(rinfo
->t_garbage_collect
);
537 listnode_delete(list
, rinfo
);
538 if (ripng_route_rte(rinfo
)
539 && CHECK_FLAG(rinfo
->flags
, RIPNG_RTF_FIB
))
540 /* The ADD message implies the update. */
541 ripng_zebra_ipv6_add(rp
);
542 ripng_info_free(rinfo
);
545 assert(rinfo
== listgetdata(listhead(list
)));
547 /* This is the only entry left in the list. We must keep it in
548 * the list for garbage collection time, with INFINITY metric.
551 rinfo
->metric
= RIPNG_METRIC_INFINITY
;
552 RIPNG_TIMER_ON(rinfo
->t_garbage_collect
, ripng_garbage_collect
,
553 ripng
->garbage_time
);
555 if (ripng_route_rte(rinfo
)
556 && CHECK_FLAG(rinfo
->flags
, RIPNG_RTF_FIB
))
557 ripng_zebra_ipv6_delete(rp
);
560 /* Set the route change flag on the first entry. */
561 rinfo
= listgetdata(listhead(list
));
562 SET_FLAG(rinfo
->flags
, RIPNG_RTF_CHANGED
);
564 /* Signal the output process to trigger an update. */
565 ripng_event(RIPNG_TRIGGERED_UPDATE
, 0);
570 /* Timeout RIPng routes. */
571 static int ripng_timeout(struct thread
*t
)
573 ripng_ecmp_delete((struct ripng_info
*)THREAD_ARG(t
));
577 static void ripng_timeout_update(struct ripng_info
*rinfo
)
579 if (rinfo
->metric
!= RIPNG_METRIC_INFINITY
) {
580 RIPNG_TIMER_OFF(rinfo
->t_timeout
);
581 RIPNG_TIMER_ON(rinfo
->t_timeout
, ripng_timeout
,
582 ripng
->timeout_time
);
586 static int ripng_filter(int ripng_distribute
, struct prefix_ipv6
*p
,
587 struct ripng_interface
*ri
)
589 struct distribute
*dist
;
590 struct access_list
*alist
;
591 struct prefix_list
*plist
;
592 int distribute
= ripng_distribute
== RIPNG_FILTER_OUT
595 const char *inout
= ripng_distribute
== RIPNG_FILTER_OUT
? "out" : "in";
597 /* Input distribute-list filtering. */
598 if (ri
->list
[ripng_distribute
]) {
599 if (access_list_apply(ri
->list
[ripng_distribute
],
602 if (IS_RIPNG_DEBUG_PACKET
)
603 zlog_debug("%s/%d filtered by distribute %s",
604 inet6_ntoa(p
->prefix
), p
->prefixlen
,
609 if (ri
->prefix
[ripng_distribute
]) {
610 if (prefix_list_apply(ri
->prefix
[ripng_distribute
],
613 if (IS_RIPNG_DEBUG_PACKET
)
614 zlog_debug("%s/%d filtered by prefix-list %s",
615 inet6_ntoa(p
->prefix
), p
->prefixlen
,
621 /* All interface filter check. */
622 dist
= distribute_lookup(NULL
);
624 if (dist
->list
[distribute
]) {
625 alist
= access_list_lookup(AFI_IP6
,
626 dist
->list
[distribute
]);
629 if (access_list_apply(alist
, (struct prefix
*)p
)
631 if (IS_RIPNG_DEBUG_PACKET
)
633 "%s/%d filtered by distribute %s",
634 inet6_ntoa(p
->prefix
),
635 p
->prefixlen
, inout
);
640 if (dist
->prefix
[distribute
]) {
641 plist
= prefix_list_lookup(AFI_IP6
,
642 dist
->prefix
[distribute
]);
645 if (prefix_list_apply(plist
, (struct prefix
*)p
)
647 if (IS_RIPNG_DEBUG_PACKET
)
649 "%s/%d filtered by prefix-list %s",
650 inet6_ntoa(p
->prefix
),
651 p
->prefixlen
, inout
);
660 /* Process RIPng route according to RFC2080. */
661 static void ripng_route_process(struct rte
*rte
, struct sockaddr_in6
*from
,
662 struct ripng_nexthop
*ripng_nexthop
,
663 struct interface
*ifp
)
666 struct prefix_ipv6 p
;
667 struct route_node
*rp
;
668 struct ripng_info
*rinfo
= NULL
, newinfo
;
669 struct ripng_interface
*ri
;
670 struct in6_addr
*nexthop
;
672 struct list
*list
= NULL
;
673 struct listnode
*node
= NULL
;
675 /* Make prefix structure. */
676 memset(&p
, 0, sizeof(struct prefix_ipv6
));
678 /* p.prefix = rte->addr; */
679 IPV6_ADDR_COPY(&p
.prefix
, &rte
->addr
);
680 p
.prefixlen
= rte
->prefixlen
;
682 /* Make sure mask is applied. */
683 /* XXX We have to check the prefix is valid or not before call
687 /* Apply input filters. */
690 ret
= ripng_filter(RIPNG_FILTER_IN
, &p
, ri
);
694 memset(&newinfo
, 0, sizeof(newinfo
));
695 newinfo
.type
= ZEBRA_ROUTE_RIPNG
;
696 newinfo
.sub_type
= RIPNG_ROUTE_RTE
;
697 if (ripng_nexthop
->flag
== RIPNG_NEXTHOP_ADDRESS
)
698 newinfo
.nexthop
= ripng_nexthop
->address
;
700 newinfo
.nexthop
= from
->sin6_addr
;
701 newinfo
.from
= from
->sin6_addr
;
702 newinfo
.ifindex
= ifp
->ifindex
;
703 newinfo
.metric
= rte
->metric
;
704 newinfo
.metric_out
= rte
->metric
; /* XXX */
705 newinfo
.tag
= ntohs(rte
->tag
); /* XXX */
708 if (ri
->routemap
[RIPNG_FILTER_IN
]) {
711 ret
= route_map_apply(ri
->routemap
[RIPNG_FILTER_IN
],
712 (struct prefix
*)&p
, RMAP_RIPNG
,
715 if (ret
== RMAP_DENYMATCH
) {
716 if (IS_RIPNG_DEBUG_PACKET
)
718 "RIPng %s/%d is filtered by route-map in",
719 inet6_ntoa(p
.prefix
), p
.prefixlen
);
723 /* Get back the object */
724 if (ripng_nexthop
->flag
== RIPNG_NEXTHOP_ADDRESS
) {
725 if (!IPV6_ADDR_SAME(&newinfo
.nexthop
,
726 &ripng_nexthop
->address
)) {
727 /* the nexthop get changed by the routemap */
728 if (IN6_IS_ADDR_LINKLOCAL(&newinfo
.nexthop
))
729 ripng_nexthop
->address
=
732 ripng_nexthop
->address
= in6addr_any
;
735 if (!IPV6_ADDR_SAME(&newinfo
.nexthop
,
737 /* the nexthop get changed by the routemap */
738 if (IN6_IS_ADDR_LINKLOCAL(&newinfo
.nexthop
)) {
739 ripng_nexthop
->flag
=
740 RIPNG_NEXTHOP_ADDRESS
;
741 ripng_nexthop
->address
=
746 rte
->tag
= htons(newinfo
.tag_out
); /* XXX */
748 newinfo
.metric_out
; /* XXX: the routemap uses the
752 /* Once the entry has been validated, update the metric by
753 * adding the cost of the network on wich the message
754 * arrived. If the result is greater than infinity, use infinity
755 * (RFC2453 Sec. 3.9.2)
758 /* Zebra ripngd can handle offset-list in. */
759 ret
= ripng_offset_list_apply_in(&p
, ifp
, &rte
->metric
);
761 /* If offset-list does not modify the metric use interface's
764 rte
->metric
+= ifp
->metric
? ifp
->metric
: 1;
766 if (rte
->metric
> RIPNG_METRIC_INFINITY
)
767 rte
->metric
= RIPNG_METRIC_INFINITY
;
769 /* Set nexthop pointer. */
770 if (ripng_nexthop
->flag
== RIPNG_NEXTHOP_ADDRESS
)
771 nexthop
= &ripng_nexthop
->address
;
773 nexthop
= &from
->sin6_addr
;
775 /* Lookup RIPng routing table. */
776 rp
= route_node_get(ripng
->table
, (struct prefix
*)&p
);
779 newinfo
.nexthop
= *nexthop
;
780 newinfo
.metric
= rte
->metric
;
781 newinfo
.tag
= ntohs(rte
->tag
);
783 /* Check to see whether there is already RIPng route on the table. */
784 if ((list
= rp
->info
) != NULL
)
785 for (ALL_LIST_ELEMENTS_RO(list
, node
, rinfo
)) {
786 /* Need to compare with redistributed entry or local
788 if (!ripng_route_rte(rinfo
))
791 if (IPV6_ADDR_SAME(&rinfo
->from
, &from
->sin6_addr
)
792 && IPV6_ADDR_SAME(&rinfo
->nexthop
, nexthop
))
795 if (!listnextnode(node
)) {
796 /* Not found in the list */
798 if (rte
->metric
> rinfo
->metric
) {
799 /* New route has a greater metric.
801 route_unlock_node(rp
);
805 if (rte
->metric
< rinfo
->metric
)
806 /* New route has a smaller metric.
807 * Replace the ECMP list
808 * with the new one in below. */
811 /* Metrics are same. Unless ECMP is disabled,
812 * keep "rinfo" null and
813 * the new route is added in the ECMP list in
821 /* Redistributed route check. */
822 if (rinfo
->type
!= ZEBRA_ROUTE_RIPNG
823 && rinfo
->metric
!= RIPNG_METRIC_INFINITY
) {
824 route_unlock_node(rp
);
828 /* Local static route. */
829 if (rinfo
->type
== ZEBRA_ROUTE_RIPNG
830 && ((rinfo
->sub_type
== RIPNG_ROUTE_STATIC
)
831 || (rinfo
->sub_type
== RIPNG_ROUTE_DEFAULT
))
832 && rinfo
->metric
!= RIPNG_METRIC_INFINITY
) {
833 route_unlock_node(rp
);
839 /* Now, check to see whether there is already an explicit route
840 for the destination prefix. If there is no such route, add
841 this route to the routing table, unless the metric is
842 infinity (there is no point in adding a route which
844 if (rte
->metric
!= RIPNG_METRIC_INFINITY
)
845 ripng_ecmp_add(&newinfo
);
847 route_unlock_node(rp
);
849 /* If there is an existing route, compare the next hop address
850 to the address of the router from which the datagram came.
851 If this datagram is from the same router as the existing
852 route, reinitialize the timeout. */
853 same
= (IN6_ARE_ADDR_EQUAL(&rinfo
->from
, &from
->sin6_addr
)
854 && (rinfo
->ifindex
== ifp
->ifindex
));
857 * RFC 2080 - Section 2.4.2:
858 * "If the new metric is the same as the old one, examine the
860 * for the existing route. If it is at least halfway to the
862 * point, switch to the new route. This heuristic is optional,
864 * highly recommended".
866 if (!ripng
->ecmp
&& !same
&& rinfo
->metric
== rte
->metric
868 && (thread_timer_remain_second(rinfo
->t_timeout
)
869 < (ripng
->timeout_time
/ 2))) {
870 ripng_ecmp_replace(&newinfo
);
872 /* Next, compare the metrics. If the datagram is from the same
873 router as the existing route, and the new metric is different
874 than the old one; or, if the new metric is lower than the old
875 one; do the following actions: */
876 else if ((same
&& rinfo
->metric
!= rte
->metric
)
877 || rte
->metric
< rinfo
->metric
) {
878 if (listcount(list
) == 1) {
879 if (newinfo
.metric
!= RIPNG_METRIC_INFINITY
)
880 ripng_ecmp_replace(&newinfo
);
882 ripng_ecmp_delete(rinfo
);
884 if (newinfo
.metric
< rinfo
->metric
)
885 ripng_ecmp_replace(&newinfo
);
886 else /* newinfo.metric > rinfo->metric */
887 ripng_ecmp_delete(rinfo
);
889 } else /* same & no change */
890 ripng_timeout_update(rinfo
);
892 /* Unlock tempolary lock of the route. */
893 route_unlock_node(rp
);
897 /* Add redistributed route to RIPng table. */
898 void ripng_redistribute_add(int type
, int sub_type
, struct prefix_ipv6
*p
,
899 ifindex_t ifindex
, struct in6_addr
*nexthop
,
902 struct route_node
*rp
;
903 struct ripng_info
*rinfo
= NULL
, newinfo
;
904 struct list
*list
= NULL
;
906 /* Redistribute route */
907 if (IN6_IS_ADDR_LINKLOCAL(&p
->prefix
))
909 if (IN6_IS_ADDR_LOOPBACK(&p
->prefix
))
912 rp
= route_node_get(ripng
->table
, (struct prefix
*)p
);
914 memset(&newinfo
, 0, sizeof(struct ripng_info
));
916 newinfo
.sub_type
= sub_type
;
917 newinfo
.ifindex
= ifindex
;
919 if (tag
<= UINT16_MAX
) /* RIPng only supports 16 bit tags */
922 if (nexthop
&& IN6_IS_ADDR_LINKLOCAL(nexthop
))
923 newinfo
.nexthop
= *nexthop
;
925 if ((list
= rp
->info
) != NULL
&& listcount(list
) != 0) {
926 rinfo
= listgetdata(listhead(list
));
928 if (rinfo
->type
== ZEBRA_ROUTE_CONNECT
929 && rinfo
->sub_type
== RIPNG_ROUTE_INTERFACE
930 && rinfo
->metric
!= RIPNG_METRIC_INFINITY
) {
931 route_unlock_node(rp
);
935 /* Manually configured RIPng route check.
936 * They have the precedence on all the other entries.
938 if (rinfo
->type
== ZEBRA_ROUTE_RIPNG
939 && ((rinfo
->sub_type
== RIPNG_ROUTE_STATIC
)
940 || (rinfo
->sub_type
== RIPNG_ROUTE_DEFAULT
))) {
941 if (type
!= ZEBRA_ROUTE_RIPNG
942 || ((sub_type
!= RIPNG_ROUTE_STATIC
)
943 && (sub_type
!= RIPNG_ROUTE_DEFAULT
))) {
944 route_unlock_node(rp
);
949 ripng_ecmp_replace(&newinfo
);
950 route_unlock_node(rp
);
952 ripng_ecmp_add(&newinfo
);
954 if (IS_RIPNG_DEBUG_EVENT
) {
957 "Redistribute new prefix %s/%d on the interface %s",
958 inet6_ntoa(p
->prefix
), p
->prefixlen
,
959 ifindex2ifname(ifindex
, VRF_DEFAULT
));
962 "Redistribute new prefix %s/%d with nexthop %s on the interface %s",
963 inet6_ntoa(p
->prefix
), p
->prefixlen
,
964 inet6_ntoa(*nexthop
),
965 ifindex2ifname(ifindex
, VRF_DEFAULT
));
968 ripng_event(RIPNG_TRIGGERED_UPDATE
, 0);
971 /* Delete redistributed route to RIPng table. */
972 void ripng_redistribute_delete(int type
, int sub_type
, struct prefix_ipv6
*p
,
975 struct route_node
*rp
;
976 struct ripng_info
*rinfo
;
978 if (IN6_IS_ADDR_LINKLOCAL(&p
->prefix
))
980 if (IN6_IS_ADDR_LOOPBACK(&p
->prefix
))
983 rp
= route_node_lookup(ripng
->table
, (struct prefix
*)p
);
986 struct list
*list
= rp
->info
;
988 if (list
!= NULL
&& listcount(list
) != 0) {
989 rinfo
= listgetdata(listhead(list
));
990 if (rinfo
!= NULL
&& rinfo
->type
== type
991 && rinfo
->sub_type
== sub_type
992 && rinfo
->ifindex
== ifindex
) {
993 /* Perform poisoned reverse. */
994 rinfo
->metric
= RIPNG_METRIC_INFINITY
;
995 RIPNG_TIMER_ON(rinfo
->t_garbage_collect
,
996 ripng_garbage_collect
,
997 ripng
->garbage_time
);
998 RIPNG_TIMER_OFF(rinfo
->t_timeout
);
1000 /* Aggregate count decrement. */
1001 ripng_aggregate_decrement(rp
, rinfo
);
1003 rinfo
->flags
|= RIPNG_RTF_CHANGED
;
1005 if (IS_RIPNG_DEBUG_EVENT
)
1007 "Poisone %s/%d on the interface %s with an "
1008 "infinity metric [delete]",
1009 inet6_ntoa(p
->prefix
),
1011 ifindex2ifname(ifindex
,
1014 ripng_event(RIPNG_TRIGGERED_UPDATE
, 0);
1017 route_unlock_node(rp
);
1021 /* Withdraw redistributed route. */
1022 void ripng_redistribute_withdraw(int type
)
1024 struct route_node
*rp
;
1025 struct ripng_info
*rinfo
= NULL
;
1026 struct list
*list
= NULL
;
1031 for (rp
= route_top(ripng
->table
); rp
; rp
= route_next(rp
))
1032 if ((list
= rp
->info
) != NULL
) {
1033 rinfo
= listgetdata(listhead(list
));
1034 if ((rinfo
->type
== type
)
1035 && (rinfo
->sub_type
!= RIPNG_ROUTE_INTERFACE
)) {
1036 /* Perform poisoned reverse. */
1037 rinfo
->metric
= RIPNG_METRIC_INFINITY
;
1038 RIPNG_TIMER_ON(rinfo
->t_garbage_collect
,
1039 ripng_garbage_collect
,
1040 ripng
->garbage_time
);
1041 RIPNG_TIMER_OFF(rinfo
->t_timeout
);
1043 /* Aggregate count decrement. */
1044 ripng_aggregate_decrement(rp
, rinfo
);
1046 rinfo
->flags
|= RIPNG_RTF_CHANGED
;
1048 if (IS_RIPNG_DEBUG_EVENT
) {
1049 struct prefix_ipv6
*p
=
1050 (struct prefix_ipv6
*)&rp
->p
;
1053 "Poisone %s/%d on the interface %s [withdraw]",
1054 inet6_ntoa(p
->prefix
),
1056 ifindex2ifname(rinfo
->ifindex
,
1060 ripng_event(RIPNG_TRIGGERED_UPDATE
, 0);
1065 /* RIP routing information. */
1066 static void ripng_response_process(struct ripng_packet
*packet
, int size
,
1067 struct sockaddr_in6
*from
,
1068 struct interface
*ifp
, int hoplimit
)
1072 struct ripng_nexthop nexthop
;
1074 /* RFC2080 2.4.2 Response Messages:
1075 The Response must be ignored if it is not from the RIPng port. */
1076 if (ntohs(from
->sin6_port
) != RIPNG_PORT_DEFAULT
) {
1077 zlog_warn("RIPng packet comes from non RIPng port %d from %s",
1078 ntohs(from
->sin6_port
), inet6_ntoa(from
->sin6_addr
));
1079 ripng_peer_bad_packet(from
);
1083 /* The datagram's IPv6 source address should be checked to see
1084 whether the datagram is from a valid neighbor; the source of the
1085 datagram must be a link-local address. */
1086 if (!IN6_IS_ADDR_LINKLOCAL(&from
->sin6_addr
)) {
1087 zlog_warn("RIPng packet comes from non link local address %s",
1088 inet6_ntoa(from
->sin6_addr
));
1089 ripng_peer_bad_packet(from
);
1093 /* It is also worth checking to see whether the response is from one
1094 of the router's own addresses. Interfaces on broadcast networks
1095 may receive copies of their own multicasts immediately. If a
1096 router processes its own output as new input, confusion is likely,
1097 and such datagrams must be ignored. */
1098 if (ripng_lladdr_check(ifp
, &from
->sin6_addr
)) {
1100 "RIPng packet comes from my own link local address %s",
1101 inet6_ntoa(from
->sin6_addr
));
1102 ripng_peer_bad_packet(from
);
1106 /* As an additional check, periodic advertisements must have their
1107 hop counts set to 255, and inbound, multicast packets sent from the
1108 RIPng port (i.e. periodic advertisement or triggered update
1109 packets) must be examined to ensure that the hop count is 255. */
1110 if (hoplimit
>= 0 && hoplimit
!= 255) {
1112 "RIPng packet comes with non 255 hop count %d from %s",
1113 hoplimit
, inet6_ntoa(from
->sin6_addr
));
1114 ripng_peer_bad_packet(from
);
1118 /* Update RIPng peer. */
1119 ripng_peer_update(from
, packet
->version
);
1121 /* Reset nexthop. */
1122 memset(&nexthop
, 0, sizeof(struct ripng_nexthop
));
1123 nexthop
.flag
= RIPNG_NEXTHOP_UNSPEC
;
1125 /* Set RTE pointer. */
1128 for (lim
= ((caddr_t
)packet
) + size
; (caddr_t
)rte
< lim
; rte
++) {
1129 /* First of all, we have to check this RTE is next hop RTE or
1130 not. Next hop RTE is completely different with normal RTE so
1131 we need special treatment. */
1132 if (rte
->metric
== RIPNG_METRIC_NEXTHOP
) {
1133 ripng_nexthop_rte(rte
, from
, &nexthop
);
1137 /* RTE information validation. */
1139 /* - is the destination prefix valid (e.g., not a multicast
1140 prefix and not a link-local address) A link-local address
1141 should never be present in an RTE. */
1142 if (IN6_IS_ADDR_MULTICAST(&rte
->addr
)) {
1144 "Destination prefix is a multicast address %s/%d [%d]",
1145 inet6_ntoa(rte
->addr
), rte
->prefixlen
,
1147 ripng_peer_bad_route(from
);
1150 if (IN6_IS_ADDR_LINKLOCAL(&rte
->addr
)) {
1152 "Destination prefix is a link-local address %s/%d [%d]",
1153 inet6_ntoa(rte
->addr
), rte
->prefixlen
,
1155 ripng_peer_bad_route(from
);
1158 if (IN6_IS_ADDR_LOOPBACK(&rte
->addr
)) {
1160 "Destination prefix is a loopback address %s/%d [%d]",
1161 inet6_ntoa(rte
->addr
), rte
->prefixlen
,
1163 ripng_peer_bad_route(from
);
1167 /* - is the prefix length valid (i.e., between 0 and 128,
1169 if (rte
->prefixlen
> 128) {
1170 zlog_warn("Invalid prefix length %s/%d from %s%%%s",
1171 inet6_ntoa(rte
->addr
), rte
->prefixlen
,
1172 inet6_ntoa(from
->sin6_addr
), ifp
->name
);
1173 ripng_peer_bad_route(from
);
1177 /* - is the metric valid (i.e., between 1 and 16, inclusive) */
1178 if (!(rte
->metric
>= 1 && rte
->metric
<= 16)) {
1179 zlog_warn("Invalid metric %d from %s%%%s", rte
->metric
,
1180 inet6_ntoa(from
->sin6_addr
), ifp
->name
);
1181 ripng_peer_bad_route(from
);
1185 /* Vincent: XXX Should we compute the direclty reachable nexthop
1186 * for our RIPng network ?
1189 /* Routing table updates. */
1190 ripng_route_process(rte
, from
, &nexthop
, ifp
);
1194 /* Response to request message. */
1195 static void ripng_request_process(struct ripng_packet
*packet
, int size
,
1196 struct sockaddr_in6
*from
,
1197 struct interface
*ifp
)
1201 struct prefix_ipv6 p
;
1202 struct route_node
*rp
;
1203 struct ripng_info
*rinfo
;
1204 struct ripng_interface
*ri
;
1206 /* Does not reponse to the requests on the loopback interfaces */
1207 if (if_is_loopback(ifp
))
1210 /* Check RIPng process is enabled on this interface. */
1215 /* When passive interface is specified, suppress responses */
1219 /* RIPng peer update. */
1220 ripng_peer_update(from
, packet
->version
);
1222 lim
= ((caddr_t
)packet
) + size
;
1225 /* The Request is processed entry by entry. If there are no
1226 entries, no response is given. */
1227 if (lim
== (caddr_t
)rte
)
1230 /* There is one special case. If there is exactly one entry in the
1231 request, and it has a destination prefix of zero, a prefix length
1232 of zero, and a metric of infinity (i.e., 16), then this is a
1233 request to send the entire routing table. In that case, a call
1234 is made to the output process to send the routing table to the
1235 requesting address/port. */
1236 if (lim
== ((caddr_t
)(rte
+ 1)) && IN6_IS_ADDR_UNSPECIFIED(&rte
->addr
)
1237 && rte
->prefixlen
== 0 && rte
->metric
== RIPNG_METRIC_INFINITY
) {
1238 /* All route with split horizon */
1239 ripng_output_process(ifp
, from
, ripng_all_route
);
1241 /* Except for this special case, processing is quite simple.
1242 Examine the list of RTEs in the Request one by one. For each
1243 entry, look up the destination in the router's routing
1244 database and, if there is a route, put that route's metric in
1245 the metric field of the RTE. If there is no explicit route
1246 to the specified destination, put infinity in the metric
1247 field. Once all the entries have been filled in, change the
1248 command from Request to Response and send the datagram back
1249 to the requestor. */
1250 memset(&p
, 0, sizeof(struct prefix_ipv6
));
1251 p
.family
= AF_INET6
;
1253 for (; ((caddr_t
)rte
) < lim
; rte
++) {
1254 p
.prefix
= rte
->addr
;
1255 p
.prefixlen
= rte
->prefixlen
;
1256 apply_mask_ipv6(&p
);
1258 rp
= route_node_lookup(ripng
->table
,
1259 (struct prefix
*)&p
);
1262 rinfo
= listgetdata(
1263 listhead((struct list
*)rp
->info
));
1264 rte
->metric
= rinfo
->metric
;
1265 route_unlock_node(rp
);
1267 rte
->metric
= RIPNG_METRIC_INFINITY
;
1269 packet
->command
= RIPNG_RESPONSE
;
1271 ripng_send_packet((caddr_t
)packet
, size
, from
, ifp
);
1275 /* First entry point of reading RIPng packet. */
1276 static int ripng_read(struct thread
*thread
)
1280 struct sockaddr_in6 from
;
1281 struct ripng_packet
*packet
;
1282 ifindex_t ifindex
= 0;
1283 struct interface
*ifp
;
1286 /* Check ripng is active and alive. */
1287 assert(ripng
!= NULL
);
1288 assert(ripng
->sock
>= 0);
1290 /* Fetch thread data and set read pointer to empty for event
1291 managing. `sock' sould be same as ripng->sock. */
1292 sock
= THREAD_FD(thread
);
1293 ripng
->t_read
= NULL
;
1295 /* Add myself to the next event. */
1296 ripng_event(RIPNG_READ
, sock
);
1298 /* Read RIPng packet. */
1299 len
= ripng_recv_packet(sock
, STREAM_DATA(ripng
->ibuf
),
1300 STREAM_SIZE(ripng
->ibuf
), &from
, &ifindex
,
1303 zlog_warn("RIPng recvfrom failed: %s.", safe_strerror(errno
));
1307 /* Check RTE boundary. RTE size (Packet length - RIPng header size
1308 (4)) must be multiple size of one RTE size (20). */
1309 if (((len
- 4) % 20) != 0) {
1310 zlog_warn("RIPng invalid packet size %d from %s", len
,
1311 inet6_ntoa(from
.sin6_addr
));
1312 ripng_peer_bad_packet(&from
);
1316 packet
= (struct ripng_packet
*)STREAM_DATA(ripng
->ibuf
);
1317 ifp
= if_lookup_by_index(ifindex
, VRF_DEFAULT
);
1319 /* RIPng packet received. */
1320 if (IS_RIPNG_DEBUG_EVENT
)
1321 zlog_debug("RIPng packet received from %s port %d on %s",
1322 inet6_ntoa(from
.sin6_addr
), ntohs(from
.sin6_port
),
1323 ifp
? ifp
->name
: "unknown");
1325 /* Logging before packet checking. */
1326 if (IS_RIPNG_DEBUG_RECV
)
1327 ripng_packet_dump(packet
, len
, "RECV");
1329 /* Packet comes from unknown interface. */
1331 zlog_warn("RIPng packet comes from unknown interface %d",
1336 /* Packet version mismatch checking. */
1337 if (packet
->version
!= ripng
->version
) {
1339 "RIPng packet version %d doesn't fit to my version %d",
1340 packet
->version
, ripng
->version
);
1341 ripng_peer_bad_packet(&from
);
1345 /* Process RIPng packet. */
1346 switch (packet
->command
) {
1348 ripng_request_process(packet
, len
, &from
, ifp
);
1350 case RIPNG_RESPONSE
:
1351 ripng_response_process(packet
, len
, &from
, ifp
, hoplimit
);
1354 zlog_warn("Invalid RIPng command %d", packet
->command
);
1355 ripng_peer_bad_packet(&from
);
1361 /* Walk down the RIPng routing table then clear changed flag. */
1362 static void ripng_clear_changed_flag(void)
1364 struct route_node
*rp
;
1365 struct ripng_info
*rinfo
= NULL
;
1366 struct list
*list
= NULL
;
1367 struct listnode
*listnode
= NULL
;
1369 for (rp
= route_top(ripng
->table
); rp
; rp
= route_next(rp
))
1370 if ((list
= rp
->info
) != NULL
)
1371 for (ALL_LIST_ELEMENTS_RO(list
, listnode
, rinfo
)) {
1372 UNSET_FLAG(rinfo
->flags
, RIPNG_RTF_CHANGED
);
1373 /* This flag can be set only on the first entry.
1379 /* Regular update of RIPng route. Send all routing formation to RIPng
1380 enabled interface. */
1381 static int ripng_update(struct thread
*t
)
1383 struct vrf
*vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
1384 struct interface
*ifp
;
1385 struct ripng_interface
*ri
;
1387 /* Clear update timer thread. */
1388 ripng
->t_update
= NULL
;
1390 /* Logging update event. */
1391 if (IS_RIPNG_DEBUG_EVENT
)
1392 zlog_debug("RIPng update timer expired!");
1394 /* Supply routes to each interface. */
1395 FOR_ALL_INTERFACES (vrf
, ifp
) {
1398 if (if_is_loopback(ifp
) || !if_is_up(ifp
))
1404 /* When passive interface is specified, suppress announce to the
1410 if (ri
->ri_send
== RIPNG_SEND_OFF
) {
1411 if (IS_RIPNG_DEBUG_EVENT
)
1413 "[Event] RIPng send to if %d is suppressed by config",
1417 #endif /* RIPNG_ADVANCED */
1419 ripng_output_process(ifp
, NULL
, ripng_all_route
);
1422 /* Triggered updates may be suppressed if a regular update is due by
1423 the time the triggered update would be sent. */
1424 if (ripng
->t_triggered_interval
) {
1425 thread_cancel(ripng
->t_triggered_interval
);
1426 ripng
->t_triggered_interval
= NULL
;
1430 /* Reset flush event. */
1431 ripng_event(RIPNG_UPDATE_EVENT
, 0);
1436 /* Triggered update interval timer. */
1437 static int ripng_triggered_interval(struct thread
*t
)
1439 ripng
->t_triggered_interval
= NULL
;
1441 if (ripng
->trigger
) {
1443 ripng_triggered_update(t
);
1448 /* Execute triggered update. */
1449 int ripng_triggered_update(struct thread
*t
)
1451 struct vrf
*vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
1452 struct interface
*ifp
;
1453 struct ripng_interface
*ri
;
1456 ripng
->t_triggered_update
= NULL
;
1458 /* Cancel interval timer. */
1459 if (ripng
->t_triggered_interval
) {
1460 thread_cancel(ripng
->t_triggered_interval
);
1461 ripng
->t_triggered_interval
= NULL
;
1465 /* Logging triggered update. */
1466 if (IS_RIPNG_DEBUG_EVENT
)
1467 zlog_debug("RIPng triggered update!");
1469 /* Split Horizon processing is done when generating triggered
1470 updates as well as normal updates (see section 2.6). */
1471 FOR_ALL_INTERFACES (vrf
, ifp
) {
1474 if (if_is_loopback(ifp
) || !if_is_up(ifp
))
1480 /* When passive interface is specified, suppress announce to the
1485 ripng_output_process(ifp
, NULL
, ripng_changed_route
);
1488 /* Once all of the triggered updates have been generated, the route
1489 change flags should be cleared. */
1490 ripng_clear_changed_flag();
1492 /* After a triggered update is sent, a timer should be set for a
1493 random interval between 1 and 5 seconds. If other changes that
1494 would trigger updates occur before the timer expires, a single
1495 update is triggered when the timer expires. */
1496 interval
= (random() % 5) + 1;
1498 ripng
->t_triggered_interval
= NULL
;
1499 thread_add_timer(master
, ripng_triggered_interval
, NULL
, interval
,
1500 &ripng
->t_triggered_interval
);
1505 /* Write routing table entry to the stream and return next index of
1506 the routing table entry in the stream. */
1507 int ripng_write_rte(int num
, struct stream
*s
, struct prefix_ipv6
*p
,
1508 struct in6_addr
*nexthop
, uint16_t tag
, uint8_t metric
)
1510 /* RIPng packet header. */
1512 stream_putc(s
, RIPNG_RESPONSE
);
1513 stream_putc(s
, RIPNG_V1
);
1517 /* Write routing table entry. */
1520 stream_write(s
, (uint8_t *)&p
->prefix
, sizeof(struct in6_addr
));
1522 stream_write(s
, (uint8_t *)nexthop
, sizeof(struct in6_addr
));
1523 stream_putw(s
, tag
);
1525 stream_putc(s
, p
->prefixlen
);
1528 stream_putc(s
, metric
);
1533 /* Send RESPONSE message to specified destination. */
1534 void ripng_output_process(struct interface
*ifp
, struct sockaddr_in6
*to
,
1538 struct route_node
*rp
;
1539 struct ripng_info
*rinfo
;
1540 struct ripng_interface
*ri
;
1541 struct ripng_aggregate
*aggregate
;
1542 struct prefix_ipv6
*p
;
1543 struct list
*ripng_rte_list
;
1544 struct list
*list
= NULL
;
1545 struct listnode
*listnode
= NULL
;
1547 if (IS_RIPNG_DEBUG_EVENT
) {
1549 zlog_debug("RIPng update routes to neighbor %s",
1550 inet6_ntoa(to
->sin6_addr
));
1552 zlog_debug("RIPng update routes on interface %s",
1556 /* Get RIPng interface. */
1559 ripng_rte_list
= ripng_rte_new();
1561 for (rp
= route_top(ripng
->table
); rp
; rp
= route_next(rp
)) {
1562 if ((list
= rp
->info
) != NULL
1563 && (rinfo
= listgetdata(listhead(list
))) != NULL
1564 && rinfo
->suppress
== 0) {
1565 /* If no route-map are applied, the RTE will be these
1569 p
= (struct prefix_ipv6
*)&rp
->p
;
1570 rinfo
->metric_out
= rinfo
->metric
;
1571 rinfo
->tag_out
= rinfo
->tag
;
1572 memset(&rinfo
->nexthop_out
, 0,
1573 sizeof(rinfo
->nexthop_out
));
1574 /* In order to avoid some local loops,
1575 * if the RIPng route has a nexthop via this interface,
1577 * otherwise set it to 0. The nexthop should not be
1579 * beyond the local broadcast/multicast area in order
1580 * to avoid an IGP multi-level recursive look-up.
1582 if (rinfo
->ifindex
== ifp
->ifindex
)
1583 rinfo
->nexthop_out
= rinfo
->nexthop
;
1585 /* Apply output filters. */
1586 ret
= ripng_filter(RIPNG_FILTER_OUT
, p
, ri
);
1590 /* Changed route only output. */
1591 if (route_type
== ripng_changed_route
1592 && (!(rinfo
->flags
& RIPNG_RTF_CHANGED
)))
1595 /* Split horizon. */
1596 if (ri
->split_horizon
== RIPNG_SPLIT_HORIZON
) {
1597 /* We perform split horizon for RIPng routes. */
1599 struct ripng_info
*tmp_rinfo
= NULL
;
1601 for (ALL_LIST_ELEMENTS_RO(list
, listnode
,
1603 if (tmp_rinfo
->type
== ZEBRA_ROUTE_RIPNG
1604 && tmp_rinfo
->ifindex
1613 /* Preparation for route-map. */
1614 rinfo
->metric_set
= 0;
1617 * and tag_out are already initialized.
1620 /* Interface route-map */
1621 if (ri
->routemap
[RIPNG_FILTER_OUT
]) {
1624 ret
= route_map_apply(
1625 ri
->routemap
[RIPNG_FILTER_OUT
],
1626 (struct prefix
*)p
, RMAP_RIPNG
, rinfo
);
1628 if (ret
== RMAP_DENYMATCH
) {
1629 if (IS_RIPNG_DEBUG_PACKET
)
1631 "RIPng %s/%d is filtered by route-map out",
1632 inet6_ntoa(p
->prefix
),
1638 /* Redistribute route-map. */
1639 if (ripng
->route_map
[rinfo
->type
].name
) {
1642 ret
= route_map_apply(
1643 ripng
->route_map
[rinfo
->type
].map
,
1644 (struct prefix
*)p
, RMAP_RIPNG
, rinfo
);
1646 if (ret
== RMAP_DENYMATCH
) {
1647 if (IS_RIPNG_DEBUG_PACKET
)
1649 "RIPng %s/%d is filtered by route-map",
1650 inet6_ntoa(p
->prefix
),
1656 /* When the route-map does not set metric. */
1657 if (!rinfo
->metric_set
) {
1658 /* If the redistribute metric is set. */
1659 if (ripng
->route_map
[rinfo
->type
].metric_config
1660 && rinfo
->metric
!= RIPNG_METRIC_INFINITY
) {
1662 ripng
->route_map
[rinfo
->type
]
1665 /* If the route is not connected or
1667 one, use default-metric value */
1668 if (rinfo
->type
!= ZEBRA_ROUTE_RIPNG
1670 != ZEBRA_ROUTE_CONNECT
1672 != RIPNG_METRIC_INFINITY
)
1674 ripng
->default_metric
;
1678 /* Apply offset-list */
1679 if (rinfo
->metric_out
!= RIPNG_METRIC_INFINITY
)
1680 ripng_offset_list_apply_out(p
, ifp
,
1681 &rinfo
->metric_out
);
1683 if (rinfo
->metric_out
> RIPNG_METRIC_INFINITY
)
1684 rinfo
->metric_out
= RIPNG_METRIC_INFINITY
;
1686 /* Perform split-horizon with poisoned reverse
1689 if (ri
->split_horizon
1690 == RIPNG_SPLIT_HORIZON_POISONED_REVERSE
) {
1691 struct ripng_info
*tmp_rinfo
= NULL
;
1693 for (ALL_LIST_ELEMENTS_RO(list
, listnode
,
1695 if ((tmp_rinfo
->type
1696 == ZEBRA_ROUTE_RIPNG
)
1697 && tmp_rinfo
->ifindex
1700 RIPNG_METRIC_INFINITY
;
1703 /* Add RTE to the list */
1704 ripng_rte_add(ripng_rte_list
, p
, rinfo
, NULL
);
1707 /* Process the aggregated RTE entry */
1708 if ((aggregate
= rp
->aggregate
) != NULL
&& aggregate
->count
> 0
1709 && aggregate
->suppress
== 0) {
1710 /* If no route-map are applied, the RTE will be these
1714 p
= (struct prefix_ipv6
*)&rp
->p
;
1715 aggregate
->metric_set
= 0;
1716 aggregate
->metric_out
= aggregate
->metric
;
1717 aggregate
->tag_out
= aggregate
->tag
;
1718 memset(&aggregate
->nexthop_out
, 0,
1719 sizeof(aggregate
->nexthop_out
));
1721 /* Apply output filters.*/
1722 ret
= ripng_filter(RIPNG_FILTER_OUT
, p
, ri
);
1726 /* Interface route-map */
1727 if (ri
->routemap
[RIPNG_FILTER_OUT
]) {
1729 struct ripng_info newinfo
;
1731 /* let's cast the aggregate structure to
1733 memset(&newinfo
, 0, sizeof(struct ripng_info
));
1734 /* the nexthop is :: */
1735 newinfo
.metric
= aggregate
->metric
;
1736 newinfo
.metric_out
= aggregate
->metric_out
;
1737 newinfo
.tag
= aggregate
->tag
;
1738 newinfo
.tag_out
= aggregate
->tag_out
;
1740 ret
= route_map_apply(
1741 ri
->routemap
[RIPNG_FILTER_OUT
],
1742 (struct prefix
*)p
, RMAP_RIPNG
,
1745 if (ret
== RMAP_DENYMATCH
) {
1746 if (IS_RIPNG_DEBUG_PACKET
)
1748 "RIPng %s/%d is filtered by route-map out",
1749 inet6_ntoa(p
->prefix
),
1754 aggregate
->metric_out
= newinfo
.metric_out
;
1755 aggregate
->tag_out
= newinfo
.tag_out
;
1756 if (IN6_IS_ADDR_LINKLOCAL(&newinfo
.nexthop_out
))
1757 aggregate
->nexthop_out
=
1758 newinfo
.nexthop_out
;
1761 /* There is no redistribute routemap for the aggregated
1764 /* Changed route only output. */
1765 /* XXX, vincent, in order to increase time convergence,
1766 * it should be announced if a child has changed.
1768 if (route_type
== ripng_changed_route
)
1771 /* Apply offset-list */
1772 if (aggregate
->metric_out
!= RIPNG_METRIC_INFINITY
)
1773 ripng_offset_list_apply_out(
1774 p
, ifp
, &aggregate
->metric_out
);
1776 if (aggregate
->metric_out
> RIPNG_METRIC_INFINITY
)
1777 aggregate
->metric_out
= RIPNG_METRIC_INFINITY
;
1779 /* Add RTE to the list */
1780 ripng_rte_add(ripng_rte_list
, p
, NULL
, aggregate
);
1784 /* Flush the list */
1785 ripng_rte_send(ripng_rte_list
, ifp
, to
);
1786 ripng_rte_free(ripng_rte_list
);
1789 /* Create new RIPng instance and set it to global variable. */
1790 static int ripng_create(void)
1792 /* ripng should be NULL. */
1793 assert(ripng
== NULL
);
1795 /* Allocaste RIPng instance. */
1796 ripng
= XCALLOC(MTYPE_RIPNG
, sizeof(struct ripng
));
1798 /* Default version and timer values. */
1799 ripng
->version
= RIPNG_V1
;
1800 ripng
->update_time
= RIPNG_UPDATE_TIMER_DEFAULT
;
1801 ripng
->timeout_time
= RIPNG_TIMEOUT_TIMER_DEFAULT
;
1802 ripng
->garbage_time
= RIPNG_GARBAGE_TIMER_DEFAULT
;
1803 ripng
->default_metric
= RIPNG_DEFAULT_METRIC_DEFAULT
;
1806 ripng
->ibuf
= stream_new(RIPNG_MAX_PACKET_SIZE
* 5);
1807 ripng
->obuf
= stream_new(RIPNG_MAX_PACKET_SIZE
);
1809 /* Initialize RIPng routig table. */
1810 ripng
->table
= route_table_init();
1811 ripng
->route
= route_table_init();
1812 ripng
->aggregate
= route_table_init();
1815 ripng
->sock
= ripng_make_socket();
1816 if (ripng
->sock
< 0)
1820 ripng_event(RIPNG_READ
, ripng
->sock
);
1821 ripng_event(RIPNG_UPDATE_EVENT
, 1);
1826 /* Send RIPng request to the interface. */
1827 int ripng_request(struct interface
*ifp
)
1830 struct ripng_packet ripng_packet
;
1832 /* In default ripd doesn't send RIP_REQUEST to the loopback interface.
1834 if (if_is_loopback(ifp
))
1837 /* If interface is down, don't send RIP packet. */
1841 if (IS_RIPNG_DEBUG_EVENT
)
1842 zlog_debug("RIPng send request to %s", ifp
->name
);
1844 memset(&ripng_packet
, 0, sizeof(ripng_packet
));
1845 ripng_packet
.command
= RIPNG_REQUEST
;
1846 ripng_packet
.version
= RIPNG_V1
;
1847 rte
= ripng_packet
.rte
;
1848 rte
->metric
= RIPNG_METRIC_INFINITY
;
1850 return ripng_send_packet((caddr_t
)&ripng_packet
, sizeof(ripng_packet
),
1855 static int ripng_update_jitter(int time
)
1857 return ((random() % (time
+ 1)) - (time
/ 2));
1860 void ripng_event(enum ripng_event event
, int sock
)
1866 thread_add_read(master
, ripng_read
, NULL
, sock
, &ripng
->t_read
);
1868 case RIPNG_UPDATE_EVENT
:
1869 if (ripng
->t_update
) {
1870 thread_cancel(ripng
->t_update
);
1871 ripng
->t_update
= NULL
;
1873 /* Update timer jitter. */
1874 jitter
= ripng_update_jitter(ripng
->update_time
);
1876 ripng
->t_update
= NULL
;
1877 thread_add_timer(master
, ripng_update
, NULL
,
1878 sock
? 2 : ripng
->update_time
+ jitter
,
1881 case RIPNG_TRIGGERED_UPDATE
:
1882 if (ripng
->t_triggered_interval
)
1885 thread_add_event(master
, ripng_triggered_update
, NULL
,
1886 0, &ripng
->t_triggered_update
);
1894 /* Print out routes update time. */
1895 static void ripng_vty_out_uptime(struct vty
*vty
, struct ripng_info
*rinfo
)
1900 char timebuf
[TIME_BUF
];
1901 struct thread
*thread
;
1903 if ((thread
= rinfo
->t_timeout
) != NULL
) {
1904 clock
= thread_timer_remain_second(thread
);
1905 tm
= gmtime(&clock
);
1906 strftime(timebuf
, TIME_BUF
, "%M:%S", tm
);
1907 vty_out(vty
, "%5s", timebuf
);
1908 } else if ((thread
= rinfo
->t_garbage_collect
) != NULL
) {
1909 clock
= thread_timer_remain_second(thread
);
1910 tm
= gmtime(&clock
);
1911 strftime(timebuf
, TIME_BUF
, "%M:%S", tm
);
1912 vty_out(vty
, "%5s", timebuf
);
1916 static char *ripng_route_subtype_print(struct ripng_info
*rinfo
)
1921 if (rinfo
->suppress
)
1924 switch (rinfo
->sub_type
) {
1925 case RIPNG_ROUTE_RTE
:
1928 case RIPNG_ROUTE_STATIC
:
1931 case RIPNG_ROUTE_DEFAULT
:
1934 case RIPNG_ROUTE_REDISTRIBUTE
:
1937 case RIPNG_ROUTE_INTERFACE
:
1948 DEFUN (show_ipv6_ripng
,
1949 show_ipv6_ripng_cmd
,
1953 "Show RIPng routes\n")
1955 struct route_node
*rp
;
1956 struct ripng_info
*rinfo
;
1957 struct ripng_aggregate
*aggregate
;
1958 struct prefix_ipv6
*p
;
1959 struct list
*list
= NULL
;
1960 struct listnode
*listnode
= NULL
;
1966 /* Header of display. */
1968 "Codes: R - RIPng, C - connected, S - Static, O - OSPF, B - BGP\n"
1970 " (n) - normal, (s) - static, (d) - default, (r) - redistribute,\n"
1971 " (i) - interface, (a/S) - aggregated/Suppressed\n\n"
1972 " Network Next Hop Via Metric Tag Time\n");
1974 for (rp
= route_top(ripng
->table
); rp
; rp
= route_next(rp
)) {
1975 if ((aggregate
= rp
->aggregate
) != NULL
) {
1976 p
= (struct prefix_ipv6
*)&rp
->p
;
1979 vty_out(vty
, "R(a) %d/%d %s/%d ", aggregate
->count
,
1980 aggregate
->suppress
, inet6_ntoa(p
->prefix
),
1983 vty_out(vty
, "R(a) %s/%d ", inet6_ntoa(p
->prefix
),
1987 vty_out(vty
, "%*s", 18, " ");
1989 vty_out(vty
, "%*s", 28, " ");
1990 vty_out(vty
, "self %2d %3" ROUTE_TAG_PRI
"\n",
1991 aggregate
->metric
, (route_tag_t
)aggregate
->tag
);
1994 if ((list
= rp
->info
) != NULL
)
1995 for (ALL_LIST_ELEMENTS_RO(list
, listnode
, rinfo
)) {
1996 p
= (struct prefix_ipv6
*)&rp
->p
;
1999 vty_out(vty
, "%c(%s) 0/%d %s/%d ",
2000 zebra_route_char(rinfo
->type
),
2001 ripng_route_subtype_print(rinfo
),
2002 rinfo
->suppress
, inet6_ntoa(p
->prefix
),
2005 vty_out(vty
, "%c(%s) %s/%d ",
2006 zebra_route_char(rinfo
->type
),
2007 ripng_route_subtype_print(rinfo
),
2008 inet6_ntoa(p
->prefix
), p
->prefixlen
);
2011 vty_out(vty
, "%*s", 18, " ");
2012 len
= vty_out(vty
, "%s",
2013 inet6_ntoa(rinfo
->nexthop
));
2017 vty_out(vty
, "%*s", len
, " ");
2020 if ((rinfo
->type
== ZEBRA_ROUTE_RIPNG
)
2021 && (rinfo
->sub_type
== RIPNG_ROUTE_RTE
)) {
2024 ifindex2ifname(rinfo
->ifindex
,
2026 } else if (rinfo
->metric
2027 == RIPNG_METRIC_INFINITY
) {
2028 len
= vty_out(vty
, "kill");
2030 len
= vty_out(vty
, "self");
2034 vty_out(vty
, "%*s", len
, " ");
2036 vty_out(vty
, " %2d %3" ROUTE_TAG_PRI
" ",
2037 rinfo
->metric
, (route_tag_t
)rinfo
->tag
);
2040 if ((rinfo
->type
== ZEBRA_ROUTE_RIPNG
)
2041 && (rinfo
->sub_type
== RIPNG_ROUTE_RTE
)) {
2042 /* RTE from remote RIP routers */
2043 ripng_vty_out_uptime(vty
, rinfo
);
2044 } else if (rinfo
->metric
2045 == RIPNG_METRIC_INFINITY
) {
2046 /* poisonous reversed routes (gc) */
2047 ripng_vty_out_uptime(vty
, rinfo
);
2057 DEFUN (show_ipv6_ripng_status
,
2058 show_ipv6_ripng_status_cmd
,
2059 "show ipv6 ripng status",
2062 "Show RIPng routes\n"
2063 "IPv6 routing protocol process parameters and statistics\n")
2065 struct vrf
*vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
2066 struct interface
*ifp
;
2071 vty_out(vty
, "Routing Protocol is \"RIPng\"\n");
2072 vty_out(vty
, " Sending updates every %ld seconds with +/-50%%,",
2073 ripng
->update_time
);
2074 vty_out(vty
, " next due in %lu seconds\n",
2075 thread_timer_remain_second(ripng
->t_update
));
2076 vty_out(vty
, " Timeout after %ld seconds,", ripng
->timeout_time
);
2077 vty_out(vty
, " garbage collect after %ld seconds\n",
2078 ripng
->garbage_time
);
2080 /* Filtering status show. */
2081 config_show_distribute(vty
);
2083 /* Default metric information. */
2084 vty_out(vty
, " Default redistribution metric is %d\n",
2085 ripng
->default_metric
);
2087 /* Redistribute information. */
2088 vty_out(vty
, " Redistributing:");
2089 ripng_redistribute_write(vty
, 0);
2092 vty_out(vty
, " Default version control: send version %d,",
2094 vty_out(vty
, " receive version %d \n", ripng
->version
);
2096 vty_out(vty
, " Interface Send Recv\n");
2098 FOR_ALL_INTERFACES (vrf
, ifp
) {
2099 struct ripng_interface
*ri
;
2103 if (ri
->enable_network
|| ri
->enable_interface
) {
2105 vty_out(vty
, " %-17s%-3d %-3d\n", ifp
->name
,
2106 ripng
->version
, ripng
->version
);
2110 vty_out(vty
, " Routing for Networks:\n");
2111 ripng_network_write(vty
, 0);
2113 vty_out(vty
, " Routing Information Sources:\n");
2115 " Gateway BadPackets BadRoutes Distance Last Update\n");
2116 ripng_peer_display(vty
);
2121 DEFUN (clear_ipv6_rip
,
2126 "Clear IPv6 RIP database\n")
2128 struct route_node
*rp
;
2129 struct ripng_info
*rinfo
;
2131 struct listnode
*listnode
;
2133 /* Clear received RIPng routes */
2134 for (rp
= route_top(ripng
->table
); rp
; rp
= route_next(rp
)) {
2139 for (ALL_LIST_ELEMENTS_RO(list
, listnode
, rinfo
)) {
2140 if (!ripng_route_rte(rinfo
))
2143 if (CHECK_FLAG(rinfo
->flags
, RIPNG_RTF_FIB
))
2144 ripng_zebra_ipv6_delete(rp
);
2149 RIPNG_TIMER_OFF(rinfo
->t_timeout
);
2150 RIPNG_TIMER_OFF(rinfo
->t_garbage_collect
);
2151 listnode_delete(list
, rinfo
);
2152 ripng_info_free(rinfo
);
2155 if (list_isempty(list
)) {
2156 list_delete_and_null(&list
);
2158 route_unlock_node(rp
);
2165 DEFUN_NOSH (router_ripng
,
2168 "Enable a routing process\n"
2169 "Make RIPng instance command\n")
2173 vty
->node
= RIPNG_NODE
;
2176 ret
= ripng_create();
2178 /* Notice to user we couldn't create RIPng. */
2180 zlog_warn("can't create RIPng");
2181 return CMD_WARNING_CONFIG_FAILED
;
2188 DEFUN (no_router_ripng
,
2189 no_router_ripng_cmd
,
2192 "Enable a routing process\n"
2193 "Make RIPng instance command\n")
2203 "Static route setup\n"
2204 "Set static RIPng route announcement\n")
2206 int idx_ipv6addr
= 1;
2208 struct prefix_ipv6 p
;
2209 struct route_node
*rp
;
2211 ret
= str2prefix_ipv6(argv
[idx_ipv6addr
]->arg
,
2212 (struct prefix_ipv6
*)&p
);
2214 vty_out(vty
, "Malformed address\n");
2215 return CMD_WARNING_CONFIG_FAILED
;
2217 apply_mask_ipv6(&p
);
2219 rp
= route_node_get(ripng
->route
, (struct prefix
*)&p
);
2221 vty_out(vty
, "There is already same static route.\n");
2222 route_unlock_node(rp
);
2225 rp
->info
= (void *)1;
2227 ripng_redistribute_add(ZEBRA_ROUTE_RIPNG
, RIPNG_ROUTE_STATIC
, &p
, 0,
2233 DEFUN (no_ripng_route
,
2235 "no route IPV6ADDR",
2237 "Static route setup\n"
2238 "Delete static RIPng route announcement\n")
2240 int idx_ipv6addr
= 2;
2242 struct prefix_ipv6 p
;
2243 struct route_node
*rp
;
2245 ret
= str2prefix_ipv6(argv
[idx_ipv6addr
]->arg
,
2246 (struct prefix_ipv6
*)&p
);
2248 vty_out(vty
, "Malformed address\n");
2249 return CMD_WARNING_CONFIG_FAILED
;
2251 apply_mask_ipv6(&p
);
2253 rp
= route_node_lookup(ripng
->route
, (struct prefix
*)&p
);
2255 vty_out(vty
, "Can't find static route.\n");
2256 return CMD_WARNING_CONFIG_FAILED
;
2259 ripng_redistribute_delete(ZEBRA_ROUTE_RIPNG
, RIPNG_ROUTE_STATIC
, &p
, 0);
2260 route_unlock_node(rp
);
2263 route_unlock_node(rp
);
2268 DEFUN (ripng_aggregate_address
,
2269 ripng_aggregate_address_cmd
,
2270 "aggregate-address X:X::X:X/M",
2271 "Set aggregate RIPng route announcement\n"
2272 "Aggregate network\n")
2274 int idx_ipv6_prefixlen
= 1;
2277 struct route_node
*node
;
2279 ret
= str2prefix_ipv6(argv
[idx_ipv6_prefixlen
]->arg
,
2280 (struct prefix_ipv6
*)&p
);
2282 vty_out(vty
, "Malformed address\n");
2283 return CMD_WARNING_CONFIG_FAILED
;
2286 /* Check aggregate alredy exist or not. */
2287 node
= route_node_get(ripng
->aggregate
, &p
);
2289 vty_out(vty
, "There is already same aggregate route.\n");
2290 route_unlock_node(node
);
2293 node
->info
= (void *)1;
2295 ripng_aggregate_add(&p
);
2300 DEFUN (no_ripng_aggregate_address
,
2301 no_ripng_aggregate_address_cmd
,
2302 "no aggregate-address X:X::X:X/M",
2304 "Delete aggregate RIPng route announcement\n"
2305 "Aggregate network\n")
2307 int idx_ipv6_prefixlen
= 2;
2310 struct route_node
*rn
;
2312 ret
= str2prefix_ipv6(argv
[idx_ipv6_prefixlen
]->arg
,
2313 (struct prefix_ipv6
*)&p
);
2315 vty_out(vty
, "Malformed address\n");
2316 return CMD_WARNING_CONFIG_FAILED
;
2319 rn
= route_node_lookup(ripng
->aggregate
, &p
);
2321 vty_out(vty
, "Can't find aggregate route.\n");
2322 return CMD_WARNING_CONFIG_FAILED
;
2324 route_unlock_node(rn
);
2326 route_unlock_node(rn
);
2328 ripng_aggregate_delete(&p
);
2333 DEFUN (ripng_default_metric
,
2334 ripng_default_metric_cmd
,
2335 "default-metric (1-16)",
2336 "Set a metric of redistribute routes\n"
2341 ripng
->default_metric
= atoi(argv
[idx_number
]->arg
);
2346 DEFUN (no_ripng_default_metric
,
2347 no_ripng_default_metric_cmd
,
2348 "no default-metric [(1-16)]",
2350 "Set a metric of redistribute routes\n"
2354 ripng
->default_metric
= RIPNG_DEFAULT_METRIC_DEFAULT
;
2361 /* RIPng update timer setup. */
2362 DEFUN (ripng_update_timer
,
2363 ripng_update_timer_cmd
,
2364 "update-timer SECOND",
2365 "Set RIPng update timer in seconds\n"
2368 unsigned long update
;
2369 char *endptr
= NULL
;
2371 update
= strtoul (argv
[0], &endptr
, 10);
2372 if (update
== ULONG_MAX
|| *endptr
!= '\0')
2374 vty_out (vty
, "update timer value error\n");
2375 return CMD_WARNING_CONFIG_FAILED
;
2378 ripng
->update_time
= update
;
2380 ripng_event (RIPNG_UPDATE_EVENT
, 0);
2384 DEFUN (no_ripng_update_timer
,
2385 no_ripng_update_timer_cmd
,
2386 "no update-timer SECOND",
2388 "Unset RIPng update timer in seconds\n"
2391 ripng
->update_time
= RIPNG_UPDATE_TIMER_DEFAULT
;
2392 ripng_event (RIPNG_UPDATE_EVENT
, 0);
2396 /* RIPng timeout timer setup. */
2397 DEFUN (ripng_timeout_timer
,
2398 ripng_timeout_timer_cmd
,
2399 "timeout-timer SECOND",
2400 "Set RIPng timeout timer in seconds\n"
2403 unsigned long timeout
;
2404 char *endptr
= NULL
;
2406 timeout
= strtoul (argv
[0], &endptr
, 10);
2407 if (timeout
== ULONG_MAX
|| *endptr
!= '\0')
2409 vty_out (vty
, "timeout timer value error\n");
2410 return CMD_WARNING_CONFIG_FAILED
;
2413 ripng
->timeout_time
= timeout
;
2418 DEFUN (no_ripng_timeout_timer
,
2419 no_ripng_timeout_timer_cmd
,
2420 "no timeout-timer SECOND",
2422 "Unset RIPng timeout timer in seconds\n"
2425 ripng
->timeout_time
= RIPNG_TIMEOUT_TIMER_DEFAULT
;
2429 /* RIPng garbage timer setup. */
2430 DEFUN (ripng_garbage_timer
,
2431 ripng_garbage_timer_cmd
,
2432 "garbage-timer SECOND",
2433 "Set RIPng garbage timer in seconds\n"
2436 unsigned long garbage
;
2437 char *endptr
= NULL
;
2439 garbage
= strtoul (argv
[0], &endptr
, 10);
2440 if (garbage
== ULONG_MAX
|| *endptr
!= '\0')
2442 vty_out (vty
, "garbage timer value error\n");
2443 return CMD_WARNING_CONFIG_FAILED
;
2446 ripng
->garbage_time
= garbage
;
2451 DEFUN (no_ripng_garbage_timer
,
2452 no_ripng_garbage_timer_cmd
,
2453 "no garbage-timer SECOND",
2455 "Unset RIPng garbage timer in seconds\n"
2458 ripng
->garbage_time
= RIPNG_GARBAGE_TIMER_DEFAULT
;
2463 DEFUN (ripng_timers
,
2465 "timers basic (0-65535) (0-65535) (0-65535)",
2466 "RIPng timers setup\n"
2468 "Routing table update timer value in second. Default is 30.\n"
2469 "Routing information timeout timer. Default is 180.\n"
2470 "Garbage collection timer. Default is 120.\n")
2473 int idx_number_2
= 3;
2474 int idx_number_3
= 4;
2475 unsigned long update
;
2476 unsigned long timeout
;
2477 unsigned long garbage
;
2479 update
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2480 timeout
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
2481 garbage
= strtoul(argv
[idx_number_3
]->arg
, NULL
, 10);
2483 /* Set each timer value. */
2484 ripng
->update_time
= update
;
2485 ripng
->timeout_time
= timeout
;
2486 ripng
->garbage_time
= garbage
;
2488 /* Reset update timer thread. */
2489 ripng_event(RIPNG_UPDATE_EVENT
, 0);
2494 DEFUN (no_ripng_timers
,
2495 no_ripng_timers_cmd
,
2496 "no timers basic [(0-65535) (0-65535) (0-65535)]",
2498 "RIPng timers setup\n"
2500 "Routing table update timer value in second. Default is 30.\n"
2501 "Routing information timeout timer. Default is 180.\n"
2502 "Garbage collection timer. Default is 120.\n")
2504 /* Set each timer value to the default. */
2505 ripng
->update_time
= RIPNG_UPDATE_TIMER_DEFAULT
;
2506 ripng
->timeout_time
= RIPNG_TIMEOUT_TIMER_DEFAULT
;
2507 ripng
->garbage_time
= RIPNG_GARBAGE_TIMER_DEFAULT
;
2509 /* Reset update timer thread. */
2510 ripng_event(RIPNG_UPDATE_EVENT
, 0);
2516 DEFUN (show_ipv6_protocols
,
2517 show_ipv6_protocols_cmd
,
2518 "show ipv6 protocols",
2521 "Routing protocol information\n")
2526 vty_out (vty
, "Routing Protocol is \"ripng\"\n");
2528 vty_out (vty
, "Sending updates every %ld seconds, next due in %d seconds\n",
2529 ripng
->update_time
, 0);
2531 vty_out (vty
, "Timerout after %ld seconds, garbage correct %ld\n",
2532 ripng
->timeout_time
,
2533 ripng
->garbage_time
);
2535 vty_out (vty
, "Outgoing update filter list for all interfaces is not set");
2536 vty_out (vty
, "Incoming update filter list for all interfaces is not set");
2542 /* Please be carefull to use this command. */
2543 DEFUN (ripng_default_information_originate
,
2544 ripng_default_information_originate_cmd
,
2545 "default-information originate",
2546 "Default route information\n"
2547 "Distribute default route\n")
2549 struct prefix_ipv6 p
;
2551 if (!ripng
->default_information
) {
2552 ripng
->default_information
= 1;
2554 str2prefix_ipv6("::/0", &p
);
2555 ripng_redistribute_add(ZEBRA_ROUTE_RIPNG
, RIPNG_ROUTE_DEFAULT
,
2562 DEFUN (no_ripng_default_information_originate
,
2563 no_ripng_default_information_originate_cmd
,
2564 "no default-information originate",
2566 "Default route information\n"
2567 "Distribute default route\n")
2569 struct prefix_ipv6 p
;
2571 if (ripng
->default_information
) {
2572 ripng
->default_information
= 0;
2574 str2prefix_ipv6("::/0", &p
);
2575 ripng_redistribute_delete(ZEBRA_ROUTE_RIPNG
,
2576 RIPNG_ROUTE_DEFAULT
, &p
, 0);
2582 /* Update ECMP routes to zebra when ECMP is disabled. */
2583 static void ripng_ecmp_disable(void)
2585 struct route_node
*rp
;
2586 struct ripng_info
*rinfo
, *tmp_rinfo
;
2588 struct listnode
*node
, *nextnode
;
2593 for (rp
= route_top(ripng
->table
); rp
; rp
= route_next(rp
))
2594 if ((list
= rp
->info
) != NULL
&& listcount(list
) > 1) {
2595 rinfo
= listgetdata(listhead(list
));
2596 if (!ripng_route_rte(rinfo
))
2599 /* Drop all other entries, except the first one. */
2600 for (ALL_LIST_ELEMENTS(list
, node
, nextnode
, tmp_rinfo
))
2601 if (tmp_rinfo
!= rinfo
) {
2602 RIPNG_TIMER_OFF(tmp_rinfo
->t_timeout
);
2604 tmp_rinfo
->t_garbage_collect
);
2605 list_delete_node(list
, node
);
2606 ripng_info_free(tmp_rinfo
);
2610 ripng_zebra_ipv6_add(rp
);
2612 /* Set the route change flag. */
2613 SET_FLAG(rinfo
->flags
, RIPNG_RTF_CHANGED
);
2615 /* Signal the output process to trigger an update. */
2616 ripng_event(RIPNG_TRIGGERED_UPDATE
, 0);
2620 DEFUN (ripng_allow_ecmp
,
2621 ripng_allow_ecmp_cmd
,
2623 "Allow Equal Cost MultiPath\n")
2626 vty_out(vty
, "ECMP is already enabled.\n");
2631 zlog_info("ECMP is enabled.");
2635 DEFUN (no_ripng_allow_ecmp
,
2636 no_ripng_allow_ecmp_cmd
,
2639 "Allow Equal Cost MultiPath\n")
2642 vty_out(vty
, "ECMP is already disabled.\n");
2647 zlog_info("ECMP is disabled.");
2648 ripng_ecmp_disable();
2652 /* RIPng configuration write function. */
2653 static int ripng_config_write(struct vty
*vty
)
2655 int ripng_network_write(struct vty
*, int);
2656 void ripng_redistribute_write(struct vty
*, int);
2658 struct route_node
*rp
;
2663 vty_out(vty
, "router ripng\n");
2665 if (ripng
->default_information
)
2666 vty_out(vty
, " default-information originate\n");
2668 ripng_network_write(vty
, 1);
2670 /* RIPng default metric configuration */
2671 if (ripng
->default_metric
!= RIPNG_DEFAULT_METRIC_DEFAULT
)
2672 vty_out(vty
, " default-metric %d\n",
2673 ripng
->default_metric
);
2675 ripng_redistribute_write(vty
, 1);
2677 /* RIP offset-list configuration. */
2678 config_write_ripng_offset_list(vty
);
2680 /* RIPng aggregate routes. */
2681 for (rp
= route_top(ripng
->aggregate
); rp
; rp
= route_next(rp
))
2682 if (rp
->info
!= NULL
)
2683 vty_out(vty
, " aggregate-address %s/%d\n",
2684 inet6_ntoa(rp
->p
.u
.prefix6
),
2687 /* ECMP configuration. */
2689 vty_out(vty
, " allow-ecmp\n");
2691 /* RIPng static routes. */
2692 for (rp
= route_top(ripng
->route
); rp
; rp
= route_next(rp
))
2693 if (rp
->info
!= NULL
)
2694 vty_out(vty
, " route %s/%d\n",
2695 inet6_ntoa(rp
->p
.u
.prefix6
),
2698 /* RIPng timers configuration. */
2699 if (ripng
->update_time
!= RIPNG_UPDATE_TIMER_DEFAULT
2700 || ripng
->timeout_time
!= RIPNG_TIMEOUT_TIMER_DEFAULT
2701 || ripng
->garbage_time
!= RIPNG_GARBAGE_TIMER_DEFAULT
) {
2702 vty_out(vty
, " timers basic %ld %ld %ld\n",
2703 ripng
->update_time
, ripng
->timeout_time
,
2704 ripng
->garbage_time
);
2707 if (ripng
->update_time
!= RIPNG_UPDATE_TIMER_DEFAULT
)
2708 vty_out (vty
, " update-timer %d\n", ripng
->update_time
);
2709 if (ripng
->timeout_time
!= RIPNG_TIMEOUT_TIMER_DEFAULT
)
2710 vty_out (vty
, " timeout-timer %d\n", ripng
->timeout_time
);
2711 if (ripng
->garbage_time
!= RIPNG_GARBAGE_TIMER_DEFAULT
)
2712 vty_out (vty
, " garbage-timer %d\n", ripng
->garbage_time
);
2715 write
+= config_write_distribute(vty
);
2717 write
+= config_write_if_rmap(vty
);
2724 /* RIPng node structure. */
2725 static struct cmd_node cmd_ripng_node
= {
2726 RIPNG_NODE
, "%s(config-router)# ", 1,
2729 static void ripng_distribute_update(struct distribute
*dist
)
2731 struct interface
*ifp
;
2732 struct ripng_interface
*ri
;
2733 struct access_list
*alist
;
2734 struct prefix_list
*plist
;
2739 ifp
= if_lookup_by_name(dist
->ifname
, VRF_DEFAULT
);
2745 if (dist
->list
[DISTRIBUTE_V6_IN
]) {
2746 alist
= access_list_lookup(AFI_IP6
,
2747 dist
->list
[DISTRIBUTE_V6_IN
]);
2749 ri
->list
[RIPNG_FILTER_IN
] = alist
;
2751 ri
->list
[RIPNG_FILTER_IN
] = NULL
;
2753 ri
->list
[RIPNG_FILTER_IN
] = NULL
;
2755 if (dist
->list
[DISTRIBUTE_V6_OUT
]) {
2756 alist
= access_list_lookup(AFI_IP6
,
2757 dist
->list
[DISTRIBUTE_V6_OUT
]);
2759 ri
->list
[RIPNG_FILTER_OUT
] = alist
;
2761 ri
->list
[RIPNG_FILTER_OUT
] = NULL
;
2763 ri
->list
[RIPNG_FILTER_OUT
] = NULL
;
2765 if (dist
->prefix
[DISTRIBUTE_V6_IN
]) {
2766 plist
= prefix_list_lookup(AFI_IP6
,
2767 dist
->prefix
[DISTRIBUTE_V6_IN
]);
2769 ri
->prefix
[RIPNG_FILTER_IN
] = plist
;
2771 ri
->prefix
[RIPNG_FILTER_IN
] = NULL
;
2773 ri
->prefix
[RIPNG_FILTER_IN
] = NULL
;
2775 if (dist
->prefix
[DISTRIBUTE_V6_OUT
]) {
2776 plist
= prefix_list_lookup(AFI_IP6
,
2777 dist
->prefix
[DISTRIBUTE_V6_OUT
]);
2779 ri
->prefix
[RIPNG_FILTER_OUT
] = plist
;
2781 ri
->prefix
[RIPNG_FILTER_OUT
] = NULL
;
2783 ri
->prefix
[RIPNG_FILTER_OUT
] = NULL
;
2786 void ripng_distribute_update_interface(struct interface
*ifp
)
2788 struct distribute
*dist
;
2790 dist
= distribute_lookup(ifp
->name
);
2792 ripng_distribute_update(dist
);
2795 /* Update all interface's distribute list. */
2796 static void ripng_distribute_update_all(struct prefix_list
*notused
)
2798 struct vrf
*vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
2799 struct interface
*ifp
;
2801 FOR_ALL_INTERFACES (vrf
, ifp
)
2802 ripng_distribute_update_interface(ifp
);
2805 static void ripng_distribute_update_all_wrapper(struct access_list
*notused
)
2807 ripng_distribute_update_all(NULL
);
2810 /* delete all the added ripng routes. */
2814 struct route_node
*rp
;
2815 struct ripng_info
*rinfo
;
2816 struct ripng_aggregate
*aggregate
;
2817 struct list
*list
= NULL
;
2818 struct listnode
*listnode
= NULL
;
2821 /* Clear RIPng routes */
2822 for (rp
= route_top(ripng
->table
); rp
; rp
= route_next(rp
)) {
2823 if ((list
= rp
->info
) != NULL
) {
2824 rinfo
= listgetdata(listhead(list
));
2825 if (ripng_route_rte(rinfo
))
2826 ripng_zebra_ipv6_delete(rp
);
2828 for (ALL_LIST_ELEMENTS_RO(list
, listnode
,
2830 RIPNG_TIMER_OFF(rinfo
->t_timeout
);
2832 rinfo
->t_garbage_collect
);
2833 ripng_info_free(rinfo
);
2835 list_delete_and_null(&list
);
2837 route_unlock_node(rp
);
2840 if ((aggregate
= rp
->aggregate
) != NULL
) {
2841 ripng_aggregate_free(aggregate
);
2842 rp
->aggregate
= NULL
;
2843 route_unlock_node(rp
);
2847 /* Cancel the RIPng timers */
2848 RIPNG_TIMER_OFF(ripng
->t_update
);
2849 RIPNG_TIMER_OFF(ripng
->t_triggered_update
);
2850 RIPNG_TIMER_OFF(ripng
->t_triggered_interval
);
2852 /* Cancel the read thread */
2853 if (ripng
->t_read
) {
2854 thread_cancel(ripng
->t_read
);
2855 ripng
->t_read
= NULL
;
2858 /* Close the RIPng socket */
2859 if (ripng
->sock
>= 0) {
2864 /* Static RIPng route configuration. */
2865 for (rp
= route_top(ripng
->route
); rp
; rp
= route_next(rp
))
2868 route_unlock_node(rp
);
2871 /* RIPng aggregated prefixes */
2872 for (rp
= route_top(ripng
->aggregate
); rp
; rp
= route_next(rp
))
2875 route_unlock_node(rp
);
2878 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++)
2879 if (ripng
->route_map
[i
].name
)
2880 free(ripng
->route_map
[i
].name
);
2882 XFREE(MTYPE_ROUTE_TABLE
, ripng
->table
);
2883 XFREE(MTYPE_ROUTE_TABLE
, ripng
->route
);
2884 XFREE(MTYPE_ROUTE_TABLE
, ripng
->aggregate
);
2886 stream_free(ripng
->ibuf
);
2887 stream_free(ripng
->obuf
);
2889 XFREE(MTYPE_RIPNG
, ripng
);
2893 ripng_clean_network();
2894 ripng_passive_interface_clean();
2895 ripng_offset_clean();
2896 ripng_interface_clean();
2897 ripng_redistribute_clean();
2900 /* Reset all values to the default settings. */
2903 /* Call ripd related reset functions. */
2904 ripng_debug_reset();
2905 ripng_route_map_reset();
2907 /* Call library reset functions. */
2909 access_list_reset();
2910 prefix_list_reset();
2912 distribute_list_reset();
2914 ripng_interface_reset();
2916 ripng_zclient_reset();
2919 static void ripng_if_rmap_update(struct if_rmap
*if_rmap
)
2921 struct interface
*ifp
;
2922 struct ripng_interface
*ri
;
2923 struct route_map
*rmap
;
2925 ifp
= if_lookup_by_name(if_rmap
->ifname
, VRF_DEFAULT
);
2931 if (if_rmap
->routemap
[IF_RMAP_IN
]) {
2932 rmap
= route_map_lookup_by_name(if_rmap
->routemap
[IF_RMAP_IN
]);
2934 ri
->routemap
[IF_RMAP_IN
] = rmap
;
2936 ri
->routemap
[IF_RMAP_IN
] = NULL
;
2938 ri
->routemap
[RIPNG_FILTER_IN
] = NULL
;
2940 if (if_rmap
->routemap
[IF_RMAP_OUT
]) {
2941 rmap
= route_map_lookup_by_name(if_rmap
->routemap
[IF_RMAP_OUT
]);
2943 ri
->routemap
[IF_RMAP_OUT
] = rmap
;
2945 ri
->routemap
[IF_RMAP_OUT
] = NULL
;
2947 ri
->routemap
[RIPNG_FILTER_OUT
] = NULL
;
2950 void ripng_if_rmap_update_interface(struct interface
*ifp
)
2952 struct if_rmap
*if_rmap
;
2954 if_rmap
= if_rmap_lookup(ifp
->name
);
2956 ripng_if_rmap_update(if_rmap
);
2959 static void ripng_routemap_update_redistribute(void)
2964 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
2965 if (ripng
->route_map
[i
].name
)
2966 ripng
->route_map
[i
].map
=
2967 route_map_lookup_by_name(
2968 ripng
->route_map
[i
].name
);
2973 static void ripng_routemap_update(const char *unused
)
2975 struct vrf
*vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
2976 struct interface
*ifp
;
2978 FOR_ALL_INTERFACES (vrf
, ifp
)
2979 ripng_if_rmap_update_interface(ifp
);
2981 ripng_routemap_update_redistribute();
2984 /* Initialize ripng structure and set commands. */
2987 /* Install RIPNG_NODE. */
2988 install_node(&cmd_ripng_node
, ripng_config_write
);
2990 /* Install ripng commands. */
2991 install_element(VIEW_NODE
, &show_ipv6_ripng_cmd
);
2992 install_element(VIEW_NODE
, &show_ipv6_ripng_status_cmd
);
2994 install_element(ENABLE_NODE
, &clear_ipv6_rip_cmd
);
2996 install_element(CONFIG_NODE
, &router_ripng_cmd
);
2997 install_element(CONFIG_NODE
, &no_router_ripng_cmd
);
2999 install_default(RIPNG_NODE
);
3000 install_element(RIPNG_NODE
, &ripng_route_cmd
);
3001 install_element(RIPNG_NODE
, &no_ripng_route_cmd
);
3002 install_element(RIPNG_NODE
, &ripng_aggregate_address_cmd
);
3003 install_element(RIPNG_NODE
, &no_ripng_aggregate_address_cmd
);
3005 install_element(RIPNG_NODE
, &ripng_default_metric_cmd
);
3006 install_element(RIPNG_NODE
, &no_ripng_default_metric_cmd
);
3008 install_element(RIPNG_NODE
, &ripng_timers_cmd
);
3009 install_element(RIPNG_NODE
, &no_ripng_timers_cmd
);
3011 install_element (VIEW_NODE
, &show_ipv6_protocols_cmd
);
3012 install_element (RIPNG_NODE
, &ripng_update_timer_cmd
);
3013 install_element (RIPNG_NODE
, &no_ripng_update_timer_cmd
);
3014 install_element (RIPNG_NODE
, &ripng_timeout_timer_cmd
);
3015 install_element (RIPNG_NODE
, &no_ripng_timeout_timer_cmd
);
3016 install_element (RIPNG_NODE
, &ripng_garbage_timer_cmd
);
3017 install_element (RIPNG_NODE
, &no_ripng_garbage_timer_cmd
);
3020 install_element(RIPNG_NODE
, &ripng_default_information_originate_cmd
);
3021 install_element(RIPNG_NODE
,
3022 &no_ripng_default_information_originate_cmd
);
3024 install_element(RIPNG_NODE
, &ripng_allow_ecmp_cmd
);
3025 install_element(RIPNG_NODE
, &no_ripng_allow_ecmp_cmd
);
3030 /* Access list install. */
3032 access_list_add_hook(ripng_distribute_update_all_wrapper
);
3033 access_list_delete_hook(ripng_distribute_update_all_wrapper
);
3035 /* Prefix list initialize.*/
3037 prefix_list_add_hook(ripng_distribute_update_all
);
3038 prefix_list_delete_hook(ripng_distribute_update_all
);
3040 /* Distribute list install. */
3041 distribute_list_init(RIPNG_NODE
);
3042 distribute_list_add_hook(ripng_distribute_update
);
3043 distribute_list_delete_hook(ripng_distribute_update
);
3045 /* Route-map for interface. */
3046 ripng_route_map_init();
3047 ripng_offset_init();
3049 route_map_add_hook(ripng_routemap_update
);
3050 route_map_delete_hook(ripng_routemap_update
);
3052 if_rmap_init(RIPNG_NODE
);
3053 if_rmap_hook_add(ripng_if_rmap_update
);
3054 if_rmap_hook_delete(ripng_if_rmap_update
);