/* Credit: CZFree.Net,Martin Devera,Netdave,Aquarius,Gandalf */\r
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */\r
\r
-/* Modified by: xChaos, 20200107\r
+/* Modified by: xChaos, 20220607\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 = "1.0.0-a";\r
+const char *version = "1.0.0-d";\r
\r
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */\r
/* Versions: 0.9.0 is development release, 1.0 will be "stable" */\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
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
for_each(ip, ips) if(eq(technology->filename, ip->technology_str))\r
{\r
- fprintf(f,"%d,%s,%d\n", ip->lmsid, ip->ruian_id_str, ip->max);\r
+ fprintf(f,"%s,%s,%d\n", ip->code, ip->ruian_id_str, ip->max);\r
}\r
fclose(f);\r
}\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
iptables_save_line(ip6preamble, IPv6);\r
}\r
\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
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(!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
{\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
}\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