summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2016-02-05 12:58:07 +0900
committerLorenzo Colitti <lorenzo@google.com>2016-02-05 13:03:18 +0900
commitc5673f350e1e38b101a4cceb221a7beddc89ba78 (patch)
tree4ed365e07d950ccbeec90d3b74577d87787c417a
parent4a5dafcc3093d55fc9d135b9a18c73bd96bcf3b1 (diff)
downloadextras-c5673f350e1e38b101a4cceb221a7beddc89ba78.tar.gz
Improve sock_diag debugging code.
- Unbreak GetConstantName on modules that contain constants whose names start with "INET_DIAG_BC". - Honour NL_DEBUG when sending dump requests. - Decode sock_diag messages differently depending on whether they are requests or responses. - Print sock_diag bytecode hex-encoded instead of raw. Change-Id: I3cc20ab635d1ff4f137aa0f9ff0ff88b1a37ce72
-rw-r--r--tests/net_test/netlink.py6
-rwxr-xr-xtests/net_test/sock_diag.py8
2 files changed, 11 insertions, 3 deletions
diff --git a/tests/net_test/netlink.py b/tests/net_test/netlink.py
index 2b8f7449..261350b4 100644
--- a/tests/net_test/netlink.py
+++ b/tests/net_test/netlink.py
@@ -80,7 +80,7 @@ class NetlinkSocket(object):
thismodule = sys.modules[module]
for name in dir(thismodule):
if name.startswith("INET_DIAG_BC"):
- break
+ continue
if (name.startswith(prefix) and
not name.startswith(prefix + "F_") and
name.isupper() and getattr(thismodule, name) == value):
@@ -237,7 +237,9 @@ class NetlinkSocket(object):
nlmsghdr = NLMsgHdr((length, command, flags, self.seq, self.pid))
# Send the request.
- self._Send(nlmsghdr.Pack() + msg.Pack() + attrs)
+ request = nlmsghdr.Pack() + msg.Pack() + attrs
+ self.MaybeDebugCommand(command, request)
+ self._Send(request)
# Keep reading netlink messages until we get a NLMSG_DONE.
out = []
diff --git a/tests/net_test/sock_diag.py b/tests/net_test/sock_diag.py
index b4d9cf64..8a84ca26 100755
--- a/tests/net_test/sock_diag.py
+++ b/tests/net_test/sock_diag.py
@@ -106,7 +106,11 @@ class SockDiag(netlink.NetlinkSocket):
def _Decode(self, command, msg, nla_type, nla_data):
"""Decodes netlink attributes to Python types."""
if msg.family == AF_INET or msg.family == AF_INET6:
- name = self._GetConstantName(__name__, nla_type, "INET_DIAG")
+ if isinstance(msg, InetDiagReqV2):
+ prefix = "INET_DIAG_REQ"
+ else:
+ prefix = "INET_DIAG"
+ name = self._GetConstantName(__name__, nla_type, prefix)
else:
# Don't know what this is. Leave it as an integer.
name = nla_type
@@ -122,6 +126,8 @@ class SockDiag(netlink.NetlinkSocket):
data = TcpInfo(nla_data)
elif name == "INET_DIAG_SKMEMINFO":
data = SkMeminfo(nla_data)
+ elif name == "INET_DIAG_REQ_BYTECODE":
+ data = nla_data.encode("hex")
else:
data = nla_data