[PATCH v2 8/8] tests: check decoding of rtnetlink link messages
Dmitry V. Levin
ldv at altlinux.org
Tue Aug 8 23:40:46 UTC 2017
On Tue, Aug 01, 2017 at 07:48:48AM +0800, JingPiao Chen wrote:
> * tests/netlink_route.c: Include <linux/if_arp.h>.
> (TEST_NL_ROUTE): New macro.
> (test_rtnl_link): New function.
> (main): Use it.
>
> Co-authored-by: Fabien Siron <fabien.siron at epita.fr>
> ---
> tests/netlink_route.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 61 insertions(+)
>
> diff --git a/tests/netlink_route.c b/tests/netlink_route.c
> index 537ab93..b8f0f93 100644
> --- a/tests/netlink_route.c
> +++ b/tests/netlink_route.c
> @@ -31,9 +31,48 @@
> #include <stdint.h>
> #include <unistd.h>
> #include <sys/socket.h>
> +#include <linux/if_arp.h>
> #include "test_netlink.h"
> #include <linux/rtnetlink.h>
Please be consistent with the order of header inclusion.
> +#ifdef HAVE_IF_INDEXTONAME
> +/* <linux/if.h> used to conflict with <net/if.h> */
> +extern unsigned int if_nametoindex(const char *);
> +# define IFINDEX_LO (if_nametoindex("lo"))
> +#else
> +# define IFINDEX_LO 1
> +#endif
> +
> +#define TEST_NL_ROUTE(fd_, nlh0_, type_, obj_, print_family_, ...) \
> + \
> + do { \
> + /* family and string */ \
> + TEST_NETLINK_((fd_), (nlh0_), \
> + type_, #type_, \
> + NLM_F_REQUEST, "NLM_F_REQUEST", \
> + sizeof(obj_) - 1, \
> + &(obj_), sizeof(obj_) - 1, \
> + (print_family_); \
> + printf(", ...}")); \
> + \
> + /* sizeof(obj_) */ \
> + TEST_NETLINK_((fd_), (nlh0_), \
> + type_, #type_, \
> + NLM_F_REQUEST, "NLM_F_REQUEST", \
> + sizeof(obj_), &(obj_), sizeof(obj_), \
> + (print_family_); \
> + __VA_ARGS__); \
> + \
> + /* short read of sizeof(obj_) */ \
> + TEST_NETLINK_((fd_), (nlh0_), \
> + type_, #type_, \
> + NLM_F_REQUEST, "NLM_F_REQUEST", \
> + sizeof(obj_), &(obj_), sizeof(obj_) - 1, \
> + (print_family_); \
> + printf(", %p}", \
> + NLMSG_DATA(TEST_NETLINK_nlh) + 1));\
> + } while (0)
Why do you have to use TEST_NETLINK_ instead of TEST_NETLINK?
--
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20170809/8def01f7/attachment.bin>
More information about the Strace-devel
mailing list