From 5969fb1c0e26fc360c59b8990aa5548830ed84de Mon Sep 17 00:00:00 2001 From: Graham Matuszewski Date: Sat, 4 Mar 2023 19:19:43 -0500 Subject: [PATCH 01/15] Add option to set the MSS value through iptables --- 11-change-ppp-mtu.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/11-change-ppp-mtu.sh b/11-change-ppp-mtu.sh index 28c489f..1b01be2 100644 --- a/11-change-ppp-mtu.sh +++ b/11-change-ppp-mtu.sh @@ -5,6 +5,7 @@ MINTERFACES="(ppp0)" # Desired MTU of PPP interfaces PTARGET=1500 +SET_MSS=true function check_mtu { ip link list | grep -E $MINTERFACES | grep 'mtu '$PTARGET > /dev/null @@ -54,6 +55,19 @@ while true; do ip link set $pinterface mtu $PTARGET fi done + + if [[ $SET_MSS ]]; then + echo "Checking if iptables MSS Value needs to be updated" + currentMSS=$(iptables -L -t mangle --line-numbers | grep -m 1 'SYN,RST/SYN TCPMSS' | sed 's/.*set \([0-9]\{4\}\).*/\1/') + targetMSS=$(($PTARGET-40)) + if [[ $currentMSS -ne $targetMSS ]]; then + echo "Updating MSS from $currentMSS to $targetMSS" + while [[ $(iptables -L -t mangle --line-numbers | grep 'SYN,RST/SYN TCPMSS') ]]; do + iptables -t mangle -D UBIOS_FORWARD_TCPMSS 1 + done + iptables -t mangle -A UBIOS_FORWARD_TCPMSS -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss $targetMSS + fi + fi # Kill pppd to apply changes (it gets restarted automatically) # This does take down existing ppp links but as pppd comes straight back up, so should the links # Only kill pppd if there are ppp interfaces active and changes were made From e7722b1dc7f9ae4a3ba8be097f6fa2d52b7d67a5 Mon Sep 17 00:00:00 2001 From: Graham Matuszewski Date: Sat, 4 Mar 2023 19:23:37 -0500 Subject: [PATCH 02/15] Add debug version of MSS iptables modification --- 11-change-ppp-mtu-debug.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/11-change-ppp-mtu-debug.sh b/11-change-ppp-mtu-debug.sh index 329db15..524be36 100644 --- a/11-change-ppp-mtu-debug.sh +++ b/11-change-ppp-mtu-debug.sh @@ -5,6 +5,7 @@ MINTERFACES="(ppp0)" # Desired MTU of PPP interfaces PTARGET=1500 +SET_MSS=true runningmtu=0 restartpppd=0 @@ -82,6 +83,20 @@ while true; do fi fi done + + if [[ $SET_MSS ]]; then + echo "Checking if iptables MSS Value needs to be updated" + currentMSS=$(iptables -L -t mangle --line-numbers | grep -m 1 'SYN,RST/SYN TCPMSS' | sed 's/.*set \([0-9]\{4\}\).*/\1/') + targetMSS=$(($PTARGET-40)) + if [[ $currentMSS -ne $targetMSS ]]; then + echo "Updating MSS from $currentMSS to $targetMSS" + while [[ $(iptables -L -t mangle --line-numbers | grep 'SYN,RST/SYN TCPMSS') ]]; do + iptables -t mangle -D UBIOS_FORWARD_TCPMSS 1 + done + iptables -t mangle -A UBIOS_FORWARD_TCPMSS -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss $targetMSS + fi + fi + if [[ $restartpppd == 1 ]]; then echo Killing pppd killall -SIGHUP pppd From 59d81c1910609e1cced317ee431f2621e8f4140f Mon Sep 17 00:00:00 2001 From: Graham Matuszewski Date: Sat, 4 Mar 2023 19:25:34 -0500 Subject: [PATCH 03/15] make scripts executable --- 10-monitor-ppp-mtu.sh | 0 11-change-ppp-mtu-debug.sh | 0 11-change-ppp-mtu.sh | 0 3 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 10-monitor-ppp-mtu.sh mode change 100644 => 100755 11-change-ppp-mtu-debug.sh mode change 100644 => 100755 11-change-ppp-mtu.sh diff --git a/10-monitor-ppp-mtu.sh b/10-monitor-ppp-mtu.sh old mode 100644 new mode 100755 diff --git a/11-change-ppp-mtu-debug.sh b/11-change-ppp-mtu-debug.sh old mode 100644 new mode 100755 diff --git a/11-change-ppp-mtu.sh b/11-change-ppp-mtu.sh old mode 100644 new mode 100755 From dbc20741239e8b2508cfbadccfb49885fe52090e Mon Sep 17 00:00:00 2001 From: Graham Matuszewski Date: Sat, 4 Mar 2023 19:47:02 -0500 Subject: [PATCH 04/15] Reverse the check for MTU in /etc/ppp/peers/* because it appears to be wrong --- 11-change-ppp-mtu-debug.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/11-change-ppp-mtu-debug.sh b/11-change-ppp-mtu-debug.sh index 524be36..8f221d6 100755 --- a/11-change-ppp-mtu-debug.sh +++ b/11-change-ppp-mtu-debug.sh @@ -33,15 +33,15 @@ while true; do echo Checking MTU for $pinterface pmtu=$(grep $(($PTARGET-8)) /etc/ppp/peers/$pinterface) if [[ $pmtu ]]; then + echo MTU already correct in /etc/ppp/peers/$pinterface + pmtucorrect=1 + else echo Current config file MTU for $pinterface is $pmtu echo Updating config file for $pinterface echo Making changes to /etc/ppp/peers/$pinterface # Update MTU in ppp interface config file sed -i 's/ '$(($PTARGET-8))'/ '$PTARGET'/g' /etc/ppp/peers/$pinterface killall -SIGHUP pppd - else - echo MTU already correct in /etc/ppp/peers/$pinterface - pmtucorrect=1 fi # Determine eth interface associated with ppp interface einterface=$(sed -n 's/plugin rp-pppoe.so \(.*\)/\1/p' /etc/ppp/peers/$pinterface) From d7635cc11095a2df91cf27ae93e2d1245b9c18eb Mon Sep 17 00:00:00 2001 From: Graham Matuszewski Date: Sat, 4 Mar 2023 22:13:26 -0500 Subject: [PATCH 05/15] change code that updates /etc/ppp/peers/* to match any pre-existing mtu or mru values --- 11-change-ppp-mtu-debug.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/11-change-ppp-mtu-debug.sh b/11-change-ppp-mtu-debug.sh index 8f221d6..32c827c 100755 --- a/11-change-ppp-mtu-debug.sh +++ b/11-change-ppp-mtu-debug.sh @@ -40,7 +40,8 @@ while true; do echo Updating config file for $pinterface echo Making changes to /etc/ppp/peers/$pinterface # Update MTU in ppp interface config file - sed -i 's/ '$(($PTARGET-8))'/ '$PTARGET'/g' /etc/ppp/peers/$pinterface + sed -i 's/mtu\s[0-9]*/mtu $PTARGET/g' /etc/ppp/peers/$pinterface + sed -i 's/mru\s[0-9]*/mru $PTARGET/g' /etc/ppp/peers/$pinterface killall -SIGHUP pppd fi # Determine eth interface associated with ppp interface From f0cd906a96cbf03bd3c90d5153651c707b5a2f05 Mon Sep 17 00:00:00 2001 From: Graham Matuszewski Date: Sat, 4 Mar 2023 22:29:27 -0500 Subject: [PATCH 06/15] update to use the variable value correctly, it needs quotes --- 11-change-ppp-mtu-debug.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/11-change-ppp-mtu-debug.sh b/11-change-ppp-mtu-debug.sh index 32c827c..b5ea5da 100755 --- a/11-change-ppp-mtu-debug.sh +++ b/11-change-ppp-mtu-debug.sh @@ -4,7 +4,7 @@ # MINTERFACES="(ppp0|ppp1|ppp10)" MINTERFACES="(ppp0)" # Desired MTU of PPP interfaces -PTARGET=1500 +PTARGET=1444 SET_MSS=true runningmtu=0 @@ -40,8 +40,8 @@ while true; do echo Updating config file for $pinterface echo Making changes to /etc/ppp/peers/$pinterface # Update MTU in ppp interface config file - sed -i 's/mtu\s[0-9]*/mtu $PTARGET/g' /etc/ppp/peers/$pinterface - sed -i 's/mru\s[0-9]*/mru $PTARGET/g' /etc/ppp/peers/$pinterface + sed -i 's/mtu\s[0-9]*/mtu '$PTARGET'/g' /etc/ppp/peers/$pinterface + sed -i 's/mru\s[0-9]*/mru '$PTARGET'/g' /etc/ppp/peers/$pinterface killall -SIGHUP pppd fi # Determine eth interface associated with ppp interface From af989be3918c6f8f0853b9fa0581500a768b4d8f Mon Sep 17 00:00:00 2001 From: Graham Matuszewski Date: Sat, 4 Mar 2023 22:37:20 -0500 Subject: [PATCH 07/15] check to see if we have target mtu for /etc/ppp/peers/* rather than checking for an older value --- 11-change-ppp-mtu-debug.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/11-change-ppp-mtu-debug.sh b/11-change-ppp-mtu-debug.sh index b5ea5da..41710dc 100755 --- a/11-change-ppp-mtu-debug.sh +++ b/11-change-ppp-mtu-debug.sh @@ -31,7 +31,7 @@ while true; do echo $pinterface is one we should be checking # Check to see if we need to update the config file echo Checking MTU for $pinterface - pmtu=$(grep $(($PTARGET-8)) /etc/ppp/peers/$pinterface) + pmtu=$(grep 'mtu $(($PTARGET))' /etc/ppp/peers/$pinterface) if [[ $pmtu ]]; then echo MTU already correct in /etc/ppp/peers/$pinterface pmtucorrect=1 From 67b0408f118beeb485a578675ac1c83d4da84560 Mon Sep 17 00:00:00 2001 From: Graham Matuszewski Date: Sat, 4 Mar 2023 22:39:10 -0500 Subject: [PATCH 08/15] check for eth interface having correct value rather than not having incorrect value --- 11-change-ppp-mtu-debug.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/11-change-ppp-mtu-debug.sh b/11-change-ppp-mtu-debug.sh index 41710dc..8709fa6 100755 --- a/11-change-ppp-mtu-debug.sh +++ b/11-change-ppp-mtu-debug.sh @@ -52,7 +52,10 @@ while true; do echo Got $emtu for $einterface # Current ethernet MTU is incorrect so needs changing echo Checking $einterface - if [[ $emtu -lt $(($PTARGET+8)) ]] ; then + if [[ $emtu -eq $(($PTARGET)) ]] ; then + echo $einterface has right MTU + emtucorrect=1 + else echo $einterface has wrong MTU # Use +12 in above command if PPPoE over VLAN echo Reconfiguring ethernet MTU to $(($PTARGET+8)) for $einterface @@ -64,10 +67,7 @@ while true; do # ip link set dev $einterface mtu $(($PTARGET+12)) && ip link set dev $einterface.6 mtu $(($PTARGET+8)) # Bring interface down and up to apply changes echo Running ip link set $einterface down \&\& ip link set $einterface up - ip link set $einterface down && ip link set $einterface up - else - echo $einterface has right MTU - emtucorrect=1 + ip link set $einterface down && ip link set $einterface up fi # A situation can occur where all the configuration files are correct # but the ppp interface is still not right From 2a7b9b1b01dbfa4a1f97a7fcb626b2b2ffcfedb4 Mon Sep 17 00:00:00 2001 From: Graham Matuszewski Date: Sat, 4 Mar 2023 22:40:20 -0500 Subject: [PATCH 09/15] add message for already having the correct mss value --- 11-change-ppp-mtu-debug.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/11-change-ppp-mtu-debug.sh b/11-change-ppp-mtu-debug.sh index 8709fa6..3ca2253 100755 --- a/11-change-ppp-mtu-debug.sh +++ b/11-change-ppp-mtu-debug.sh @@ -95,6 +95,8 @@ while true; do iptables -t mangle -D UBIOS_FORWARD_TCPMSS 1 done iptables -t mangle -A UBIOS_FORWARD_TCPMSS -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss $targetMSS + else + echo "iptables already has correct MSS Value" fi fi From b76d112fd9e1c503da24b26f1b86b0d034320d70 Mon Sep 17 00:00:00 2001 From: Graham Matuszewski Date: Sat, 4 Mar 2023 22:45:21 -0500 Subject: [PATCH 10/15] when verifying the running mtu, check against the correct value rather than not having the incorrect value --- 11-change-ppp-mtu-debug.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/11-change-ppp-mtu-debug.sh b/11-change-ppp-mtu-debug.sh index 3ca2253..87a5f2c 100755 --- a/11-change-ppp-mtu-debug.sh +++ b/11-change-ppp-mtu-debug.sh @@ -76,8 +76,8 @@ while true; do if [ $pmtucorrect -eq 1 ] && [ $emtucorrect -eq 1 ]; then # Config files are all correct echo Config files are now all set correctly - runningmtu=$(ip link list | grep $pinterface | grep $(($PTARGET-8))) - if [ ! -z $runningmtu ]; then + runningmtu=$(ip link list | grep $pinterface | grep $(($PTARGET))) + if [ -z $runningmtu ]; then echo $pinterface still has wrong MTU restartpppd=1 fi From 6a02ce1c5dfb2737a854ddd1c0f96327934412cb Mon Sep 17 00:00:00 2001 From: Graham Matuszewski Date: Sat, 4 Mar 2023 22:54:27 -0500 Subject: [PATCH 11/15] delay the config change restart of pppd until after the eth interface has been changed. otherwise it will not restart correctly --- 11-change-ppp-mtu-debug.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/11-change-ppp-mtu-debug.sh b/11-change-ppp-mtu-debug.sh index 87a5f2c..fcb779f 100755 --- a/11-change-ppp-mtu-debug.sh +++ b/11-change-ppp-mtu-debug.sh @@ -42,7 +42,7 @@ while true; do # Update MTU in ppp interface config file sed -i 's/mtu\s[0-9]*/mtu '$PTARGET'/g' /etc/ppp/peers/$pinterface sed -i 's/mru\s[0-9]*/mru '$PTARGET'/g' /etc/ppp/peers/$pinterface - killall -SIGHUP pppd + restartpppd=1 fi # Determine eth interface associated with ppp interface einterface=$(sed -n 's/plugin rp-pppoe.so \(.*\)/\1/p' /etc/ppp/peers/$pinterface) From 00130e8462d74407143ef4a31240ecdfe41a8353 Mon Sep 17 00:00:00 2001 From: Graham Matuszewski Date: Sat, 4 Mar 2023 23:11:12 -0500 Subject: [PATCH 12/15] Match changes made in the debug file --- 11-change-ppp-mtu.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/11-change-ppp-mtu.sh b/11-change-ppp-mtu.sh index 1b01be2..64b8f05 100755 --- a/11-change-ppp-mtu.sh +++ b/11-change-ppp-mtu.sh @@ -25,12 +25,13 @@ while true; do if [[ $pinterface =~ $MINTERFACES ]]; then # Check to see if we need to update the config file echo Checking $pinterface > /dev/null - pmtu=$(grep $(($PTARGET-8)) /etc/ppp/peers/$pinterface) - if [[ $pmtu ]]; then + pmtu=$(grep $(($PTARGET)) /etc/ppp/peers/$pinterface) + if [[ -z $pmtu ]]; then echo Updating config file for $pinterface > /dev/null echo Making changes to /etc/ppp/peers/$pinterface > /dev/null # Update MTU in ppp interface config file - sed -i 's/ '$(($PTARGET-8))'/ '$PTARGET'/g' /etc/ppp/peers/$pinterface + sed -i 's/mtu\s[0-9]*/mtu '$PTARGET'/g' /etc/ppp/peers/$pinterface + sed -i 's/mru\s[0-9]*/mru '$PTARGET'/g' /etc/ppp/peers/$pinterface fi # Determine eth interface associated with ppp interface einterface=$(sed -n 's/plugin rp-pppoe.so \(.*\)/\1/p' /etc/ppp/peers/$pinterface) @@ -38,7 +39,9 @@ while true; do emtu=$(ip link show $einterface | head -n1 |sed 's/.*mtu \([0-9]\{4\}\).*/\1/') # Current ethernet MTU is incorrect so needs changing echo Checking $einterface > /dev/null - if [[ $emtu -lt $(($PTARGET+8)) ]] ; then + if [[ $emtu -eq $(($PTARGET)) ]] ; then + echo $einterface has right MTU > /dev/null + else echo $einterface has wrong MTU > /dev/null # Use +12 in above command if PPPoE over VLAN echo Reconfiguring ethernet MTU to $(($PTARGET+8)) for $einterface > /dev/null @@ -49,8 +52,6 @@ while true; do # ip link set dev $einterface mtu $(($PTARGET+12)) && ip link set dev $einterface.6 mtu $(($PTARGET+8)) # Bring interface down and up to apply changes ip link set $einterface down && ip link set $einterface up - else - echo $einterface has right MTU > /dev/null fi ip link set $pinterface mtu $PTARGET fi From d38ce68925e41d236311d9b4c042646f5a1bb8fb Mon Sep 17 00:00:00 2001 From: Graham Matuszewski Date: Sat, 4 Mar 2023 23:17:10 -0500 Subject: [PATCH 13/15] return default to 1500 --- 11-change-ppp-mtu-debug.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/11-change-ppp-mtu-debug.sh b/11-change-ppp-mtu-debug.sh index fcb779f..71725f6 100755 --- a/11-change-ppp-mtu-debug.sh +++ b/11-change-ppp-mtu-debug.sh @@ -4,7 +4,7 @@ # MINTERFACES="(ppp0|ppp1|ppp10)" MINTERFACES="(ppp0)" # Desired MTU of PPP interfaces -PTARGET=1444 +PTARGET=1500 SET_MSS=true runningmtu=0 From 780e3e6efbeada3ba1516e0a6fe34b32ad807f77 Mon Sep 17 00:00:00 2001 From: Graham Matuszewski Date: Sat, 4 Mar 2023 23:36:44 -0500 Subject: [PATCH 14/15] isolate the SET_MSS changes --- 11-change-ppp-mtu-debug.sh | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/11-change-ppp-mtu-debug.sh b/11-change-ppp-mtu-debug.sh index 71725f6..670acc2 100755 --- a/11-change-ppp-mtu-debug.sh +++ b/11-change-ppp-mtu-debug.sh @@ -5,7 +5,7 @@ MINTERFACES="(ppp0)" # Desired MTU of PPP interfaces PTARGET=1500 -SET_MSS=true +SET_MSS=FALSE runningmtu=0 restartpppd=0 @@ -31,18 +31,17 @@ while true; do echo $pinterface is one we should be checking # Check to see if we need to update the config file echo Checking MTU for $pinterface - pmtu=$(grep 'mtu $(($PTARGET))' /etc/ppp/peers/$pinterface) + pmtu=$(grep $(($PTARGET-8)) /etc/ppp/peers/$pinterface) if [[ $pmtu ]]; then - echo MTU already correct in /etc/ppp/peers/$pinterface - pmtucorrect=1 - else echo Current config file MTU for $pinterface is $pmtu echo Updating config file for $pinterface echo Making changes to /etc/ppp/peers/$pinterface # Update MTU in ppp interface config file - sed -i 's/mtu\s[0-9]*/mtu '$PTARGET'/g' /etc/ppp/peers/$pinterface - sed -i 's/mru\s[0-9]*/mru '$PTARGET'/g' /etc/ppp/peers/$pinterface - restartpppd=1 + sed -i 's/ '$(($PTARGET-8))'/ '$PTARGET'/g' /etc/ppp/peers/$pinterface + killall -SIGHUP pppd + else + echo MTU already correct in /etc/ppp/peers/$pinterface + pmtucorrect=1 fi # Determine eth interface associated with ppp interface einterface=$(sed -n 's/plugin rp-pppoe.so \(.*\)/\1/p' /etc/ppp/peers/$pinterface) @@ -52,10 +51,7 @@ while true; do echo Got $emtu for $einterface # Current ethernet MTU is incorrect so needs changing echo Checking $einterface - if [[ $emtu -eq $(($PTARGET)) ]] ; then - echo $einterface has right MTU - emtucorrect=1 - else + if [[ $emtu -lt $(($PTARGET+8)) ]] ; then echo $einterface has wrong MTU # Use +12 in above command if PPPoE over VLAN echo Reconfiguring ethernet MTU to $(($PTARGET+8)) for $einterface @@ -67,7 +63,10 @@ while true; do # ip link set dev $einterface mtu $(($PTARGET+12)) && ip link set dev $einterface.6 mtu $(($PTARGET+8)) # Bring interface down and up to apply changes echo Running ip link set $einterface down \&\& ip link set $einterface up - ip link set $einterface down && ip link set $einterface up + ip link set $einterface down && ip link set $einterface up + else + echo $einterface has right MTU + emtucorrect=1 fi # A situation can occur where all the configuration files are correct # but the ppp interface is still not right @@ -76,8 +75,8 @@ while true; do if [ $pmtucorrect -eq 1 ] && [ $emtucorrect -eq 1 ]; then # Config files are all correct echo Config files are now all set correctly - runningmtu=$(ip link list | grep $pinterface | grep $(($PTARGET))) - if [ -z $runningmtu ]; then + runningmtu=$(ip link list | grep $pinterface | grep $(($PTARGET-8))) + if [ ! -z $runningmtu ]; then echo $pinterface still has wrong MTU restartpppd=1 fi From ddfcb3f803b9d07e7d279ee53fa9ca1b6a5f5848 Mon Sep 17 00:00:00 2001 From: Graham Matuszewski Date: Sat, 4 Mar 2023 23:38:32 -0500 Subject: [PATCH 15/15] isolate set_mss changes --- 11-change-ppp-mtu.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/11-change-ppp-mtu.sh b/11-change-ppp-mtu.sh index 64b8f05..ae03db8 100755 --- a/11-change-ppp-mtu.sh +++ b/11-change-ppp-mtu.sh @@ -5,7 +5,7 @@ MINTERFACES="(ppp0)" # Desired MTU of PPP interfaces PTARGET=1500 -SET_MSS=true +SET_MSS=false function check_mtu { ip link list | grep -E $MINTERFACES | grep 'mtu '$PTARGET > /dev/null @@ -25,13 +25,12 @@ while true; do if [[ $pinterface =~ $MINTERFACES ]]; then # Check to see if we need to update the config file echo Checking $pinterface > /dev/null - pmtu=$(grep $(($PTARGET)) /etc/ppp/peers/$pinterface) - if [[ -z $pmtu ]]; then + pmtu=$(grep $(($PTARGET-8)) /etc/ppp/peers/$pinterface) + if [[ $pmtu ]]; then echo Updating config file for $pinterface > /dev/null echo Making changes to /etc/ppp/peers/$pinterface > /dev/null # Update MTU in ppp interface config file - sed -i 's/mtu\s[0-9]*/mtu '$PTARGET'/g' /etc/ppp/peers/$pinterface - sed -i 's/mru\s[0-9]*/mru '$PTARGET'/g' /etc/ppp/peers/$pinterface + sed -i 's/ '$(($PTARGET-8))'/ '$PTARGET'/g' /etc/ppp/peers/$pinterface fi # Determine eth interface associated with ppp interface einterface=$(sed -n 's/plugin rp-pppoe.so \(.*\)/\1/p' /etc/ppp/peers/$pinterface) @@ -39,9 +38,7 @@ while true; do emtu=$(ip link show $einterface | head -n1 |sed 's/.*mtu \([0-9]\{4\}\).*/\1/') # Current ethernet MTU is incorrect so needs changing echo Checking $einterface > /dev/null - if [[ $emtu -eq $(($PTARGET)) ]] ; then - echo $einterface has right MTU > /dev/null - else + if [[ $emtu -lt $(($PTARGET+8)) ]] ; then echo $einterface has wrong MTU > /dev/null # Use +12 in above command if PPPoE over VLAN echo Reconfiguring ethernet MTU to $(($PTARGET+8)) for $einterface > /dev/null @@ -52,6 +49,8 @@ while true; do # ip link set dev $einterface mtu $(($PTARGET+12)) && ip link set dev $einterface.6 mtu $(($PTARGET+8)) # Bring interface down and up to apply changes ip link set $einterface down && ip link set $einterface up + else + echo $einterface has right MTU > /dev/null fi ip link set $pinterface mtu $PTARGET fi @@ -69,6 +68,7 @@ while true; do iptables -t mangle -A UBIOS_FORWARD_TCPMSS -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss $targetMSS fi fi + # Kill pppd to apply changes (it gets restarted automatically) # This does take down existing ppp links but as pppd comes straight back up, so should the links # Only kill pppd if there are ppp interfaces active and changes were made