From 2a9dd3842b8ac465b719cdde9e6bd4cfc1fdfdd8 Mon Sep 17 00:00:00 2001
From: FFS-Roland <roland.volkmann@t-online.de>
Date: Wed, 28 Dec 2016 11:12:57 +0100
Subject: [PATCH] Allow changes of MTU without changing segment.

---
 ffs-set-segment/files/usr/sbin/ffs-set-segment | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/ffs-set-segment/files/usr/sbin/ffs-set-segment b/ffs-set-segment/files/usr/sbin/ffs-set-segment
index 05abd27..baa3b20 100755
--- a/ffs-set-segment/files/usr/sbin/ffs-set-segment
+++ b/ffs-set-segment/files/usr/sbin/ffs-set-segment
@@ -22,7 +22,7 @@ if [ -z "$SEGINFO" ]; then
     exit 1
 fi
 SEGINFO=${SEGINFO/Address 1: 2001:2:0:711::/}
-VPNMTU=$(echo $SEGINFO | cut -d':' -s -f1)
+NEWMTU=$(echo $SEGINFO | cut -d':' -s -f1)
 SEGMENT=$(echo $SEGINFO | cut -d':' -f2)
 
 let PORT=SEGMENT+10040
@@ -40,11 +40,17 @@ do
     fi
 done
 
-if [ "$CHANGED" = "1" ]; then
-    if [ -n "$VPNMTU" ]; then
-        uci set fastd.mesh_vpn.mtu="$VPNMTU"
-        echo MTU set to $VPNMTU
+if [ -n "$NEWMTU" ]; then
+    OLDMTU=`uci get fastd.mesh_vpn.mtu`
+    if [ "$NEWMTU" != "$OLDMTU" ]; then
+        uci set fastd.mesh_vpn.mtu="$NEWMTU"
+        CHANGED=1
     fi
+fi
+
+if [ "$CHANGED" = "1" ]; then
     /etc/init.d/fastd restart
-    echo Segment set to $SEGNUM
+    echo Set Segment: $SEGNUM, MTU: $NEWMTU
+else
+    echo No changes
 fi
-- 
GitLab