dhclient-script: fix bound

Message ID 1503926835-2098-1-git-send-email-jonatan.schlag@ipfire.org
State New
Headers show
Series
  • dhclient-script: fix bound
Related show

Commit Message

Jonatan Schlag Aug. 28, 2017, 1:27 p.m.
When we get a BOUND we should have only new_* variables set.
So it is stated in the manpage.
Apparently, also old_* variables are set so we never got into the block where the IP address was set.
We now always set a new IP Address when we get a BOUND.

Fixes: #11363

Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
---
 src/dhclient-script | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Michael Tremer Sept. 7, 2017, 7:46 p.m. | #1
Thanks for investigating this one. It was a tough one. Great work!

-Michael

On Mon, 2017-08-28 at 15:27 +0200, Jonatan Schlag wrote:
> When we get a BOUND we should have only new_* variables set.
> So it is stated in the manpage.
> Apparently, also old_* variables are set so we never got into the block where
> the IP address was set.
> We now always set a new IP Address when we get a BOUND.
> 
> Fixes: #11363
> 
> Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
> ---
>  src/dhclient-script | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/src/dhclient-script b/src/dhclient-script
> index c2e0678..ec990bf 100644
> --- a/src/dhclient-script
> +++ b/src/dhclient-script
> @@ -197,7 +197,8 @@ case "${reason}" in
>  
>  	BOUND|RENEW|REBIND|REBOOT)
>  		# Check if the IP address has changed. If so, delete all
> routes and stuff.
> -		if [ -n "${old_ip_address}" -a "${old_ip_address}" !=
> "${new_ip_address}" ]; then
> +		if [ -n "${old_ip_address}" -a "${old_ip_address}" !=
> "${new_ip_address}" ] || \
> +			[ "${reason}" = "BOUND" ]; then
>  			ipv4_flush_device ${interface}
>  		fi
>  
> @@ -208,7 +209,8 @@ case "${reason}" in
>  					[ ! "${old_network_number}" =
> "${new_network_number}" ] || \
>  					[ ! "${old_broadcast_address}" =
> "${new_broadcast_address}" ] || \
>  					[ ! "${old_routers}" =
> "${new_routers}" ] || \
> -					[ ! "${old_interface_mtu}" =
> "${new_interface_mtu}" ]; then
> +					[ ! "${old_interface_mtu}" =
> "${new_interface_mtu}" ] || \
> +					[ "${reason}" = "BOUND" ]; then
>  
>  
>  					# Calc the prefix from the subnet
> mask

Patch

diff --git a/src/dhclient-script b/src/dhclient-script
index c2e0678..ec990bf 100644
--- a/src/dhclient-script
+++ b/src/dhclient-script
@@ -197,7 +197,8 @@  case "${reason}" in
 
 	BOUND|RENEW|REBIND|REBOOT)
 		# Check if the IP address has changed. If so, delete all routes and stuff.
-		if [ -n "${old_ip_address}" -a "${old_ip_address}" != "${new_ip_address}" ]; then
+		if [ -n "${old_ip_address}" -a "${old_ip_address}" != "${new_ip_address}" ] || \
+			[ "${reason}" = "BOUND" ]; then
 			ipv4_flush_device ${interface}
 		fi
 
@@ -208,7 +209,8 @@  case "${reason}" in
 					[ ! "${old_network_number}" = "${new_network_number}" ] || \
 					[ ! "${old_broadcast_address}" = "${new_broadcast_address}" ] || \
 					[ ! "${old_routers}" = "${new_routers}" ] || \
-					[ ! "${old_interface_mtu}" = "${new_interface_mtu}" ]; then
+					[ ! "${old_interface_mtu}" = "${new_interface_mtu}" ] || \
+					[ "${reason}" = "BOUND" ]; then
 
 
 					# Calc the prefix from the subnet mask