Skip to content

Commit

Permalink
add -F flag, which configures sysctl(8) setting by rtsold itself (rat…
Browse files Browse the repository at this point in the history
…her than

warn about the current setting).  basically for boot floppy which does not
want to include sysctl(8).
  • Loading branch information
itojun committed Jan 5, 2004
1 parent bbc4611 commit 37e4544
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 19 deletions.
18 changes: 17 additions & 1 deletion kame/kame/rtsold/if.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $KAME: if.c,v 1.29 2003/10/23 04:55:28 suz Exp $ */
/* $OpenBSD: if.c,v 1.18 2004/01/05 20:32:50 itojun Exp $ */

/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
Expand Down Expand Up @@ -309,6 +309,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. */
Expand Down
20 changes: 16 additions & 4 deletions kame/kame/rtsold/rtsold.8
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.\" $KAME: rtsold.8,v 1.21 2004/01/03 06:15:18 itojun Exp $
.\" $OpenBSD: rtsold.8,v 1.18 2004/01/05 20:32:50 itojun Exp $
.\"
.\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
.\" All rights reserved.
Expand Down Expand Up @@ -37,15 +37,15 @@
.\"
.Sh SYNOPSIS
.Nm rtsold
.Op Fl dDfm1
.Op Fl dDfFm1
.Op Fl O Ar script-name
.Ar interface ...
.Nm rtsold
.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
Expand Down Expand Up @@ -177,6 +177,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,
Expand Down
35 changes: 22 additions & 13 deletions kame/kame/rtsold/rtsold.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $KAME: rtsold.c,v 1.78 2004/01/03 06:14:37 itojun Exp $ */
/* $OpenBSD: rtsold.c,v 1.35 2004/01/05 20:32:50 itojun Exp $ */

/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
Expand Down Expand Up @@ -87,6 +87,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;
Expand Down Expand Up @@ -153,9 +154,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) {
Expand All @@ -171,6 +172,9 @@ main(int argc, char **argv)
case 'f':
fflag = 1;
break;
case 'F':
Fflag = 1;
break;
case 'm':
mobile_node = 1;
break;
Expand Down Expand Up @@ -219,12 +223,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");
}

#ifndef SMALL
/* initialization to dump internal status to a file */
Expand Down Expand Up @@ -758,11 +767,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);
}
Expand Down
3 changes: 2 additions & 1 deletion kame/kame/rtsold/rtsold.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $KAME: rtsold.h,v 1.20 2003/10/23 04:55:28 suz Exp $ */
/* $OpenBSD: rtsold.h,v 1.11 2004/01/05 20:32:50 itojun Exp $ */

/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
Expand Down Expand Up @@ -82,6 +82,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));
Expand Down

0 comments on commit 37e4544

Please sign in to comment.