Commit 6692a1a5 authored by Simon Kelley's avatar Simon Kelley

Fix dhcp-range sanity checking.

parent a37cd7aa
...@@ -2401,10 +2401,8 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma ...@@ -2401,10 +2401,8 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
{ {
new->prefix = 64; /* default */ new->prefix = 64; /* default */
new->end6 = new->start6; new->end6 = new->start6;
new->next = daemon->dhcp6;
/* dhcp-range=:: enables DHCP stateless on any interface */ daemon->dhcp6 = new;
if (IN6_IS_ADDR_UNSPECIFIED(&new->start6))
new->prefix = 0;
for (leasepos = 1; leasepos < k; leasepos++) for (leasepos = 1; leasepos < k; leasepos++)
{ {
...@@ -2432,9 +2430,6 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma ...@@ -2432,9 +2430,6 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
break; break;
} }
new->next = daemon->dhcp6;
daemon->dhcp6 = new;
/* bare integer < 128 is prefix value */ /* bare integer < 128 is prefix value */
if (leasepos < k) if (leasepos < k)
{ {
...@@ -2446,21 +2441,27 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma ...@@ -2446,21 +2441,27 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
{ {
new->prefix = pref; new->prefix = pref;
leasepos++; leasepos++;
}
}
if (new->prefix != 64) if (new->prefix != 64)
{ {
if ((new->flags & (CONTEXT_RA_ONLY | CONTEXT_RA_NAME | CONTEXT_RA_STATELESS))) if ((new->flags & (CONTEXT_RA_ONLY | CONTEXT_RA_NAME | CONTEXT_RA_STATELESS)))
ret_err(_("prefix must be exactly 64 for RA subnets")); ret_err(_("prefix length must be exactly 64 for RA subnets"));
else if (new->template_interface) else if (new->flags & CONTEXT_TEMPLATE)
ret_err(_("prefix must be exactly 64 for subnet constructors")); ret_err(_("prefix length must be exactly 64 for subnet constructors"));
} }
if (new->prefix < 64) if (new->prefix < 64)
ret_err(_("prefix must be at least 64")); ret_err(_("prefix length must be at least 64"));
}
}
if (!is_same_net6(&new->start6, &new->end6, new->prefix)) if (!is_same_net6(&new->start6, &new->end6, new->prefix))
ret_err(_("inconsistent DHCPv6 range")); ret_err(_("inconsistent DHCPv6 range"));
/* dhcp-range=:: enables DHCP stateless on any interface */
if (IN6_IS_ADDR_UNSPECIFIED(&new->start6) && !(new->flags & CONTEXT_TEMPLATE))
new->prefix = 0;
if (new->flags & CONTEXT_TEMPLATE) if (new->flags & CONTEXT_TEMPLATE)
{ {
struct in6_addr zero; struct in6_addr zero;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment