fixed linkconfig parameter name to match other linkconfig signatures
This commit is contained in:
parent
3fb8ae0439
commit
5b0ed13e78
1 changed files with 16 additions and 16 deletions
|
@ -185,55 +185,55 @@ class OvsNet(PyCoreNet):
|
||||||
|
|
||||||
ebtables_queue.ebchange(self)
|
ebtables_queue.ebchange(self)
|
||||||
|
|
||||||
def linkconfig(self, interface, bw=None, delay=None, loss=None, duplicate=None,
|
def linkconfig(self, netif, bw=None, delay=None, loss=None, duplicate=None,
|
||||||
jitter=None, netif2=None, devname=None):
|
jitter=None, netif2=None, devname=None):
|
||||||
"""
|
"""
|
||||||
Configure link parameters by applying tc queuing disciplines on the
|
Configure link parameters by applying tc queuing disciplines on the
|
||||||
interface.
|
interface.
|
||||||
"""
|
"""
|
||||||
if not devname:
|
if not devname:
|
||||||
devname = interface.localname
|
devname = netif.localname
|
||||||
|
|
||||||
tc = [constants.TC_BIN, "qdisc", "replace", "dev", devname]
|
tc = [constants.TC_BIN, "qdisc", "replace", "dev", devname]
|
||||||
parent = ["root"]
|
parent = ["root"]
|
||||||
|
|
||||||
# attempt to set bandwidth and update as needed if value changed
|
# attempt to set bandwidth and update as needed if value changed
|
||||||
bandwidth_changed = interface.setparam("bw", bw)
|
bandwidth_changed = netif.setparam("bw", bw)
|
||||||
if bandwidth_changed:
|
if bandwidth_changed:
|
||||||
# from tc-tbf(8): minimum value for burst is rate / kernel_hz
|
# from tc-tbf(8): minimum value for burst is rate / kernel_hz
|
||||||
if bw > 0:
|
if bw > 0:
|
||||||
if self.up:
|
if self.up:
|
||||||
burst = max(2 * interface.mtu, bw / 1000)
|
burst = max(2 * netif.mtu, bw / 1000)
|
||||||
limit = 0xffff # max IP payload
|
limit = 0xffff # max IP payload
|
||||||
tbf = ["tbf", "rate", str(bw), "burst", str(burst), "limit", str(limit)]
|
tbf = ["tbf", "rate", str(bw), "burst", str(burst), "limit", str(limit)]
|
||||||
logger.info("linkconfig: %s" % [tc + parent + ["handle", "1:"] + tbf])
|
logger.info("linkconfig: %s" % [tc + parent + ["handle", "1:"] + tbf])
|
||||||
utils.check_cmd(tc + parent + ["handle", "1:"] + tbf)
|
utils.check_cmd(tc + parent + ["handle", "1:"] + tbf)
|
||||||
interface.setparam("has_tbf", True)
|
netif.setparam("has_tbf", True)
|
||||||
elif interface.getparam("has_tbf") and bw <= 0:
|
elif netif.getparam("has_tbf") and bw <= 0:
|
||||||
tcd = [] + tc
|
tcd = [] + tc
|
||||||
tcd[2] = "delete"
|
tcd[2] = "delete"
|
||||||
|
|
||||||
if self.up:
|
if self.up:
|
||||||
utils.check_cmd(tcd + parent)
|
utils.check_cmd(tcd + parent)
|
||||||
|
|
||||||
interface.setparam("has_tbf", False)
|
netif.setparam("has_tbf", False)
|
||||||
# removing the parent removes the child
|
# removing the parent removes the child
|
||||||
interface.setparam("has_netem", False)
|
netif.setparam("has_netem", False)
|
||||||
|
|
||||||
if interface.getparam("has_tbf"):
|
if netif.getparam("has_tbf"):
|
||||||
parent = ["parent", "1:1"]
|
parent = ["parent", "1:1"]
|
||||||
|
|
||||||
netem = ["netem"]
|
netem = ["netem"]
|
||||||
delay_changed = interface.setparam("delay", delay)
|
delay_changed = netif.setparam("delay", delay)
|
||||||
|
|
||||||
if loss is not None:
|
if loss is not None:
|
||||||
loss = float(loss)
|
loss = float(loss)
|
||||||
loss_changed = interface.setparam("loss", loss)
|
loss_changed = netif.setparam("loss", loss)
|
||||||
|
|
||||||
if duplicate is not None:
|
if duplicate is not None:
|
||||||
duplicate = float(duplicate)
|
duplicate = float(duplicate)
|
||||||
duplicate_changed = interface.setparam("duplicate", duplicate)
|
duplicate_changed = netif.setparam("duplicate", duplicate)
|
||||||
jitter_changed = interface.setparam("jitter", jitter)
|
jitter_changed = netif.setparam("jitter", jitter)
|
||||||
|
|
||||||
# if nothing changed return
|
# if nothing changed return
|
||||||
if not any([bandwidth_changed, delay_changed, loss_changed, duplicate_changed, jitter_changed]):
|
if not any([bandwidth_changed, delay_changed, loss_changed, duplicate_changed, jitter_changed]):
|
||||||
|
@ -256,7 +256,7 @@ class OvsNet(PyCoreNet):
|
||||||
|
|
||||||
if delay <= 0 and jitter <= 0 and loss <= 0 and duplicate <= 0:
|
if delay <= 0 and jitter <= 0 and loss <= 0 and duplicate <= 0:
|
||||||
# possibly remove netem if it exists and parent queue wasn"t removed
|
# possibly remove netem if it exists and parent queue wasn"t removed
|
||||||
if not interface.getparam("has_netem"):
|
if not netif.getparam("has_netem"):
|
||||||
return
|
return
|
||||||
|
|
||||||
tc[2] = "delete"
|
tc[2] = "delete"
|
||||||
|
@ -264,12 +264,12 @@ class OvsNet(PyCoreNet):
|
||||||
if self.up:
|
if self.up:
|
||||||
logger.info("linkconfig: %s" % ([tc + parent + ["handle", "10:"]],))
|
logger.info("linkconfig: %s" % ([tc + parent + ["handle", "10:"]],))
|
||||||
utils.check_cmd(tc + parent + ["handle", "10:"])
|
utils.check_cmd(tc + parent + ["handle", "10:"])
|
||||||
interface.setparam("has_netem", False)
|
netif.setparam("has_netem", False)
|
||||||
elif len(netem) > 1:
|
elif len(netem) > 1:
|
||||||
if self.up:
|
if self.up:
|
||||||
logger.info("linkconfig: %s" % ([tc + parent + ["handle", "10:"] + netem],))
|
logger.info("linkconfig: %s" % ([tc + parent + ["handle", "10:"] + netem],))
|
||||||
utils.check_cmd(tc + parent + ["handle", "10:"] + netem)
|
utils.check_cmd(tc + parent + ["handle", "10:"] + netem)
|
||||||
interface.setparam("has_netem", True)
|
netif.setparam("has_netem", True)
|
||||||
|
|
||||||
def linknet(self, network):
|
def linknet(self, network):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue