The DHCP server can instruct clients to configure a certain MTU.
This used to be done by setting the MTU of the interface. However, dhcpcd has changed this behaviour using routes to.
We used to have a modified version of the old mechanism which no longer works well with the new system and is therefore to be dropped.
This is the first commit in the series implementing the new behaviour and telling dhcpcd to use the configured MTU.
Fixes: #12563 Signed-off-by: Michael Tremer michael.tremer@ipfire.org --- src/initscripts/networking/functions.network | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/initscripts/networking/functions.network b/src/initscripts/networking/functions.network index 7ec50f436..eae4a7b7c 100644 --- a/src/initscripts/networking/functions.network +++ b/src/initscripts/networking/functions.network @@ -61,7 +61,7 @@ dhcpcd_start() { # This function will start a dhcpcd on a speciefied device.
local device="$1" - local dhcp_start="" + local dhcp_start=()
boot_mesg -n "Starting dhcpcd on the ${device} interface..."
@@ -76,11 +76,16 @@ dhcpcd_start() {
# Check if a DHCP hostname has been set. if [ -n "${RED_DHCP_HOSTNAME}" ]; then - dhcp_start+="-h ${RED_DHCP_HOSTNAME}" + dhcp_start+=( "-h" "${RED_DHCP_HOSTNAME}" ) + fi + + # Tell dhcpcd to use the configured MTU + if [ -n "${RED_DHCP_FORCE_MTU}" ]; then + dhcp_start+=( "--static" "mtu=${RED_DHCP_FORCE_MTU}" ) fi
# Start dhcpcd. - /sbin/dhcpcd ${dhcp_start} ${device} >/dev/null 2>&1 + /sbin/dhcpcd "${dhcp_start[@]}" ${device} >/dev/null 2>&1 ret="$?"
if [ "${ret}" -eq 0 ]; then
This is being replaced by adding the MTU option to any routes that dhcpcd installs.
Signed-off-by: Michael Tremer michael.tremer@ipfire.org --- config/dhcpc/dhcpcd-hooks/10-mtu | 33 -------------------------------- config/rootfiles/common/dhcpcd | 1 - lfs/dhcpcd | 1 - 3 files changed, 35 deletions(-) delete mode 100644 config/dhcpc/dhcpcd-hooks/10-mtu
diff --git a/config/dhcpc/dhcpcd-hooks/10-mtu b/config/dhcpc/dhcpcd-hooks/10-mtu deleted file mode 100644 index 8eb429751..000000000 --- a/config/dhcpc/dhcpcd-hooks/10-mtu +++ /dev/null @@ -1,33 +0,0 @@ -# Configure the MTU for the interface - -eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings) - -set_mtu() -{ - local mtu=$1 - ip link set "$interface" mtu "$mtu" - - # test for buggy nic that lose link at mtu set... - carrier=`cat /sys/class/net/$interface/carrier` - if [ "$carrier" == "0" ]; then - syslog info "Warning! Carrier loss after MTU set. Reinit needed..." - ip link set "$interface" down - ip link set "$interface" up - exit 1 - fi -} - -if [ -n "$new_interface_mtu" ] && $if_up; then - if [ $RED_DHCP_FORCE_MTU -ge 576 ]; then - new_interface_mtu=$RED_DHCP_FORCE_MTU - fi - if [ ! "$new_interface_mtu" == "$ifmtu" ]; then - # The smalled MTU dhcpcd can work with is 576 - if [ "$new_interface_mtu" -gt 576 ]; then - if set_mtu "$new_interface_mtu"; then - syslog info "MTU set to $new_interface_mtu" - fi - fi - fi -fi - diff --git a/config/rootfiles/common/dhcpcd b/config/rootfiles/common/dhcpcd index 672a47a30..d36b105f1 100644 --- a/config/rootfiles/common/dhcpcd +++ b/config/rootfiles/common/dhcpcd @@ -9,7 +9,6 @@ var/ipfire/dhcpc/dhcpcd-hooks #var/ipfire/dhcpc/dhcpcd-hooks/00-linux #var/ipfire/dhcpc/dhcpcd-hooks/01-test #var/ipfire/dhcpc/dhcpcd-hooks/02-dump -#var/ipfire/dhcpc/dhcpcd-hooks/10-mtu #var/ipfire/dhcpc/dhcpcd-hooks/30-hostname #var/ipfire/dhcpc/dhcpcd-hooks/70-dhcpcd.exe var/ipfire/dhcpc/dhcpcd-run-hooks diff --git a/lfs/dhcpcd b/lfs/dhcpcd index 8c4a593ad..8291d076a 100644 --- a/lfs/dhcpcd +++ b/lfs/dhcpcd @@ -90,7 +90,6 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) rm -f $(CONFIG_ROOT)/dhcpc/dhcpcd-hooks/50-ypbind
install -m 644 $(DIR_SRC)/config/dhcpc/dhcpcd.conf $(CONFIG_ROOT)/dhcpc/ - install -m 444 $(DIR_SRC)/config/dhcpc/dhcpcd-hooks/10-mtu $(CONFIG_ROOT)/dhcpc/dhcpcd-hooks
chown root:root $(CONFIG_ROOT)/dhcpc/dhcpcd.conf
Reviewed-by: Peter Müller peter.mueller@ipfire.org
This is being replaced by adding the MTU option to any routes that dhcpcd installs.
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
config/dhcpc/dhcpcd-hooks/10-mtu | 33 -------------------------------- config/rootfiles/common/dhcpcd | 1 - lfs/dhcpcd | 1 - 3 files changed, 35 deletions(-) delete mode 100644 config/dhcpc/dhcpcd-hooks/10-mtu
diff --git a/config/dhcpc/dhcpcd-hooks/10-mtu b/config/dhcpc/dhcpcd-hooks/10-mtu deleted file mode 100644 index 8eb429751..000000000 --- a/config/dhcpc/dhcpcd-hooks/10-mtu +++ /dev/null @@ -1,33 +0,0 @@ -# Configure the MTU for the interface
-eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
-set_mtu() -{
- local mtu=$1
- ip link set "$interface" mtu "$mtu"
- # test for buggy nic that lose link at mtu set...
- carrier=`cat /sys/class/net/$interface/carrier`
- if [ "$carrier" == "0" ]; then
syslog info "Warning! Carrier loss after MTU set. Reinit needed..."
ip link set "$interface" down
ip link set "$interface" up
exit 1
- fi
-}
-if [ -n "$new_interface_mtu" ] && $if_up; then
- if [ $RED_DHCP_FORCE_MTU -ge 576 ]; then
new_interface_mtu=$RED_DHCP_FORCE_MTU
- fi
- if [ ! "$new_interface_mtu" == "$ifmtu" ]; then
# The smalled MTU dhcpcd can work with is 576
if [ "$new_interface_mtu" -gt 576 ]; then
if set_mtu "$new_interface_mtu"; then
syslog info "MTU set to $new_interface_mtu"
fi
fi
- fi
-fi
diff --git a/config/rootfiles/common/dhcpcd b/config/rootfiles/common/dhcpcd index 672a47a30..d36b105f1 100644 --- a/config/rootfiles/common/dhcpcd +++ b/config/rootfiles/common/dhcpcd @@ -9,7 +9,6 @@ var/ipfire/dhcpc/dhcpcd-hooks #var/ipfire/dhcpc/dhcpcd-hooks/00-linux #var/ipfire/dhcpc/dhcpcd-hooks/01-test #var/ipfire/dhcpc/dhcpcd-hooks/02-dump -#var/ipfire/dhcpc/dhcpcd-hooks/10-mtu #var/ipfire/dhcpc/dhcpcd-hooks/30-hostname #var/ipfire/dhcpc/dhcpcd-hooks/70-dhcpcd.exe var/ipfire/dhcpc/dhcpcd-run-hooks diff --git a/lfs/dhcpcd b/lfs/dhcpcd index 8c4a593ad..8291d076a 100644 --- a/lfs/dhcpcd +++ b/lfs/dhcpcd @@ -90,7 +90,6 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) rm -f $(CONFIG_ROOT)/dhcpc/dhcpcd-hooks/50-ypbind
install -m 644 $(DIR_SRC)/config/dhcpc/dhcpcd.conf $(CONFIG_ROOT)/dhcpc/
install -m 444 $(DIR_SRC)/config/dhcpc/dhcpcd-hooks/10-mtu $(CONFIG_ROOT)/dhcpc/dhcpcd-hooks
chown root:root $(CONFIG_ROOT)/dhcpc/dhcpcd.conf
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 +
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
Reviewed-by: Peter Müller peter.mueller@ipfire.org
The DHCP server can instruct clients to configure a certain MTU.
This used to be done by setting the MTU of the interface. However, dhcpcd has changed this behaviour using routes to.
We used to have a modified version of the old mechanism which no longer works well with the new system and is therefore to be dropped.
This is the first commit in the series implementing the new behaviour and telling dhcpcd to use the configured MTU.
Fixes: #12563 Signed-off-by: Michael Tremer michael.tremer@ipfire.org
src/initscripts/networking/functions.network | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/initscripts/networking/functions.network b/src/initscripts/networking/functions.network index 7ec50f436..eae4a7b7c 100644 --- a/src/initscripts/networking/functions.network +++ b/src/initscripts/networking/functions.network @@ -61,7 +61,7 @@ dhcpcd_start() { # This function will start a dhcpcd on a speciefied device.
local device="$1"
- local dhcp_start=""
local dhcp_start=()
boot_mesg -n "Starting dhcpcd on the ${device} interface..."
@@ -76,11 +76,16 @@ dhcpcd_start() {
# Check if a DHCP hostname has been set. if [ -n "${RED_DHCP_HOSTNAME}" ]; then
dhcp_start+="-h ${RED_DHCP_HOSTNAME}"
dhcp_start+=( "-h" "${RED_DHCP_HOSTNAME}" )
fi
# Tell dhcpcd to use the configured MTU
if [ -n "${RED_DHCP_FORCE_MTU}" ]; then
dhcp_start+=( "--static" "mtu=${RED_DHCP_FORCE_MTU}" )
fi
# Start dhcpcd.
- /sbin/dhcpcd ${dhcp_start} ${device} >/dev/null 2>&1
/sbin/dhcpcd "${dhcp_start[@]}" ${device} >/dev/null 2>&1 ret="$?"
if [ "${ret}" -eq 0 ]; then