mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 18:28:25 +00:00
radv.c tidying.
This commit is contained in:
24
src/radv.c
24
src/radv.c
@@ -276,7 +276,6 @@ static void send_ra(int iface, char *iface_name, struct in6_addr *dest)
|
||||
static int add_prefixes(struct in6_addr *local, int prefix,
|
||||
int scope, int if_index, int dad, void *vparam)
|
||||
{
|
||||
struct dhcp_context *context;
|
||||
struct ra_param *param = vparam;
|
||||
|
||||
(void)scope; /* warning */
|
||||
@@ -290,11 +289,11 @@ static int add_prefixes(struct in6_addr *local, int prefix,
|
||||
!IN6_IS_ADDR_LINKLOCAL(local) &&
|
||||
!IN6_IS_ADDR_MULTICAST(local))
|
||||
{
|
||||
int do_prefix = 0;
|
||||
int do_slaac = 0;
|
||||
int deprecate = 0;
|
||||
unsigned int time = 0xffffffff;
|
||||
struct in6_addr *addr = NULL;
|
||||
struct prefix_opt *opt;
|
||||
struct dhcp_context *context;
|
||||
|
||||
for (context = daemon->ra_contexts; context; context = context->next)
|
||||
if (prefix == context->prefix &&
|
||||
@@ -331,16 +330,20 @@ static int add_prefixes(struct in6_addr *local, int prefix,
|
||||
param->first = 0;
|
||||
param->found_context = 1;
|
||||
|
||||
if (context->flags & CONTEXT_RA_DONE)
|
||||
continue;
|
||||
|
||||
if (!(context->flags & CONTEXT_RA_DONE))
|
||||
{
|
||||
context->flags |= CONTEXT_RA_DONE;
|
||||
addr = &context->start6;
|
||||
do_prefix = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (addr && (opt = expand(sizeof(struct prefix_opt))))
|
||||
if (do_prefix)
|
||||
{
|
||||
u64 addrpart = addr6part(addr);
|
||||
struct prefix_opt *opt;
|
||||
|
||||
if ((opt = expand(sizeof(struct prefix_opt))))
|
||||
{
|
||||
u64 addrpart = addr6part(local);
|
||||
u64 mask = (prefix == 64) ? (u64)-1LL : (1LLU << (128 - prefix)) - 1LLU;
|
||||
|
||||
/* lifetimes must be min 2 hrs, by RFC 2462 */
|
||||
@@ -356,7 +359,7 @@ static int add_prefixes(struct in6_addr *local, int prefix,
|
||||
opt->preferred_lifetime = htonl(deprecate ? 0 : time);
|
||||
opt->reserved = 0;
|
||||
|
||||
opt->prefix = *addr;
|
||||
opt->prefix = *local;
|
||||
setaddr6part(&opt->prefix, addrpart & ~mask);
|
||||
|
||||
inet_ntop(AF_INET6, &opt->prefix, daemon->addrbuff, ADDRSTRLEN);
|
||||
@@ -364,6 +367,7 @@ static int add_prefixes(struct in6_addr *local, int prefix,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user