From 3524cd080b113ee3735ff1d49022c71d990a1568 Mon Sep 17 00:00:00 2001 From: Lorenzo Colitti Date: Fri, 8 May 2015 16:41:57 +0900 Subject: [PATCH] Support dumping neighbour cache entries. Change-Id: I69675c9d8ee4a8c6e2daf4bbe60d9858855019ea --- tests/net_test/iproute.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/net_test/iproute.py b/tests/net_test/iproute.py index cde18037..df1c1210 100644 --- a/tests/net_test/iproute.py +++ b/tests/net_test/iproute.py @@ -64,6 +64,7 @@ RTM_DELROUTE = 25 RTM_GETROUTE = 26 RTM_NEWNEIGH = 28 RTM_DELNEIGH = 29 +RTM_GETNEIGH = 30 RTM_NEWRULE = 32 RTM_DELRULE = 33 RTM_GETRULE = 34 @@ -133,12 +134,16 @@ IfAddrMsg = cstruct.Struct( "family prefixlen flags scope index") IFACacheinfo = cstruct.Struct( "IFACacheinfo", "=IIII", "prefered valid cstamp tstamp") +NDACacheinfo = cstruct.Struct( + "NDACacheinfo", "=IIII", "confirmed used updated refcnt") ### Neighbour table entry constants. See include/uapi/linux/neighbour.h. # Neighbour cache entry attributes. NDA_DST = 1 NDA_LLADDR = 2 +NDA_CACHEINFO = 3 +NDA_PROBES = 4 # Neighbour cache entry states. NUD_PERMANENT = 0x80 @@ -293,7 +298,7 @@ class IPRoute(object): "RTA_OIF", "RTA_PRIORITY", "RTA_TABLE", "RTA_MARK", "IFLA_MTU", "IFLA_TXQLEN", "IFLA_GROUP", "IFLA_EXT_MASK", "IFLA_PROMISCUITY", "IFLA_NUM_RX_QUEUES", - "IFLA_NUM_TX_QUEUES"]: + "IFLA_NUM_TX_QUEUES", "NDA_PROBES"]: data = struct.unpack("=I", nla_data)[0] elif name == "FRA_SUPPRESS_PREFIXLEN": data = struct.unpack("=i", nla_data)[0] @@ -311,6 +316,8 @@ class IPRoute(object): data = RTACacheinfo(nla_data) elif name == "IFA_CACHEINFO": data = IFACacheinfo(nla_data) + elif name == "NDA_CACHEINFO": + data = NDACacheinfo(nla_data) elif name in ["NDA_LLADDR", "IFLA_ADDRESS"]: data = ":".join(x.encode("hex") for x in nla_data) else: @@ -664,6 +671,10 @@ class IPRoute(object): def DelNeighbour(self, version, addr, lladdr, dev): self._Neighbour(version, False, addr, lladdr, dev, 0) + def DumpNeighbours(self, version): + ndmsg = NdMsg((0, 0, 0, 0, 0)) + return self._Dump(RTM_GETNEIGH, ndmsg, NdMsg) + if __name__ == "__main__": iproute = IPRoute() -- 2.11.0