aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorHajimu UMEMOTO <ume@FreeBSD.org>2004-01-14 17:42:03 +0000
committerHajimu UMEMOTO <ume@FreeBSD.org>2004-01-14 17:42:03 +0000
commitfcdaee31279ffa6b3505c94450085e1808de3e77 (patch)
treecccc02033f7c2ccb5644562f4c92694699fc5194 /usr.sbin
parent8e7409eda3dc9290e4b67152c57b0fee3975c523 (diff)
downloadsrc-fcdaee31279ffa6b3505c94450085e1808de3e77.tar.gz
src-fcdaee31279ffa6b3505c94450085e1808de3e77.zip
add -F flag, which configures sysctl(8) setting by rtsold
itself (rather than warn about the current setting). Obtained from: KAME
Notes
Notes: svn path=/head/; revision=124525
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/rtsold/if.c16
-rw-r--r--usr.sbin/rtsold/rtsold.818
-rw-r--r--usr.sbin/rtsold/rtsold.c33
-rw-r--r--usr.sbin/rtsold/rtsold.h1
4 files changed, 53 insertions, 15 deletions
diff --git a/usr.sbin/rtsold/if.c b/usr.sbin/rtsold/if.c
index 99a1b0ee0126..23e4e6fa02b3 100644
--- a/usr.sbin/rtsold/if.c
+++ b/usr.sbin/rtsold/if.c
@@ -300,6 +300,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 2490890a0766..1e2a3bfa3625 100644
--- a/usr.sbin/rtsold/rtsold.8
+++ b/usr.sbin/rtsold/rtsold.8
@@ -39,15 +39,15 @@
.\"
.Sh SYNOPSIS
.Nm
-.Op Fl dDfm1
+.Op Fl dDfFm1
.Op Fl O Ar script-name
.Ar interface ...
.Nm
-.Op Fl dDfm1
+.Op Fl dDfFm1
.Op Fl O Ar script-name
.Fl a
.Nm rtsol
-.Op Fl dD
+.Op Fl dDF
.Op Fl O Ar script-name
.Ar interface ...
.Nm rtsol
@@ -176,6 +176,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 e058dd750207..bfdbc68e62e4 100644
--- a/usr.sbin/rtsold/rtsold.c
+++ b/usr.sbin/rtsold/rtsold.c
@@ -62,6 +62,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;
@@ -120,9 +121,9 @@ main(int argc, char **argv)
if (argv0 && argv0[strlen(argv0) - 1] != 'd') {
fflag = 1;
once = 1;
- opts = "adDO:";
+ opts = "adDFO:";
} else
- opts = "adDfm1O:";
+ opts = "adDfFm1O:";
while ((ch = getopt(argc, argv, opts)) != -1) {
switch (ch) {
@@ -138,6 +139,9 @@ main(int argc, char **argv)
case 'f':
fflag = 1;
break;
+ case 'F':
+ Fflag = 1;
+ break;
case 'm':
mobile_node = 1;
break;
@@ -186,12 +190,17 @@ main(int argc, char **argv)
srandom((u_long)time(NULL));
#endif
- /* 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");
+ }
/* initialization to dump internal status to a file */
signal(SIGUSR1, rtsold_set_dump_file);
@@ -720,11 +729,11 @@ static void
usage(char *progname)
{
if (progname && progname[strlen(progname) - 1] != 'd') {
- fprintf(stderr, "usage: rtsol [-dD] interfaces...\n");
- fprintf(stderr, "usage: rtsol [-dD] -a\n");
+ fprintf(stderr, "usage: rtsol [-dDF] interfaces...\n");
+ fprintf(stderr, "usage: rtsol [-dDF] -a\n");
} else {
- fprintf(stderr, "usage: rtsold [-adDfm1] interfaces...\n");
- fprintf(stderr, "usage: rtsold [-dDfm1] -a\n");
+ fprintf(stderr, "usage: rtsold [-adDfFm1] interfaces...\n");
+ fprintf(stderr, "usage: rtsold [-dDfFm1] -a\n");
}
exit(1);
}
diff --git a/usr.sbin/rtsold/rtsold.h b/usr.sbin/rtsold/rtsold.h
index 09577a50898f..e25ed955e98f 100644
--- a/usr.sbin/rtsold/rtsold.h
+++ b/usr.sbin/rtsold/rtsold.h
@@ -84,6 +84,7 @@ extern int lladdropt_length __P((struct sockaddr_dl *));
extern void lladdropt_fill __P((struct sockaddr_dl *, struct nd_opt_hdr *));
extern struct sockaddr_dl *if_nametosdl __P((char *));
extern int getinet6sysctl __P((int));
+extern int setinet6sysctl __P((int, int));
/* rtsol.c */
extern int sockopen __P((void));