From: Thomas Markwalder Date: Wed, 12 Apr 2017 17:24:49 +0000 (-0400) Subject: [v4_1_esv] Execute pool statements separately in dhcpinform() X-Git-Tag: v4_1_esv_r15b1~27 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ca90a25308b6822eb975c8eb60da21ef6a0a4689;p=thirdparty%2Fdhcp.git [v4_1_esv] Execute pool statements separately in dhcpinform() Merged 43291a. --- diff --git a/RELNOTES b/RELNOTES index c04da0e54..1823537e2 100644 --- a/RELNOTES +++ b/RELNOTES @@ -74,6 +74,7 @@ by Eric Young (eay@cryptsoft.com). Prior to this the server only evaluated options down to the subnet scope. Thanks to Fernando Soto at BlueCat Networks for reporting the issue. [ISC-Bugs #43219] + [ISC-Bugs #45051] - When memory allocation fails in a repeated way the process writes "Run out of memory." on the standard error and exists with status 1. diff --git a/server/dhcp.c b/server/dhcp.c index 9d01f02d3..bbcb3cb93 100644 --- a/server/dhcp.c +++ b/server/dhcp.c @@ -3,7 +3,7 @@ DHCP Protocol engine. */ /* - * Copyright (c) 2004-2016 by Internet Systems Consortium, Inc. ("ISC") + * Copyright (c) 2004-2017 by Internet Systems Consortium, Inc. ("ISC") * Copyright (c) 1995-2003 by Internet Software Consortium * * Permission to use, copy, modify, and distribute this software for any @@ -975,7 +975,6 @@ void dhcpinform (packet, ms_nulltp) isc_boolean_t zeroed_ciaddr; struct interface_info *interface; int result; - struct lease* cip_lease = NULL; /* The client should set ciaddr to its IP address, but apparently it's common for clients not to do this, so we'll use their IP @@ -1063,25 +1062,34 @@ void dhcpinform (packet, ms_nulltp) outgoing.raw = &raw; if (subnet) { + + /* Execute statements network statements starting at the + * subnet level */ + execute_statements_in_scope(NULL, packet, NULL, NULL, + packet->options, options, + &global_scope, subnet->group, NULL); + /* If we have ciaddr, find its lease so we can find its pool. */ if (zeroed_ciaddr == ISC_FALSE) { + struct lease* cip_lease = NULL; + find_lease_by_ip_addr (&cip_lease, cip, MDL); - } - /* Execute statements starting at the pool scope if we can - * otherwise the subnet scope is a far as we can go. */ - execute_statements_in_scope((struct binding_value **)0, - packet, (struct lease *)0, - (struct client_state *)0, - packet->options, options, - &global_scope, - (cip_lease != NULL && - cip_lease->pool != NULL ? - cip_lease->pool->group : - subnet->group), NULL); - - if (cip_lease) { - lease_dereference (&cip_lease, MDL); + /* Overlay with pool options if ciaddr mapped to + * a lease. */ + if (cip_lease) { + if (cip_lease->pool && cip_lease->pool->group) { + execute_statements_in_scope( + NULL, packet, NULL, NULL, + packet->options, options, + &global_scope, + cip_lease->pool->group, + cip_lease->pool-> + shared_network->group); + } + + lease_dereference (&cip_lease, MDL); + } } }