]> granicus.if.org Git - strace/commitdiff
Decode AF_SMC netlink messages unconditionally
authorEugene Syromyatnikov <evgsyr@gmail.com>
Sun, 19 Aug 2018 08:43:47 +0000 (10:43 +0200)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 21 Aug 2018 11:28:14 +0000 (11:28 +0000)
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.

netlink_smc_diag.c
netlink_sock_diag.c
tests/nlattr_smc_diag_msg.c

index 53ae27ba85442fc50fe9474fb2b75dfbf8d0c0d7..4ce31e792f798db9f9e97c07390b518478e35a7c 100644 (file)
 #include "defs.h"
 #include <sys/socket.h>
 
-#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 <arpa/inet.h>
-# include <linux/smc_diag.h>
+#include <arpa/inet.h>
+#include <linux/smc_diag.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"
+#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 */
index dd1e03d3602a0592458782a2c179c4b81ea23736..d77218cd8f8ecb624152c8ddbe990133788439e6 100644 (file)
 #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
index 2e65ebd829d104fa73aabd8b637bc1d662dce60a..4f4fea20a47bb0cd549dfaf1a2ed12853a6706a8 100644 (file)
 #include "tests.h"
 #include <sys/socket.h>
 
-#ifdef AF_SMC
-
-# include <stdio.h>
-# include <string.h>
-# include <stdint.h>
-# include <arpa/inet.h>
-# include "test_nlattr.h"
-# include <linux/rtnetlink.h>
-# include <linux/smc_diag.h>
-# include <linux/sock_diag.h>
-
-# 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 <stdio.h>
+#include <string.h>
+#include <stdint.h>
+#include <arpa/inet.h>
+#include "test_nlattr.h"
+#include <linux/rtnetlink.h>
+#include <linux/smc_diag.h>
+#include <linux/sock_diag.h>
+
+#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