diff mbox

[OpenWrt-Devel,v2] netifd: Request DHCP option 121 (classless route) by default

Message ID 1448059856-8493-1-git-send-email-baptiste@bitsofnetworks.org
State Changes Requested
Headers show

Commit Message

Baptiste Jonglez Nov. 20, 2015, 10:50 p.m. UTC
From: Baptiste Jonglez <git@bitsofnetworks.org>

This option is useful when the gateway configured by DHCP cannot be in
the same subnet as the client.  This happens, for instance, when using
DHCP to hand out addresses in /32 subnets.

A new configuration option "classlessroute" is available, allowing
users to disable this feature (the option defaults to true).

Signed-off-by: Baptiste Jonglez <git@bitsofnetworks.org>
---
 package/network/config/netifd/files/lib/netifd/proto/dhcp.sh | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Baptiste Jonglez Dec. 20, 2015, 10:27 a.m. UTC | #1
Hi,

Any news on this patch?  As requested, the v2 patch introduces a
configuration knob to disable requesting option 121.

Thanks,
Baptiste

On Fri, Nov 20, 2015 at 11:50:56PM +0100, Baptiste Jonglez wrote:
> From: Baptiste Jonglez <git@bitsofnetworks.org>
> 
> This option is useful when the gateway configured by DHCP cannot be in
> the same subnet as the client.  This happens, for instance, when using
> DHCP to hand out addresses in /32 subnets.
> 
> A new configuration option "classlessroute" is available, allowing
> users to disable this feature (the option defaults to true).
> 
> Signed-off-by: Baptiste Jonglez <git@bitsofnetworks.org>
> ---
>  package/network/config/netifd/files/lib/netifd/proto/dhcp.sh | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh b/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh
> index 0e88af9..aae0e44 100755
> --- a/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh
> +++ b/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh
> @@ -20,14 +20,15 @@ proto_dhcp_init_config() {
>  	proto_config_add_string zone
>  	proto_config_add_string mtu6rd
>  	proto_config_add_string customroutes
> +	proto_config_add_boolean classlessroute
>  }
>  
>  proto_dhcp_setup() {
>  	local config="$1"
>  	local iface="$2"
>  
> -	local ipaddr hostname clientid vendorid broadcast reqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes
> -	json_get_vars ipaddr hostname clientid vendorid broadcast reqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes
> +	local ipaddr hostname clientid vendorid broadcast reqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes classlessroute
> +	json_get_vars ipaddr hostname clientid vendorid broadcast reqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes classlessroute
>  
>  	local opt dhcpopts
>  	for opt in $reqopts; do
> @@ -47,6 +48,8 @@ proto_dhcp_setup() {
>  	[ -n "$mtu6rd" ] && proto_export "MTU6RD=$mtu6rd"
>  	[ -n "$customroutes" ] && proto_export "CUSTOMROUTES=$customroutes"
>  	[ "$delegate" = "0" ] && proto_export "IFACE6RD_DELEGATE=0"
> +	# Request classless route option (see RFC 3442) by default
> +	[ "$classlessroute" = "0" ] || append dhcpopts "-O 121"
>  
>  	proto_export "INTERFACE=$config"
>  	proto_run_command "$config" udhcpc \
diff mbox

Patch

diff --git a/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh b/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh
index 0e88af9..aae0e44 100755
--- a/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh
+++ b/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh
@@ -20,14 +20,15 @@  proto_dhcp_init_config() {
 	proto_config_add_string zone
 	proto_config_add_string mtu6rd
 	proto_config_add_string customroutes
+	proto_config_add_boolean classlessroute
 }
 
 proto_dhcp_setup() {
 	local config="$1"
 	local iface="$2"
 
-	local ipaddr hostname clientid vendorid broadcast reqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes
-	json_get_vars ipaddr hostname clientid vendorid broadcast reqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes
+	local ipaddr hostname clientid vendorid broadcast reqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes classlessroute
+	json_get_vars ipaddr hostname clientid vendorid broadcast reqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes classlessroute
 
 	local opt dhcpopts
 	for opt in $reqopts; do
@@ -47,6 +48,8 @@  proto_dhcp_setup() {
 	[ -n "$mtu6rd" ] && proto_export "MTU6RD=$mtu6rd"
 	[ -n "$customroutes" ] && proto_export "CUSTOMROUTES=$customroutes"
 	[ "$delegate" = "0" ] && proto_export "IFACE6RD_DELEGATE=0"
+	# Request classless route option (see RFC 3442) by default
+	[ "$classlessroute" = "0" ] || append dhcpopts "-O 121"
 
 	proto_export "INTERFACE=$config"
 	proto_run_command "$config" udhcpc \