From 5450cb417ed9adc4abb072f449e2ea4e68d0551e Mon Sep 17 00:00:00 2001 From: xchaos Date: Sun, 27 Mar 2022 15:55:48 +0000 Subject: [PATCH 1/3] fixed HTB quantum 1514 instead of r2q git-svn-id: https://dev.arachne.cz/repos/prometheus/trunk@279 251d49ef-1d17-4917-a970-b30cf55b089b --- prometheus.c | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/prometheus.c b/prometheus.c index 4cc02a0..9ddd593 100644 --- a/prometheus.c +++ b/prometheus.c @@ -7,7 +7,7 @@ /* Credit: CZFree.Net,Martin Devera,Netdave,Aquarius,Gandalf */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -/* Modified by: xChaos, 20200107 +/* Modified by: xChaos, 20220327 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 = "1.0.0-a"; +const char *version = "1.0.0-b"; /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* Versions: 0.9.0 is development release, 1.0 will be "stable" */ @@ -118,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; @@ -333,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); @@ -374,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) { @@ -979,16 +980,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); } } @@ -1015,8 +1016,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); } @@ -1191,8 +1192,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 @@ -1203,10 +1204,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); } } @@ -1359,8 +1360,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")) @@ -1431,8 +1432,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")) @@ -1447,8 +1448,8 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); /*-----------------------------------------------------------------*/ 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); + 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); -- 2.30.2 From 296d0585b23ee7c91267d0cb9238dce836106180 Mon Sep 17 00:00:00 2001 From: xchaos Date: Sat, 11 Mar 2023 17:20:27 +0000 Subject: [PATCH 2/3] lmsid -> code git-svn-id: https://dev.arachne.cz/repos/prometheus/trunk@280 251d49ef-1d17-4917-a970-b30cf55b089b --- htmlandlogs.c | 20 ++++++++++---------- ipstruct.h | 2 +- json.c | 6 +++--- parsehosts.c | 37 ++++++++++++++++++++----------------- prometheus.c | 39 ++++++++++++++++++++++++++------------- 5 files changed, 60 insertions(+), 44 deletions(-) diff --git a/htmlandlogs.c b/htmlandlogs.c index 798544d..431d044 100644 --- a/htmlandlogs.c +++ b/htmlandlogs.c @@ -18,7 +18,7 @@ extern int dry_run; extern int qos_proxy; extern char *title; extern char *log_url; -extern int found_lmsid; +extern int found_code; extern char *lms_url; extern char *log_dir; extern char *ip6prefix; @@ -42,9 +42,9 @@ void append_log(struct IP *self) /*using global variables*/ f = fopen(str, "a"); if(f > 0) { - fprintf(f, "%ld\t%s\t%Lu\t%Lu\t%Lu\t%Lu\t%d\t%d\t%d\t%d\t%s", + fprintf(f, "%ld\t%s\t%Lu\t%Lu\t%Lu\t%Lu\t%d\t%d\t%d\t%s\t%s", time(NULL), self->name, self->traffic, self->direct, self->proxy, - self->upload, self->min, self->max, self->desired, self->lmsid, d); /* d = date*/ + self->upload, self->min, self->max, self->desired, self->code, d); /* d = date*/ fclose(f); } else @@ -125,7 +125,7 @@ void write_htmlandlogs(char *html, char *d, int total, int just_preview) i=0; if(f > 0) { - unsigned long long total_traffic=0, total_direct=0, total_proxy=0, total_upload=0, tmp_sum = 0; + unsigned long long total_traffic = 1 /* prevent divide by zero */ , total_direct=0, total_proxy=0, total_upload=0, tmp_sum = 0; unsigned long long total_pktup = 0, total_pktdown = 0; int active_classes = 0; // int colspan = 14; @@ -133,7 +133,7 @@ void write_htmlandlogs(char *html, char *d, int total, int just_preview) int agreg_count = 0, limit_count = 0, prio_count = 0; int popup_button = 0; /* IPv6 vs. IPv4 stats */ - unsigned long long pkts4 =0, pkts6 = 0, bytes4 = 0, bytes6 = 0; + unsigned long long pkts4 = 1, pkts6 = 1 /*prevent divide by zero */, bytes4 = 0, bytes6 = 0; int count4 = 0, count6 = 0; int mpkts; double perc6; @@ -255,15 +255,15 @@ style=\"cursor: pointer;\">+%d]", fputs("\n",f); /* ----------------------------------------------- */ - if(found_lmsid) + if(found_code) { fputs("",f); - if(ip->lmsid > 0) + if(ip->code[0]) { - fprintf(f, "%04d\n", - lms_url, ip->lmsid, ip->lmsid); + fprintf(f, "%s\n", + lms_url, ip->code, ip->code); } - else if(ip->lmsid == 0) + else if(ip->code[0] == 0) { fputs("------",f); } diff --git a/ipstruct.h b/ipstruct.h index 3b80747..17635ff 100644 --- a/ipstruct.h +++ b/ipstruct.h @@ -15,7 +15,7 @@ struct IP int aggregated; int fixedprio; int group; - int lmsid; + char *code; int pps_limit; unsigned long long direct; unsigned long long proxy; diff --git a/json.c b/json.c index c04a568..f09f916 100644 --- a/json.c +++ b/json.c @@ -15,7 +15,7 @@ void write_json_traffic(char *json) for_each(ip, ips) { - if( ip->lmsid > 0 + if( ip->code[0] > 0 and (ip->traffic or ip->direct or ip->proxy or ip->upload)) { if(jsoncount) @@ -23,10 +23,10 @@ void write_json_traffic(char *json) fprintf(f, ",\n"); } fprintf(f, - " \"%s\":{ \"lms\": %d, \"ip\":\"%s\", \"total\":%Lu, \"down\":%Lu, \ + " \"%s\":{ \"code\": %s, \"ip\":\"%s\", \"total\":%Lu, \"down\":%Lu, \ \"proxy\":%Lu, \"up\":%Lu, \"min\":%d, \"max\":%d, \"limit\":%d, \ \"pktsup\":%Lu, \"pktsdown\":%Lu, \"realquota\":%Lu, \"credit\":%Lu, \"dailyquota\":%ld }", - ip->name, ip->lmsid, ip->addr, ip->traffic, ip->direct, ip->proxy, + ip->name, ip->code, ip->addr, ip->traffic, ip->direct, ip->proxy, ip->upload, ip->min, ip->desired, ip->max, ip->pktsup, ip->pktsdown, ip->realquota, ip->credit, (ip->min*ip->keyword->data_limit+(ip->keyword->fixed_limit<<20))); jsoncount++; diff --git a/parsehosts.c b/parsehosts.c index f356f16..cc2548f 100644 --- a/parsehosts.c +++ b/parsehosts.c @@ -13,7 +13,7 @@ extern struct Keyword *keyword, *defaultkeyword, *keywords; extern struct Macro *macro, *macros; extern int class_count; extern int ip_count; -extern int found_lmsid; +extern int found_code; extern int free_min; extern const int highest_priority; extern char *ip6prefix; @@ -29,7 +29,7 @@ void TheIP(char *ipaddr, int is_network) ip->addr = ipaddr; ip->sharing = NULL; ip->prio = highest_priority+1; - ip->lmsid = -1; + ip->code = "-----"; ip->fixedprio = \ ip->aggregated = \ ip->mark = \ @@ -74,7 +74,7 @@ struct IP *lastIP6range, *lastIP6uplink; void parse_and_append_ip(char *str, struct IP *listhead) { char *ptr, *ipaddr, *nextip6, *ip6buf; - char *ip6uplink = NULL, *ip6range = NULL, *ipname = NULL, *lmsid = NULL; + char *ip6uplink = NULL, *ip6range = NULL, *ipname = NULL, *code = NULL; if(ip6prefix) /* Try this only if IPv6 subsystem is active... */ { @@ -105,7 +105,7 @@ void parse_and_append_ip(char *str, struct IP *listhead) ptr = strchr(str, '{'); if(ptr) { - lmsid = ++ptr; + code = ++ptr; while(*ptr and *ptr != '}') { ptr++; @@ -144,9 +144,9 @@ void parse_and_append_ip(char *str, struct IP *listhead) } ip->name = ip6range; ip->keyword = defaultkeyword; /* settings for default keyword */ - if(lmsid) + if(code) { - ip->lmsid = atoi(lmsid); + ip->code = code; } lastIP6range = ip; } @@ -163,9 +163,9 @@ void parse_and_append_ip(char *str, struct IP *listhead) TheIP(ip6uplink, FALSE); /* always new IP - more IPs in single uplink network */ ip->name = ip6uplink; ip->keyword = defaultkeyword; /* settings for default keyword */ - if(lmsid) + if(code) { - ip->lmsid = atoi(lmsid); + ip->code = code; } lastIP6uplink = ip; } @@ -180,10 +180,10 @@ void parse_and_append_ip(char *str, struct IP *listhead) TheIP(ipaddr, (listhead==networks)); } ip->name = ipname; - if(lmsid) + if(code) { - ip->lmsid = atoi(lmsid); - found_lmsid = TRUE; + ip->code = code; + found_code = TRUE; } } @@ -375,14 +375,17 @@ void parse_hosts(char *hosts) } } - /* avg MTU bytes * 8 >> 10 = in bits, max is in kb/s */ - pktratio = (ip->keyword->allowed_avgmtu*8) >> 10; - if(pktratio > 0) + if(ip->keyword->allowed_avgmtu) { - ip->pps_limit = ip->max/pktratio; - if(ip->pps_limit > 10000) /* this limit seems to be hardcoded in iptables */ + /* avg MTU bytes * 8 >> 10 = in bits, max is in kb/s */ + pktratio = (ip->keyword->allowed_avgmtu*8) >> 10; + if(pktratio > 0) { - ip->pps_limit = 0; /* do not apply packet limits */ + ip->pps_limit = ip->max/pktratio; + if(ip->pps_limit > 10000) /* this limit seems to be hardcoded in iptables */ + { + ip->pps_limit = 0; /* do not apply packet limits */ + } } } diff --git a/prometheus.c b/prometheus.c index 9ddd593..d8069b8 100644 --- a/prometheus.c +++ b/prometheus.c @@ -7,7 +7,7 @@ /* Credit: CZFree.Net,Martin Devera,Netdave,Aquarius,Gandalf */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -/* Modified by: xChaos, 20220327 +/* 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 = "1.0.0-b"; +const char *version = "1.0.0-d"; /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* Versions: 0.9.0 is development release, 1.0 will be "stable" */ @@ -105,7 +105,7 @@ 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 */ @@ -663,7 +663,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); { for_each(ip, ips) if(eq(technology->filename, ip->technology_str)) { - fprintf(f,"%d,%s,%d\n", ip->lmsid, ip->ruian_id_str, ip->max); + fprintf(f,"%s,%s,%d\n", ip->code, ip->ruian_id_str, ip->max); } fclose(f); } @@ -684,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 */ @@ -782,6 +782,15 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); 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 */ { for_each(interface, interfaces) @@ -1279,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) @@ -1390,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); } @@ -1445,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 quantum %d", - tc, interface->name, parent, OVERLIMIT_CLASS, overlimit_min, overlimit_max, burst, lowest_priority, htb_quantum); - 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(); -- 2.30.2 From 5aca3d039171ff9609353f2cfffa0020b76ce542 Mon Sep 17 00:00:00 2001 From: xchaos Date: Sat, 28 Oct 2023 12:58:51 +0000 Subject: [PATCH 3/3] -b Boot mode git-svn-id: https://dev.arachne.cz/repos/prometheus/trunk@281 251d49ef-1d17-4917-a970-b30cf55b089b --- help.c | 3 ++- prometheus.c | 21 +++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/help.c b/help.c index 868f0e6..049b156 100644 --- a/help.c +++ b/help.c @@ -1,4 +1,4 @@ -/* Modified by: xChaos, 20131029 */ +/* Modified by: xChaos, 20231028 */ #include "cll1-0.6.2.h" @@ -9,6 +9,7 @@ void help(void) puts("Command line switches:\n\ \n\ -d Dry run (preview tc and iptables commands on stdout)\n\ +-b Boot run (no to gather and write data transfer statistics)\n\ -r Run (reset all statistics and start shaping - daily usage)\n\ -p just generate Preview of data transfer statistics and exit (after -r)\n\ -s Start shaping FUP limits (keeps data transfer stat like -p) (after -r)\n\ diff --git a/prometheus.c b/prometheus.c index d8069b8..8aacb50 100644 --- a/prometheus.c +++ b/prometheus.c @@ -7,7 +7,7 @@ /* Credit: CZFree.Net,Martin Devera,Netdave,Aquarius,Gandalf */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -/* Modified by: xChaos, 20220607 +/* Modified by: xChaos, 20231028 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 = "1.0.0-d"; +const char *version = "1.0.1"; /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* Versions: 0.9.0 is development release, 1.0 will be "stable" */ @@ -87,7 +87,8 @@ int filter_type = 1; /*1 mark, 2 classify*/ char *final_chain = "DROP"; /* REJECT would be better, but it is impossible in mangle */ char *mark = "MARK"; char *mark_iptables = "MARK --set-mark "; -int dry_run = FALSE; /* preview - use puts() instead of system() */ +int dry_run = FALSE; /* preview commands - use puts() instead of system() */ +int skip_stats = FALSE; /* skip generating statistics */ 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]"; 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"; FILE *iptables_file = NULL; @@ -188,7 +189,6 @@ const char *tr_odd_even(void) } } - /* ====== iptables indexes are used to reduce complexity to log8(N) ===== */ char *index_id(char *ip, int bitmask); @@ -504,6 +504,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); argument("-s") { run=TRUE; just_preview=TRUE; start_shaping=TRUE; } argument("-r") { run=TRUE; } argument("-n") { run=TRUE; nodelay=TRUE; } + argument("-b") { run=TRUE; nodelay=TRUE; skip_stats=TRUE; } argument("-a") { run=TRUE; just_networks=TRUE; } argument("-l") { just_logs=TRUE; } argument("-m") { just_logs=TRUE; } @@ -546,7 +547,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); interface->chain = "FORWARD"; interface->idxprefix = "forw"; push(interface, interfaces); - printf("Upstream interface %s: medium %s capacity %ld kbps\n", interface->name, medium, interface->speed); + printf("Upstream interface %s: medium %s capacity %Ld kbps\n", interface->name, medium, interface->speed); } } done; /* ugly macro end */ @@ -572,7 +573,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); interface->chain = "POSTROUTING"; interface->idxprefix = "post"; push(interface, interfaces); - printf("Downstream interface %s: medium %s capacity %ld kbps\n", interface->name, medium, interface->speed); + printf("Downstream interface %s: medium %s capacity %Ld kbps\n", interface->name, medium, interface->speed); } } done; /* ugly macro end */ @@ -593,7 +594,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); hosts = althosts; } - if(just_flush<9) + if(just_flush<9 && !skip_stats) { /*-----------------------------------------------------------------*/ puts("Parsing iptables verbose output ..."); @@ -1134,7 +1135,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); agreg = (int)((float)(avg_mbps_down+1)/min_mbps+.5); ip->max /= agreg; ip->pps_limit /= agreg; - printf("Download aggregation 1:%d for %s (min: %lu Mbps avg: %ld Mbps)\n", agreg, ip->name, min_mbps, avg_mbps_down); + printf("Download aggregation 1:%d for %s (min: %d Mbps avg: %ld Mbps)\n", agreg, ip->name, min_mbps, avg_mbps_down); } else { @@ -1154,7 +1155,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); unshape_this_ip = 0; agreg = (int)((float)(avg_mbps_up+1)/min_mbps+.5); ip->max /= agreg; - printf("Upload aggregation 1:%d for %s: (min: %lu Mbps avg: %ld Mbps)\n", agreg, ip->name, min_mbps, avg_mbps_up); + printf("Upload aggregation 1:%d for %s: (min: %d Mbps avg: %ld Mbps)\n", agreg, ip->name, min_mbps, avg_mbps_up); } else { @@ -1241,7 +1242,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); json_traffic=json_preview; } - if(!dry_run && !just_flush) + if(!dry_run && !just_flush && !skip_stats) { /*-----------------------------------------------------------------*/ printf("Writing json traffic overview %s ... ", json_traffic); -- 2.30.2