[3/3] dhcpcd: Allow freely setting MTU

Message ID 20220222121806.1208994-3-michael.tremer@ipfire.org
State Accepted
Commit 7cdd550577065923b0430e79fa1fe6c722911840
Headers
Series [1/3] dhcpcd: Force setting MTU through dhcpcd |

Commit Message

Michael Tremer Feb. 22, 2022, 12:18 p.m. UTC
  Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
---
 lfs/dhcpcd                                    |  1 +
 ...ow-free-selection-of-MTU-by-the-user.patch | 44 +++++++++++++++++++
 2 files changed, 45 insertions(+)
 create mode 100644 src/patches/dhcpcd-9.4.0-Allow-free-selection-of-MTU-by-the-user.patch
  

Comments

Peter Müller Feb. 22, 2022, 7:17 p.m. UTC | #1
Reviewed-by: Peter Müller <peter.mueller@ipfire.org>

> Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
> ---
>   lfs/dhcpcd                                    |  1 +
>   ...ow-free-selection-of-MTU-by-the-user.patch | 44 +++++++++++++++++++
>   2 files changed, 45 insertions(+)
>   create mode 100644 src/patches/dhcpcd-9.4.0-Allow-free-selection-of-MTU-by-the-user.patch
> 
> diff --git a/lfs/dhcpcd b/lfs/dhcpcd
> index 8291d076a..03349ddc7 100644
> --- a/lfs/dhcpcd
> +++ b/lfs/dhcpcd
> @@ -70,6 +70,7 @@ $(subst %,%_MD5,$(objects)) :
>   $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
>   	@$(PREBUILD)
>   	@rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE)
> +	cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/dhcpcd-9.4.0-Allow-free-selection-of-MTU-by-the-user.patch
>   	cd $(DIR_APP) && ./configure \
>   			--prefix="" \
>   			--sysconfdir=/var/ipfire/dhcpc \
> diff --git a/src/patches/dhcpcd-9.4.0-Allow-free-selection-of-MTU-by-the-user.patch b/src/patches/dhcpcd-9.4.0-Allow-free-selection-of-MTU-by-the-user.patch
> new file mode 100644
> index 000000000..69a35daf5
> --- /dev/null
> +++ b/src/patches/dhcpcd-9.4.0-Allow-free-selection-of-MTU-by-the-user.patch
> @@ -0,0 +1,44 @@
> +From 1acff721a3874a74efc9921a1e07bd48bd7efab0 Mon Sep 17 00:00:00 2001
> +From: Michael Tremer <michael.tremer@ipfire.org>
> +Date: Tue, 22 Feb 2022 12:07:15 +0000
> +Subject: [PATCH] Allow free selection of MTU by the user
> +
> +Various ISPs (or equipment?) seem to hand out an MTU of only 576 bytes.
> +Hwoever, this does not seem to be intentional which is why we would like
> +to manually overwrite this in the configuration.
> +
> +dhcpcd only allows setting a maximum MTU of 1472 bytes which does not
> +seem to have any rationale (any more). Although Ethernet might limit any
> +MTU to less, IPv6 and IPv4 support MTUs of up to 64KiB.
> +
> +This patch allows the user to configure the MTU freely with providing
> +some sanity check.
> +
> +Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
> +---
> + src/dhcp-common.h | 9 +++++----
> + 1 file changed, 5 insertions(+), 4 deletions(-)
> +
> +diff --git a/src/dhcp-common.h b/src/dhcp-common.h
> +index a82fcd4c..d6620822 100644
> +--- a/src/dhcp-common.h
> ++++ b/src/dhcp-common.h
> +@@ -46,10 +46,11 @@
> + #define NS_MAXLABEL MAXLABEL
> + #endif
> +
> +-/* Max MTU - defines dhcp option length */
> +-#define	IP_UDP_SIZE		  28
> +-#define	MTU_MAX			1500 - IP_UDP_SIZE
> +-#define	MTU_MIN			 576 + IP_UDP_SIZE
> ++/* Max/Min MTU */
> ++#define	MTU_MAX			65536
> ++#define	MTU_MIN			  576
> ++
> ++#define	IP_UDP_SIZE		   28
> +
> + #define	OT_REQUEST		(1 << 0)
> + #define	OT_UINT8		(1 << 1)
> +--
> +2.30.2
> +
  

Patch

diff --git a/lfs/dhcpcd b/lfs/dhcpcd
index 8291d076a..03349ddc7 100644
--- a/lfs/dhcpcd
+++ b/lfs/dhcpcd
@@ -70,6 +70,7 @@  $(subst %,%_MD5,$(objects)) :
 $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
 	@$(PREBUILD)
 	@rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE)
+	cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/dhcpcd-9.4.0-Allow-free-selection-of-MTU-by-the-user.patch
 	cd $(DIR_APP) && ./configure \
 			--prefix="" \
 			--sysconfdir=/var/ipfire/dhcpc \
diff --git a/src/patches/dhcpcd-9.4.0-Allow-free-selection-of-MTU-by-the-user.patch b/src/patches/dhcpcd-9.4.0-Allow-free-selection-of-MTU-by-the-user.patch
new file mode 100644
index 000000000..69a35daf5
--- /dev/null
+++ b/src/patches/dhcpcd-9.4.0-Allow-free-selection-of-MTU-by-the-user.patch
@@ -0,0 +1,44 @@ 
+From 1acff721a3874a74efc9921a1e07bd48bd7efab0 Mon Sep 17 00:00:00 2001
+From: Michael Tremer <michael.tremer@ipfire.org>
+Date: Tue, 22 Feb 2022 12:07:15 +0000
+Subject: [PATCH] Allow free selection of MTU by the user
+
+Various ISPs (or equipment?) seem to hand out an MTU of only 576 bytes.
+Hwoever, this does not seem to be intentional which is why we would like
+to manually overwrite this in the configuration.
+
+dhcpcd only allows setting a maximum MTU of 1472 bytes which does not
+seem to have any rationale (any more). Although Ethernet might limit any
+MTU to less, IPv6 and IPv4 support MTUs of up to 64KiB.
+
+This patch allows the user to configure the MTU freely with providing
+some sanity check.
+
+Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
+---
+ src/dhcp-common.h | 9 +++++----
+ 1 file changed, 5 insertions(+), 4 deletions(-)
+
+diff --git a/src/dhcp-common.h b/src/dhcp-common.h
+index a82fcd4c..d6620822 100644
+--- a/src/dhcp-common.h
++++ b/src/dhcp-common.h
+@@ -46,10 +46,11 @@
+ #define NS_MAXLABEL MAXLABEL
+ #endif
+ 
+-/* Max MTU - defines dhcp option length */
+-#define	IP_UDP_SIZE		  28
+-#define	MTU_MAX			1500 - IP_UDP_SIZE
+-#define	MTU_MIN			 576 + IP_UDP_SIZE
++/* Max/Min MTU */
++#define	MTU_MAX			65536
++#define	MTU_MIN			  576
++
++#define	IP_UDP_SIZE		   28
+ 
+ #define	OT_REQUEST		(1 << 0)
+ #define	OT_UINT8		(1 << 1)
+-- 
+2.30.2
+