[1/3] dhcpcd: Force setting MTU through dhcpcd
Commit Message
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(-)
Comments
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
@@ -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