Commit 26f44b70 authored by Paolo Abeni's avatar Paolo Abeni

Merge branch 'trace-use-tp_store_addrs-macro'

Jason Xing says:

====================
trace: use TP_STORE_ADDRS macro

Using the macro for other tracepoints use to be more concise.
No functional change.
====================

Link: https://lore.kernel.org/r/20240325034347.19522-1-kerneljasonxing@gmail.comSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parents 75925faf 646700ce
...@@ -41,4 +41,33 @@ ...@@ -41,4 +41,33 @@
#endif #endif
#define TP_STORE_V4MAPPED(__entry, saddr, daddr) \
do { \
struct in6_addr *pin6; \
\
pin6 = (struct in6_addr *)__entry->saddr_v6; \
ipv6_addr_set_v4mapped(saddr, pin6); \
pin6 = (struct in6_addr *)__entry->daddr_v6; \
ipv6_addr_set_v4mapped(daddr, pin6); \
} while (0)
#if IS_ENABLED(CONFIG_IPV6)
#define TP_STORE_ADDRS(__entry, saddr, daddr, saddr6, daddr6) \
do { \
if (sk->sk_family == AF_INET6) { \
struct in6_addr *pin6; \
\
pin6 = (struct in6_addr *)__entry->saddr_v6; \
*pin6 = saddr6; \
pin6 = (struct in6_addr *)__entry->daddr_v6; \
*pin6 = daddr6; \
} else { \
TP_STORE_V4MAPPED(__entry, saddr, daddr); \
} \
} while (0)
#else
#define TP_STORE_ADDRS(__entry, saddr, daddr, saddr6, daddr6) \
TP_STORE_V4MAPPED(__entry, saddr, daddr)
#endif
#endif #endif
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <linux/tracepoint.h> #include <linux/tracepoint.h>
#include <linux/ipv6.h> #include <linux/ipv6.h>
#include <linux/tcp.h> #include <linux/tcp.h>
#include <trace/events/net_probe_common.h>
#define family_names \ #define family_names \
EM(AF_INET) \ EM(AF_INET) \
...@@ -159,7 +160,6 @@ TRACE_EVENT(inet_sock_set_state, ...@@ -159,7 +160,6 @@ TRACE_EVENT(inet_sock_set_state,
TP_fast_assign( TP_fast_assign(
const struct inet_sock *inet = inet_sk(sk); const struct inet_sock *inet = inet_sk(sk);
struct in6_addr *pin6;
__be32 *p32; __be32 *p32;
__entry->skaddr = sk; __entry->skaddr = sk;
...@@ -177,20 +177,8 @@ TRACE_EVENT(inet_sock_set_state, ...@@ -177,20 +177,8 @@ TRACE_EVENT(inet_sock_set_state,
p32 = (__be32 *) __entry->daddr; p32 = (__be32 *) __entry->daddr;
*p32 = inet->inet_daddr; *p32 = inet->inet_daddr;
#if IS_ENABLED(CONFIG_IPV6) TP_STORE_ADDRS(__entry, inet->inet_saddr, inet->inet_daddr,
if (sk->sk_family == AF_INET6) { sk->sk_v6_rcv_saddr, sk->sk_v6_daddr);
pin6 = (struct in6_addr *)__entry->saddr_v6;
*pin6 = sk->sk_v6_rcv_saddr;
pin6 = (struct in6_addr *)__entry->daddr_v6;
*pin6 = sk->sk_v6_daddr;
} else
#endif
{
pin6 = (struct in6_addr *)__entry->saddr_v6;
ipv6_addr_set_v4mapped(inet->inet_saddr, pin6);
pin6 = (struct in6_addr *)__entry->daddr_v6;
ipv6_addr_set_v4mapped(inet->inet_daddr, pin6);
}
), ),
TP_printk("family=%s protocol=%s sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c oldstate=%s newstate=%s", TP_printk("family=%s protocol=%s sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c oldstate=%s newstate=%s",
...@@ -223,7 +211,6 @@ TRACE_EVENT(inet_sk_error_report, ...@@ -223,7 +211,6 @@ TRACE_EVENT(inet_sk_error_report,
TP_fast_assign( TP_fast_assign(
const struct inet_sock *inet = inet_sk(sk); const struct inet_sock *inet = inet_sk(sk);
struct in6_addr *pin6;
__be32 *p32; __be32 *p32;
__entry->error = sk->sk_err; __entry->error = sk->sk_err;
...@@ -238,20 +225,8 @@ TRACE_EVENT(inet_sk_error_report, ...@@ -238,20 +225,8 @@ TRACE_EVENT(inet_sk_error_report,
p32 = (__be32 *) __entry->daddr; p32 = (__be32 *) __entry->daddr;
*p32 = inet->inet_daddr; *p32 = inet->inet_daddr;
#if IS_ENABLED(CONFIG_IPV6) TP_STORE_ADDRS(__entry, inet->inet_saddr, inet->inet_daddr,
if (sk->sk_family == AF_INET6) { sk->sk_v6_rcv_saddr, sk->sk_v6_daddr);
pin6 = (struct in6_addr *)__entry->saddr_v6;
*pin6 = sk->sk_v6_rcv_saddr;
pin6 = (struct in6_addr *)__entry->daddr_v6;
*pin6 = sk->sk_v6_daddr;
} else
#endif
{
pin6 = (struct in6_addr *)__entry->saddr_v6;
ipv6_addr_set_v4mapped(inet->inet_saddr, pin6);
pin6 = (struct in6_addr *)__entry->daddr_v6;
ipv6_addr_set_v4mapped(inet->inet_daddr, pin6);
}
), ),
TP_printk("family=%s protocol=%s sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c error=%d", TP_printk("family=%s protocol=%s sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c error=%d",
......
...@@ -12,35 +12,6 @@ ...@@ -12,35 +12,6 @@
#include <net/tcp.h> #include <net/tcp.h>
#include <linux/sock_diag.h> #include <linux/sock_diag.h>
#define TP_STORE_V4MAPPED(__entry, saddr, daddr) \
do { \
struct in6_addr *pin6; \
\
pin6 = (struct in6_addr *)__entry->saddr_v6; \
ipv6_addr_set_v4mapped(saddr, pin6); \
pin6 = (struct in6_addr *)__entry->daddr_v6; \
ipv6_addr_set_v4mapped(daddr, pin6); \
} while (0)
#if IS_ENABLED(CONFIG_IPV6)
#define TP_STORE_ADDRS(__entry, saddr, daddr, saddr6, daddr6) \
do { \
if (sk->sk_family == AF_INET6) { \
struct in6_addr *pin6; \
\
pin6 = (struct in6_addr *)__entry->saddr_v6; \
*pin6 = saddr6; \
pin6 = (struct in6_addr *)__entry->daddr_v6; \
*pin6 = daddr6; \
} else { \
TP_STORE_V4MAPPED(__entry, saddr, daddr); \
} \
} while (0)
#else
#define TP_STORE_ADDRS(__entry, saddr, daddr, saddr6, daddr6) \
TP_STORE_V4MAPPED(__entry, saddr, daddr)
#endif
/* /*
* tcp event with arguments sk and skb * tcp event with arguments sk and skb
* *
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment