X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=python%2Fbwlimit.py;h=8221e7b91878afaf72680544bfa692a47727a62b;hb=05b5a9ba6c637e5b7ff30a0ea67a9ebb32e8a595;hp=61355c82772245e3bcf9914e624913793db57a0c;hpb=924afbaf4bd0566d7ea8ad8890a34cfeceeee30a;p=util-vserver.git diff --git a/python/bwlimit.py b/python/bwlimit.py index 61355c8..8221e7b 100644 --- a/python/bwlimit.py +++ b/python/bwlimit.py @@ -46,7 +46,7 @@ # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # -# $Id: bwlimit.py,v 1.12 2006/04/24 20:04:13 mlhuang Exp $ +# $Id: bwlimit.py,v 1.15 2007/02/07 04:21:11 mlhuang Exp $ # import sys, os, re, getopt @@ -348,8 +348,11 @@ def init(dev = dev, bwcap = bwmax): # Set up the root class (and tell VNET what it is). Packets sent # by root end up here and are capped at the node bandwidth # cap. - on(root_xid, dev, share = root_share) - file("/proc/sys/vnet/root_class", "w").write("%d" % ((1 << 16) | default_minor | root_xid)) + #on(root_xid, dev, share = root_share) + #try: + # file("/proc/sys/vnet/root_class", "w").write("%d" % ((1 << 16) | default_minor | root_xid)) + #except: + # pass # Set up the default class. Packets that fail classification end # up here. @@ -508,12 +511,20 @@ def on(xid, dev = dev, share = None, minrate = None, maxrate = None, minexemptra maxexemptrate = get_tc_rate(maxexemptrate) # Sanity checks + if maxrate < bwmin: + maxrate = bwmin if maxrate > bwcap: maxrate = bwcap + if minrate < bwmin: + minrate = bwmin if minrate > maxrate: minrate = maxrate + if maxexemptrate < bwmin: + maxexemptrate = bwmin if maxexemptrate > bwmax: maxexemptrate = bwmax + if minexemptrate < bwmin: + minexemptrate = bwmin if minexemptrate > maxexemptrate: minexemptrate = maxexemptrate @@ -563,7 +574,7 @@ def exempt_init(group_name, node_ips): """ # Clean up - iptables = "/sbin/iptables -t vnet %s POSTROUTING" + iptables = "/sbin/iptables -t MANGLE %s POSTROUTING" run(iptables % "-F") run("/sbin/ipset -X " + group_name)