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

Fix dhcp-range sanity checking.

parent a37cd7aa
...@@ -2401,11 +2401,9 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma ...@@ -2401,11 +2401,9 @@ 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++)
{ {
if (strcmp(a[leasepos], "static") == 0) if (strcmp(a[leasepos], "static") == 0)
...@@ -2431,10 +2429,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma ...@@ -2431,10 +2429,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
else else
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,20 +2441,26 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma ...@@ -2446,20 +2441,26 @@ 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->flags & (CONTEXT_RA_ONLY | CONTEXT_RA_NAME | CONTEXT_RA_STATELESS)))
ret_err(_("prefix must be exactly 64 for RA subnets"));
else if (new->template_interface)
ret_err(_("prefix must be exactly 64 for subnet constructors"));
}
if (new->prefix < 64)
ret_err(_("prefix must be at least 64"));
} }
} }
if (new->prefix != 64)
{
if ((new->flags & (CONTEXT_RA_ONLY | CONTEXT_RA_NAME | CONTEXT_RA_STATELESS)))
ret_err(_("prefix length must be exactly 64 for RA subnets"));
else if (new->flags & CONTEXT_TEMPLATE)
ret_err(_("prefix length must be exactly 64 for subnet constructors"));
}
if (new->prefix < 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)
{ {
......
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