mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 10:18:25 +00:00
RA managed-bit and use-SLAAC bit tweaks.
This commit is contained in:
@@ -23,7 +23,6 @@ struct daemon *daemon;
|
||||
|
||||
static volatile pid_t pid = 0;
|
||||
static volatile int pipewrite;
|
||||
static int alarm_queued = 0;
|
||||
|
||||
static int set_dns_listeners(time_t now, fd_set *set, int *maxfdp);
|
||||
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 */
|
||||
void send_alarm(time_t event, time_t now)
|
||||
{
|
||||
|
||||
if (now != 0 && event == 0)
|
||||
return;
|
||||
|
||||
if ((now == 0 || difftime(event, now) <= 0.0))
|
||||
if (now == 0 || event != 0)
|
||||
{
|
||||
if (!alarm_queued)
|
||||
{
|
||||
send_event(pipewrite, EVENT_ALARM, 0, NULL);
|
||||
alarm_queued = 1;
|
||||
}
|
||||
/* 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);
|
||||
else
|
||||
alarm((unsigned)difftime(event, now));
|
||||
}
|
||||
else
|
||||
alarm((unsigned)difftime(event, now));
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
case EVENT_ALARM:
|
||||
alarm_queued = 0;
|
||||
#ifdef HAVE_DHCP
|
||||
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->code = 0;
|
||||
ra->hop_limit = hop_limit;
|
||||
ra->flags = 0;
|
||||
ra->flags = 0x00;
|
||||
ra->lifetime = htons(1800); /* AdvDefaultLifetime*/
|
||||
ra->reachable_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 */
|
||||
if (parm.managed)
|
||||
ra->flags = 0xc0;
|
||||
ra->flags = 0xc0; /* M flag, managed, O flag, other */
|
||||
|
||||
/* decide where we're sending */
|
||||
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->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 */
|
||||
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->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;
|
||||
context->ra_time = 0;
|
||||
}
|
||||
@@ -335,7 +343,7 @@ static int add_prefixes(struct in6_addr *local, int prefix,
|
||||
opt->len = 4;
|
||||
opt->prefix_len = prefix;
|
||||
/* 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->reserved = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user