diff options
author | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2004-01-05 20:32:51 +0000 |
---|---|---|
committer | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2004-01-05 20:32:51 +0000 |
commit | bbade9b3df20012c2859965bd5030f98edde4565 (patch) | |
tree | 335d25c2189a6b697b0e9b4f18091b738555ea6c | |
parent | a7f3d4cee5ffbaf25dcc0de2baca26eca6662525 (diff) |
add -F option, which sets sysctl(8) variables rather than warn(3) about the
current setting. basically for boot floppy. req'ed by fries@. deraadt@ ok.
-rw-r--r-- | usr.sbin/rtsold/if.c | 18 | ||||
-rw-r--r-- | usr.sbin/rtsold/rtsold.8 | 20 | ||||
-rw-r--r-- | usr.sbin/rtsold/rtsold.c | 27 | ||||
-rw-r--r-- | usr.sbin/rtsold/rtsold.h | 3 |
4 files changed, 53 insertions, 15 deletions
diff --git a/usr.sbin/rtsold/if.c b/usr.sbin/rtsold/if.c index 7456c330ed7..b421b488282 100644 --- a/usr.sbin/rtsold/if.c +++ b/usr.sbin/rtsold/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.17 2003/10/05 15:29:28 deraadt Exp $ */ +/* $OpenBSD: if.c,v 1.18 2004/01/05 20:32:50 itojun Exp $ */ /* $KAME: if.c,v 1.18 2002/05/31 10:10:03 itojun Exp $ */ /* @@ -299,6 +299,22 @@ getinet6sysctl(int code) return value; } +int +setinet6sysctl(int code, int newval) +{ + int mib[] = { CTL_NET, PF_INET6, IPPROTO_IPV6, 0 }; + int value; + size_t size; + + mib[3] = code; + size = sizeof(value); + if (sysctl(mib, sizeof(mib)/sizeof(mib[0]), &value, &size, + &newval, sizeof(newval)) < 0) + return -1; + else + return value; +} + /*------------------------------------------------------------*/ /* get ia6_flags for link-local addr on if. returns -1 on error. */ diff --git a/usr.sbin/rtsold/rtsold.8 b/usr.sbin/rtsold/rtsold.8 index 97f890b5d35..9395d1772e4 100644 --- a/usr.sbin/rtsold/rtsold.8 +++ b/usr.sbin/rtsold/rtsold.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: rtsold.8,v 1.17 2004/01/03 06:20:17 itojun Exp $ +.\" $OpenBSD: rtsold.8,v 1.18 2004/01/05 20:32:50 itojun Exp $ .\" $KAME: rtsold.8,v 1.17 2001/07/09 22:30:37 itojun Exp $ .\" .\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -38,13 +38,13 @@ .\" .Sh SYNOPSIS .Nm rtsold -.Op Fl dDfm1 +.Op Fl dDfFm1 .Ar interface ... .Nm rtsold -.Op Fl dDfm1 +.Op Fl dDfFm1 .Fl a .Nm rtsol -.Op Fl dD +.Op Fl dDF .Ar interface ... .Nm rtsol .Op Fl dD @@ -156,6 +156,18 @@ from becoming a daemon (foreground mode). Warning messages are generated to standard error instead of .Xr syslog 3 . +.It Fl F +Configure +.Xr sysctl 8 +variable related to +.Nm +by itself. +Without +.Fl F , +.Nm +will not alter and obey the current +.Xr sysctl 8 +settings. .It Fl m Enable mobility support. If this option is specified, diff --git a/usr.sbin/rtsold/rtsold.c b/usr.sbin/rtsold/rtsold.c index cdb3ab695d2..a6701f9ef44 100644 --- a/usr.sbin/rtsold/rtsold.c +++ b/usr.sbin/rtsold/rtsold.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtsold.c,v 1.34 2004/01/03 06:20:17 itojun Exp $ */ +/* $OpenBSD: rtsold.c,v 1.35 2004/01/05 20:32:50 itojun Exp $ */ /* $KAME: rtsold.c,v 1.75 2004/01/03 00:00:07 itojun Exp $ */ /* @@ -60,6 +60,7 @@ struct ifinfo *iflist; struct timeval tm_max = {0x7fffffff, 0x7fffffff}; static int log_upto = 999; static int fflag = 0; +static int Fflag = 0; /* force setting sysctl parameters */ int aflag = 0; int dflag = 0; @@ -119,9 +120,9 @@ main(int argc, char *argv[]) if (argv0 && argv0[strlen(argv0) - 1] != 'd') { fflag = 1; once = 1; - opts = "adD"; + opts = "adDF"; } else - opts = "adDfm1"; + opts = "adDfFm1"; while ((ch = getopt(argc, argv, opts)) != -1) { switch (ch) { @@ -137,6 +138,9 @@ main(int argc, char *argv[]) case 'f': fflag = 1; break; + case 'F': + Fflag = 1; + break; case 'm': mobile_node = 1; break; @@ -172,12 +176,17 @@ main(int argc, char *argv[]) setlogmask(LOG_UPTO(log_upto)); } - /* warn if accept_rtadv is down */ - if (!getinet6sysctl(IPV6CTL_ACCEPT_RTADV)) - warnx("kernel is configured not to accept RAs"); - /* warn if forwarding is up */ - if (getinet6sysctl(IPV6CTL_FORWARDING)) - warnx("kernel is configured as a router, not a host"); + if (Fflag) { + setinet6sysctl(IPV6CTL_ACCEPT_RTADV, 1); + setinet6sysctl(IPV6CTL_FORWARDING, 0); + } else { + /* warn if accept_rtadv is down */ + if (!getinet6sysctl(IPV6CTL_ACCEPT_RTADV)) + warnx("kernel is configured not to accept RAs"); + /* warn if forwarding is up */ + if (getinet6sysctl(IPV6CTL_FORWARDING)) + warnx("kernel is configured as a router, not a host"); + } #ifndef SMALL /* initialization to dump internal status to a file */ diff --git a/usr.sbin/rtsold/rtsold.h b/usr.sbin/rtsold/rtsold.h index af03c4236a0..95c883b9f8b 100644 --- a/usr.sbin/rtsold/rtsold.h +++ b/usr.sbin/rtsold/rtsold.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rtsold.h,v 1.10 2002/05/31 21:24:28 itojun Exp $ */ +/* $OpenBSD: rtsold.h,v 1.11 2004/01/05 20:32:50 itojun Exp $ */ /* $KAME: rtsold.h,v 1.14 2002/05/31 10:10:03 itojun Exp $ */ /* @@ -77,6 +77,7 @@ extern int lladdropt_length(struct sockaddr_dl *); extern void lladdropt_fill(struct sockaddr_dl *, struct nd_opt_hdr *); extern struct sockaddr_dl *if_nametosdl(char *); extern int getinet6sysctl(int); +extern int setinet6sysctl(int, int); /* rtsol.c */ extern int sockopen(void); |