diff options
-rw-r--r-- | usr.sbin/dhcpd/options.c | 28 | ||||
-rw-r--r-- | usr.sbin/dhcpd/tables.c | 8 |
2 files changed, 32 insertions, 4 deletions
diff --git a/usr.sbin/dhcpd/options.c b/usr.sbin/dhcpd/options.c index 459ad6c8b75..6557d1eae5b 100644 --- a/usr.sbin/dhcpd/options.c +++ b/usr.sbin/dhcpd/options.c @@ -1,4 +1,4 @@ -/* $OpenBSD: options.c,v 1.28 2014/07/28 16:45:35 tobias Exp $ */ +/* $OpenBSD: options.c,v 1.29 2015/06/27 14:29:39 krw Exp $ */ /* DHCP options parsing and reassembly. */ @@ -227,6 +227,14 @@ create_priority_list(unsigned char *priority_list, unsigned char *prl, if (!prl) prl_len = 0; for(i = 0; i < prl_len; i++) { + /* CLASSLESS routes always have priority, sayeth RFC 3442. */ + if (prl[i] == DHO_CLASSLESS_STATIC_ROUTES || + prl[i] == DHO_CLASSLESS_MS_STATIC_ROUTES) { + priority_list[priority_len++] = prl[i]; + stored_list[prl[i]] = 1; + } + } + for(i = 0; i < prl_len; i++) { if (stored_list[prl[i]]) continue; priority_list[priority_len++] = prl[i]; @@ -379,6 +387,7 @@ store_options(unsigned char *buffer, int main_buffer_size, int buflen, code, cutoff, i, incr, ix, length, optstart, overflow; int second_cutoff; int bufix = 0; + int stored_classless = 0; overload &= 3; /* Only consider valid bits. */ @@ -406,6 +415,20 @@ store_options(unsigned char *buffer, int main_buffer_size, if (!options[code] || !tree_evaluate(options[code])) continue; + /* + * RFC 3442 says: + * + * When a DHCP client requests the Classless Static + * Routes option and also requests either or both of the + * Router option and the Static Routes option, and the + * DHCP server is sending Classless Static Routes options + * to that client, the server SHOULD NOT include the + * Router or Static Routes options. + */ + if ((code == DHO_ROUTERS || code == DHO_STATIC_ROUTES) && + stored_classless) + continue; + /* We should now have a constant length for the option. */ length = options[code]->len; @@ -449,6 +472,9 @@ zapfrags: else goto zapfrags; } + if (code == DHO_CLASSLESS_STATIC_ROUTES || + code == DHO_CLASSLESS_MS_STATIC_ROUTES) + stored_classless = 1; } if (bufix == (4 + (overload ? 3 : 0))) diff --git a/usr.sbin/dhcpd/tables.c b/usr.sbin/dhcpd/tables.c index 027af5d42c5..3633474d686 100644 --- a/usr.sbin/dhcpd/tables.c +++ b/usr.sbin/dhcpd/tables.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tables.c,v 1.10 2014/01/21 03:07:51 krw Exp $ */ +/* $OpenBSD: tables.c,v 1.11 2015/06/27 14:29:39 krw Exp $ */ /* Tables of information... */ @@ -340,6 +340,8 @@ unsigned char dhcp_option_default_priority_list[256] = { DHO_DHCP_CLIENT_IDENTIFIER, DHO_SUBNET_MASK, DHO_TIME_OFFSET, + DHO_CLASSLESS_STATIC_ROUTES, /* MUST be before DHO_ROUTERS! */ + DHO_CLASSLESS_MS_STATIC_ROUTES, /* DITTO! */ DHO_ROUTERS, DHO_TIME_SERVERS, DHO_NAME_SERVERS, @@ -399,7 +401,7 @@ unsigned char dhcp_option_default_priority_list[256] = { 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, - 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, + 120, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, @@ -411,7 +413,7 @@ unsigned char dhcp_option_default_priority_list[256] = { 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, - 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, + 240, 241, 242, 243, 244, 245, 246, 247, 248, 250, 251, 252, 253, 254 }; |