tcp and udp bpf_iter can reuse some socket ids in btf_sock_ids, so make it global. I put the extern definition in btf_ids.h as a central place so it can be easily discovered by developers.
Showing the changes to include/linux (1 of 3 files). Show all
Unified · Split
| @@ -97,4 +97,34 @@ asm( \ · 96 unmodified lines | ||
| 97 | 97 | |
| 98 | 98 | #endif /* CONFIG_DEBUG_INFO_BTF */ |
| 99 | 99 | |
| 100 | +#ifdef CONFIG_NET | |
| 101 | +/* Define a list of socket types which can be the argument for | |
| 102 | + * skc_to_*_sock() helpers. All these sockets should have | |
| 103 | + * sock_common as the first argument in its memory layout. | |
| 104 | + */ | |
| 105 | +#define BTF_SOCK_TYPE_xxx \ | |
| 106 | + BTF_SOCK_TYPE(BTF_SOCK_TYPE_INET, inet_sock) \ | |
| 107 | + BTF_SOCK_TYPE(BTF_SOCK_TYPE_INET_CONN, inet_connection_sock) \ | |
| 108 | + BTF_SOCK_TYPE(BTF_SOCK_TYPE_INET_REQ, inet_request_sock) \ | |
| 109 | + BTF_SOCK_TYPE(BTF_SOCK_TYPE_INET_TW, inet_timewait_sock) \ | |
| 110 | + BTF_SOCK_TYPE(BTF_SOCK_TYPE_REQ, request_sock) \ | |
| 111 | + BTF_SOCK_TYPE(BTF_SOCK_TYPE_SOCK, sock) \ | |
| 112 | + BTF_SOCK_TYPE(BTF_SOCK_TYPE_SOCK_COMMON, sock_common) \ | |
| 113 | + BTF_SOCK_TYPE(BTF_SOCK_TYPE_TCP, tcp_sock) \ | |
| 114 | + BTF_SOCK_TYPE(BTF_SOCK_TYPE_TCP_REQ, tcp_request_sock) \ | |
| 115 | + BTF_SOCK_TYPE(BTF_SOCK_TYPE_TCP_TW, tcp_timewait_sock) \ | |
| 116 | + BTF_SOCK_TYPE(BTF_SOCK_TYPE_TCP6, tcp6_sock) \ | |
| 117 | + BTF_SOCK_TYPE(BTF_SOCK_TYPE_UDP, udp_sock) \ | |
| 118 | + BTF_SOCK_TYPE(BTF_SOCK_TYPE_UDP6, udp6_sock) | |
| 119 | + | |
| 120 | +enum { | |
| 121 | +#define BTF_SOCK_TYPE(name, str) name, | |
| 122 | +BTF_SOCK_TYPE_xxx | |
| 123 | +#undef BTF_SOCK_TYPE | |
| 124 | +MAX_BTF_SOCK_TYPE, | |
| 125 | +}; | |
| 126 | + | |
| 127 | +extern u32 btf_sock_ids[]; | |
| 128 | +#endif | |
| 129 | + | |
| 100 | 130 | #endif |