X-Git-Url: https://git.harvie.cz/?p=svn%2FPrometheus-QoS%2F.git;a=blobdiff_plain;f=parsehosts.c;h=7e12a41b34d1280821ef1c916e417675fade4b4a;hp=ac9b39fd47c374f23c965bb159f3223c2648258c;hb=a25842fafee4469c8acbacd673fc4c905bcab3f9;hpb=9694a8ec9258e894c4001b076a6c7f6c0e5a46f4 diff --git a/parsehosts.c b/parsehosts.c index ac9b39f..7e12a41 100644 --- a/parsehosts.c +++ b/parsehosts.c @@ -40,6 +40,7 @@ void TheIP(char *ipaddr, int is_network) ip->direct = \ ip->traffic = \ ip->pktsup = \ + ip->pps_limit = \ ip->pktsdown = 0; ip->keyword = keywords; ip->v6 = (strchr(ip->addr,':')!=NULL); @@ -252,13 +253,21 @@ void parse_hosts(char *hosts) else { ip->max -= ip->keyword->reserve_max; - if(ip->maxmin) + if(ip->max < ip->min) { - ip->max=ip->min; + ip->max = ip->min; } } - ip->mark = FIRSTIPCLASS+1+class_count++; + /* MTU is 1450 bytes = 11600 bits ~= 12 kbit, max is in kb/s + average pkt 1/2 MTU = 6 kbit*/ + ip->pps_limit = ip->max/6; + if(ip->pps_limit > 10000) /* this limit seems to be hardcoded in iptables */ + { + ip->pps_limit = 0; /* do not apply packet limits */ + } + + ip->mark = FIRSTIPCLASS+1+class_count++; update_network(ip->addr, ip); if_exists(group,groups,(group->min == ip->min))