net_probe_common.h 1.2 KB

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