[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] Remus: python netlink fixes
# HG changeset patch # User Keir Fraser <keir.fraser@xxxxxxxxxx> # Date 1272961853 -3600 # Node ID 99a85cb72c9f2c37ee0fc97c6c13239f14d93a83 # Parent a167ea374f26ed06c7dd518599e202822e26ef97 Remus: python netlink fixes Fix deprecation warning in Qdisc class under python 2.6. Fix rtattr length and padding (rta_len is unaligned). Null-terminate qdisc name in rtnl messages. Signed-off-by: Brendan Cully <brendan@xxxxxxxxx> --- tools/python/xen/remus/netlink.py | 10 +++++++--- tools/python/xen/remus/qdisc.py | 6 +++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff -r a167ea374f26 -r 99a85cb72c9f tools/python/xen/remus/netlink.py --- a/tools/python/xen/remus/netlink.py Thu Apr 29 19:38:52 2010 +0100 +++ b/tools/python/xen/remus/netlink.py Tue May 04 09:30:53 2010 +0100 @@ -1,4 +1,6 @@ # netlink wrappers + +# See include/linux/netlink.h and rtnetlink.h import socket, struct import xen.lowlevel.netlink @@ -77,9 +79,9 @@ class rtattr(object): return align(self.rta_len) def pack(self): - self.rta_len = self.fmtlen + align(len(self.body), 2) + self.rta_len = self.fmtlen + len(self.body) s = struct.pack(self.fmt, self.rta_len, self.rta_type) + self.body - pad = self.rta_len - len(s) + pad = align(self.rta_len) - len(s) if pad: s += '\0' * pad return s @@ -127,14 +129,16 @@ class nlmsg(object): attr.rta_type = type attr.body = data self.rta += attr.pack() + self.nlmsg_len = len(self) def settype(self, cmd): self.nlmsg_type = cmd def pack(self): - return struct.pack(self.fmt, len(self), self.nlmsg_type, + s = struct.pack(self.fmt, len(self), self.nlmsg_type, self.nlmsg_flags, self.nlmsg_seq, self.nlmsg_pid) + self.body + self.rta + return s def unpack(self, msg): args = struct.unpack(self.fmt, msg[:self.fmtlen]) diff -r a167ea374f26 -r 99a85cb72c9f tools/python/xen/remus/qdisc.py --- a/tools/python/xen/remus/qdisc.py Thu Apr 29 19:38:52 2010 +0100 +++ b/tools/python/xen/remus/qdisc.py Tue May 04 09:30:53 2010 +0100 @@ -35,7 +35,7 @@ class addrequest(request): flags = netlink.NLM_F_EXCL|netlink.NLM_F_CREATE super(addrequest, self).__init__(netlink.RTM_NEWQDISC, flags=flags, dev=dev, handle=handle) - self.n.addattr(netlink.TCA_KIND, qdisc.kind) + self.n.addattr(netlink.TCA_KIND, qdisc.kind + '\0') opts = qdisc.pack() if opts: self.n.addattr(netlink.TCA_OPTIONS, opts) @@ -49,7 +49,7 @@ class changerequest(request): def __init__(self, dev, handle, qdisc): super(changerequest, self).__init__(netlink.RTM_NEWQDISC, dev=dev, handle=handle) - self.n.addattr(netlink.TCA_KIND, qdisc.kind) + self.n.addattr(netlink.TCA_KIND, qdisc.kind + '\0') opts = qdisc.pack() if opts: self.n.addattr(netlink.TCA_OPTIONS, opts) @@ -59,7 +59,7 @@ class Qdisc(object): if qdict: kind = qdict.get('kind') cls = qdisc_kinds.get(kind, cls) - obj = super(Qdisc, cls).__new__(cls, qdict=qdict, *args, **opts) + obj = super(Qdisc, cls).__new__(cls) return obj def __init__(self, qdict): _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |