From: Eugene Syromyatnikov Date: Sun, 19 Aug 2018 08:43:47 +0000 (+0200) Subject: Decode AF_SMC netlink messages unconditionally X-Git-Tag: v4.25~81 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9d2848e51762394996e4bbd15c31c6f1e76580b1;p=strace Decode AF_SMC netlink messages unconditionally As smc_diag.h is bundled, there is little sense to build AF_SMC support conditionally. * netlink_smc_diag.c [!AF_SMC]: Include xlat/addrfams.h under XLAT_MACROS_ONLY, enable the rest of file. * netlink_sock_diag.c: Include xlat/addrfams.h under XLAT_MACROS_ONLY. (diag_decoders): Remove "ifdef AF_SMC" condition for [AF_SMC], reorder in accordance with address family values. * tests/nlattr_smc_diag_msg.c [!AF_SMC]: Define AF_SMC to 43, enable the rest of test. --- diff --git a/netlink_smc_diag.c b/netlink_smc_diag.c index 53ae27ba..4ce31e79 100644 --- a/netlink_smc_diag.c +++ b/netlink_smc_diag.c @@ -29,20 +29,24 @@ #include "defs.h" #include -#ifdef AF_SMC +#ifndef AF_SMC +# define XLAT_MACROS_ONLY +# include "xlat/addrfams.h" +# undef XLAT_MACROS_ONLY +#endif -# include "netlink.h" -# include "netlink_sock_diag.h" -# include "nlattr.h" -# include "print_fields.h" +#include "netlink.h" +#include "netlink_sock_diag.h" +#include "nlattr.h" +#include "print_fields.h" -# include -# include +#include +#include -# include "xlat/smc_diag_attrs.h" -# include "xlat/smc_diag_extended_flags.h" -# include "xlat/smc_link_group_roles.h" -# include "xlat/smc_states.h" +#include "xlat/smc_diag_attrs.h" +#include "xlat/smc_diag_extended_flags.h" +#include "xlat/smc_link_group_roles.h" +#include "xlat/smc_states.h" DECL_NETLINK_DIAG_DECODER(decode_smc_diag_req) { @@ -186,5 +190,3 @@ DECL_NETLINK_DIAG_DECODER(decode_smc_diag_msg) ARRAY_SIZE(smc_diag_msg_nla_decoders), NULL); } } - -#endif /* AF_SMC */ diff --git a/netlink_sock_diag.c b/netlink_sock_diag.c index dd1e03d3..d77218cd 100644 --- a/netlink_sock_diag.c +++ b/netlink_sock_diag.c @@ -31,6 +31,10 @@ #include "netlink.h" #include "netlink_sock_diag.h" +#define XLAT_MACROS_ONLY +#include "xlat/addrfams.h" +#undef XLAT_MACROS_ONLY + static void decode_family(struct tcb *const tcp, const uint8_t family, const kernel_ulong_t addr, const unsigned int len) @@ -50,14 +54,12 @@ typedef DECL_NETLINK_DIAG_DECODER((*netlink_diag_decoder_t)); static const struct { const netlink_diag_decoder_t request, response; } diag_decoders[] = { + [AF_UNIX] = { decode_unix_diag_req, decode_unix_diag_msg }, [AF_INET] = { decode_inet_diag_req, decode_inet_diag_msg }, [AF_INET6] = { decode_inet_diag_req, decode_inet_diag_msg }, [AF_NETLINK] = { decode_netlink_diag_req, decode_netlink_diag_msg }, [AF_PACKET] = { decode_packet_diag_req, decode_packet_diag_msg }, -#ifdef AF_SMC [AF_SMC] = { decode_smc_diag_req, decode_smc_diag_msg }, -#endif - [AF_UNIX] = { decode_unix_diag_req, decode_unix_diag_msg } }; bool diff --git a/tests/nlattr_smc_diag_msg.c b/tests/nlattr_smc_diag_msg.c index 2e65ebd8..4f4fea20 100644 --- a/tests/nlattr_smc_diag_msg.c +++ b/tests/nlattr_smc_diag_msg.c @@ -29,23 +29,25 @@ #include "tests.h" #include -#ifdef AF_SMC - -# include -# include -# include -# include -# include "test_nlattr.h" -# include -# include -# include - -# ifndef SMC_CLNT -# define SMC_CLNT 0 -# endif -# ifndef SMC_ACTIVE -# define SMC_ACTIVE 1 -# endif +#ifndef AF_SMC +# define AF_SMC 43 +#endif + +#include +#include +#include +#include +#include "test_nlattr.h" +#include +#include +#include + +#ifndef SMC_CLNT +# define SMC_CLNT 0 +#endif +#ifndef SMC_ACTIVE +# define SMC_ACTIVE 1 +#endif static const char address[] = "12.34.56.78"; @@ -195,9 +197,3 @@ int main(void) printf("+++ exited with 0 +++\n"); return 0; } - -#else - -SKIP_MAIN_UNDEFINED("AF_SMC") - -#endif