sync with latest kame.

- remove obsolete non-advanced-api support.
- if a routing entry exists for aggregate prefix (-A), do not overwrite
  the routing entry (exit with error).
This commit is contained in:
itojun 2000-07-15 04:55:40 +00:00
parent 4b70eef93f
commit 06ee23e6b3
2 changed files with 25 additions and 45 deletions

View File

@ -1,9 +1,8 @@
# $NetBSD: Makefile,v 1.2 2000/02/25 06:22:05 itojun Exp $
# $NetBSD: Makefile,v 1.3 2000/07/15 04:55:40 itojun Exp $
PROG= route6d
MAN= route6d.8
CPPFLAGS+=-Dss_len=__ss_len -Dss_family=__ss_family -DADVAPI -DINET6 \
-DHAVE_GETIFADDRS
CPPFLAGS+=-Dss_len=__ss_len -Dss_family=__ss_family -DINET6 -DHAVE_GETIFADDRS
.include <bsd.prog.mk>

View File

@ -1,5 +1,5 @@
/* $NetBSD: route6d.c,v 1.14 2000/07/09 03:06:18 itojun Exp $ */
/* $KAME: route6d.c,v 1.30 2000/06/04 06:48:03 itojun Exp $ */
/* $NetBSD: route6d.c,v 1.15 2000/07/15 04:55:41 itojun Exp $ */
/* $KAME: route6d.c,v 1.32 2000/07/15 04:50:43 itojun Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -32,7 +32,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: route6d.c,v 1.14 2000/07/09 03:06:18 itojun Exp $");
__RCSID("$NetBSD: route6d.c,v 1.15 2000/07/15 04:55:41 itojun Exp $");
#endif
#include <stdio.h>
@ -58,9 +58,7 @@ __RCSID("$NetBSD: route6d.c,v 1.14 2000/07/09 03:06:18 itojun Exp $");
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <sys/sysctl.h>
#ifdef ADVAPI
#include <sys/uio.h>
#endif
#include <net/if.h>
#if defined(__FreeBSD__) && __FreeBSD__ >= 3
#include <net/if_var.h>
@ -517,10 +515,7 @@ ripalarm(sig)
void
init()
{
#ifdef ADVAPI
int i;
#endif
int int0, int255, error;
int i, int0, int255, error;
struct addrinfo hints, *res;
char port[10];
@ -552,7 +547,7 @@ init()
if (setsockopt(ripsock, IPPROTO_IPV6, IPV6_MULTICAST_LOOP,
&int0, sizeof(int0)) < 0)
fatal("rip IPV6_MULTICAST_LOOP");
#ifdef ADVAPI
i = 1;
#ifdef IPV6_RECVPKTINFO
if (setsockopt(ripsock, IPPROTO_IPV6, IPV6_RECVPKTINFO, &i,
@ -563,7 +558,6 @@ init()
sizeof(i)) < 0)
fatal("rip IPV6_PKTINFO");
#endif
#endif /*ADVAPI*/
memset(&hints, 0, sizeof(hints));
hints.ai_family = PF_INET6;
@ -832,7 +826,6 @@ sendpacket(sin, len)
* RIP6_REQUEST message. SO_DONTROUTE has been specified to
* other sockets.
*/
#ifdef ADVAPI
struct msghdr m;
struct cmsghdr *cm;
struct iovec iov[2];
@ -879,13 +872,7 @@ sendpacket(sin, len)
trace(1, "sendmsg: %s\n", strerror(errno));
return errno;
}
#else
if (sendto(ripsock, ripbuf, len, 0 /*MSG_DONTROUTE*/,
(struct sockaddr *)sin, sizeof(struct sockaddr_in6)) < 0) {
trace(1, "sendto: %s\n", strerror(errno));
return errno;
}
#endif
return 0;
}
@ -903,24 +890,19 @@ riprecv()
struct netinfo6 *np, *nq;
struct riprt *rrt;
int len, nn, need_trigger, index;
#ifndef ADVAPI
int flen;
#endif
char buf[4 * RIP6_MAXMTU];
time_t t;
#ifdef ADVAPI
struct msghdr m;
struct cmsghdr *cm;
struct iovec iov[2];
u_char cmsgbuf[256];
struct in6_pktinfo *pi;
#endif /*ADVAPI*/
struct iff *iffp;
struct in6_addr ia;
int ok;
need_trigger = 0;
#ifdef ADVAPI
m.msg_name = (caddr_t)&fsock;
m.msg_namelen = sizeof(fsock);
iov[0].iov_base = (caddr_t)buf;
@ -945,16 +927,6 @@ riprecv()
}
if (index && IN6_IS_ADDR_LINKLOCAL(&fsock.sin6_addr))
SET_IN6_LINKLOCAL_IFINDEX(fsock.sin6_addr, index);
#else
flen = sizeof(struct sockaddr_in6);
if ((len = recvfrom(ripsock, buf, sizeof(buf), 0,
(struct sockaddr *)&fsock, &flen)) < 0)
fatal("recvfrom");
if (IN6_IS_ADDR_LINKLOCAL(&fsock.sin6_addr))
index = IN6_LINKLOCAL_IFINDEX(fsock.sin6_addr);
else
index = 0;
#endif /*ADVAPI*/
nh = fsock.sin6_addr;
nn = (len - sizeof(struct rip6) + sizeof(struct netinfo6)) /
@ -2812,6 +2784,22 @@ ifonly:
rrt->rrt_rflags = RRTF_AGGREGATE;
rrt->rrt_t = 0;
rrt->rrt_index = loopifindex;
if (getroute(&rrt->rrt_info, &gw)) {
#if 0
/*
* When the address has already been registered in the
* kernel routing table, it should be removed
*/
delroute(&rrt->rrt_info, &gw);
#else
/* it is more safe behavior */
errno = EINVAL;
fatal("%s/%u already in routing table, "
"cannot aggregate",
inet6_n2p(&rrt->rrt_info.rip6_dest),
rrt->rrt_info.rip6_plen);
#endif
}
/* Put the route to the list */
rrt->rrt_next = riprt;
riprt = rrt;
@ -2821,13 +2809,6 @@ ifonly:
/* Add this route to the kernel */
if (nflag) /* do not modify kernel routing table */
continue;
if (getroute(&rrt->rrt_info, &gw)) {
/*
* When the address has already been registered in the
* kernel routing table, it should be removed
*/
delroute(&rrt->rrt_info, &gw);
}
addroute(rrt, &in6addr_loopback, loopifcp);
}
}