1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-07 13:14:51 +00:00

add -F flag, which configures sysctl(8) setting by rtsold

itself (rather than warn about the current setting).

Obtained from:	KAME
This commit is contained in:
Hajimu UMEMOTO 2004-01-14 17:42:03 +00:00
parent 8e7409eda3
commit fcdaee3127
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=124525
4 changed files with 53 additions and 15 deletions

View File

@ -300,6 +300,22 @@ getinet6sysctl(int code)
return value; 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. */ /* get ia6_flags for link-local addr on if. returns -1 on error. */

View File

@ -39,15 +39,15 @@
.\" .\"
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm .Nm
.Op Fl dDfm1 .Op Fl dDfFm1
.Op Fl O Ar script-name .Op Fl O Ar script-name
.Ar interface ... .Ar interface ...
.Nm .Nm
.Op Fl dDfm1 .Op Fl dDfFm1
.Op Fl O Ar script-name .Op Fl O Ar script-name
.Fl a .Fl a
.Nm rtsol .Nm rtsol
.Op Fl dD .Op Fl dDF
.Op Fl O Ar script-name .Op Fl O Ar script-name
.Ar interface ... .Ar interface ...
.Nm rtsol .Nm rtsol
@ -176,6 +176,18 @@ from becoming a daemon (foreground mode).
Warning messages are generated to standard error Warning messages are generated to standard error
instead of instead of
.Xr syslog 3 . .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 .It Fl m
Enable mobility support. Enable mobility support.
If this option is specified, If this option is specified,

View File

@ -62,6 +62,7 @@ struct ifinfo *iflist;
struct timeval tm_max = {0x7fffffff, 0x7fffffff}; struct timeval tm_max = {0x7fffffff, 0x7fffffff};
static int log_upto = 999; static int log_upto = 999;
static int fflag = 0; static int fflag = 0;
static int Fflag = 0; /* force setting sysctl parameters */
int aflag = 0; int aflag = 0;
int dflag = 0; int dflag = 0;
@ -120,9 +121,9 @@ main(int argc, char **argv)
if (argv0 && argv0[strlen(argv0) - 1] != 'd') { if (argv0 && argv0[strlen(argv0) - 1] != 'd') {
fflag = 1; fflag = 1;
once = 1; once = 1;
opts = "adDO:"; opts = "adDFO:";
} else } else
opts = "adDfm1O:"; opts = "adDfFm1O:";
while ((ch = getopt(argc, argv, opts)) != -1) { while ((ch = getopt(argc, argv, opts)) != -1) {
switch (ch) { switch (ch) {
@ -138,6 +139,9 @@ main(int argc, char **argv)
case 'f': case 'f':
fflag = 1; fflag = 1;
break; break;
case 'F':
Fflag = 1;
break;
case 'm': case 'm':
mobile_node = 1; mobile_node = 1;
break; break;
@ -186,12 +190,17 @@ main(int argc, char **argv)
srandom((u_long)time(NULL)); srandom((u_long)time(NULL));
#endif #endif
/* warn if accept_rtadv is down */ if (Fflag) {
if (!getinet6sysctl(IPV6CTL_ACCEPT_RTADV)) setinet6sysctl(IPV6CTL_ACCEPT_RTADV, 1);
warnx("kernel is configured not to accept RAs"); setinet6sysctl(IPV6CTL_FORWARDING, 0);
/* warn if forwarding is up */ } else {
if (getinet6sysctl(IPV6CTL_FORWARDING)) /* warn if accept_rtadv is down */
warnx("kernel is configured as a router, not a host"); 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 */ /* initialization to dump internal status to a file */
signal(SIGUSR1, rtsold_set_dump_file); signal(SIGUSR1, rtsold_set_dump_file);
@ -720,11 +729,11 @@ static void
usage(char *progname) usage(char *progname)
{ {
if (progname && progname[strlen(progname) - 1] != 'd') { if (progname && progname[strlen(progname) - 1] != 'd') {
fprintf(stderr, "usage: rtsol [-dD] interfaces...\n"); fprintf(stderr, "usage: rtsol [-dDF] interfaces...\n");
fprintf(stderr, "usage: rtsol [-dD] -a\n"); fprintf(stderr, "usage: rtsol [-dDF] -a\n");
} else { } else {
fprintf(stderr, "usage: rtsold [-adDfm1] interfaces...\n"); fprintf(stderr, "usage: rtsold [-adDfFm1] interfaces...\n");
fprintf(stderr, "usage: rtsold [-dDfm1] -a\n"); fprintf(stderr, "usage: rtsold [-dDfFm1] -a\n");
} }
exit(1); exit(1);
} }

View File

@ -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 void lladdropt_fill __P((struct sockaddr_dl *, struct nd_opt_hdr *));
extern struct sockaddr_dl *if_nametosdl __P((char *)); extern struct sockaddr_dl *if_nametosdl __P((char *));
extern int getinet6sysctl __P((int)); extern int getinet6sysctl __P((int));
extern int setinet6sysctl __P((int, int));
/* rtsol.c */ /* rtsol.c */
extern int sockopen __P((void)); extern int sockopen __P((void));