1*ee549be6SMasami Hiramatsu /* SPDX-License-Identifier: GPL-2.0 */ 2*ee549be6SMasami Hiramatsu 3*ee549be6SMasami Hiramatsu #if !defined(_TRACE_NET_PROBE_COMMON_H) || defined(TRACE_HEADER_MULTI_READ) 4*ee549be6SMasami Hiramatsu #define _TRACE_NET_PROBE_COMMON_H 5*ee549be6SMasami Hiramatsu 6*ee549be6SMasami Hiramatsu #define TP_STORE_ADDR_PORTS_V4(__entry, inet, sk) \ 7*ee549be6SMasami Hiramatsu do { \ 8*ee549be6SMasami Hiramatsu struct sockaddr_in *v4 = (void *)__entry->saddr; \ 9*ee549be6SMasami Hiramatsu \ 10*ee549be6SMasami Hiramatsu v4->sin_family = AF_INET; \ 11*ee549be6SMasami Hiramatsu v4->sin_port = inet->inet_sport; \ 12*ee549be6SMasami Hiramatsu v4->sin_addr.s_addr = inet->inet_saddr; \ 13*ee549be6SMasami Hiramatsu v4 = (void *)__entry->daddr; \ 14*ee549be6SMasami Hiramatsu v4->sin_family = AF_INET; \ 15*ee549be6SMasami Hiramatsu v4->sin_port = inet->inet_dport; \ 16*ee549be6SMasami Hiramatsu v4->sin_addr.s_addr = inet->inet_daddr; \ 17*ee549be6SMasami Hiramatsu } while (0) 18*ee549be6SMasami Hiramatsu 19*ee549be6SMasami Hiramatsu #if IS_ENABLED(CONFIG_IPV6) 20*ee549be6SMasami Hiramatsu 21*ee549be6SMasami Hiramatsu #define TP_STORE_ADDR_PORTS(__entry, inet, sk) \ 22*ee549be6SMasami Hiramatsu do { \ 23*ee549be6SMasami Hiramatsu if (sk->sk_family == AF_INET6) { \ 24*ee549be6SMasami Hiramatsu struct sockaddr_in6 *v6 = (void *)__entry->saddr; \ 25*ee549be6SMasami Hiramatsu \ 26*ee549be6SMasami Hiramatsu v6->sin6_family = AF_INET6; \ 27*ee549be6SMasami Hiramatsu v6->sin6_port = inet->inet_sport; \ 28*ee549be6SMasami Hiramatsu v6->sin6_addr = inet6_sk(sk)->saddr; \ 29*ee549be6SMasami Hiramatsu v6 = (void *)__entry->daddr; \ 30*ee549be6SMasami Hiramatsu v6->sin6_family = AF_INET6; \ 31*ee549be6SMasami Hiramatsu v6->sin6_port = inet->inet_dport; \ 32*ee549be6SMasami Hiramatsu v6->sin6_addr = sk->sk_v6_daddr; \ 33*ee549be6SMasami Hiramatsu } else \ 34*ee549be6SMasami Hiramatsu TP_STORE_ADDR_PORTS_V4(__entry, inet, sk); \ 35*ee549be6SMasami Hiramatsu } while (0) 36*ee549be6SMasami Hiramatsu 37*ee549be6SMasami Hiramatsu #else 38*ee549be6SMasami Hiramatsu 39*ee549be6SMasami Hiramatsu #define TP_STORE_ADDR_PORTS(__entry, inet, sk) \ 40*ee549be6SMasami Hiramatsu TP_STORE_ADDR_PORTS_V4(__entry, inet, sk); 41*ee549be6SMasami Hiramatsu 42*ee549be6SMasami Hiramatsu #endif 43*ee549be6SMasami Hiramatsu 44*ee549be6SMasami Hiramatsu #endif 45