From patchwork Tue Feb 22 12:18:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tremer X-Patchwork-Id: 5220 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4K2yqs3tBnz3xgb for ; Tue, 22 Feb 2022 12:18:17 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4K2yqp2g7nz3wJ; Tue, 22 Feb 2022 12:18:14 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4K2yqn6KdBz2yrp; Tue, 22 Feb 2022 12:18:13 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4K2yqm00Wvz2xKb for ; Tue, 22 Feb 2022 12:18:11 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4K2yql1f00zXD; Tue, 22 Feb 2022 12:18:11 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1645532291; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=vb6ObdjNAQzhZdStwrhh9lq5nPQlPvFEBgaUWb46Bpo=; b=Hb7jnJ7d/EA+gQYA3pR1+X7AVlYDEwzTZ1nDYQwjWokGvCN7PfYs+B3q74Odunup+Nm1DW 6TnkivhpISx62BDA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1645532291; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=vb6ObdjNAQzhZdStwrhh9lq5nPQlPvFEBgaUWb46Bpo=; b=mnjIDCl2sS9uhq7vOBfmCq79SvVxqgv37rRygWVN8FkTBP0DwaykuTdkh5eU7Y3TDDBWt8 LIyw4EcYxoUXS1vryM+MlA4dCUT6Yc8xGkJln8L004z2d7O+lL4O6JNQ7O8jskFP1Hc0Is kh/IBEt/XODdwHQQBXbxSDh26NtJins+xpkHRhRiihG9oTR0SyLjoA2mv4dxdWfjTUEzGv 0R6S/cUu1G5YBRsbXI6bFA2n3TItDlUcLVKBlkl7RuldqiZ66S5fSXevrkUWkYPIwjbUke gSzolOsn/VdrmHYznvyeDGQkmypr3Ob/a6pcQYnW66IFpGeA8pEs7Ez1I2qpNg== From: Michael Tremer To: development@lists.ipfire.org Subject: [PATCH 1/3] dhcpcd: Force setting MTU through dhcpcd Date: Tue, 22 Feb 2022 12:18:04 +0000 Message-Id: <20220222121806.1208994-1-michael.tremer@ipfire.org> MIME-Version: 1.0 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Tremer Errors-To: development-bounces@lists.ipfire.org Sender: "Development" 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 Reviewed-by: Peter Müller --- 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 From patchwork Tue Feb 22 12:18:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tremer X-Patchwork-Id: 5219 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4K2yqs3nzjz3xgY for ; Tue, 22 Feb 2022 12:18:17 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4K2yqp2wz6z4n8; Tue, 22 Feb 2022 12:18:14 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4K2yqn6zCbz30H7; Tue, 22 Feb 2022 12:18:13 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4K2yqm02NYz2xVY for ; Tue, 22 Feb 2022 12:18:11 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4K2yql5QwJz29H; Tue, 22 Feb 2022 12:18:11 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1645532291; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MTmtPzIiEA4aYW6bNJFReul7dwl8afbYnLN/aQc+i24=; b=oyOhT1U5XAP+d3iLelGaBPjALxOKG9xO2u4V1HvpQvW/fOWklOXfYFFT4U6ihbyjyuY9i4 uh+5jvXB8pH1fvAg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1645532291; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MTmtPzIiEA4aYW6bNJFReul7dwl8afbYnLN/aQc+i24=; b=ePui7UQtUBQ/RLrtOXHbWcYa+PyTC2ei5NnJ9cf6hzQfASyI8lvyWoQCKt7z8I1Zix3Nt+ k3QZUoHXqNuamjlo1cjcyp33Pj7UJTNHgbNNwZnPPI64PMU7luu/6mznbhSyok9ky4XHcJ 530okazOI++/7hNp080w2V9dnLbNkm7VL9CkUsFo5hiq+9BHGEBhz0eKTn3PG3L7YSb3Bb yRy8/7myUph9lio4oTRDHLjaTOFiaI+yHzFcsAPZmMlmGPF4qmUH4Cfhh0Ys/n5+sw0EmH pWSTtGp2rFv//esZ87AwJao901AvjTaoR1OBP12Z6oyWozzoniSV/hhJHYRJFQ== From: Michael Tremer To: development@lists.ipfire.org Subject: [PATCH 2/3] dhcpcd: Remove old MTU setting script Date: Tue, 22 Feb 2022 12:18:05 +0000 Message-Id: <20220222121806.1208994-2-michael.tremer@ipfire.org> In-Reply-To: <20220222121806.1208994-1-michael.tremer@ipfire.org> References: <20220222121806.1208994-1-michael.tremer@ipfire.org> MIME-Version: 1.0 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Tremer Errors-To: development-bounces@lists.ipfire.org Sender: "Development" This is being replaced by adding the MTU option to any routes that dhcpcd installs. Signed-off-by: Michael Tremer Reviewed-by: Peter Müller --- 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 From patchwork Tue Feb 22 12:18:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tremer X-Patchwork-Id: 5221 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4K2yqt1177z3xgf for ; Tue, 22 Feb 2022 12:18:18 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4K2yqp45kPz5Qb; Tue, 22 Feb 2022 12:18:14 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4K2yqp0DJRz30Hd; Tue, 22 Feb 2022 12:18:14 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4K2yqm0PLdz2y3C for ; Tue, 22 Feb 2022 12:18:12 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4K2yql67b9z33v; Tue, 22 Feb 2022 12:18:11 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1645532291; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UOH9sDkLTssrtr/l58aKA8VgjMC6R5U2NDv5TtLgV00=; b=24DbEEZLLZwBQtERwNRTXQSJf3dg4r9mt3GCyKxNzqJrcQKApqbW8ciekrrf7xpTu9BNuI DdpXdbNnKB4OQDAQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1645532291; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UOH9sDkLTssrtr/l58aKA8VgjMC6R5U2NDv5TtLgV00=; b=wZTU1FK7ubXW8cn1KRIVK1uw1bXdchlE2ScWWeG862HBrxRYI9CiBCeP0w/HnMXo5AfRaK KKs6bSuj7mOvhmFIMZ09lCSDgT/NthHvckvoIz+FTzVOvN1LW3/ycqeShBZ5cz7wlCOBbp aF1LxGCG2OgqqfjCEi1DHyeA6Wce1uu/KnWWNbCSPRzKcoj8peU1mua/qZX5rnc1o1Yy3v h5A5WyY4qr2VNY9ivUCw2nK/uihJxFUY9iTE9/RQ1sqxfCi5RVgifnrkXNMLZWXfGA1nud uPL3cPEv0Fq3LvFe7dfWK6S3NvdoNslM9xAQfWemaldx/oPABgfw6ecuA6PvUg== From: Michael Tremer To: development@lists.ipfire.org Subject: [PATCH 3/3] dhcpcd: Allow freely setting MTU Date: Tue, 22 Feb 2022 12:18:06 +0000 Message-Id: <20220222121806.1208994-3-michael.tremer@ipfire.org> In-Reply-To: <20220222121806.1208994-1-michael.tremer@ipfire.org> References: <20220222121806.1208994-1-michael.tremer@ipfire.org> MIME-Version: 1.0 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Tremer Errors-To: development-bounces@lists.ipfire.org Sender: "Development" Signed-off-by: Michael Tremer Reviewed-by: Peter Müller --- 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 +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 +--- + 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 +