git://git.onelab.eu
/
util-vserver.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge 0.30.214.
[util-vserver.git]
/
python
/
bwlimit.py
diff --git
a/python/bwlimit.py
b/python/bwlimit.py
index
5f35fe8
..
8221e7b
100644
(file)
--- a/
python/bwlimit.py
+++ b/
python/bwlimit.py
@@
-46,7
+46,7
@@
# Mark Huang <mlhuang@cs.princeton.edu>
# Copyright (C) 2006 The Trustees of Princeton University
#
# Mark Huang <mlhuang@cs.princeton.edu>
# Copyright (C) 2006 The Trustees of Princeton University
#
-# $Id: bwlimit.py,v 1.1
1 2006/03/15 16:41:21 smuir
Exp $
+# $Id: bwlimit.py,v 1.1
5 2007/02/07 04:21:11 mlhuang
Exp $
#
import sys, os, re, getopt
#
import sys, os, re, getopt
@@
-303,14
+303,17
@@
def tc(cmd):
return run(TC + " " + cmd)
return run(TC + " " + cmd)
-def init(dev
, bwcap
):
+def init(dev
= dev, bwcap = bwmax
):
"""
(Re)initialize the bandwidth limits on this node
"""
"""
(Re)initialize the bandwidth limits on this node
"""
- #
l
oad the module used to manage exempt classes
+ #
L
oad the module used to manage exempt classes
run("/sbin/modprobe ip_set_iphash")
run("/sbin/modprobe ip_set_iphash")
+ # Save current settings
+ paramslist = get(None, dev)
+
# Delete root qdisc 1: if it exists. This will also automatically
# delete any child classes.
for line in tc("qdisc show dev %s" % dev):
# Delete root qdisc 1: if it exists. This will also automatically
# delete any child classes.
for line in tc("qdisc show dev %s" % dev):
@@
-345,13
+348,24
@@
def init(dev, bwcap):
# 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.
# 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.
on(default_xid, dev, share = default_share)
# Set up the default class. Packets that fail classification end
# up here.
on(default_xid, dev, share = default_share)
+ # Restore old settings
+ for (xid, share,
+ minrate, maxrate,
+ minexemptrate, maxexemptrate,
+ bytes, exemptbytes) in paramslist:
+ if xid not in (root_xid, default_xid):
+ on(xid, dev, share, minrate, maxrate, minexemptrate, maxexemptrate)
+
def get(xid = None, dev = dev):
"""
def get(xid = None, dev = dev):
"""
@@
-497,12
+511,20
@@
def on(xid, dev = dev, share = None, minrate = None, maxrate = None, minexemptra
maxexemptrate = get_tc_rate(maxexemptrate)
# Sanity checks
maxexemptrate = get_tc_rate(maxexemptrate)
# Sanity checks
+ if maxrate < bwmin:
+ maxrate = bwmin
if maxrate > bwcap:
maxrate = bwcap
if maxrate > bwcap:
maxrate = bwcap
+ if minrate < bwmin:
+ minrate = bwmin
if minrate > maxrate:
minrate = maxrate
if minrate > maxrate:
minrate = maxrate
+ if maxexemptrate < bwmin:
+ maxexemptrate = bwmin
if maxexemptrate > bwmax:
maxexemptrate = bwmax
if maxexemptrate > bwmax:
maxexemptrate = bwmax
+ if minexemptrate < bwmin:
+ minexemptrate = bwmin
if minexemptrate > maxexemptrate:
minexemptrate = maxexemptrate
if minexemptrate > maxexemptrate:
minexemptrate = maxexemptrate
@@
-552,7
+574,7
@@
def exempt_init(group_name, node_ips):
"""
# Clean up
"""
# 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)
run(iptables % "-F")
run("/sbin/ipset -X " + group_name)