]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
QoS: Improve saving enabled/disable state
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 5 Jan 2016 21:00:19 +0000 (21:00 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 5 Jan 2016 21:04:05 +0000 (21:04 +0000)
It was reported that the QoS did not stop when
the user clicked the "stop" button. This patch
fixes that.

Fixes #10664

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Acked-by: Arne Fitzenreiter <arne.fitzenreiter@ipfire.org>
config/rootfiles/core/97/filelists/files
config/rootfiles/core/97/update.sh
html/cgi-bin/qos.cgi
src/misc-progs/qosctrl.c

index df2e4880c7beee5c5dbc11ae4d209b6487c1cdfa..22fc4f0245d5ceecfe3ac31a2b8af52ee0b7b43e 100644 (file)
@@ -1,4 +1,6 @@
 etc/system-release
 etc/issue
 srv/web/ipfire/cgi-bin/ovpnmain.cgi
+srv/web/ipfire/cgi-bin/qos.cgi
 usr/bin/pgrep
+usr/local/bin/qosctrl
index e6d4f21b790cbf7b55a4e07ee8c991974004f58c..85131da83f25a4ccdb9cacd5be422c3a568b1c40 100644 (file)
@@ -43,6 +43,9 @@ extract_files
 # Start services
 /etc/init.d/dnsmasq start
 
+# Delete old QoS enabled indicator
+rm -f /var/ipfire/qos/enable
+
 # This update need a reboot...
 #touch /var/run/need_reboot
 
index 39c3ed8431155b0ebf422cfa6d00adf4f8eccd4f..590ad15bff37e60e45b8fa2b8a34b0763d56da8b 100644 (file)
@@ -463,18 +463,16 @@ if ($qossettings{'ACTION'} eq $Lang::tr{'start'})
        $qossettings{'ENABLED'} = 'on';
        &General::writehash("${General::swroot}/qos/settings", \%qossettings);
        system("/usr/local/bin/qosctrl generate >/dev/null 2>&1");
-       system("/usr/bin/touch /var/ipfire/qos/enable");
        system("/usr/local/bin/qosctrl start >/dev/null 2>&1");
        system("logger -t ipfire 'QoS started'");
 }
 elsif ($qossettings{'ACTION'} eq $Lang::tr{'stop'})
 {
-       system("/usr/local/bin/qosctrl stop >/dev/null 2>&1");
-       unlink "/var/ipfire/qos/bin/qos.sh";
-       unlink "/var/ipfire/qos/enable";
-       system("logger -t ipfire 'QoS stopped'");
        $qossettings{'ENABLED'} = 'off';
        &General::writehash("${General::swroot}/qos/settings", \%qossettings);
+       system("/usr/local/bin/qosctrl stop >/dev/null 2>&1");
+       system("/usr/local/bin/qosctrl generate >/dev/null 2>&1");
+       system("logger -t ipfire 'QoS stopped'");
 }
 elsif ($qossettings{'ACTION'} eq $Lang::tr{'restart'})
 {
@@ -587,7 +585,6 @@ END
                $qossettings{'ENABLED'} = 'on';
                &General::writehash("${General::swroot}/qos/settings", \%qossettings);
                system("/usr/local/bin/qosctrl generate >/dev/null 2>&1");
-               system("/usr/bin/touch /var/ipfire/qos/enable");
                system("/usr/local/bin/qosctrl start >/dev/null 2>&1");
                system("logger -t ipfire 'QoS started'");
        } else {
index b8317466b645ac89e21f0a4b5640055914cdc239..c00dbcf7ceac5f82c52ee71f1fd0f7dc3fc748ed 100644 (file)
 #include <sys/types.h>
 #include <fcntl.h>
 #include "setuid.h"
+#include "libsmooth.h"
 
 #define QOS_SH "/var/ipfire/qos/bin/qos.sh"
 
 int main(int argc, char *argv[]) {
-
+       struct keyvalue* kv = NULL;
         int fd = -1;
+       int r = 0;
 
         if (!(initsetuid()))
                 exit(1);
@@ -28,14 +30,28 @@ int main(int argc, char *argv[]) {
         }
 
         if (strcmp(argv[1], "generate") == 0) {
-                safe_system("/usr/bin/perl /var/ipfire/qos/bin/makeqosscripts.pl > " QOS_SH);
+               kv = initkeyvalues();
+               if (!readkeyvalues(kv, CONFIG_ROOT "/qos/settings")) {
+                       fprintf(stderr, "Cannot read QoS settings\n");
+                       r = 1;
+                       goto END;
+               }
+
+               char enabled[STRING_SIZE];
+               if (!findkey(kv, "ENABLED", enabled))
+                       strcpy(enabled, "off");
+
+               if (strcmp(enabled, "on") == 0)
+                       safe_system("/usr/bin/perl /var/ipfire/qos/bin/makeqosscripts.pl > " QOS_SH);
+               else
+                       unlink(QOS_SH);
         }
 
         if ((fd = open(QOS_SH, O_RDONLY)) != -1) {
                 close(fd);
         } else {
                 // If there is no qos.sh do nothing.
-                exit(0);
+                goto END;
         }
 
         safe_system("chmod 755 " QOS_SH " &>/dev/null");
@@ -53,5 +69,9 @@ int main(int argc, char *argv[]) {
                 exit(1);
         }
 
-        return 0;
+END:
+       if (kv)
+               freekeyvalues(kv);
+
+        return r;
 }