Probe for the availability of AF_INET6 at startup. If it's not
available, default ipv6cp to disabled and refuse to let the user enable it.
This commit is contained in:
parent
a886247185
commit
971abb295e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=81697
@ -99,6 +99,7 @@
|
|||||||
#include "datalink.h"
|
#include "datalink.h"
|
||||||
#include "iface.h"
|
#include "iface.h"
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
|
#include "probe.h"
|
||||||
#ifdef HAVE_DES
|
#ifdef HAVE_DES
|
||||||
#include "mppe.h"
|
#include "mppe.h"
|
||||||
#endif
|
#endif
|
||||||
@ -809,10 +810,12 @@ bundle_Create(const char *prefix, int type, int unit)
|
|||||||
*bundle.cfg.auth.name = '\0';
|
*bundle.cfg.auth.name = '\0';
|
||||||
*bundle.cfg.auth.key = '\0';
|
*bundle.cfg.auth.key = '\0';
|
||||||
bundle.cfg.opt = OPT_IDCHECK | OPT_LOOPBACK | OPT_SROUTES | OPT_TCPMSSFIXUP |
|
bundle.cfg.opt = OPT_IDCHECK | OPT_LOOPBACK | OPT_SROUTES | OPT_TCPMSSFIXUP |
|
||||||
#ifndef NOINET6
|
|
||||||
OPT_IPCP | OPT_IPV6CP |
|
|
||||||
#endif
|
|
||||||
OPT_THROUGHPUT | OPT_UTMP;
|
OPT_THROUGHPUT | OPT_UTMP;
|
||||||
|
#ifndef NOINET6
|
||||||
|
bundle.cfg.opt |= OPT_IPCP;
|
||||||
|
if (probe.ipv6_available)
|
||||||
|
bundle.cfg.opt |= OPT_IPV6CP;
|
||||||
|
#endif
|
||||||
*bundle.cfg.label = '\0';
|
*bundle.cfg.label = '\0';
|
||||||
bundle.cfg.ifqueue = DEF_IFQUEUE;
|
bundle.cfg.ifqueue = DEF_IFQUEUE;
|
||||||
bundle.cfg.choked.timeout = CHOKED_TIMEOUT;
|
bundle.cfg.choked.timeout = CHOKED_TIMEOUT;
|
||||||
|
@ -101,6 +101,7 @@
|
|||||||
#include "datalink.h"
|
#include "datalink.h"
|
||||||
#include "iface.h"
|
#include "iface.h"
|
||||||
#include "id.h"
|
#include "id.h"
|
||||||
|
#include "probe.h"
|
||||||
|
|
||||||
/* ``set'' values */
|
/* ``set'' values */
|
||||||
#define VAR_AUTHKEY 0
|
#define VAR_AUTHKEY 0
|
||||||
@ -2573,13 +2574,19 @@ OptSet(struct cmdargs const *arg)
|
|||||||
unsigned keep; /* Keep these bits */
|
unsigned keep; /* Keep these bits */
|
||||||
unsigned add; /* Add these bits */
|
unsigned add; /* Add these bits */
|
||||||
|
|
||||||
if ((cmd = ident_cmd(arg->argv[arg->argn-2], &keep, &add)) == NULL)
|
if (ident_cmd(arg->argv[arg->argn - 2], &keep, &add) == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
if (add == NEG_ENABLED && bit == OPT_IPV6CP && !probe.ipv6_available) {
|
||||||
|
log_Printf(LogWARN, "IPv6 is not available on this machine\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (add)
|
if (add)
|
||||||
arg->bundle->cfg.opt |= bit;
|
arg->bundle->cfg.opt |= bit;
|
||||||
else
|
else
|
||||||
arg->bundle->cfg.opt &= ~bit;
|
arg->bundle->cfg.opt &= ~bit;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,6 +304,8 @@ main(int argc, char **argv)
|
|||||||
struct prompt *prompt;
|
struct prompt *prompt;
|
||||||
struct switches sw;
|
struct switches sw;
|
||||||
|
|
||||||
|
probe_Init();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We open 3 descriptors to ensure that STDIN_FILENO, STDOUT_FILENO and
|
* We open 3 descriptors to ensure that STDIN_FILENO, STDOUT_FILENO and
|
||||||
* STDERR_FILENO are always open. These are closed before DoLoop(),
|
* STDERR_FILENO are always open. These are closed before DoLoop(),
|
||||||
@ -531,9 +533,6 @@ DoLoop(struct bundle *bundle)
|
|||||||
{
|
{
|
||||||
fd_set *rfds, *wfds, *efds;
|
fd_set *rfds, *wfds, *efds;
|
||||||
int i, nfds, nothing_done;
|
int i, nfds, nothing_done;
|
||||||
struct probe probe;
|
|
||||||
|
|
||||||
probe_Init(&probe);
|
|
||||||
|
|
||||||
if ((rfds = mkfdset()) == NULL) {
|
if ((rfds = mkfdset()) == NULL) {
|
||||||
log_Printf(LogERROR, "DoLoop: Cannot create fd_set\n");
|
log_Printf(LogERROR, "DoLoop: Cannot create fd_set\n");
|
||||||
|
@ -27,11 +27,15 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "probe.h"
|
#include "probe.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
|
struct probe probe;
|
||||||
|
|
||||||
/* Does select() alter the passed time value ? */
|
/* Does select() alter the passed time value ? */
|
||||||
static int
|
static int
|
||||||
select_changes_time(void)
|
select_changes_time(void)
|
||||||
@ -44,10 +48,29 @@ select_changes_time(void)
|
|||||||
return t.tv_usec != 100000;
|
return t.tv_usec != 100000;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
#ifndef NOINET6
|
||||||
probe_Init(struct probe *p)
|
static int
|
||||||
|
ipv6_available(void)
|
||||||
{
|
{
|
||||||
p->select_changes_time = select_changes_time() ? 1 : 0;
|
int s;
|
||||||
log_Printf(LogDEBUG, "Select changes time: %s\n",
|
|
||||||
p->select_changes_time ? "yes" : "no");
|
if ((s = ID0socket(AF_INET6, SOCK_DGRAM, 0)) == -1)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
close(s);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void
|
||||||
|
probe_Init()
|
||||||
|
{
|
||||||
|
probe.select_changes_time = select_changes_time() ? 1 : 0;
|
||||||
|
log_Printf(LogDEBUG, "Select changes time: %s\n",
|
||||||
|
probe.select_changes_time ? "yes" : "no");
|
||||||
|
#ifndef NOINET6
|
||||||
|
probe.ipv6_available = ipv6_available() ? 1 : 0;
|
||||||
|
log_Printf(LogDEBUG, "IPv6 available: %s\n",
|
||||||
|
probe.ipv6_available ? "yes" : "no");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,11 @@
|
|||||||
|
|
||||||
struct probe {
|
struct probe {
|
||||||
unsigned select_changes_time : 1;
|
unsigned select_changes_time : 1;
|
||||||
|
#ifndef NOINET6
|
||||||
|
unsigned ipv6_available : 1;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void probe_Init(struct probe *);
|
extern struct probe probe;
|
||||||
|
|
||||||
|
extern void probe_Init(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user