mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 18:28:25 +00:00
RA managed-bit and use-SLAAC bit tweaks.
This commit is contained in:
@@ -576,14 +576,14 @@ for details. Instead, the keyword
|
|||||||
.B ra-names
|
.B ra-names
|
||||||
may be used. This does the same at ra-only, but also enables a mode
|
may be used. This does the same at ra-only, but also enables a mode
|
||||||
which gives DNS names to dual-stack hosts which do SLAAC for
|
which gives DNS names to dual-stack hosts which do SLAAC for
|
||||||
IPv6. Dnsmasq uses the hosts IPv4 lease to derive the name, network
|
IPv6. Dnsmasq uses the host's IPv4 lease to derive the name, network
|
||||||
segment and MAC address and assumes that the host will also have an
|
segment and MAC address and assumes that the host will also have an
|
||||||
IPv6 address calculated using the SLAAC alogrithm, on the same network
|
IPv6 address calculated using the SLAAC alogrithm, on the same network
|
||||||
segment. An AAAA record is added to the DNS for this IPv6
|
segment. The address is pinged, and if a reply is received, an AAAA
|
||||||
|
record is added to the DNS for this IPv6
|
||||||
address. Note that this is only happens for directly-connected
|
address. Note that this is only happens for directly-connected
|
||||||
networks, (not one doing DHCP via a relay) and it will generate an
|
networks, (not one doing DHCP via a relay) and it will not work
|
||||||
erroneous AAAA record if a host is using privacy extensions or does
|
if a host is using privacy extensions.
|
||||||
not support IPv6. Use with care.
|
|
||||||
|
|
||||||
The interface:<interface name> section is not normally used. See the
|
The interface:<interface name> section is not normally used. See the
|
||||||
NOTES section for details of this.
|
NOTES section for details of this.
|
||||||
@@ -1292,13 +1292,17 @@ only a subset of this is needed, and dnsmasq can handle it, using
|
|||||||
existing DHCP configuration to provide most data. When RA is enabled,
|
existing DHCP configuration to provide most data. When RA is enabled,
|
||||||
dnsmasq will advertise a prefix for each dhcp-range, with default
|
dnsmasq will advertise a prefix for each dhcp-range, with default
|
||||||
router and recursive DNS server as the relevant link-local address on
|
router and recursive DNS server as the relevant link-local address on
|
||||||
the machine running dnsmasq. The "managed address" bits are set,
|
the machine running dnsmasq. The "managed address" bits are set, and
|
||||||
except for a dhcp-range which is marked as "ra-only", in which case RA
|
the "use SLAAC" bit is reset, except for a dhcp-range which is
|
||||||
is provided but no DHCPv6 service and the managed address bits are
|
marked as "ra-only" or "ra-names", in which case RA is provided but no
|
||||||
cleared.
|
DHCPv6 service and the managed address bits are
|
||||||
|
cleared and the "use SLAAC" bit set. If the same subnet appears in a
|
||||||
|
normal dhcp-range and an "ra-only" dhcp-range, then the "managed
|
||||||
|
address" bits and the "use SLAAC" bits are all set, allowing SLAAC and
|
||||||
|
DHCP address to co-exist on the same subnet.
|
||||||
.B enable-ra
|
.B enable-ra
|
||||||
enables router advertisement for prefixes where dnsmasq is doing
|
enables router advertisement for prefixes where dnsmasq is doing
|
||||||
DHCPv6. It is not needed to "ra-only" prefixes. Creating an "ra-only"
|
DHCPv6. It is not needed for "ra-only" prefixes. Creating an "ra-only"
|
||||||
prefix and not setting
|
prefix and not setting
|
||||||
.B enable-ra
|
.B enable-ra
|
||||||
sends advertisements only to "ra-only" prefixes.
|
sends advertisements only to "ra-only" prefixes.
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ struct daemon *daemon;
|
|||||||
|
|
||||||
static volatile pid_t pid = 0;
|
static volatile pid_t pid = 0;
|
||||||
static volatile int pipewrite;
|
static volatile int pipewrite;
|
||||||
static int alarm_queued = 0;
|
|
||||||
|
|
||||||
static int set_dns_listeners(time_t now, fd_set *set, int *maxfdp);
|
static int set_dns_listeners(time_t now, fd_set *set, int *maxfdp);
|
||||||
static void check_dns_listeners(fd_set *set, time_t now);
|
static void check_dns_listeners(fd_set *set, time_t now);
|
||||||
@@ -868,20 +867,14 @@ static void sig_handler(int sig)
|
|||||||
/* now == 0 -> queue immediate callback */
|
/* now == 0 -> queue immediate callback */
|
||||||
void send_alarm(time_t event, time_t now)
|
void send_alarm(time_t event, time_t now)
|
||||||
{
|
{
|
||||||
|
if (now == 0 || event != 0)
|
||||||
if (now != 0 && event == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ((now == 0 || difftime(event, now) <= 0.0))
|
|
||||||
{
|
{
|
||||||
if (!alarm_queued)
|
/* alarm(0) or alarm(-ve) doesn't do what we want.... */
|
||||||
{
|
if ((now == 0 || difftime(event, now) <= 0.0))
|
||||||
send_event(pipewrite, EVENT_ALARM, 0, NULL);
|
send_event(pipewrite, EVENT_ALARM, 0, NULL);
|
||||||
alarm_queued = 1;
|
else
|
||||||
}
|
alarm((unsigned)difftime(event, now));
|
||||||
}
|
}
|
||||||
else
|
|
||||||
alarm((unsigned)difftime(event, now));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void send_event(int fd, int event, int data, char *msg)
|
void send_event(int fd, int event, int data, char *msg)
|
||||||
@@ -995,7 +988,6 @@ static void async_event(int pipe, time_t now)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case EVENT_ALARM:
|
case EVENT_ALARM:
|
||||||
alarm_queued = 0;
|
|
||||||
#ifdef HAVE_DHCP
|
#ifdef HAVE_DHCP
|
||||||
if (daemon->dhcp || daemon->dhcp6)
|
if (daemon->dhcp || daemon->dhcp6)
|
||||||
{
|
{
|
||||||
|
|||||||
16
src/radv.c
16
src/radv.c
@@ -206,7 +206,7 @@ static void send_ra(int iface, char *iface_name, struct in6_addr *dest)
|
|||||||
ra->type = ND_ROUTER_ADVERT;
|
ra->type = ND_ROUTER_ADVERT;
|
||||||
ra->code = 0;
|
ra->code = 0;
|
||||||
ra->hop_limit = hop_limit;
|
ra->hop_limit = hop_limit;
|
||||||
ra->flags = 0;
|
ra->flags = 0x00;
|
||||||
ra->lifetime = htons(1800); /* AdvDefaultLifetime*/
|
ra->lifetime = htons(1800); /* AdvDefaultLifetime*/
|
||||||
ra->reachable_time = 0;
|
ra->reachable_time = 0;
|
||||||
ra->retrans_time = 0;
|
ra->retrans_time = 0;
|
||||||
@@ -246,7 +246,7 @@ static void send_ra(int iface, char *iface_name, struct in6_addr *dest)
|
|||||||
|
|
||||||
/* set managed bits unless we're providing only RA on this link */
|
/* set managed bits unless we're providing only RA on this link */
|
||||||
if (parm.managed)
|
if (parm.managed)
|
||||||
ra->flags = 0xc0;
|
ra->flags = 0xc0; /* M flag, managed, O flag, other */
|
||||||
|
|
||||||
/* decide where we're sending */
|
/* decide where we're sending */
|
||||||
memset(&addr, 0, sizeof(addr));
|
memset(&addr, 0, sizeof(addr));
|
||||||
@@ -293,7 +293,11 @@ static int add_prefixes(struct in6_addr *local, int prefix,
|
|||||||
is_same_net6(local, &context->start6, prefix) &&
|
is_same_net6(local, &context->start6, prefix) &&
|
||||||
is_same_net6(local, &context->end6, prefix))
|
is_same_net6(local, &context->end6, prefix))
|
||||||
{
|
{
|
||||||
if (!(context->flags & CONTEXT_RA_ONLY))
|
int do_slaac = 0;
|
||||||
|
|
||||||
|
if (context->flags & CONTEXT_RA_ONLY)
|
||||||
|
do_slaac = 1;
|
||||||
|
else
|
||||||
{
|
{
|
||||||
/* don't do RA for non-ra-only unless --enable-ra is set */
|
/* don't do RA for non-ra-only unless --enable-ra is set */
|
||||||
if (!option_bool(OPT_RA))
|
if (!option_bool(OPT_RA))
|
||||||
@@ -317,6 +321,10 @@ static int add_prefixes(struct in6_addr *local, int prefix,
|
|||||||
is_same_net6(local, &tmp->start6, prefix) &&
|
is_same_net6(local, &tmp->start6, prefix) &&
|
||||||
is_same_net6(local, &tmp->end6, prefix))
|
is_same_net6(local, &tmp->end6, prefix))
|
||||||
{
|
{
|
||||||
|
/* if any dhcp-range with ra-only on this subnet
|
||||||
|
set the "do_slaac" bit */
|
||||||
|
if (tmp->flags & CONTEXT_RA_ONLY)
|
||||||
|
do_slaac = 1;
|
||||||
tmp->flags |= CONTEXT_RA_DONE;
|
tmp->flags |= CONTEXT_RA_DONE;
|
||||||
context->ra_time = 0;
|
context->ra_time = 0;
|
||||||
}
|
}
|
||||||
@@ -335,7 +343,7 @@ static int add_prefixes(struct in6_addr *local, int prefix,
|
|||||||
opt->len = 4;
|
opt->len = 4;
|
||||||
opt->prefix_len = prefix;
|
opt->prefix_len = prefix;
|
||||||
/* autonomous only is we're not doing dhcp */
|
/* autonomous only is we're not doing dhcp */
|
||||||
opt->flags = (context->flags & CONTEXT_RA_ONLY) ? 0xc0 : 0x00;
|
opt->flags = do_slaac ? 0x40 : 0x00;
|
||||||
opt->valid_lifetime = opt->preferred_lifetime = htonl(time);
|
opt->valid_lifetime = opt->preferred_lifetime = htonl(time);
|
||||||
opt->reserved = 0;
|
opt->reserved = 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user