Add support for ND6_IFF_IFDISABLED and ND6_IFF_ACCEPT_RTADV to

the -F flag.

MFC after:	3 days
This commit is contained in:
Hiroki Sato 2009-09-12 22:14:58 +00:00
parent 70a873df0f
commit eb87e699b2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=197141
4 changed files with 60 additions and 7 deletions

View File

@ -48,6 +48,7 @@
#include <netinet/icmp6.h>
#include <netinet6/in6_var.h>
#include <netinet6/nd6.h>
#include <stdio.h>
#include <unistd.h>
@ -78,9 +79,15 @@ int
interface_up(char *name)
{
struct ifreq ifr;
struct in6_ndireq nd;
int llflag;
int s;
int error;
memset(&ifr, 0, sizeof(ifr));
strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
memset(&nd, 0, sizeof(nd));
strlcpy(nd.ifname, name, sizeof(nd.ifname));
if (ioctl(ifsock, SIOCGIFFLAGS, (caddr_t)&ifr) < 0) {
warnmsg(LOG_WARNING, __func__, "ioctl(SIOCGIFFLAGS): %s",
@ -94,9 +101,56 @@ interface_up(char *name)
"ioctl(SIOCSIFFLAGS): %s", strerror(errno));
return(-1);
}
if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
warnmsg(LOG_WARNING, __func__, "socket(AF_INET6, SOCK_DGRAM): %s",
strerror(errno));
return(-1);
}
if (ioctl(s, SIOCGIFINFO_IN6, (caddr_t)&nd) < 0) {
warnmsg(LOG_WARNING, __func__, "ioctl(SIOCGIFINFO_IN6): %s",
strerror(errno));
close(s);
return(-1);
}
warnmsg(LOG_DEBUG, __func__, "checking if %s is ready...", name);
if (nd.ndi.flags & ND6_IFF_IFDISABLED) {
if (Fflag) {
nd.ndi.flags &= ~ND6_IFF_IFDISABLED;
if (ioctl(s, SIOCSIFINFO_IN6, (caddr_t)&nd)) {
warnmsg(LOG_WARNING, __func__,
"ioctl(SIOCSIFINFO_IN6): %s",
strerror(errno));
close(s);
return(-1);
}
} else {
warnmsg(LOG_WARNING, __func__,
"%s is disabled.", name);
close(s);
return(-1);
}
}
if (!(nd.ndi.flags & ND6_IFF_ACCEPT_RTADV)) {
if (Fflag) {
nd.ndi.flags |= ND6_IFF_ACCEPT_RTADV;
if (ioctl(s, SIOCSIFINFO_IN6, (caddr_t)&nd)) {
warnmsg(LOG_WARNING, __func__,
"ioctl(SIOCSIFINFO_IN6): %s",
strerror(errno));
close(s);
return(-1);
}
} else {
warnmsg(LOG_WARNING, __func__,
"%s does not accept Router Advertisement.", name);
close(s);
return(-1);
}
}
close(s);
llflag = get_llflag(name);
if (llflag < 0) {
warnmsg(LOG_WARNING, __func__,

View File

@ -29,7 +29,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd May 17, 1998
.Dd September 2, 2009
.Dt RTSOLD 8
.Os
.\"
@ -186,7 +186,9 @@ if they are incompatible with proper operation,
warning messages will be generated,
but Router Solicitations will still be sent.
The settings may be changed manually with
.Xr sysctl 8 .
.Xr sysctl 8
and
.Xr ifconfig 8 .
.It Fl m
Enable mobility support.
If this option is specified,

View File

@ -62,8 +62,8 @@ 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 Fflag = 0; /* force setting sysctl parameters */
int aflag = 0;
int dflag = 0;
@ -197,12 +197,8 @@ main(int argc, char **argv)
#endif
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");

View File

@ -67,6 +67,7 @@ struct ifinfo {
extern struct timeval tm_max;
extern int dflag;
extern int aflag;
extern int Fflag;
extern char *otherconf_script;
extern int ifconfig(char *);
extern void iflist_init(void);