Skip to content

Bug fixes and inverting some logic#5

Open
matuszeg wants to merge 15 commits intoTotalGriffLock:mainfrom
matuszeg:bugs
Open

Bug fixes and inverting some logic#5
matuszeg wants to merge 15 commits intoTotalGriffLock:mainfrom
matuszeg:bugs

Conversation

@matuszeg
Copy link

@matuszeg matuszeg commented Mar 5, 2023

I went to use this script to replace the one I wrote myself for this same MTU ppp problem. And when I went to do that I ran into some issues. I needed to set my MTU to 1444 which all of the "$PTARGET-8" checks failed against, so I removed them and inverted the logic in some places to check if things are in the desired state instead of checking if things are in a specific wrong state.

I am going to leave comments on the individual changes with more specifics.

# 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)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

look for mtu 1500 or whatever the PTARGET is instead of just PTARGET-8 (1492) because there is no guarantee that will actually be the value. also if someone has other changes with the same number somewhere else in this file that would cause problems. so i changed it to look for exactly the target mtu value. i assumed the mru would be the same which i think is fine.

I also made it look for the correct rather than the wrong because ptarget-8 is never going to be true if you have a ptarget of like 1444

echo MTU already correct in /etc/ppp/peers/$pinterface
pmtucorrect=1
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
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of doing a ptarget-8 replacement i changed this to replace the number value of mtu and mru lines individually no matter what value they have. for aforementioned ptarget-8 problems

# Current ethernet MTU is incorrect so needs changing
echo Checking $einterface
if [[ $emtu -lt $(($PTARGET+8)) ]] ; then
if [[ $emtu -eq $(($PTARGET)) ]] ; then
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed this to look for the correct rather than the incorrect but that incorrect is not always right. it would only be right if you were trying to increase the mtu rather than decrease. which is what i want to do. so this works for both

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)))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get rid of the -8 check here and look for if it doesnt have the correct value instead of it having the specific wrong value

pmtucorrect=1
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
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i noticed when using this script that the ppp0 interface would have the wrong value after it worked, but the config would be correct. i realized it was because this was happening too soon, it needs to happen after the eth interface is updated. so i just set restartpppd=1 here and have pppd restart later instead of right away

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant