1 /* SPDX-License-Identifier: GPL-2.0 */
3 #if !defined(_TRACE_NET_PROBE_COMMON_H) || defined(TRACE_HEADER_MULTI_READ)
4 #define _TRACE_NET_PROBE_COMMON_H
6 #define TP_STORE_ADDR_PORTS_V4(__entry, inet, sk) \
8 struct sockaddr_in *v4 = (void *)__entry->saddr; \
10 v4->sin_family = AF_INET; \
11 v4->sin_port = inet->inet_sport; \
12 v4->sin_addr.s_addr = inet->inet_saddr; \
13 v4 = (void *)__entry->daddr; \
14 v4->sin_family = AF_INET; \
15 v4->sin_port = inet->inet_dport; \
16 v4->sin_addr.s_addr = inet->inet_daddr; \
19 #if IS_ENABLED(CONFIG_IPV6)
21 #define TP_STORE_ADDR_PORTS(__entry, inet, sk) \
23 if (sk->sk_family == AF_INET6) { \
24 struct sockaddr_in6 *v6 = (void *)__entry->saddr; \
26 v6->sin6_family = AF_INET6; \
27 v6->sin6_port = inet->inet_sport; \
28 v6->sin6_addr = inet6_sk(sk)->saddr; \
29 v6 = (void *)__entry->daddr; \
30 v6->sin6_family = AF_INET6; \
31 v6->sin6_port = inet->inet_dport; \
32 v6->sin6_addr = sk->sk_v6_daddr; \
34 TP_STORE_ADDR_PORTS_V4(__entry, inet, sk); \
39 #define TP_STORE_ADDR_PORTS(__entry, inet, sk) \
40 TP_STORE_ADDR_PORTS_V4(__entry, inet, sk);