mirror of
http://thekelleys.org.uk/git/dnsmasq.git
synced 2026-11-23 20:21:53 +00:00
Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a813111379 | ||
|
|
18f0fb050b | ||
|
|
05e92e5afe | ||
|
|
4723d49dad | ||
|
|
fbbc14541a | ||
|
|
5ef33279f2 | ||
|
|
1e02a85970 | ||
|
|
0e88d53faa | ||
|
|
01d1b8ddf2 |
No files matched your search
@@ -4,8 +4,12 @@ version 2.61
|
|||||||
and allows us to find the prefix length for IPv6
|
and allows us to find the prefix length for IPv6
|
||||||
addresses.
|
addresses.
|
||||||
|
|
||||||
Add ra-names DHCPv6 keyword which adds AAAA records
|
Add ra-names, ra-stateless and slaac keywords for DHCPv6.
|
||||||
for dual-stack hosts which get IPv6 addresses via SLAAC.
|
Dnsmasq can now synthesise AAAA records for dual-stack
|
||||||
|
hosts which get IPv6 addresses via SLAAC. It is also now
|
||||||
|
possible to use SLAAC and stateless DHCPv6, and to
|
||||||
|
tell clients to use SLAAC addresses as well as DHCP ones.
|
||||||
|
Thanks to Dave Taht for help with this.
|
||||||
|
|
||||||
Add --dhcp-duid to allow DUID-EN uids to be used.
|
Add --dhcp-duid to allow DUID-EN uids to be used.
|
||||||
|
|
||||||
@@ -66,6 +70,9 @@ version 2.61
|
|||||||
Fix bug in address6_available() which caused DHCPv6 lease
|
Fix bug in address6_available() which caused DHCPv6 lease
|
||||||
aquistion to fail of more than one dhcp-range in use.
|
aquistion to fail of more than one dhcp-range in use.
|
||||||
|
|
||||||
|
Provide RDNSS and DNSSL data in router advertisements,
|
||||||
|
using the settings provided for DHCP options
|
||||||
|
option6:domain-search and option6:dns-server.
|
||||||
|
|
||||||
|
|
||||||
version 2.60
|
version 2.60
|
||||||
|
|||||||
@@ -1343,6 +1343,10 @@ the machine running dnsmasq. By default, he "managed address" bits are set, and
|
|||||||
the "use SLAAC" bit is reset. This can be changed for individual
|
the "use SLAAC" bit is reset. This can be changed for individual
|
||||||
subnets with the mode keywords described in
|
subnets with the mode keywords described in
|
||||||
.B --dhcp-range.
|
.B --dhcp-range.
|
||||||
|
RFC6106 DNS parameters are included in the advertisements. By default,
|
||||||
|
the relevant link-local address of the machine running dnsmasq is sent
|
||||||
|
as recursive DNS server. If provided, the DHCPv6 options dns-server and
|
||||||
|
domain-search are used for RDNSS and DNSSL.
|
||||||
.TP
|
.TP
|
||||||
.B --enable-tftp[=<interface>]
|
.B --enable-tftp[=<interface>]
|
||||||
Enable the TFTP server function. This is deliberately limited to that
|
Enable the TFTP server function. This is deliberately limited to that
|
||||||
|
|||||||
@@ -111,6 +111,13 @@ struct dhcp_netid *option_filter(struct dhcp_netid *tags, struct dhcp_netid *con
|
|||||||
last_tag->next = tags;
|
last_tag->next = tags;
|
||||||
tagif = run_tag_if(context_tags);
|
tagif = run_tag_if(context_tags);
|
||||||
|
|
||||||
|
/* reset stuff with tag:!<tag> which now matches. */
|
||||||
|
for (opt = opts; opt; opt = opt->next)
|
||||||
|
if (!(opt->flags & (DHOPT_ENCAPSULATE | DHOPT_VENDOR | DHOPT_RFC3925)) &&
|
||||||
|
(opt->flags & DHOPT_TAGOK) &&
|
||||||
|
!match_netid(opt->netid, tagif, 0))
|
||||||
|
opt->flags &= ~DHOPT_TAGOK;
|
||||||
|
|
||||||
for (opt = opts; opt; opt = opt->next)
|
for (opt = opts; opt; opt = opt->next)
|
||||||
if (!(opt->flags & (DHOPT_ENCAPSULATE | DHOPT_VENDOR | DHOPT_RFC3925 | DHOPT_TAGOK)) &&
|
if (!(opt->flags & (DHOPT_ENCAPSULATE | DHOPT_VENDOR | DHOPT_RFC3925 | DHOPT_TAGOK)) &&
|
||||||
match_netid(opt->netid, tagif, 0))
|
match_netid(opt->netid, tagif, 0))
|
||||||
|
|||||||
@@ -54,6 +54,7 @@
|
|||||||
#define OPTION6_RECONFIGURE_MSG 19
|
#define OPTION6_RECONFIGURE_MSG 19
|
||||||
#define OPTION6_RECONF_ACCEPT 20
|
#define OPTION6_RECONF_ACCEPT 20
|
||||||
#define OPTION6_DNS_SERVER 23
|
#define OPTION6_DNS_SERVER 23
|
||||||
|
#define OPTION6_DOMAIN_SEARCH 24
|
||||||
#define OPTION6_REMOTE_ID 37
|
#define OPTION6_REMOTE_ID 37
|
||||||
#define OPTION6_SUBSCRIBER_ID 38
|
#define OPTION6_SUBSCRIBER_ID 38
|
||||||
#define OPTION6_FQDN 39
|
#define OPTION6_FQDN 39
|
||||||
|
|||||||
+2
-2
@@ -33,12 +33,12 @@ void dhcp6_init(void)
|
|||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
struct sockaddr_in6 saddr;
|
struct sockaddr_in6 saddr;
|
||||||
#if defined(IP_TOS) && defined(IPTOS_CLASS_CS6)
|
#if defined(IPV6_TCLASS) && defined(IPTOS_CLASS_CS6)
|
||||||
int class = IPTOS_CLASS_CS6;
|
int class = IPTOS_CLASS_CS6;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((fd = socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP)) == -1 ||
|
if ((fd = socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP)) == -1 ||
|
||||||
#if defined(IP_TOS) && defined(IPTOS_CLASS_CS6)
|
#if defined(IPV6_TCLASS) && defined(IPTOS_CLASS_CS6)
|
||||||
setsockopt(fd, IPPROTO_IPV6, IPV6_TCLASS, &class, sizeof(class)) == -1 ||
|
setsockopt(fd, IPPROTO_IPV6, IPV6_TCLASS, &class, sizeof(class)) == -1 ||
|
||||||
#endif
|
#endif
|
||||||
!fix_fd(fd) ||
|
!fix_fd(fd) ||
|
||||||
|
|||||||
+4
-1
@@ -373,7 +373,10 @@ static int find_interface_v6(struct in6_addr *local, int prefix,
|
|||||||
|
|
||||||
void lease_ping_reply(struct in6_addr *sender, unsigned char *packet, char *interface)
|
void lease_ping_reply(struct in6_addr *sender, unsigned char *packet, char *interface)
|
||||||
{
|
{
|
||||||
slaac_ping_reply(sender, packet, interface, leases);
|
/* We may be doing RA but not DHCPv4, in which case the lease
|
||||||
|
database may not exist and we have nothing to do anyway */
|
||||||
|
if (daemon->dhcp)
|
||||||
|
slaac_ping_reply(sender, packet, interface, leases);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+25
-13
@@ -1000,6 +1000,7 @@ static char *parse_dhcp_opt(char *arg, int flags)
|
|||||||
while (arg && *arg)
|
while (arg && *arg)
|
||||||
{
|
{
|
||||||
u16 len = strlen(arg);
|
u16 len = strlen(arg);
|
||||||
|
unhide_metas(arg);
|
||||||
PUTSHORT(len, p);
|
PUTSHORT(len, p);
|
||||||
memcpy(p, arg, len);
|
memcpy(p, arg, len);
|
||||||
p += len;
|
p += len;
|
||||||
@@ -1013,29 +1014,40 @@ static char *parse_dhcp_opt(char *arg, int flags)
|
|||||||
}
|
}
|
||||||
else if (comma && (opt_len & OT_RFC1035_NAME))
|
else if (comma && (opt_len & OT_RFC1035_NAME))
|
||||||
{
|
{
|
||||||
int i, commas = 1;
|
unsigned char *p = NULL, *newp, *end;
|
||||||
unsigned char *p, *newp;
|
int len = 0;
|
||||||
|
|
||||||
for (i = 0; comma[i]; i++)
|
|
||||||
if (comma[i] == ',')
|
|
||||||
commas++;
|
|
||||||
|
|
||||||
newp = opt_malloc(strlen(comma)+(2*commas));
|
|
||||||
p = newp;
|
|
||||||
arg = comma;
|
arg = comma;
|
||||||
comma = split(arg);
|
comma = split(arg);
|
||||||
|
|
||||||
while (arg && *arg)
|
while (arg && *arg)
|
||||||
{
|
{
|
||||||
p = do_rfc1035_name(p, arg);
|
char *dom = canonicalise_opt(arg);
|
||||||
*p++ = 0;
|
if (!dom)
|
||||||
|
{
|
||||||
|
problem = _("bad domain in dhcp-option");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
newp = opt_malloc(len + strlen(dom) + 2);
|
||||||
|
|
||||||
|
if (p)
|
||||||
|
{
|
||||||
|
memcpy(newp, p, len);
|
||||||
|
free(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
p = newp;
|
||||||
|
end = do_rfc1035_name(p + len, dom);
|
||||||
|
*end++ = 0;
|
||||||
|
len = end - p;
|
||||||
|
free(dom);
|
||||||
|
|
||||||
arg = comma;
|
arg = comma;
|
||||||
comma = split(arg);
|
comma = split(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
new->val = newp;
|
new->val = p;
|
||||||
new->len = p - newp;
|
new->len = len;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ struct prefix_opt {
|
|||||||
#define ICMP6_OPT_PREFIX 3
|
#define ICMP6_OPT_PREFIX 3
|
||||||
#define ICMP6_OPT_MTU 5
|
#define ICMP6_OPT_MTU 5
|
||||||
#define ICMP6_OPT_RDNSS 25
|
#define ICMP6_OPT_RDNSS 25
|
||||||
|
#define ICMP6_OPT_DNSSL 31
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
+128
-64
@@ -29,6 +29,7 @@
|
|||||||
struct ra_param {
|
struct ra_param {
|
||||||
int ind, managed, other, found_context, first;
|
int ind, managed, other, found_context, first;
|
||||||
char *if_name;
|
char *if_name;
|
||||||
|
struct dhcp_netid *tags;
|
||||||
struct in6_addr link_local;
|
struct in6_addr link_local;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -50,7 +51,7 @@ void ra_init(time_t now)
|
|||||||
{
|
{
|
||||||
struct icmp6_filter filter;
|
struct icmp6_filter filter;
|
||||||
int fd;
|
int fd;
|
||||||
#if defined(IP_TOS) && defined(IPTOS_CLASS_CS6)
|
#if defined(IPV6_TCLASS) && defined(IPTOS_CLASS_CS6)
|
||||||
int class = IPTOS_CLASS_CS6;
|
int class = IPTOS_CLASS_CS6;
|
||||||
#endif
|
#endif
|
||||||
int val = 255; /* radvd uses this value */
|
int val = 255; /* radvd uses this value */
|
||||||
@@ -72,7 +73,7 @@ void ra_init(time_t now)
|
|||||||
|
|
||||||
if ((fd = socket(PF_INET6, SOCK_RAW, IPPROTO_ICMPV6)) == -1 ||
|
if ((fd = socket(PF_INET6, SOCK_RAW, IPPROTO_ICMPV6)) == -1 ||
|
||||||
getsockopt(fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS, &hop_limit, &len) ||
|
getsockopt(fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS, &hop_limit, &len) ||
|
||||||
#if defined(IP_TOS) && defined(IPTOS_CLASS_CS6)
|
#if defined(IPV6_TCLASS) && defined(IPTOS_CLASS_CS6)
|
||||||
setsockopt(fd, IPPROTO_IPV6, IPV6_TCLASS, &class, sizeof(class)) == -1 ||
|
setsockopt(fd, IPPROTO_IPV6, IPV6_TCLASS, &class, sizeof(class)) == -1 ||
|
||||||
#endif
|
#endif
|
||||||
!fix_fd(fd) ||
|
!fix_fd(fd) ||
|
||||||
@@ -116,8 +117,7 @@ void icmp6_packet(void)
|
|||||||
char control6[CMSG_SPACE(sizeof(struct in6_pktinfo))];
|
char control6[CMSG_SPACE(sizeof(struct in6_pktinfo))];
|
||||||
} control_u;
|
} control_u;
|
||||||
struct sockaddr_in6 from;
|
struct sockaddr_in6 from;
|
||||||
unsigned char *p;
|
unsigned char *packet;
|
||||||
char *mac = "";
|
|
||||||
struct iname *tmp;
|
struct iname *tmp;
|
||||||
struct dhcp_context *context;
|
struct dhcp_context *context;
|
||||||
|
|
||||||
@@ -133,6 +133,8 @@ void icmp6_packet(void)
|
|||||||
if ((sz = recv_dhcp_packet(daemon->icmp6fd, &msg)) == -1 || sz < 8)
|
if ((sz = recv_dhcp_packet(daemon->icmp6fd, &msg)) == -1 || sz < 8)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
packet = (unsigned char *)daemon->outpacket.iov_base;
|
||||||
|
|
||||||
for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr))
|
for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr))
|
||||||
if (cmptr->cmsg_level == IPPROTO_IPV6 && cmptr->cmsg_type == daemon->v6pktinfo)
|
if (cmptr->cmsg_level == IPPROTO_IPV6 && cmptr->cmsg_type == daemon->v6pktinfo)
|
||||||
{
|
{
|
||||||
@@ -160,36 +162,25 @@ void icmp6_packet(void)
|
|||||||
if (!context->interface || strcmp(context->interface, interface) == 0)
|
if (!context->interface || strcmp(context->interface, interface) == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (!context)
|
if (!context || packet[1] != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
p = (unsigned char *)daemon->outpacket.iov_base;
|
if (packet[0] == ICMP6_ECHO_REPLY)
|
||||||
|
lease_ping_reply(&from.sin6_addr, packet, interface);
|
||||||
if (p[1] != 0)
|
else if (packet[0] == ND_ROUTER_SOLICIT)
|
||||||
return;
|
|
||||||
|
|
||||||
if (p[0] == ICMP6_ECHO_REPLY)
|
|
||||||
{
|
{
|
||||||
/* We may be doing RA but not DHCPv4, in which case the lease
|
char *mac = "";
|
||||||
database may not exist and we have nothing to do anyway */
|
|
||||||
if (daemon->dhcp)
|
/* look for link-layer address option for logging */
|
||||||
lease_ping_reply(&from.sin6_addr, p, interface);
|
if (sz >= 16 && packet[8] == ICMP6_OPT_SOURCE_MAC && (packet[9] * 8) + 8 <= sz)
|
||||||
return;
|
{
|
||||||
|
print_mac(daemon->namebuff, &packet[10], (packet[9] * 8) - 2);
|
||||||
|
mac = daemon->namebuff;
|
||||||
|
}
|
||||||
|
|
||||||
|
my_syslog(MS_DHCP | LOG_INFO, "RTR-SOLICIT(%s) %s", interface, mac);
|
||||||
|
send_ra(if_index, interface, &from.sin6_addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p[0] != ND_ROUTER_SOLICIT)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* look for link-layer address option for logging */
|
|
||||||
if (sz >= 16 && p[8] == ICMP6_OPT_SOURCE_MAC && (p[9] * 8) + 8 <= sz)
|
|
||||||
{
|
|
||||||
print_mac(daemon->namebuff, &p[10], (p[9] * 8) - 2);
|
|
||||||
mac = daemon->namebuff;
|
|
||||||
}
|
|
||||||
|
|
||||||
my_syslog(MS_DHCP | LOG_INFO, "RTR-SOLICIT(%s) %s", interface, mac);
|
|
||||||
|
|
||||||
send_ra(if_index, interface, &from.sin6_addr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void send_ra(int iface, char *iface_name, struct in6_addr *dest)
|
static void send_ra(int iface, char *iface_name, struct in6_addr *dest)
|
||||||
@@ -199,6 +190,9 @@ static void send_ra(int iface, char *iface_name, struct in6_addr *dest)
|
|||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
struct sockaddr_in6 addr;
|
struct sockaddr_in6 addr;
|
||||||
struct dhcp_context *context;
|
struct dhcp_context *context;
|
||||||
|
struct dhcp_netid iface_id;
|
||||||
|
struct dhcp_opt *opt_cfg;
|
||||||
|
int done_dns = 0;
|
||||||
|
|
||||||
save_counter(0);
|
save_counter(0);
|
||||||
ra = expand(sizeof(struct ra_packet));
|
ra = expand(sizeof(struct ra_packet));
|
||||||
@@ -218,8 +212,16 @@ static void send_ra(int iface, char *iface_name, struct in6_addr *dest)
|
|||||||
parm.if_name = iface_name;
|
parm.if_name = iface_name;
|
||||||
parm.first = 1;
|
parm.first = 1;
|
||||||
|
|
||||||
|
/* set tag with name == interface */
|
||||||
|
iface_id.net = iface_name;
|
||||||
|
iface_id.next = NULL;
|
||||||
|
parm.tags = &iface_id;
|
||||||
|
|
||||||
for (context = daemon->ra_contexts; context; context = context->next)
|
for (context = daemon->ra_contexts; context; context = context->next)
|
||||||
context->flags &= ~CONTEXT_RA_DONE;
|
{
|
||||||
|
context->flags &= ~CONTEXT_RA_DONE;
|
||||||
|
context->netid.next = &context->netid;
|
||||||
|
}
|
||||||
|
|
||||||
if (!iface_enumerate(AF_INET6, &parm, add_prefixes) ||
|
if (!iface_enumerate(AF_INET6, &parm, add_prefixes) ||
|
||||||
!parm.found_context)
|
!parm.found_context)
|
||||||
@@ -237,13 +239,62 @@ static void send_ra(int iface, char *iface_name, struct in6_addr *dest)
|
|||||||
|
|
||||||
iface_enumerate(AF_LOCAL, &iface, add_lla);
|
iface_enumerate(AF_LOCAL, &iface, add_lla);
|
||||||
|
|
||||||
/* RDNSS, RFC 6106 */
|
/* RDNSS, RFC 6106, use relevant DHCP6 options */
|
||||||
put_opt6_char(ICMP6_OPT_RDNSS);
|
(void)option_filter(parm.tags, NULL, daemon->dhcp_opts6);
|
||||||
put_opt6_char(3);
|
|
||||||
put_opt6_short(0);
|
|
||||||
put_opt6_long(1800); /* lifetime - twice RA retransmit */
|
|
||||||
put_opt6(&parm.link_local, IN6ADDRSZ);
|
|
||||||
|
|
||||||
|
for (opt_cfg = daemon->dhcp_opts6; opt_cfg; opt_cfg = opt_cfg->next)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* netids match and not encapsulated? */
|
||||||
|
if (!(opt_cfg->flags & DHOPT_TAGOK))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (opt_cfg->opt == OPTION6_DNS_SERVER)
|
||||||
|
{
|
||||||
|
struct in6_addr *a = (struct in6_addr *)opt_cfg->val;
|
||||||
|
|
||||||
|
done_dns = 1;
|
||||||
|
if (opt_cfg->len == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
put_opt6_char(ICMP6_OPT_RDNSS);
|
||||||
|
put_opt6_char((opt_cfg->len/8) + 1);
|
||||||
|
put_opt6_short(0);
|
||||||
|
put_opt6_long(1800); /* lifetime - twice RA retransmit */
|
||||||
|
/* zero means "self" */
|
||||||
|
for (i = 0; i < opt_cfg->len; i += IN6ADDRSZ, a++)
|
||||||
|
if (IN6_IS_ADDR_UNSPECIFIED(a))
|
||||||
|
put_opt6(&parm.link_local, IN6ADDRSZ);
|
||||||
|
else
|
||||||
|
put_opt6(a, IN6ADDRSZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opt_cfg->opt == OPTION6_DOMAIN_SEARCH && opt_cfg->len != 0)
|
||||||
|
{
|
||||||
|
int len = ((opt_cfg->len+7)/8);
|
||||||
|
|
||||||
|
put_opt6_char(ICMP6_OPT_DNSSL);
|
||||||
|
put_opt6_char(len + 1);
|
||||||
|
put_opt6_short(0);
|
||||||
|
put_opt6_long(1800); /* lifetime - twice RA retransmit */
|
||||||
|
put_opt6(opt_cfg->val, opt_cfg->len);
|
||||||
|
|
||||||
|
/* pad */
|
||||||
|
for (i = opt_cfg->len; i < len * 8; i++)
|
||||||
|
put_opt6_char(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!done_dns)
|
||||||
|
{
|
||||||
|
/* default == us. */
|
||||||
|
put_opt6_char(ICMP6_OPT_RDNSS);
|
||||||
|
put_opt6_char(3);
|
||||||
|
put_opt6_short(0);
|
||||||
|
put_opt6_long(1800); /* lifetime - twice RA retransmit */
|
||||||
|
put_opt6(&parm.link_local, IN6ADDRSZ);
|
||||||
|
}
|
||||||
|
|
||||||
/* 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)
|
||||||
@@ -276,7 +327,6 @@ static void send_ra(int iface, char *iface_name, struct in6_addr *dest)
|
|||||||
static int add_prefixes(struct in6_addr *local, int prefix,
|
static int add_prefixes(struct in6_addr *local, int prefix,
|
||||||
int scope, int if_index, int dad, void *vparam)
|
int scope, int if_index, int dad, void *vparam)
|
||||||
{
|
{
|
||||||
struct dhcp_context *context;
|
|
||||||
struct ra_param *param = vparam;
|
struct ra_param *param = vparam;
|
||||||
|
|
||||||
(void)scope; /* warning */
|
(void)scope; /* warning */
|
||||||
@@ -290,11 +340,11 @@ static int add_prefixes(struct in6_addr *local, int prefix,
|
|||||||
!IN6_IS_ADDR_LINKLOCAL(local) &&
|
!IN6_IS_ADDR_LINKLOCAL(local) &&
|
||||||
!IN6_IS_ADDR_MULTICAST(local))
|
!IN6_IS_ADDR_MULTICAST(local))
|
||||||
{
|
{
|
||||||
|
int do_prefix = 0;
|
||||||
int do_slaac = 0;
|
int do_slaac = 0;
|
||||||
int deprecate = 0;
|
int deprecate = 0;
|
||||||
unsigned int time = 0xffffffff;
|
unsigned int time = 0xffffffff;
|
||||||
struct in6_addr *addr = NULL;
|
struct dhcp_context *context;
|
||||||
struct prefix_opt *opt;
|
|
||||||
|
|
||||||
for (context = daemon->ra_contexts; context; context = context->next)
|
for (context = daemon->ra_contexts; context; context = context->next)
|
||||||
if (prefix == context->prefix &&
|
if (prefix == context->prefix &&
|
||||||
@@ -305,8 +355,12 @@ static int add_prefixes(struct in6_addr *local, int prefix,
|
|||||||
(CONTEXT_RA_ONLY | CONTEXT_RA_NAME | CONTEXT_RA_STATELESS)))
|
(CONTEXT_RA_ONLY | CONTEXT_RA_NAME | CONTEXT_RA_STATELESS)))
|
||||||
{
|
{
|
||||||
do_slaac = 1;
|
do_slaac = 1;
|
||||||
if (context->flags & CONTEXT_RA_STATELESS)
|
if (context->flags & CONTEXT_DHCP)
|
||||||
param->other = 1;
|
{
|
||||||
|
param->other = 1;
|
||||||
|
if (!(context->flags & CONTEXT_RA_STATELESS))
|
||||||
|
param->managed = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -331,36 +385,46 @@ static int add_prefixes(struct in6_addr *local, int prefix,
|
|||||||
param->first = 0;
|
param->first = 0;
|
||||||
param->found_context = 1;
|
param->found_context = 1;
|
||||||
|
|
||||||
if (context->flags & CONTEXT_RA_DONE)
|
/* collect dhcp-range tags */
|
||||||
continue;
|
if (context->netid.next == &context->netid && context->netid.net)
|
||||||
|
{
|
||||||
|
context->netid.next = param->tags;
|
||||||
|
param->tags = &context->netid;
|
||||||
|
}
|
||||||
|
|
||||||
context->flags |= CONTEXT_RA_DONE;
|
if (!(context->flags & CONTEXT_RA_DONE))
|
||||||
addr = &context->start6;
|
{
|
||||||
|
context->flags |= CONTEXT_RA_DONE;
|
||||||
|
do_prefix = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addr && (opt = expand(sizeof(struct prefix_opt))))
|
if (do_prefix)
|
||||||
{
|
{
|
||||||
u64 addrpart = addr6part(addr);
|
struct prefix_opt *opt;
|
||||||
u64 mask = (prefix == 64) ? (u64)-1LL : (1LLU << (128 - prefix)) - 1LLU;
|
|
||||||
|
|
||||||
/* lifetimes must be min 2 hrs, by RFC 2462 */
|
if ((opt = expand(sizeof(struct prefix_opt))))
|
||||||
if (time < 7200)
|
{
|
||||||
time = 7200;
|
/* zero net part of address */
|
||||||
|
setaddr6part(local, addr6part(local) & ~((prefix == 64) ? (u64)-1LL : (1LLU << (128 - prefix)) - 1LLU));
|
||||||
|
|
||||||
opt->type = ICMP6_OPT_PREFIX;
|
/* lifetimes must be min 2 hrs, by RFC 2462 */
|
||||||
opt->len = 4;
|
if (time < 7200)
|
||||||
opt->prefix_len = prefix;
|
time = 7200;
|
||||||
/* autonomous only is we're not doing dhcp */
|
|
||||||
opt->flags = do_slaac ? 0x40 : 0x00;
|
|
||||||
opt->valid_lifetime = htonl(time);
|
|
||||||
opt->preferred_lifetime = htonl(deprecate ? 0 : time);
|
|
||||||
opt->reserved = 0;
|
|
||||||
|
|
||||||
opt->prefix = *addr;
|
opt->type = ICMP6_OPT_PREFIX;
|
||||||
setaddr6part(&opt->prefix, addrpart & ~mask);
|
opt->len = 4;
|
||||||
|
opt->prefix_len = prefix;
|
||||||
|
/* autonomous only if we're not doing dhcp */
|
||||||
|
opt->flags = do_slaac ? 0x40 : 0x00;
|
||||||
|
opt->valid_lifetime = htonl(time);
|
||||||
|
opt->preferred_lifetime = htonl(deprecate ? 0 : time);
|
||||||
|
opt->reserved = 0;
|
||||||
|
opt->prefix = *local;
|
||||||
|
|
||||||
inet_ntop(AF_INET6, &opt->prefix, daemon->addrbuff, ADDRSTRLEN);
|
inet_ntop(AF_INET6, local, daemon->addrbuff, ADDRSTRLEN);
|
||||||
my_syslog(MS_DHCP | LOG_INFO, "RTR-ADVERT(%s) %s", param->if_name, daemon->addrbuff);
|
my_syslog(MS_DHCP | LOG_INFO, "RTR-ADVERT(%s) %s", param->if_name, daemon->addrbuff);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-19
@@ -349,28 +349,28 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
|
|||||||
|
|
||||||
if (len != 0 && len < 255)
|
if (len != 0 && len < 255)
|
||||||
{
|
{
|
||||||
unsigned char *pp, *op = opt6_ptr(opt, 1);
|
unsigned char *pp, *op = opt6_ptr(opt, 1);
|
||||||
char *pq = daemon->dhcp_buff;
|
char *pq = daemon->dhcp_buff;
|
||||||
|
|
||||||
pp = op;
|
pp = op;
|
||||||
while (*op != 0 && ((op + (*op) + 1) - pp) < len)
|
while (*op != 0 && ((op + (*op)) - pp) < len)
|
||||||
{
|
{
|
||||||
memcpy(pq, op+1, *op);
|
memcpy(pq, op+1, *op);
|
||||||
pq += *op;
|
pq += *op;
|
||||||
op += (*op)+1;
|
op += (*op)+1;
|
||||||
*(pq++) = '.';
|
*(pq++) = '.';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pq != daemon->dhcp_buff)
|
if (pq != daemon->dhcp_buff)
|
||||||
pq--;
|
pq--;
|
||||||
*pq = 0;
|
*pq = 0;
|
||||||
|
|
||||||
if (legal_hostname(daemon->dhcp_buff))
|
if (legal_hostname(daemon->dhcp_buff))
|
||||||
{
|
{
|
||||||
client_hostname = daemon->dhcp_buff;
|
client_hostname = daemon->dhcp_buff;
|
||||||
if (option_bool(OPT_LOG_OPTS))
|
if (option_bool(OPT_LOG_OPTS))
|
||||||
my_syslog(MS_DHCP | LOG_INFO, _("%u client provides name: %s"), xid, client_hostname);
|
my_syslog(MS_DHCP | LOG_INFO, _("%u client provides name: %s"), xid, client_hostname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user