X-Git-Url: http://git.harvie.cz/?a=blobdiff_plain;ds=sidebyside;f=prometheus.c;h=d8069b89661bc1aa747247495dd58cc1b881bd56;hb=296d0585b23ee7c91267d0cb9238dce836106180;hp=71b2a32e13c9a8188cac8dea38a67d22d0736e42;hpb=56f6397ec3e60052dce31b6417ff64572b880897;p=svn%2FPrometheus-QoS%2F.git
diff --git a/prometheus.c b/prometheus.c
index 71b2a32..d8069b8 100644
--- a/prometheus.c
+++ b/prometheus.c
@@ -2,12 +2,12 @@
/* Prometheus QoS - you can "steal fire" from your ISP */
/* "fair-per-IP" quality of service (QoS) utility */
/* requires Linux 2.4.x or 2.6.x with HTB support */
-/* Copyright(C) 2005-2017 Michael Polak, Arachne Aerospace */
+/* Copyright(C) 2005-2020 Michael Polak, Arachne Aerospace */
/* iptables-restore support Copyright(C) 2007-2008 ludva */
/* Credit: CZFree.Net,Martin Devera,Netdave,Aquarius,Gandalf */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-/* Modified by: xChaos, 20171012
+/* Modified by: xChaos, 20220607
ludva, 20080415
Prometheus QoS is free software; you can redistribute it and/or
@@ -29,7 +29,7 @@
#include "cll1-0.6.2.h"
#include "ipstruct.h"
-const char *version = "0.9.0-a";
+const char *version = "1.0.0-d";
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* Versions: 0.9.0 is development release, 1.0 will be "stable" */
@@ -40,7 +40,7 @@ const char *version = "0.9.0-a";
/* Warning: unofficial Github mirror is not supported by author! */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-const char *stats_html_signature = "Statistics generated by Prometheus QoS version %s
GPL+Copyright(C)2005-2017 Michael Polak, Arachne Labs\n";
+const char *stats_html_signature = "Statistics generated by Prometheus QoS version %s
GPL+Copyright(C)2005-2020 Michael Polak, Arachne Labs\n";
#define STRLEN 512
#undef DEBUG
@@ -61,7 +61,9 @@ char *hosts = "/etc/prometheus/hosts"; /* per-IP bandwidth definition
char *macrosfile = "/etc/prometheus/prometheus.macros"; /* rewrite rules for most common tariffs */
char *upstreamfile = "/etc/prometheus/upstream.interfaces"; /* list of interfaces to manage */
char *downstreamfile = "/etc/prometheus/downstream.interfaces"; /* list of interfaces to manage */
+char *qosfreefile = "/etc/prometheus/qosfree.interfaces"; /* list of interfaces to manage */
char *iptablesfile = "/var/spool/prometheus.iptables"; /* temporary file for iptables-restore*/
+char *iptablesdump = "/var/spool/prometheus.iptables-dump"; /* temporary file for iptables -L -v -x -n -t mangle */
char *ip6tablesfile = "/var/spool/prometheus.ip6tables"; /* temporary file for ip6tables-restore*/
char *credit = "/var/lib/misc/prometheus.credit"; /* credit log file */
char *classmap = "/var/lib/misc/prometheus.classes"; /* credit log file */
@@ -100,8 +102,10 @@ char *medium = "1000Mbit"; /* 10Mbit/100Mbit ethernet */
char *ip6prefix = NULL; /* Prefix for global /48 IPv6 subnet */
char *qos_leaf = "sfq perturb 5"; /* leaf discipline */
char *qos_free_zone = NULL; /* QoS free zone */
+char *qos_free_dst_ipset = NULL; /* QoS free zone - dst match ipset name, must be prepared outside prometheus */
+char *qos_free_src_ipset = NULL; /* QoS free zone - src match ipset name, must be prepared outside prometheus */
/* int qos_proxy = TRUE; include proxy port to QoS */
-int found_lmsid = FALSE; /* show links to users in LMS information system */
+int found_code = FALSE; /* show links to users in LMS information system */
int include_upload = TRUE; /* upload+download=total traffic */
/* char *proxy_ip = "192.168.1.1/32"; our IP with proxy port */
/* int proxy_port = 3128; proxy port number */
@@ -114,7 +118,8 @@ int overlimit_max = 512; /* maximum allowed bandwidth for all undefined hos
int qos_free_delay = 0; /* seconds to sleep before applying new QoS rules */
int digital_divide = 2; /* controls digital divide weirdness ratio, 1...3 */
int max_nesting = 5; /* /include/uapi/linux/pkt_sched.h: #define TC_HTB_MAXDEPTH 8 [... - 3 parent classes] */
-int htb_r2q = 256; /* should work for leaf values 512 kbps to 8 Mbps */
+//obsolete: int htb_r2q = 256; /* should work for leaf values 512 kbps to 8 Mbps */
+int htb_quantum = 1514; /* MTU + ethernet header */
int burst = 8; /* HTB burst (in kbits) */
int burst_main = 64;
int burst_group = 32;
@@ -138,6 +143,7 @@ struct Keyword *keyword, *defaultkeyword=NULL, *keywords = NULL;
struct Macro *macro, *macros = NULL;
struct Index *idxs = NULL, *idx, *metaindex;
struct Interface *interfaces = NULL, *interface;
+struct QosFreeInterface *qosfreeinterfaces = NULL, *qosfreeinterface;
#define FREE_CLASS 3
#define OVERLIMIT_CLASS 4
@@ -286,10 +292,12 @@ void get_config(char *config_filename)
option("ip6tables-save",ip6tablessave);
option("ip6tables-restore",ip6tablesrestore);
option("iptables-in-filename",iptablesfile);
+ option("iptables-dump-filename",iptablesdump);
option("ip6tables-in-filename",ip6tablesfile);
option("hosts",hosts);
option("downstream-interfaces-list-filename",downstreamfile);
option("upstream-interfaces-list-filename",upstreamfile);
+ option("qos-free-interfaces-list-filename",qosfreefile);
option("macros-filename",macrosfile);
option("ip6-prefix",ip6prefix);
option("medium",medium);
@@ -311,6 +319,8 @@ void get_config(char *config_filename)
option("lms-url",lms_url);
ioption("use-jquery-popups",use_jquery_popups);
option("qos-free-zone",qos_free_zone);
+ option("qos-free-dst-ipset",qos_free_dst_ipset);
+ option("qos-free-src-ipset",qos_free_src_ipset);
ioption("qos-free-delay",qos_free_delay);
/* ioption("qos-proxy-enable",qos_proxy); */
/* option("qos-proxy-ip",proxy_ip);*/
@@ -324,7 +334,7 @@ void get_config(char *config_filename)
ioption("htb-burst-main",burst_main);
ioption("htb-burst-group",burst_group);
ioption("htb-nesting-limit",max_nesting);
- ioption("htb-r2q",htb_r2q);
+ ioption("htb-quantum",htb_quantum);
ioption("magic-include-upload",include_upload);
ioption("magic-treshold",magic_treshold);
option("filter-type", cnf);
@@ -365,7 +375,7 @@ void get_config(char *config_filename)
}
-/* ========== This function executes, logs OR ALSO prints command ========== */
+/* ========== This function executes, logs or also prints command ========== */
void safe_run(char *cmd)
{
@@ -395,6 +405,10 @@ void iptables_save_line(char *line, int ipv6)
}
}
+#define IPv4 FALSE
+#define IPv6 TRUE
+
+
void run_iptables_restore(void)
{
char *restor;
@@ -404,7 +418,7 @@ void run_iptables_restore(void)
printf("Running %s <%s ...\n", iptablesrestore, iptablesfile);
/*-----------------------------------------------------------------*/
- iptables_save_line("COMMIT", FALSE);
+ iptables_save_line("COMMIT", IPv4);
fclose(iptables_file);
if(dry_run)
{
@@ -423,7 +437,7 @@ void run_iptables_restore(void)
/*-----------------------------------------------------------------*/
printf("Running %s <%s ...\n", ip6tablesrestore, ip6tablesfile);
/*-----------------------------------------------------------------*/
- iptables_save_line("COMMIT", TRUE);
+ iptables_save_line("COMMIT", IPv6);
fclose(ip6tables_file);
if(dry_run)
{
@@ -562,7 +576,6 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
}
}
done; /* ugly macro end */
-
if(just_logs)
{
@@ -601,6 +614,12 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
string(str, STRLEN);
string(limit_pkts, STRLEN);
+ /*-----------------------------------------------------------------*/
+ printf("Parsing qos free interfaces file %s ...\n", qosfreefile);
+ /*-----------------------------------------------------------------*/
+ load(qosfreeinterface, qosfreeinterfaces,
+ qosfreefile, QosFreeInterface, name);
+
/*-----------------------------------------------------------------*/
printf("Parsing macro definition file %s ...\n", macrosfile);
/*-----------------------------------------------------------------*/
@@ -624,14 +643,34 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
printf("Parsing class defintion file %s ...\n", hosts);
/*-----------------------------------------------------------------*/
parse_hosts(hosts);
-/*
- //this was pretty dumb idea anyway...
- if(just_networks)
+
+#ifdef MONITORINGTRHU_CTU
+//special hack only to generate certain required CSV statistics for www.ctu.cz (regulation body)
+//not required for everyday use, requires special syntax sugar in hosts file, see parsehosts.c
+ for_each(technology, technologies)
{
- analyse_topology("/usr/sbin/traceroute -n -m 10 -w 2 %s.%d");
- exit(-1);
- }
-*/
+ char *filename;
+ FILE *f;
+ string(filename, strlen(log_dir) + strlen(technology->filename) + 5);
+ strcpy(filename, log_dir);
+ strcat(filename, technology->filename);
+ strcat(filename, ".csv");
+ /*-----------------------------------------------------------------*/
+ printf("Writing report file %s ...\n", filename);
+ /*-----------------------------------------------------------------*/
+ f = fopen(filename, "w");
+ if(f)
+ {
+ for_each(ip, ips) if(eq(technology->filename, ip->technology_str))
+ {
+ fprintf(f,"%s,%s,%d\n", ip->code, ip->ruian_id_str, ip->max);
+ }
+ fclose(f);
+ }
+ else
+ perror(filename);
+ }
+#endif
/*-----------------------------------------------------------------*/
puts("Resolving shared connections ...");
@@ -645,7 +684,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
sharedip->traffic_up += ip->upload;
ip->traffic = 0;
ip->mark = sharedip->mark;
- ip->lmsid = sharedip->lmsid;
+ ip->code = sharedip->code;
ip->pps_limit = sharedip->pps_limit; /* no other way to do this */
/* Ugly hack: append IPv4 addresses of sharedip to IPv6 uplinks */
@@ -705,7 +744,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
perror(iptablesfile);
exit(-1);
}
- iptables_save_line(iptablespreamble, FALSE);
+ iptables_save_line(iptablespreamble, IPv4);
if(ip6prefix)
{
@@ -715,8 +754,8 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
perror(ip6tablesfile);
exit(-1);
}
- iptables_save_line(iptablespreamble, TRUE);
- iptables_save_line(ip6preamble, TRUE);
+ iptables_save_line(iptablespreamble, IPv6);
+ iptables_save_line(ip6preamble, IPv6);
}
run_iptables_restore();
@@ -735,22 +774,59 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
}
iptables_file=fopen(iptablesfile,"w");
- iptables_save_line(iptablespreamble, FALSE);
+ iptables_save_line(iptablespreamble, IPv4);
if(ip6prefix)
{
ip6tables_file=fopen(ip6tablesfile,"w");
- iptables_save_line(iptablespreamble, TRUE);
- iptables_save_line(ip6preamble, TRUE);
+ iptables_save_line(iptablespreamble, IPv6);
+ iptables_save_line(ip6preamble, IPv6);
+ }
+
+ /* this doesn't seem to be way to go... about 2/3 of all packets have ACK flag set
+ maybe with --length 40:100 it would make some sense, but not enought
+ for_each(interface, interfaces)
+ {
+ sprintf(str,"-A %s -m tcp -p tcp --tcp-flags ACK ACK -o %s -j ACCEPT", interface->chain, interface->name);
+ iptables_save_line(str, IPv4);
}
+ */
- if(qos_free_zone && *qos_free_zone!='0') /* this is currently supported only for IPv4 */
+ if(qos_free_zone && *qos_free_zone != '0') /* this is currently supported only for IPv4 */
{
for_each(interface, interfaces)
{
- sprintf(str,"-A %s -s %s -o %s -j ACCEPT", interface->chain, qos_free_zone, interface->name);
- iptables_save_line(str, FALSE);
+ sprintf(str,"-A %s -%c %s -o %s -j ACCEPT", interface->chain, (interface->is_upstream?'d':'s'), qos_free_zone, interface->name);
+ iptables_save_line(str, IPv4);
}
}
+
+ if(qos_free_dst_ipset && *qos_free_dst_ipset != '0') /* this is currently supported only for IPv4 */
+ {
+ for_each(interface, interfaces)
+ {
+ 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);
+ iptables_save_line(str, IPv4);
+ }
+ }
+
+ if(qos_free_src_ipset && *qos_free_src_ipset != '0') /* this is currently supported only for IPv4 */
+ {
+ for_each(interface, interfaces)
+ {
+ 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);
+ iptables_save_line(str, IPv4);
+ }
+ }
+
+ for_each(qosfreeinterface, qosfreeinterfaces)
+ {
+ sprintf(str,"-A FORWARD -i %s -j ACCEPT", qosfreeinterface->name);
+ iptables_save_line(str, IPv4);
+ iptables_save_line(str, IPv6);
+ sprintf(str,"-A POSTROUTING -o %s -j ACCEPT", qosfreeinterface->name);
+ iptables_save_line(str, IPv4);
+ iptables_save_line(str, IPv6);
+ }
if(ip_count > idxtable_treshold1 && !just_flush)
{
@@ -760,12 +836,12 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
printf("Detected %d addresses - indexing iptables rules to improve performance...\n",ip_count);
/*-----------------------------------------------------------------*/
- iptables_save_line(":post_common - [0:0]", FALSE);
- iptables_save_line(":forw_common - [0:0]", FALSE);
+ iptables_save_line(":post_common - [0:0]", IPv4);
+ iptables_save_line(":forw_common - [0:0]", IPv4);
if(ip6prefix)
{
- iptables_save_line(":post_common - [0:0]", TRUE);
- iptables_save_line(":forw_common - [0:0]", TRUE);
+ iptables_save_line(":post_common - [0:0]", IPv6);
+ iptables_save_line(":forw_common - [0:0]", IPv6);
}
for_each(ip,ips) if(ip->addr && *(ip->addr) && !eq(ip->addr,"0.0.0.0/0"))
@@ -868,10 +944,12 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
buf = interface->chain;
}
- sprintf(str,"-A %s -d %s/%d -o %s -j %s_%s", buf, subnet, idx->bitmask, interface->name, interface->idxprefix, idx->id);
+ sprintf(str, "-A %s -%c %s/%d -o %s -j %s_%s",
+ buf, (interface->is_upstream?'s':'d'), subnet, idx->bitmask, interface->name, interface->idxprefix, idx->id);
iptables_save_line(str, idx->ipv6);
- sprintf(str,"-A %s -d %s/%d -o %s -j %s_common", buf, subnet, idx->bitmask, interface->name, interface->idxprefix);
+ sprintf(str, "-A %s -%c %s/%d -o %s -j %s_common",
+ buf, (interface->is_upstream?'s':'d'), subnet, idx->bitmask, interface->name, interface->idxprefix);
iptables_save_line(str, idx->ipv6);
}
}
@@ -880,11 +958,11 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
for_each(interface, interfaces)
{
sprintf(str,"-A %s -o %s -j %s_common", interface->chain, interface->name, interface->idxprefix);
- iptables_save_line(str, FALSE);
+ iptables_save_line(str, IPv4);
if(ip6prefix)
{
sprintf(str,"-A %s -o %s -j %s_common", interface->chain, interface->name, interface->idxprefix);
- iptables_save_line(str, TRUE);
+ iptables_save_line(str, IPv6);
}
}
}
@@ -911,16 +989,16 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
for_each(interface, interfaces)
{
- sprintf(str, "%s qdisc add dev %s root handle 1: htb r2q %d default 1",
- tc, interface->name, htb_r2q);
+ sprintf(str, "%s qdisc add dev %s root handle 1: htb default 1",
+ tc, interface->name);
safe_run(str);
- sprintf(str, "%s class add dev %s parent 1: classid 1:2 htb rate %s ceil %s burst %dk prio %d",
- tc, interface->name, medium, medium, burst_main, highest_priority);
+ sprintf(str, "%s class add dev %s parent 1: classid 1:2 htb rate %s ceil %s burst %dk prio %d quantum %d",
+ tc, interface->name, medium, medium, burst_main, highest_priority, htb_quantum);
safe_run(str);
- sprintf(str, "%s class add dev %s parent 1:2 classid 1:1 htb rate %Ldkbit ceil %Ldkbit burst %dk prio %d",
- tc, interface->name, interface->speed, interface->speed, burst_main, highest_priority);
+ sprintf(str, "%s class add dev %s parent 1:2 classid 1:1 htb rate %Ldkbit ceil %Ldkbit burst %dk prio %d quantum %d",
+ tc, interface->name, interface->speed, interface->speed, burst_main, highest_priority, htb_quantum);
safe_run(str);
}
}
@@ -947,8 +1025,8 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
{
if(!just_preview)
{
- 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",
- tc, interface->name, parent, group->id, rate, max, burst_group, highest_priority+1, group->desired);
+ 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",
+ tc, interface->name, parent, group->id, rate, max, burst_group, highest_priority+1, htb_quantum, group->desired);
safe_run(str);
}
@@ -1123,8 +1201,8 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
{
printf("[down %s: %dk-%dk wants %d]", interface->name, ip->min, ip->max, ip->desired);
}
- sprintf(str, "%s class change dev %s parent 1:%d classid 1:%d htb rate %dkbit ceil %dkbit burst %dk prio %d",
- tc, interface->name, ip->group, ip->mark, ip->min, ip->max, burst, ip->prio);
+ sprintf(str, "%s class change dev %s parent 1:%d classid 1:%d htb rate %dkbit ceil %dkbit burst %dk prio %d quantum %d",
+ tc, interface->name, ip->group, ip->mark, ip->min, ip->max, burst, ip->prio, htb_quantum);
safe_run(str);
}
else
@@ -1135,10 +1213,10 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
(int)((ip->desired/ip->keyword->asymetry_ratio)-ip->keyword->asymetry_fixed),
(int)((ip->desired/ip->keyword->asymetry_ratio)-ip->keyword->asymetry_fixed));
}
- sprintf(str,"%s class change dev %s parent 1:%d classid 1:%d htb rate %dkbit ceil %dkbit burst %dk prio %d",
+ sprintf(str,"%s class change dev %s parent 1:%d classid 1:%d htb rate %dkbit ceil %dkbit burst %dk prio %d quantum %d",
tc, interface->name, ip->group, ip->mark,
(int)((ip->min/ip->keyword->asymetry_ratio)-ip->keyword->asymetry_fixed),
- (int)((ip->max/ip->keyword->asymetry_ratio)-ip->keyword->asymetry_fixed), burst, ip->prio);
+ (int)((ip->max/ip->keyword->asymetry_ratio)-ip->keyword->asymetry_fixed), burst, ip->prio, htb_quantum);
safe_run(str);
}
}
@@ -1174,6 +1252,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
printf("Writing statistics into HTML page %s ...\n", html);
/*-----------------------------------------------------------------*/
write_htmlandlogs(html, d, total, just_preview);
+ printf("\n");
}
if(just_preview)
@@ -1209,7 +1288,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
}
/*-----------------------------------------------------------------*/
- printf(" + generating iptables and tc classes ... ");
+ printf(" + generating iptables and tc classes ... \n");
/*-----------------------------------------------------------------*/
for_each(ip, ips) if(ip->mark > 0)
@@ -1257,25 +1336,27 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
#endif
/* ------------------------------------------------ iptables classify */
- sprintf(str, "-A %s -d %s/%d -o %s -j %s%d",
- chain, ip->addr, ip->mask,
+ sprintf(str, "-A %s -%c %s/%d -o %s -j %s%d",
+ chain, (interface->is_upstream?'s':'d'), ip->addr, ip->mask,
interface->name, mark_iptables, ip->mark);
iptables_save_line(str, ip->v6);
- sprintf(str, "-A %s -d %s/%d -o %s %s-j ACCEPT",
- chain, ip->addr, ip->mask, interface->name, limit_pkts);
+ sprintf(str, "-A %s -%c %s/%d -o %s %s-j ACCEPT",
+ chain, (interface->is_upstream?'s':'d'),ip->addr, ip->mask,
+ interface->name, limit_pkts);
iptables_save_line(str, ip->v6);
- if(limit_pkts)
+ if(*limit_pkts) /* non-empty string?*/
{
/* classify overlimit packets to separate overlimit class */
- sprintf(str, "-A %s -d %s/%d -o %s -j %s%d",
- chain, ip->addr, ip->mask,
+ sprintf(str, "-A %s -%c %s/%d -o %s -j %s%d",
+ chain, (interface->is_upstream?'s':'d'), ip->addr, ip->mask,
interface->name, mark_iptables, OVERLIMIT_CLASS);
iptables_save_line(str, ip->v6);
- sprintf(str, "-A %s -d %s/%d -o %s -j ACCEPT",
- chain, ip->addr, ip->mask, interface->name);
+ sprintf(str, "-A %s -%c %s/%d -o %s -j ACCEPT",
+ chain, (interface->is_upstream?'s':'d'), ip->addr, ip->mask,
+ interface->name);
iptables_save_line(str, ip->v6);
}
@@ -1288,8 +1369,8 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
printf("[down: %dk-%dk]", ip->min, ip->max);
#endif
- sprintf(str, "%s class add dev %s parent 1:%d classid 1:%d htb rate %dkbit ceil %dkbit burst %dk prio %d",
- tc, interface->name, ip->group, ip->mark, ip->min, ip->max, burst, ip->prio);
+ sprintf(str, "%s class add dev %s parent 1:%d classid 1:%d htb rate %dkbit ceil %dkbit burst %dk prio %d quantum %d",
+ tc, interface->name, ip->group, ip->mark, ip->min, ip->max, burst, ip->prio, htb_quantum);
safe_run(str);
if(strcmpi(ip->keyword->leaf_discipline, "none"))
@@ -1318,10 +1399,11 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
{
fprintf(f, "%s %d\n", ip->addr, ip->mark);
}
+ printf(".");
}
if(f > 0)
{
- puts("done.");
+ puts(" done.");
fclose(f);
}
@@ -1344,15 +1426,15 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
sprintf(str, "-A %s -o %s -j %s%d",
chain, interface->name, mark_iptables, FREE_CLASS);
- iptables_save_line(str, FALSE); /* only for IPv4 */
+ iptables_save_line(str, IPv4); /* only for IPv4 */
}
sprintf(str,"-A %s -o %s -j %s", chain, interface->name, final_chain);
- iptables_save_line(str, FALSE);
+ iptables_save_line(str, IPv4);
if(ip6prefix)
{
sprintf(str,"-A %s -o %s -j %s", chain, interface->name, final_chain);
- iptables_save_line(str, TRUE);
+ iptables_save_line(str, IPv6);
}
if(free_min) /* allocate free bandwith if it is not zero... */
@@ -1360,8 +1442,8 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
/*-----------------------------------------------------------------*/
puts("Generating free bandwith class ...");
/*-----------------------------------------------------------------*/
- sprintf(str, "%s class add dev %s parent 1:%d classid 1:%d htb rate %dkbit ceil %dkbit burst %dk prio %d",
- tc, interface->name, parent, FREE_CLASS, free_min, free_max,burst, lowest_priority);
+ sprintf(str, "%s class add dev %s parent 1:%d classid 1:%d htb rate %dkbit ceil %dkbit burst %dk prio %d quantum %d",
+ tc, interface->name, parent, FREE_CLASS, free_min, free_max,burst, lowest_priority, htb_quantum);
safe_run(str);
/* tc SFQ */
if(strcmpi(qos_leaf, "none"))
@@ -1373,12 +1455,15 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
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);
safe_run(str);
}
- /*-----------------------------------------------------------------*/
- puts("Generating bandwith class for overlimit packets...");
- /*-----------------------------------------------------------------*/
- sprintf(str, "%s class add dev %s parent 1:%d classid 1:%d htb rate %dkbit ceil %dkbit burst %dk prio %d",
- tc, interface->name, parent, OVERLIMIT_CLASS, overlimit_min, overlimit_max, burst, lowest_priority);
- safe_run(str);
+ if(*limit_pkts) /* non-empty string?*/
+ {
+ /*-----------------------------------------------------------------*/
+ puts("Generating bandwith class for overlimit packets...");
+ /*-----------------------------------------------------------------*/
+ sprintf(str, "%s class add dev %s parent 1:%d classid 1:%d htb rate %dkbit ceil %dkbit burst %dk prio %d quantum %d",
+ tc, interface->name, parent, OVERLIMIT_CLASS, overlimit_min, overlimit_max, burst, lowest_priority, htb_quantum);
+ safe_run(str);
+ }
}
printf("Total IP count: %d\n", i);
run_iptables_restore();