Masami Hiramatsu | ee549be | 2017-12-29 11:47:55 +0900 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | |
| 3 | #if !defined(_TRACE_NET_PROBE_COMMON_H) || defined(TRACE_HEADER_MULTI_READ) |
| 4 | #define _TRACE_NET_PROBE_COMMON_H |
| 5 | |
| 6 | #define TP_STORE_ADDR_PORTS_V4(__entry, inet, sk) \ |
| 7 | do { \ |
| 8 | struct sockaddr_in *v4 = (void *)__entry->saddr; \ |
| 9 | \ |
| 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; \ |
| 17 | } while (0) |
| 18 | |
| 19 | #if IS_ENABLED(CONFIG_IPV6) |
| 20 | |
| 21 | #define TP_STORE_ADDR_PORTS(__entry, inet, sk) \ |
| 22 | do { \ |
| 23 | if (sk->sk_family == AF_INET6) { \ |
| 24 | struct sockaddr_in6 *v6 = (void *)__entry->saddr; \ |
| 25 | \ |
| 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; \ |
| 33 | } else \ |
| 34 | TP_STORE_ADDR_PORTS_V4(__entry, inet, sk); \ |
| 35 | } while (0) |
| 36 | |
| 37 | #else |
| 38 | |
| 39 | #define TP_STORE_ADDR_PORTS(__entry, inet, sk) \ |
| 40 | TP_STORE_ADDR_PORTS_V4(__entry, inet, sk); |
| 41 | |
| 42 | #endif |
| 43 | |
| 44 | #endif |