From a213cb48c593f34544da80d0462572b2410e36b1 Mon Sep 17 00:00:00 2001 From: Lorenzo Colitti Date: Tue, 10 Nov 2015 16:59:37 +0900 Subject: Minor changes to netlink code. 1. Remove IpRoute._Debug, since it's identical to the superclass version. 2. Add some setsockopt constants to netlink.py. 3. Do the right thing if the kernel returns an error in a dump request. Change-Id: I37e49b35f1366760a408c7c4a73f95164d796a2e --- tests/net_test/iproute.py | 4 ---- tests/net_test/net_test.py | 7 +++++-- tests/net_test/netlink.py | 4 ++++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/net_test/iproute.py b/tests/net_test/iproute.py index fef4b5c5..7c9eec0f 100644 --- a/tests/net_test/iproute.py +++ b/tests/net_test/iproute.py @@ -209,10 +209,6 @@ class IPRoute(netlink.NetlinkSocket): FAMILY = NETLINK_ROUTE - def _Debug(self, s): - if self.DEBUG: - print s - def _NlAttrIPAddress(self, nla_type, family, address): return self._NlAttr(nla_type, socket.inet_pton(family, address)) diff --git a/tests/net_test/net_test.py b/tests/net_test/net_test.py index 09a6a555..ada7eba9 100755 --- a/tests/net_test/net_test.py +++ b/tests/net_test/net_test.py @@ -30,11 +30,14 @@ IPV6_RECVERR = 25 IP_TRANSPARENT = 19 IPV6_TRANSPARENT = 75 IPV6_TCLASS = 67 -SO_BINDTODEVICE = 25 -SO_MARK = 36 IPV6_FLOWLABEL_MGR = 32 IPV6_FLOWINFO_SEND = 33 +SO_BINDTODEVICE = 25 +SO_MARK = 36 +SO_PROTOCOL = 38 +SO_DOMAIN = 39 + ETH_P_IP = 0x0800 ETH_P_IPV6 = 0x86dd diff --git a/tests/net_test/netlink.py b/tests/net_test/netlink.py index 65dc4b66..6b2c60d1 100644 --- a/tests/net_test/netlink.py +++ b/tests/net_test/netlink.py @@ -227,6 +227,10 @@ class NetlinkSocket(object): response_type = NLMsgHdr(data).type if response_type == NLMSG_DONE: break + elif response_type == NLMSG_ERROR: + # Likely means that the kernel didn't like our dump request. + # Parse the error and throw an exception. + self._ParseAck(data) out.extend(self._GetMsgList(msgtype, data, False)) return out -- cgit v1.2.3