summaryrefslogtreecommitdiff
path: root/usr.sbin/rtadvd
diff options
context:
space:
mode:
authorJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2001-02-04 06:22:06 +0000
committerJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2001-02-04 06:22:06 +0000
commite13de9618a383db8e6cab9b59a0ba8d3b82e1b16 (patch)
tree95b8ae35bc7a09a2c91baeae7aea16aae18304ab /usr.sbin/rtadvd
parent47800ffd47d856d9ac396fafa16a5eb44608b84a (diff)
avoid infinite loop when -s is specified (select loop mistake).
make agetent() 32bit clean. KAME PR 127. disable -R (router renumbering receiver). sync with kame.
Diffstat (limited to 'usr.sbin/rtadvd')
-rw-r--r--usr.sbin/rtadvd/advcap.c10
-rw-r--r--usr.sbin/rtadvd/advcap.h6
-rw-r--r--usr.sbin/rtadvd/config.c74
-rw-r--r--usr.sbin/rtadvd/rtadvd.813
-rw-r--r--usr.sbin/rtadvd/rtadvd.c25
5 files changed, 71 insertions, 57 deletions
diff --git a/usr.sbin/rtadvd/advcap.c b/usr.sbin/rtadvd/advcap.c
index 0dd4a27b433..9e187fcc4b1 100644
--- a/usr.sbin/rtadvd/advcap.c
+++ b/usr.sbin/rtadvd/advcap.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: advcap.c,v 1.3 2000/05/23 11:23:22 itojun Exp $ */
-/* $KAME: advcap.c,v 1.4 2000/05/23 11:17:40 itojun Exp $ */
+/* $OpenBSD: advcap.c,v 1.4 2001/02/04 06:22:05 itojun Exp $ */
+/* $KAME: advcap.c,v 1.5 2001/02/01 09:12:08 jinmei Exp $ */
/*
* Copyright (c) 1983 The Regents of the University of California.
@@ -96,7 +96,7 @@ int getent __P((char *, char *, char *));
int tnchktc __P((void));
int tnamatch __P((char *));
static char *tskip __P((char *));
-int tgetnum __P((char *));
+long long tgetnum __P((char *));
int tgetflag __P((char *));
char *tgetstr __P((char *, char **));
static char *tdecode __P((char *, char **));
@@ -307,11 +307,11 @@ breakbreak:
* a # character. If the option is not found we return -1.
* Note that we handle octal numbers beginning with 0.
*/
-int
+long long
tgetnum(id)
char *id;
{
- register long int i;
+ register long long i;
register int base;
register char *bp = tbuf;
diff --git a/usr.sbin/rtadvd/advcap.h b/usr.sbin/rtadvd/advcap.h
index e69cdd6d77e..34c3fa17d85 100644
--- a/usr.sbin/rtadvd/advcap.h
+++ b/usr.sbin/rtadvd/advcap.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: advcap.h,v 1.3 2000/05/23 11:23:22 itojun Exp $ */
-/* $KAME: advcap.h,v 1.2 2000/05/16 13:34:13 itojun Exp $ */
+/* $OpenBSD: advcap.h,v 1.4 2001/02/04 06:22:05 itojun Exp $ */
+/* $KAME: advcap.h,v 1.3 2001/02/01 09:12:08 jinmei Exp $ */
/*
* Copyright (C) 1994,1995 by Andrey A. Chernov, Moscow, Russia.
@@ -38,7 +38,7 @@ __BEGIN_DECLS
extern int agetent __P((char *, const char *));
extern int agetflag __P((const char *));
-extern int agetnum __P((const char *));
+extern long long agetnum __P((const char *));
extern char *agetstr __P((const char *, char **));
__END_DECLS
diff --git a/usr.sbin/rtadvd/config.c b/usr.sbin/rtadvd/config.c
index 1ad74776141..bdeef70f368 100644
--- a/usr.sbin/rtadvd/config.c
+++ b/usr.sbin/rtadvd/config.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: config.c,v 1.10 2001/01/23 15:36:40 itojun Exp $ */
-/* $KAME: config.c,v 1.29 2001/01/23 14:13:08 jinmei Exp $ */
+/* $OpenBSD: config.c,v 1.11 2001/02/04 06:22:05 itojun Exp $ */
+/* $KAME: config.c,v 1.32 2001/02/01 09:12:08 jinmei Exp $ */
/*
* Copyright (C) 1998 WIDE Project.
@@ -85,6 +85,7 @@ getconfig(intface)
char tbuf[BUFSIZ];
struct rainfo *tmp;
long val;
+ long long val64;
char buf[BUFSIZ];
char *bp = buf;
char *addr;
@@ -216,20 +217,23 @@ getconfig(intface)
}
tmp->reachabletime = (u_int32_t)val;
- MAYHAVE(val, "retrans", DEF_ADVRETRANSTIMER);
- if (val < 0 || val > 0xffffffff) {
+ MAYHAVE(val64, "retrans", DEF_ADVRETRANSTIMER);
+ if (val64 < 0 || val64 > 0xffffffff) {
syslog(LOG_ERR,
"<%s> retrans time out of range", __FUNCTION__);
exit(1);
}
- tmp->retranstimer = (u_int32_t)val;
+ tmp->retranstimer = (u_int32_t)val64;
-#ifdef MIP6
- if (!mobileip6)
+#ifndef MIP6
+ if (agetstr("hapref", &bp) || agetstr("hatime", &bp)) {
+ syslog(LOG_ERR,
+ "<%s> mobile-ip6 configuration not supported",
+ __FUNCTION__);
+ exit(1);
+ }
#else
- if (1)
-#endif
- {
+ if (!mobileip6) {
if (agetstr("hapref", &bp) || agetstr("hatime", &bp)) {
syslog(LOG_ERR,
"<%s> mobile-ip6 configuration without "
@@ -237,9 +241,7 @@ getconfig(intface)
__FUNCTION__);
exit(1);
}
- }
-#ifdef MIP6
- else {
+ } else {
tmp->hapref = 0;
if ((val = agetnum("hapref")) >= 0)
tmp->hapref = (int16_t)val;
@@ -315,7 +317,7 @@ getconfig(intface)
{
MAYHAVE(val, entbuf,
(ND_OPT_PI_FLAG_ONLINK|ND_OPT_PI_FLAG_AUTO|
- ND_OPT_PI_FLAG_RTADDR));
+ ND_OPT_PI_FLAG_ROUTER));
} else
#endif
{
@@ -325,18 +327,18 @@ getconfig(intface)
pfx->onlinkflg = val & ND_OPT_PI_FLAG_ONLINK;
pfx->autoconfflg = val & ND_OPT_PI_FLAG_AUTO;
#ifdef MIP6
- pfx->routeraddr = val & ND_OPT_PI_FLAG_RTADDR;
+ pfx->routeraddr = val & ND_OPT_PI_FLAG_ROUTER;
#endif
makeentry(entbuf, i, "vltime", added);
- MAYHAVE(val, entbuf, DEF_ADVVALIDLIFETIME);
- if (val < 0 || val > 0xffffffff) {
+ MAYHAVE(val64, entbuf, DEF_ADVVALIDLIFETIME);
+ if (val64 < 0 || val64 > 0xffffffff) {
syslog(LOG_ERR,
"<%s> vltime out of range",
__FUNCTION__);
exit(1);
}
- pfx->validlifetime = (u_int32_t)val;
+ pfx->validlifetime = (u_int32_t)val64;
makeentry(entbuf, i, "vltimedecr", added);
if (agetflag(entbuf)) {
@@ -347,14 +349,14 @@ getconfig(intface)
}
makeentry(entbuf, i, "pltime", added);
- MAYHAVE(val, entbuf, DEF_ADVPREFERREDLIFETIME);
- if (val < 0 || val > 0xffffffff) {
+ MAYHAVE(val64, entbuf, DEF_ADVPREFERREDLIFETIME);
+ if (val64 < 0 || val64 > 0xffffffff) {
syslog(LOG_ERR,
"<%s> pltime out of range",
__FUNCTION__);
exit(1);
}
- pfx->preflifetime = (u_int32_t)val;
+ pfx->preflifetime = (u_int32_t)val64;
makeentry(entbuf, i, "pltimedecr", added);
if (agetflag(entbuf)) {
@@ -669,8 +671,8 @@ make_packet(struct rainfo *rainfo)
struct nd_opt_prefix_info *ndopt_pi;
struct nd_opt_mtu *ndopt_mtu;
#ifdef MIP6
- struct nd_opt_advint *ndopt_advint;
- struct nd_opt_hai *ndopt_hai;
+ struct nd_opt_advinterval *ndopt_advint;
+ struct nd_opt_homeagent_info *ndopt_hai;
#endif
struct prefix *pfx;
@@ -693,9 +695,9 @@ make_packet(struct rainfo *rainfo)
packlen += sizeof(struct nd_opt_mtu);
#ifdef MIP6
if (mobileip6 && rainfo->maxinterval)
- packlen += sizeof(struct nd_opt_advint);
+ packlen += sizeof(struct nd_opt_advinterval);
if (mobileip6 && rainfo->hatime)
- packlen += sizeof(struct nd_opt_hai);
+ packlen += sizeof(struct nd_opt_homeagent_info);
#endif
/* allocate memory for the packet */
@@ -747,25 +749,25 @@ make_packet(struct rainfo *rainfo)
#ifdef MIP6
if (mobileip6 && rainfo->maxinterval) {
- ndopt_advint = (struct nd_opt_advint *)buf;
- ndopt_advint->nd_opt_int_type = ND_OPT_ADV_INTERVAL;
- ndopt_advint->nd_opt_int_len = 1;
- ndopt_advint->nd_opt_int_reserved = 0;
- ndopt_advint->nd_opt_int_interval = ntohl(rainfo->maxinterval *
+ ndopt_advint = (struct nd_opt_advinterval *)buf;
+ ndopt_advint->nd_opt_adv_type = ND_OPT_ADVINTERVAL;
+ ndopt_advint->nd_opt_adv_len = 1;
+ ndopt_advint->nd_opt_adv_reserved = 0;
+ ndopt_advint->nd_opt_adv_interval = ntohl(rainfo->maxinterval *
1000);
- buf += sizeof(struct nd_opt_advint);
+ buf += sizeof(struct nd_opt_advinterval);
}
#endif
#ifdef MIP6
if (rainfo->hatime) {
- ndopt_hai = (struct nd_opt_hai *)buf;
- ndopt_hai->nd_opt_hai_type = ND_OPT_HA_INFORMATION;
+ ndopt_hai = (struct nd_opt_homeagent_info *)buf;
+ ndopt_hai->nd_opt_hai_type = ND_OPT_HOMEAGENT_INFO;
ndopt_hai->nd_opt_hai_len = 1;
ndopt_hai->nd_opt_hai_reserved = 0;
- ndopt_hai->nd_opt_hai_pref = ntohs(rainfo->hapref);
+ ndopt_hai->nd_opt_hai_preference = ntohs(rainfo->hapref);
ndopt_hai->nd_opt_hai_lifetime = ntohs(rainfo->hatime);
- buf += sizeof(struct nd_opt_hai);
+ buf += sizeof(struct nd_opt_homeagent_info);
}
#endif
@@ -788,7 +790,7 @@ make_packet(struct rainfo *rainfo)
#ifdef MIP6
if (pfx->routeraddr)
ndopt_pi->nd_opt_pi_flags_reserved |=
- ND_OPT_PI_FLAG_RTADDR;
+ ND_OPT_PI_FLAG_ROUTER;
#endif
if (pfx->vltimeexpire || pfx->pltimeexpire)
gettimeofday(&now, NULL);
diff --git a/usr.sbin/rtadvd/rtadvd.8 b/usr.sbin/rtadvd/rtadvd.8
index 58e40c21f06..c5a9fd39f97 100644
--- a/usr.sbin/rtadvd/rtadvd.8
+++ b/usr.sbin/rtadvd/rtadvd.8
@@ -1,5 +1,5 @@
-.\" $OpenBSD: rtadvd.8,v 1.13 2001/01/15 11:06:28 itojun Exp $
-.\" $KAME: rtadvd.8,v 1.15 2000/12/22 08:54:29 jinmei Exp $
+.\" $OpenBSD: rtadvd.8,v 1.14 2001/02/04 06:22:05 itojun Exp $
+.\" $KAME: rtadvd.8,v 1.17 2001/02/04 05:34:38 jinmei Exp $
.\"
.\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
.\" All rights reserved.
@@ -110,7 +110,7 @@ tries to join the first advertising interface appeared in the command
line.
This option has meaning only with the
.Fl R
-option, which enables auto routing renumbering.
+option, which enables routing renumbering protocol support.
.\".It Fl m
.\"Enables mobile IPv6 support.
.\"This changes the content of router advertisement option, as well as
@@ -118,6 +118,12 @@ option, which enables auto routing renumbering.
.It Fl R
Accept router renumbering requests.
If you enable it, certain IPsec setup is suggested for security reasons.
+.\"On KAME-based systems,
+.\".Xr rrenumd 8
+.\"generates router renumbering request packets.
+This option is currently disabled, and is ignored by
+.Nm
+with a warning message.
.It Fl s
Do not add or delete prefixes dynamically.
Only statically configured prefixes, if any, will be advertised.
@@ -156,7 +162,6 @@ in which
dumps its internal state.
.El
.Sh SEE ALSO
-.Xr daemon 3 ,
.Xr rtadvd.conf 5 ,
.Xr rtsol 8
.Sh HISTORY
diff --git a/usr.sbin/rtadvd/rtadvd.c b/usr.sbin/rtadvd/rtadvd.c
index a67aae688b3..ad7288301b2 100644
--- a/usr.sbin/rtadvd/rtadvd.c
+++ b/usr.sbin/rtadvd/rtadvd.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: rtadvd.c,v 1.8 2001/01/15 11:06:28 itojun Exp $ */
-/* $KAME: rtadvd.c,v 1.47 2001/01/15 05:50:25 itojun Exp $ */
+/* $OpenBSD: rtadvd.c,v 1.9 2001/02/04 06:22:05 itojun Exp $ */
+/* $KAME: rtadvd.c,v 1.50 2001/02/04 06:15:15 itojun Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -79,7 +79,8 @@ struct in6_addr in6a_site_allrouters;
static char *dumpfilename = "/var/run/rtadvd.dump"; /* XXX: should be configurable */
static char *pidfilename = "/var/run/rtadvd.pid"; /* should be configurable */
static char *mcastif;
-int sock, rtsock;
+int sock;
+int rtsock = -1;
#ifdef MIP6
int mobileip6 = 0;
#endif
@@ -189,7 +190,10 @@ main(argc, argv)
break;
#endif
case 'R':
- accept_rr = 1;
+ fprintf(stderr, "rtadvd: "
+ "the -R option is currently ignored.\n");
+ /* accept_rr = 1; */
+ /* run anyway... */
break;
case 's':
sflag = 1;
@@ -250,10 +254,13 @@ main(argc, argv)
FD_ZERO(&fdset);
FD_SET(sock, &fdset);
maxfd = sock;
- rtsock_open();
- FD_SET(rtsock, &fdset);
- if (rtsock > sock)
- maxfd = rtsock;
+ if (sflag == 0) {
+ rtsock_open();
+ FD_SET(rtsock, &fdset);
+ if (rtsock > sock)
+ maxfd = rtsock;
+ } else
+ rtsock = -1;
signal(SIGTERM, (void *)set_die);
signal(SIGUSR1, (void *)rtadvd_set_dump_file);
@@ -297,7 +304,7 @@ main(argc, argv)
}
if (i == 0) /* timeout */
continue;
- if (sflag == 0 && FD_ISSET(rtsock, &select_fd))
+ if (rtsock != -1 && FD_ISSET(rtsock, &select_fd))
rtmsg_input();
if (FD_ISSET(sock, &select_fd))
rtadvd_input();