[PATCH v2 1/7] rtnl_neigh: fix ndm_type field decode in struct ndmsg

JingPiao Chen chenjingpiao at gmail.com
Tue Aug 29 07:45:17 UTC 2017


* defs.h (routing_types): New xlat prototype.
* rtnl_neigh.c (decode_ndmsg): Fix ndm_type decode.
* xlat/nda_types.in: Remove it.
* tests/netlink_route.c (test_rtnl_neigh): Update the test.
* tests/nlattr_ndmsg.c (init_ndmsg, print_ndmsg): Likewise.
---
 defs.h                |  1 +
 rtnl_neigh.c          |  3 +--
 tests/netlink_route.c |  4 ++--
 tests/nlattr_ndmsg.c  |  4 ++--
 xlat/nda_types.in     | 12 ------------
 5 files changed, 6 insertions(+), 18 deletions(-)
 delete mode 100644 xlat/nda_types.in

diff --git a/defs.h b/defs.h
index e37c555..5323920 100644
--- a/defs.h
+++ b/defs.h
@@ -294,6 +294,7 @@ extern const struct xlat open_mode_flags[];
 extern const struct xlat resource_flags[];
 extern const struct xlat routing_scopes[];
 extern const struct xlat routing_table_ids[];
+extern const struct xlat routing_types[];
 extern const struct xlat setns_types[];
 extern const struct xlat sg_io_info[];
 extern const struct xlat socketlayers[];
diff --git a/rtnl_neigh.c b/rtnl_neigh.c
index 2ce237a..7191ecb 100644
--- a/rtnl_neigh.c
+++ b/rtnl_neigh.c
@@ -38,7 +38,6 @@
 # include <linux/neighbour.h>
 #endif
 
-#include "xlat/nda_types.h"
 #include "xlat/neighbor_cache_entry_flags.h"
 #include "xlat/neighbor_cache_entry_states.h"
 #include "xlat/rtnl_neigh_attrs.h"
@@ -64,7 +63,7 @@ DECL_NETLINK_ROUTE_DECODER(decode_ndmsg)
 					  neighbor_cache_entry_flags,
 					  "NTF_???");
 			PRINT_FIELD_XVAL(", ", ndmsg, ndm_type,
-					 nda_types, "NDA_???");
+					 routing_types, "RTN_???");
 			decode_nla = true;
 		}
 	} else
diff --git a/tests/netlink_route.c b/tests/netlink_route.c
index f9bd0d8..6af3b13 100644
--- a/tests/netlink_route.c
+++ b/tests/netlink_route.c
@@ -308,7 +308,7 @@ test_rtnl_neigh(const int fd)
 		.ndm_ifindex = ifindex_lo(),
 		.ndm_state = NUD_PERMANENT,
 		.ndm_flags = NTF_PROXY,
-		.ndm_type = NDA_UNSPEC
+		.ndm_type = RTN_UNSPEC
 	};
 
 	TEST_NL_ROUTE(fd, nlh0, RTM_GETNEIGH, msg,
@@ -316,7 +316,7 @@ test_rtnl_neigh(const int fd)
 		      printf(", ndm_ifindex=" IFINDEX_LO_STR
 			     ", ndm_state=NUD_PERMANENT"
 			     ", ndm_flags=NTF_PROXY"
-			     ", ndm_type=NDA_UNSPEC}"));
+			     ", ndm_type=RTN_UNSPEC}"));
 }
 
 static void
diff --git a/tests/nlattr_ndmsg.c b/tests/nlattr_ndmsg.c
index adf5147..67aee88 100644
--- a/tests/nlattr_ndmsg.c
+++ b/tests/nlattr_ndmsg.c
@@ -50,7 +50,7 @@ init_ndmsg(struct nlmsghdr *const nlh, const unsigned int msg_len)
 		.ndm_ifindex = ifindex_lo(),
 		.ndm_state = NUD_PERMANENT,
 		.ndm_flags = NTF_PROXY,
-		.ndm_type = NDA_UNSPEC
+		.ndm_type = RTN_UNSPEC
 	);
 }
 
@@ -62,7 +62,7 @@ print_ndmsg(const unsigned int msg_len)
 	       ", ndm_ifindex=" IFINDEX_LO_STR
 	       ", ndm_state=NUD_PERMANENT"
 	       ", ndm_flags=NTF_PROXY"
-	       ", ndm_type=NDA_UNSPEC}",
+	       ", ndm_type=RTN_UNSPEC}",
 	       msg_len);
 }
 
diff --git a/xlat/nda_types.in b/xlat/nda_types.in
deleted file mode 100644
index fed013a..0000000
--- a/xlat/nda_types.in
+++ /dev/null
@@ -1,12 +0,0 @@
-NDA_UNSPEC		0
-NDA_DST			1
-NDA_LLADDR		2
-NDA_CACHEINFO		3
-NDA_PROBES		4
-NDA_VLAN		5
-NDA_PORT		6
-NDA_VNI			7
-NDA_IFINDEX		8
-NDA_MASTER		9
-NDA_LINK_NETNSID	10
-NDA_SRC_VNI		11
-- 
2.7.4





More information about the Strace-devel mailing list