/* Prometheus QoS - you can "steal fire" from your ISP */\r
/* "fair-per-IP" quality of service (QoS) utility */\r
/* requires Linux 2.4.x or 2.6.x with HTB support */\r
-/* Copyright(C) 2005-2019 Michael Polak, Arachne Aerospace */\r
+/* Copyright(C) 2005-2020 Michael Polak, Arachne Aerospace */\r
/* iptables-restore support Copyright(C) 2007-2008 ludva */\r
/* Credit: CZFree.Net,Martin Devera,Netdave,Aquarius,Gandalf */\r
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */\r
\r
-/* Modified by: xChaos, 20190127\r
+/* Modified by: xChaos, 20231028\r
ludva, 20080415\r
\r
Prometheus QoS is free software; you can redistribute it and/or\r
#include "cll1-0.6.2.h"\r
#include "ipstruct.h"\r
\r
-const char *version = "0.9.1";\r
+const char *version = "1.0.1";\r
\r
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */\r
/* Versions: 0.9.0 is development release, 1.0 will be "stable" */\r
/* Warning: unofficial Github mirror is not supported by author! */\r
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */\r
\r
-const char *stats_html_signature = "<span class=\"small\">Statistics generated by Prometheus QoS version %s<br />GPL+Copyright(C)2005-2017 Michael Polak, <a target=\"_blank\" href=\"http://www.arachne.cz/\">Arachne Labs</a></span>\n";\r
+const char *stats_html_signature = "<span class=\"small\">Statistics generated by Prometheus QoS version %s<br />GPL+Copyright(C)2005-2020 Michael Polak, <a target=\"_blank\" href=\"http://www.arachne.cz/\">Arachne Labs</a></span>\n";\r
\r
#define STRLEN 512\r
#undef DEBUG\r
char *downstreamfile = "/etc/prometheus/downstream.interfaces"; /* list of interfaces to manage */\r
char *qosfreefile = "/etc/prometheus/qosfree.interfaces"; /* list of interfaces to manage */\r
char *iptablesfile = "/var/spool/prometheus.iptables"; /* temporary file for iptables-restore*/\r
+char *iptablesdump = "/var/spool/prometheus.iptables-dump"; /* temporary file for iptables -L -v -x -n -t mangle */\r
char *ip6tablesfile = "/var/spool/prometheus.ip6tables"; /* temporary file for ip6tables-restore*/\r
char *credit = "/var/lib/misc/prometheus.credit"; /* credit log file */\r
char *classmap = "/var/lib/misc/prometheus.classes"; /* credit log file */\r
char *final_chain = "DROP"; /* REJECT would be better, but it is impossible in mangle */\r
char *mark = "MARK";\r
char *mark_iptables = "MARK --set-mark ";\r
-int dry_run = FALSE; /* preview - use puts() instead of system() */\r
-int mix_new_hosts = FALSE; /* execute only commands not already in log of iptables */\r
+int dry_run = FALSE; /* preview commands - use puts() instead of system() */\r
+int skip_stats = FALSE; /* skip generating statistics */\r
char *iptablespreamble = "*mangle\n:PREROUTING ACCEPT [0:0]\n:POSTROUTING ACCEPT [0:0]\n:INPUT ACCEPT [0:0]\n:OUTPUT ACCEPT [0:0]\n:FORWARD ACCEPT [0:0]";\r
char *ip6preamble = "-A FORWARD -p ipv6-icmp -j ACCEPT\n-A POSTROUTING -p ipv6-icmp -j ACCEPT\n-A FORWARD -s fe80::/10 -j ACCEPT\n-A FORWARD -d ff00::/8 -j ACCEPT\n-A POSTROUTING -s fe80::/10 -j ACCEPT\n-A POSTROUTING -d ff00::/8 -j ACCEPT";\r
FILE *iptables_file = NULL;\r
char *ip6prefix = NULL; /* Prefix for global /48 IPv6 subnet */\r
char *qos_leaf = "sfq perturb 5"; /* leaf discipline */\r
char *qos_free_zone = NULL; /* QoS free zone */\r
+char *qos_free_dst_ipset = NULL; /* QoS free zone - dst match ipset name, must be prepared outside prometheus */\r
+char *qos_free_src_ipset = NULL; /* QoS free zone - src match ipset name, must be prepared outside prometheus */\r
/* int qos_proxy = TRUE; include proxy port to QoS */\r
-int found_lmsid = FALSE; /* show links to users in LMS information system */\r
+int found_code = FALSE; /* show links to users in LMS information system */\r
int include_upload = TRUE; /* upload+download=total traffic */\r
/* char *proxy_ip = "192.168.1.1/32"; our IP with proxy port */\r
/* int proxy_port = 3128; proxy port number */\r
int qos_free_delay = 0; /* seconds to sleep before applying new QoS rules */\r
int digital_divide = 2; /* controls digital divide weirdness ratio, 1...3 */ \r
int max_nesting = 5; /* /include/uapi/linux/pkt_sched.h: #define TC_HTB_MAXDEPTH 8 [... - 3 parent classes] */\r
-int htb_r2q = 256; /* should work for leaf values 512 kbps to 8 Mbps */\r
+//obsolete: int htb_r2q = 256; /* should work for leaf values 512 kbps to 8 Mbps */\r
+int htb_quantum = 1514; /* MTU + ethernet header */\r
int burst = 8; /* HTB burst (in kbits) */\r
int burst_main = 64;\r
int burst_group = 32;\r
FILE *log_file = NULL;\r
char *kwd = "via-prometheus"; /* /etc/hosts comment, eg. #qos-64-128 */\r
\r
-const int highest_priority = 0; /* highest HTB priority (HTB built-in value is 0) */\r
-const int lowest_priority = 7; /* lowest HTB priority /include/uapi/linux/pkt_sched.h: #define TC_HTB_NUMPRIO 8 */\r
-const int idxtable_treshold1 = 24; /* this is no longer configurable */\r
-const int idxtable_treshold2 = 12; /* this is no longer configurable */\r
-const int idxtable_bitmask1 = 3; /* this is no longer configurable */\r
-const int idxtable_bitmask2 = 3; /* this is no longer configurable */\r
+const int highest_priority = 0; /* highest HTB priority (HTB built-in value is 0) */\r
+const int lowest_priority = 7; /* lowest HTB priority /include/uapi/linux/pkt_sched.h: #define TC_HTB_NUMPRIO 8 */\r
+const int idxtable_treshold1 = 24; /* this is no longer configurable */\r
+const int idxtable_treshold2 = 12; /* this is no longer configurable */\r
+const int idxtable_bitmask1 = 3; /* this is no longer configurable */\r
+const int idxtable_bitmask2 = 3; /* this is no longer configurable */\r
\r
struct IP *ips = NULL, *networks = NULL, *ip, *sharedip;\r
struct Group *groups = NULL, *group;\r
struct Index *idxs = NULL, *idx, *metaindex;\r
struct Interface *interfaces = NULL, *interface;\r
struct QosFreeInterface *qosfreeinterfaces = NULL, *qosfreeinterface;\r
-struct Textfile *previous_commands = NULL, *previous_iptables = NULL, *previous_ip6tables = NULL, *textline;\r
\r
#define FREE_CLASS 3\r
#define OVERLIMIT_CLASS 4\r
option("ip6tables-save",ip6tablessave);\r
option("ip6tables-restore",ip6tablesrestore);\r
option("iptables-in-filename",iptablesfile);\r
+ option("iptables-dump-filename",iptablesdump);\r
option("ip6tables-in-filename",ip6tablesfile);\r
option("hosts",hosts);\r
option("downstream-interfaces-list-filename",downstreamfile);\r
option("lms-url",lms_url);\r
ioption("use-jquery-popups",use_jquery_popups);\r
option("qos-free-zone",qos_free_zone);\r
+ option("qos-free-dst-ipset",qos_free_dst_ipset);\r
+ option("qos-free-src-ipset",qos_free_src_ipset);\r
ioption("qos-free-delay",qos_free_delay);\r
/* ioption("qos-proxy-enable",qos_proxy); */\r
/* option("qos-proxy-ip",proxy_ip);*/\r
ioption("htb-burst-main",burst_main);\r
ioption("htb-burst-group",burst_group);\r
ioption("htb-nesting-limit",max_nesting);\r
- ioption("htb-r2q",htb_r2q);\r
+ ioption("htb-quantum",htb_quantum);\r
ioption("magic-include-upload",include_upload);\r
ioption("magic-treshold",magic_treshold); \r
option("filter-type", cnf); \r
}\r
\r
\r
-/* ========== This function executes, logs OR ALSO prints command ========== */\r
+/* ========== This function executes, logs or also prints command ========== */\r
\r
void safe_run(char *cmd)\r
{\r
}\r
else\r
{\r
- int skip_cmd = FALSE;\r
- if(mix_new_hosts)\r
- for_each(textline, previous_commands)\r
- if(eq(textline->str, cmd))\r
- {\r
- skip_cmd = TRUE;\r
- break;\r
- }\r
- \r
- if(!skip_cmd)\r
- {\r
- if(mix_new_hosts)\r
- {\r
- printf("Executing command: %s\n", cmd);\r
- }\r
- system(cmd);\r
- }\r
+ system(cmd);\r
}\r
if(log_file)\r
{\r
}\r
\r
void iptables_save_line(char *line, int ipv6)\r
-{ \r
+{\r
if(ipv6)\r
{\r
- if(mix_new_hosts)\r
- for_each(textline, previous_ip6tables)\r
- if(eq(textline->str, line))\r
- return;\r
-\r
fprintf(ip6tables_file,"%s\n",line);\r
}\r
else\r
{\r
- if(mix_new_hosts)\r
- for_each(textline, previous_iptables)\r
- if(eq(textline->str, line))\r
- return; \r
-\r
fprintf(iptables_file,"%s\n",line);\r
}\r
- if(mix_new_hosts)\r
- {\r
- printf("Adding iptables/ip6tables rule: %s\n", line);\r
- } \r
}\r
\r
#define IPv4 FALSE\r
int just_preview = FALSE; /* preview - generate just stats */\r
int start_shaping = FALSE; /* apply FUP - requires classmap file */\r
int stop_shaping = FALSE; /* lift FUP - requires classmap file */\r
- int reduce_ceil = 0; /* allow only rate+(ceil-rate)/2, /4, etc. */\r
+ int reduce_ceil = 0; /* allow only rate+(ceil-rate)/2, /4, etc. */\r
int just_logs = FALSE; /* just parse logs */\r
int run = FALSE;\r
int total = 0;\r
\r
printf("\n\\r
Prometheus QoS - \"fair-per-IP\" Quality of Service setup utility.\n\\r
-Version %s - Copyright (C)2005-2019 Michael Polak, Arachne Labs\n\\r
+Version %s - Copyright (C)2005-2017 Michael Polak, Arachne Labs\n\\r
iptables-restore & burst tunning & classify modification by Ludva\n\\r
Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);\r
\r
{\r
argument("-c") { nextargument(config); }\r
argument("-h") { nextargument(althosts);}\r
- argument("-d") { run = TRUE; dry_run = TRUE; }\r
- argument("-f") { run = TRUE; just_flush = TRUE; }\r
- argument("-9") { run = TRUE; just_flush = 9; }\r
- argument("-p") { run = TRUE; just_preview = TRUE; }\r
- argument("-q") { run = TRUE; just_preview = TRUE; stop_shaping = TRUE; }\r
- argument("-2") { run = TRUE; just_preview = TRUE; reduce_ceil = 2; }\r
- argument("-4") { run = TRUE; just_preview = TRUE; reduce_ceil = 4; }\r
- argument("-s") { run = TRUE; just_preview = TRUE; start_shaping = TRUE; }\r
- argument("-x") { run = TRUE; just_preview = TRUE; mix_new_hosts = TRUE; }\r
- argument("-r") { run = TRUE; }\r
- argument("-n") { run = TRUE; nodelay = TRUE; }\r
- argument("-a") { run = TRUE; just_networks = TRUE; }\r
- argument("-l") { just_logs = TRUE; }\r
- argument("-m") { just_logs = TRUE; }\r
- argument("-y") { just_logs = TRUE; }\r
+ argument("-d") { run=TRUE; dry_run=TRUE; }\r
+ argument("-f") { run=TRUE; just_flush=TRUE; }\r
+ argument("-9") { run=TRUE; just_flush=9; }\r
+ argument("-p") { run=TRUE; just_preview=TRUE; }\r
+ argument("-q") { run=TRUE; just_preview=TRUE; stop_shaping=TRUE; }\r
+ argument("-2") { run=TRUE; just_preview=TRUE; reduce_ceil=2; }\r
+ argument("-4") { run=TRUE; just_preview=TRUE; reduce_ceil=4; }\r
+ argument("-s") { run=TRUE; just_preview=TRUE; start_shaping=TRUE; }\r
+ argument("-r") { run=TRUE; }\r
+ argument("-n") { run=TRUE; nodelay=TRUE; }\r
+ argument("-b") { run=TRUE; nodelay=TRUE; skip_stats=TRUE; }\r
+ argument("-a") { run=TRUE; just_networks=TRUE; }\r
+ argument("-l") { just_logs=TRUE; }\r
+ argument("-m") { just_logs=TRUE; }\r
+ argument("-y") { just_logs=TRUE; }\r
argument("-?") { help(); exit(0); }\r
argument("--help") { help(); exit(0); }\r
argument("-v") { exit(0); } \r
interface->chain = "FORWARD";\r
interface->idxprefix = "forw";\r
push(interface, interfaces);\r
- printf("Upstream interface %s: medium %s capacity %ld kbps\n", interface->name, medium, interface->speed);\r
+ printf("Upstream interface %s: medium %s capacity %Ld kbps\n", interface->name, medium, interface->speed);\r
}\r
}\r
done; /* ugly macro end */\r
interface->chain = "POSTROUTING";\r
interface->idxprefix = "post";\r
push(interface, interfaces);\r
- printf("Downstream interface %s: medium %s capacity %ld kbps\n", interface->name, medium, interface->speed);\r
+ printf("Downstream interface %s: medium %s capacity %Ld kbps\n", interface->name, medium, interface->speed);\r
}\r
}\r
done; /* ugly macro end */\r
hosts = althosts;\r
}\r
\r
- if(!mix_new_hosts && just_flush<9)\r
+ if(just_flush<9 && !skip_stats)\r
{\r
/*-----------------------------------------------------------------*/\r
puts("Parsing iptables verbose output ...");\r
}\r
done; /* ugly macro end */\r
\r
+\r
+\r
/*-----------------------------------------------------------------*/\r
printf("Parsing class defintion file %s ...\n", hosts);\r
/*-----------------------------------------------------------------*/\r
parse_hosts(hosts);\r
-/*\r
- //this was pretty dumb idea anyway...\r
- if(just_networks)\r
- {\r
- analyse_topology("/usr/sbin/traceroute -n -m 10 -w 2 %s.%d");\r
- exit(-1); \r
- }\r
-*/\r
\r
- if(mix_new_hosts)\r
+#ifdef MONITORINGTRHU_CTU\r
+//special hack only to generate certain required CSV statistics for www.ctu.cz (regulation body)\r
+//not required for everyday use, requires special syntax sugar in hosts file, see parsehosts.c\r
+ for_each(technology, technologies)\r
{\r
- char *new_filename;\r
+ char *filename;\r
+ FILE *f;\r
+ string(filename, strlen(log_dir) + strlen(technology->filename) + 5);\r
+ strcpy(filename, log_dir);\r
+ strcat(filename, technology->filename); \r
+ strcat(filename, ".csv");\r
/*-----------------------------------------------------------------*/\r
- printf("Loading log of previously executed commands %s ...\n", cmdlog);\r
+ printf("Writing report file %s ...\n", filename);\r
/*-----------------------------------------------------------------*/\r
- load(textline, previous_commands, cmdlog, Textfile, str);\r
- /*-----------------------------------------------------------------*/\r
- printf("Loading log of iptables-restore commands %s ...\n", iptablesfile);\r
- /*-----------------------------------------------------------------*/\r
- load(textline, previous_iptables, iptablesfile, Textfile, str);\r
- /*-----------------------------------------------------------------*/\r
- printf("Loading log of ip6tables-restore commands %s ...\n", ip6tablesfile);\r
- /*-----------------------------------------------------------------*/\r
- load(textline, previous_ip6tables, ip6tablesfile, Textfile, str);\r
-\r
- string(new_filename, strlen(iptablesfile)+2);\r
- strcpy(new_filename, iptablesfile);\r
- strcat(new_filename, "-x");\r
- iptablesfile = new_filename;\r
-\r
- string(new_filename, strlen(ip6tablesfile)+2);\r
- strcpy(new_filename, ip6tablesfile);\r
- strcat(new_filename, "-x");\r
- ip6tablesfile = new_filename;\r
- }\r
+ f = fopen(filename, "w");\r
+ if(f)\r
+ {\r
+ for_each(ip, ips) if(eq(technology->filename, ip->technology_str))\r
+ {\r
+ fprintf(f,"%s,%s,%d\n", ip->code, ip->ruian_id_str, ip->max);\r
+ }\r
+ fclose(f);\r
+ }\r
+ else\r
+ perror(filename); \r
+ } \r
+#endif\r
\r
/*-----------------------------------------------------------------*/\r
puts("Resolving shared connections ...");\r
sharedip->traffic_up += ip->upload;\r
ip->traffic = 0;\r
ip->mark = sharedip->mark; \r
- ip->lmsid = sharedip->lmsid;\r
+ ip->code = sharedip->code;\r
ip->pps_limit = sharedip->pps_limit; /* no other way to do this */\r
\r
/* Ugly hack: append IPv4 addresses of sharedip to IPv6 uplinks */\r
}\r
}\r
\r
- if(!mix_new_hosts && enable_credit && just_flush<9)\r
+ if(enable_credit && just_flush<9)\r
{\r
/*-----------------------------------------------------------------*/\r
printf("Parsing credit file %s ...\n", credit);\r
}\r
\r
\r
- if(!mix_new_hosts && !just_preview)\r
+ if(!just_preview)\r
{\r
/*-----------------------------------------------------------------*/\r
puts("Initializing iptables and tc classes ...");\r
iptables_save_line(ip6preamble, IPv6);\r
}\r
\r
- if(qos_free_zone && *qos_free_zone!='0') /* this is currently supported only for IPv4 */\r
+ /* this doesn't seem to be way to go... about 2/3 of all packets have ACK flag set\r
+ maybe with --length 40:100 it would make some sense, but not enought \r
+ for_each(interface, interfaces)\r
+ {\r
+ sprintf(str,"-A %s -m tcp -p tcp --tcp-flags ACK ACK -o %s -j ACCEPT", interface->chain, interface->name);\r
+ iptables_save_line(str, IPv4);\r
+ }\r
+ */\r
+\r
+ if(qos_free_zone && *qos_free_zone != '0') /* this is currently supported only for IPv4 */\r
{\r
for_each(interface, interfaces)\r
{\r
iptables_save_line(str, IPv4);\r
}\r
}\r
+\r
+ if(qos_free_dst_ipset && *qos_free_dst_ipset != '0') /* this is currently supported only for IPv4 */\r
+ {\r
+ for_each(interface, interfaces)\r
+ {\r
+ sprintf(str,"-A %s -m set --match-set %s %s -o %s -j ACCEPT", interface->chain, qos_free_dst_ipset, (interface->is_upstream?"dst":"src"), interface->name);\r
+ iptables_save_line(str, IPv4);\r
+ }\r
+ }\r
+\r
+ if(qos_free_src_ipset && *qos_free_src_ipset != '0') /* this is currently supported only for IPv4 */\r
+ {\r
+ for_each(interface, interfaces)\r
+ {\r
+ sprintf(str,"-A %s -m set --match-set %s %s -o %s -j ACCEPT", interface->chain, qos_free_src_ipset, (interface->is_upstream?"src":"dst"), interface->name);\r
+ iptables_save_line(str, IPv4);\r
+ }\r
+ }\r
\r
for_each(qosfreeinterface, qosfreeinterfaces)\r
{\r
exit(0);\r
}\r
\r
- if(!mix_new_hosts && !just_preview)\r
+ if(!just_preview)\r
{\r
if(!dry_run && !nodelay && qos_free_delay)\r
{\r
\r
for_each(interface, interfaces)\r
{\r
- sprintf(str, "%s qdisc add dev %s root handle 1: htb r2q %d default 1",\r
- tc, interface->name, htb_r2q);\r
+ sprintf(str, "%s qdisc add dev %s root handle 1: htb default 1",\r
+ tc, interface->name);\r
safe_run(str);\r
\r
- sprintf(str, "%s class add dev %s parent 1: classid 1:2 htb rate %s ceil %s burst %dk prio %d",\r
- tc, interface->name, medium, medium, burst_main, highest_priority);\r
+ sprintf(str, "%s class add dev %s parent 1: classid 1:2 htb rate %s ceil %s burst %dk prio %d quantum %d",\r
+ tc, interface->name, medium, medium, burst_main, highest_priority, htb_quantum);\r
safe_run(str);\r
\r
- sprintf(str, "%s class add dev %s parent 1:2 classid 1:1 htb rate %Ldkbit ceil %Ldkbit burst %dk prio %d",\r
- tc, interface->name, interface->speed, interface->speed, burst_main, highest_priority);\r
+ sprintf(str, "%s class add dev %s parent 1:2 classid 1:1 htb rate %Ldkbit ceil %Ldkbit burst %dk prio %d quantum %d",\r
+ tc, interface->name, interface->speed, interface->speed, burst_main, highest_priority, htb_quantum);\r
safe_run(str);\r
}\r
}\r
\r
- if(mix_new_hosts)\r
- {\r
- /*-----------------------------------------------------------------*/\r
- puts("Locating heavy downloaders and generating root classes ...");\r
- /*-----------------------------------------------------------------*/\r
- sort(ip,ips,desc_order_by,traffic);\r
- }\r
+ /*-----------------------------------------------------------------*/\r
+ puts("Locating heavy downloaders and generating root classes ...");\r
+ /*-----------------------------------------------------------------*/\r
+ sort(ip,ips,desc_order_by,traffic); \r
\r
/*-----------------------------------------------------------------*/\r
for_each(interface, interfaces)\r
{\r
if(!just_preview)\r
{\r
- sprintf(str, "%s class add dev %s parent 1:%d classid 1:%d htb rate %Ldkbit ceil %Ldkbit burst %dk prio %d #down desired %d", \r
- tc, interface->name, parent, group->id, rate, max, burst_group, highest_priority+1, group->desired);\r
+ sprintf(str, "%s class add dev %s parent 1:%d classid 1:%d htb rate %Ldkbit ceil %Ldkbit burst %dk prio %d quantum %d #down desired %d", \r
+ tc, interface->name, parent, group->id, rate, max, burst_group, highest_priority+1, htb_quantum, group->desired);\r
safe_run(str);\r
}\r
\r
agreg = (int)((float)(avg_mbps_down+1)/min_mbps+.5);\r
ip->max /= agreg;\r
ip->pps_limit /= agreg;\r
- printf("Download aggregation 1:%d for %s (min: %lu Mbps avg: %ld Mbps)\n", agreg, ip->name, min_mbps, avg_mbps_down);\r
+ printf("Download aggregation 1:%d for %s (min: %d Mbps avg: %ld Mbps)\n", agreg, ip->name, min_mbps, avg_mbps_down);\r
}\r
else\r
{\r
unshape_this_ip = 0;\r
agreg = (int)((float)(avg_mbps_up+1)/min_mbps+.5);\r
ip->max /= agreg;\r
- printf("Upload aggregation 1:%d for %s: (min: %lu Mbps avg: %ld Mbps)\n", agreg, ip->name, min_mbps, avg_mbps_up);\r
+ printf("Upload aggregation 1:%d for %s: (min: %d Mbps avg: %ld Mbps)\n", agreg, ip->name, min_mbps, avg_mbps_up);\r
}\r
else\r
{\r
{\r
printf("[down %s: %dk-%dk wants %d]", interface->name, ip->min, ip->max, ip->desired);\r
}\r
- sprintf(str, "%s class change dev %s parent 1:%d classid 1:%d htb rate %dkbit ceil %dkbit burst %dk prio %d", \r
- tc, interface->name, ip->group, ip->mark, ip->min, ip->max, burst, ip->prio);\r
+ sprintf(str, "%s class change dev %s parent 1:%d classid 1:%d htb rate %dkbit ceil %dkbit burst %dk prio %d quantum %d", \r
+ tc, interface->name, ip->group, ip->mark, ip->min, ip->max, burst, ip->prio, htb_quantum);\r
safe_run(str);\r
}\r
else\r
(int)((ip->desired/ip->keyword->asymetry_ratio)-ip->keyword->asymetry_fixed),\r
(int)((ip->desired/ip->keyword->asymetry_ratio)-ip->keyword->asymetry_fixed));\r
}\r
- sprintf(str,"%s class change dev %s parent 1:%d classid 1:%d htb rate %dkbit ceil %dkbit burst %dk prio %d",\r
+ sprintf(str,"%s class change dev %s parent 1:%d classid 1:%d htb rate %dkbit ceil %dkbit burst %dk prio %d quantum %d",\r
tc, interface->name, ip->group, ip->mark,\r
(int)((ip->min/ip->keyword->asymetry_ratio)-ip->keyword->asymetry_fixed),\r
- (int)((ip->max/ip->keyword->asymetry_ratio)-ip->keyword->asymetry_fixed), burst, ip->prio);\r
+ (int)((ip->max/ip->keyword->asymetry_ratio)-ip->keyword->asymetry_fixed), burst, ip->prio, htb_quantum);\r
safe_run(str);\r
}\r
}\r
json_traffic=json_preview;\r
}\r
\r
- if(!mix_new_hosts && !dry_run && !just_flush)\r
+ if(!dry_run && !just_flush && !skip_stats)\r
{\r
/*-----------------------------------------------------------------*/\r
printf("Writing json traffic overview %s ... ", json_traffic);\r
printf("Writing statistics into HTML page %s ...\n", html);\r
/*-----------------------------------------------------------------*/\r
write_htmlandlogs(html, d, total, just_preview);\r
+ printf("\n");\r
}\r
\r
if(just_preview)\r
\r
printf("Statistics preview generated (-%c switch) - now exiting ...\n", swchar);\r
exit(0);\r
- }\r
- \r
+ } \r
+\r
i=0;\r
#ifdef DEBUG\r
printf("%-22s %-15s mark\n","name","ip");\r
}\r
\r
/*-----------------------------------------------------------------*/\r
- printf(" + generating iptables and tc classes ... ");\r
+ printf(" + generating iptables and tc classes ... \n");\r
/*-----------------------------------------------------------------*/\r
\r
for_each(ip, ips) if(ip->mark > 0)\r
printf("[down: %dk-%dk]", ip->min, ip->max);\r
#endif\r
\r
- sprintf(str, "%s class add dev %s parent 1:%d classid 1:%d htb rate %dkbit ceil %dkbit burst %dk prio %d", \r
- tc, interface->name, ip->group, ip->mark, ip->min, ip->max, burst, ip->prio);\r
+ sprintf(str, "%s class add dev %s parent 1:%d classid 1:%d htb rate %dkbit ceil %dkbit burst %dk prio %d quantum %d", \r
+ tc, interface->name, ip->group, ip->mark, ip->min, ip->max, burst, ip->prio, htb_quantum);\r
safe_run(str);\r
\r
if(strcmpi(ip->keyword->leaf_discipline, "none"))\r
{\r
fprintf(f, "%s %d\n", ip->addr, ip->mark);\r
}\r
+ printf(".");\r
}\r
if(f > 0)\r
{\r
- puts("done.");\r
+ puts(" done.");\r
fclose(f);\r
}\r
\r
/*-----------------------------------------------------------------*/\r
puts("Generating free bandwith class ...");\r
/*-----------------------------------------------------------------*/\r
- sprintf(str, "%s class add dev %s parent 1:%d classid 1:%d htb rate %dkbit ceil %dkbit burst %dk prio %d",\r
- tc, interface->name, parent, FREE_CLASS, free_min, free_max,burst, lowest_priority);\r
+ sprintf(str, "%s class add dev %s parent 1:%d classid 1:%d htb rate %dkbit ceil %dkbit burst %dk prio %d quantum %d",\r
+ tc, interface->name, parent, FREE_CLASS, free_min, free_max,burst, lowest_priority, htb_quantum);\r
safe_run(str);\r
/* tc SFQ */\r
if(strcmpi(qos_leaf, "none"))\r
sprintf(str,"%s filter add dev %s parent 1:0 protocol ip handle %d fw flowid 1:%d", tc, interface->name, FREE_CLASS, FREE_CLASS);\r
safe_run(str);\r
}\r
- /*-----------------------------------------------------------------*/\r
- puts("Generating bandwith class for overlimit packets...");\r
- /*-----------------------------------------------------------------*/\r
- sprintf(str, "%s class add dev %s parent 1:%d classid 1:%d htb rate %dkbit ceil %dkbit burst %dk prio %d",\r
- tc, interface->name, parent, OVERLIMIT_CLASS, overlimit_min, overlimit_max, burst, lowest_priority);\r
- safe_run(str);\r
+ if(*limit_pkts) /* non-empty string?*/\r
+ {\r
+ /*-----------------------------------------------------------------*/\r
+ puts("Generating bandwith class for overlimit packets...");\r
+ /*-----------------------------------------------------------------*/\r
+ sprintf(str, "%s class add dev %s parent 1:%d classid 1:%d htb rate %dkbit ceil %dkbit burst %dk prio %d quantum %d", \r
+ tc, interface->name, parent, OVERLIMIT_CLASS, overlimit_min, overlimit_max, burst, lowest_priority, htb_quantum);\r
+ safe_run(str);\r
+ }\r
} \r
printf("Total IP count: %d\n", i);\r
run_iptables_restore();\r