Browse Source

sqm-scripts: clean up interface selection for hotplugging

The initial conversion to restart sqm on interfaces it is configured
for in case of (transient) dis- and reappearance was half finished.
These changes clean up the handling of exlicitly passed interfaces
in run.sh: no second argument defaults to all configured interfaces
the alternative is an individual interface name passed as 2nd
argument to run.sh. The first argument either is start or stop.
No argument at all will behave as if start was passed.
Survives light testing...

Signed-off-by: Sebastian Moeller <moeller0@gmx.de>
Sebastian Moeller 9 years ago
parent
commit
d5a203f1eb

+ 1
- 1
net/sqm-scripts/files/etc/hotplug.d/iface/11-sqm View File

@@ -1,3 +1,3 @@
1 1
 #!/bin/sh
2 2
 
3
-[ "$ACTION" = ifup ] && /usr/lib/sqm/run.sh interface ${DEVICE}
3
+[ "$ACTION" = ifup ] && /usr/lib/sqm/run.sh start ${DEVICE}

+ 1
- 1
net/sqm-scripts/files/etc/init.d/sqm View File

@@ -4,7 +4,7 @@ START=50
4 4
 
5 5
 reload()
6 6
 {
7
-/usr/lib/sqm/run.sh
7
+/usr/lib/sqm/run.sh start
8 8
 }
9 9
 
10 10
 restart()

+ 23
- 13
net/sqm-scripts/files/usr/lib/sqm/run.sh View File

@@ -13,29 +13,39 @@ STOP=
13 13
 ACTIVE_STATE_PREFIX="SQM_active_on_"
14 14
 ACTIVE_STATE_FILE_DIR="/var/run/SQM"
15 15
 mkdir -p ${ACTIVE_STATE_FILE_DIR}
16
-PROTO_STATE_FILE_LIST=$( ls ${ACTIVE_STATE_FILE_DIR}/${ACTIVE_STATE_PREFIX}* 2> /dev/null )
16
+
17
+
18
+START_ON_IF=$2	# only process this interface
19
+# TODO if $2 is empty select all interfaces with running sqm instance
20
+if [ -z ${START_ON_IF} ] ;
21
+then
22
+    # find all interfaces with active sqm instance
23
+    logger -t SQM -s "Trying to start/stop SQM on all interfaces."
24
+    PROTO_STATE_FILE_LIST=$( ls ${ACTIVE_STATE_FILE_DIR}/${ACTIVE_STATE_PREFIX}* 2> /dev/null )
25
+else
26
+    # only try to restart the just hotplugged interface, so reduce the list of interfaces to stop to the specified one
27
+    logger -t SQM -s "Trying to start/stop SQM on interface ${START_ON_IF}"
28
+    PROTO_STATE_FILE_LIST=${ACTIVE_STATE_FILE_DIR}/${ACTIVE_STATE_PREFIX}${START_ON_IF}
29
+fi
30
+
31
+
17 32
 
18 33
 
19 34
 case ${1} in
35
+    start)
36
+	# just run through, same as passing no argument
37
+	;;
20 38
     stop)
21 39
         logger -t SQM -s "run.sh stop"
22 40
 	STOP=$1
23 41
         ;;
24
-    interface)
25
-	START_ON_IF=$2	# only process this interface
26
-	logger -t SQM -s "Trying to re-start SQM on interface ${START_ON_IF}"
27
-	# TODO if $2 is empty just bail...
28
-	if [ -z ${START_ON_IF} ] ;
29
-	then
30
-	    logger -t SQM -s "Interface name missing, nothing to do, bailing out"
31
-	    return 0
32
-	fi
33
-	# only try to restart the just hotplugged interface, so reduce the list of interfaces to stop to the specified one
34
-	PROTO_STATE_FILE_LIST=${ACTIVE_STATE_FILE_DIR}/${ACTIVE_STATE_PREFIX}${START_ON_IF}
35
-	;;
36 42
 esac
37 43
 
38 44
 
45
+
46
+
47
+
48
+
39 49
 # the current uci config file does not necessarily contain sections for all interfaces with active
40 50
 # SQM instances, so use the ACTIVE_STATE_FILES to detect the interfaces on which to stop SQM.
41 51
 # Currently the .qos scripts start with stopping any existing traffic shaping so this should not