Add support for ND6_IFF_IFDISABLED and ND6_IFF_ACCEPT_RTADV to
the -F flag. MFC after: 3 days
This commit is contained in:
parent
70a873df0f
commit
eb87e699b2
@ -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__,
|
||||
|
@ -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,
|
||||
|
@ -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");
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user