tools/testing/selftests/bpf/progs/xdp_synproxy_kern.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/xdp_synproxy_kern.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/xdp_synproxy_kern.c- Extension
.c- Size
- 21321 bytes
- Lines
- 866
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
vmlinux.hbpf/bpf_helpers.hbpf/bpf_endian.hasm/errno.hbpf_compiler.h
Detected Declarations
struct bpf_ct_opts___localstruct tcpopt_contextstruct header_pointersfunction swap_eth_addrfunction csum_foldfunction csum_tcpudp_magicfunction csum_ipv6_magicfunction tcp_clock_nsfunction tcp_ns_to_tsfunction tcp_clock_msfunction tscookie_tcpopt_parsefunction tscookie_tcpopt_parse_batchfunction tscookie_initfunction values_get_tcpipoptsfunction values_inc_synacksfunction check_port_allowedfunction tcp_dissectfunction tcp_lookupfunction tcp_mkoptionsfunction tcp_gen_synackfunction tcpv4_gen_synackfunction tcpv6_gen_synackfunction syncookie_handle_synfunction syncookie_handle_ackfunction syncookie_part1function syncookie_part2function syncookie_xdpfunction syncookie_tc
Annotated Snippet
struct bpf_ct_opts___local {
s32 netns_id;
s32 error;
u8 l4proto;
u8 dir;
u8 reserved[2];
} __attribute__((preserve_access_index));
#define BPF_F_CURRENT_NETNS (-1)
extern struct nf_conn *bpf_xdp_ct_lookup(struct xdp_md *xdp_ctx,
struct bpf_sock_tuple *bpf_tuple,
__u32 len_tuple,
struct bpf_ct_opts___local *opts,
__u32 len_opts) __ksym;
extern struct nf_conn *bpf_skb_ct_lookup(struct __sk_buff *skb_ctx,
struct bpf_sock_tuple *bpf_tuple,
u32 len_tuple,
struct bpf_ct_opts___local *opts,
u32 len_opts) __ksym;
extern void bpf_ct_release(struct nf_conn *ct) __ksym;
static __always_inline void swap_eth_addr(__u8 *a, __u8 *b)
{
__u8 tmp[ETH_ALEN];
__builtin_memcpy(tmp, a, ETH_ALEN);
__builtin_memcpy(a, b, ETH_ALEN);
__builtin_memcpy(b, tmp, ETH_ALEN);
}
static __always_inline __u16 csum_fold(__u32 csum)
{
csum = (csum & 0xffff) + (csum >> 16);
csum = (csum & 0xffff) + (csum >> 16);
return (__u16)~csum;
}
static __always_inline __u16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
__u32 len, __u8 proto,
__u32 csum)
{
__u64 s = csum;
s += (__u32)saddr;
s += (__u32)daddr;
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
s += proto + len;
#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
s += (proto + len) << 8;
#else
#error Unknown endian
#endif
s = (s & 0xffffffff) + (s >> 32);
s = (s & 0xffffffff) + (s >> 32);
return csum_fold((__u32)s);
}
static __always_inline __u16 csum_ipv6_magic(const struct in6_addr *saddr,
const struct in6_addr *daddr,
__u32 len, __u8 proto, __u32 csum)
{
__u64 sum = csum;
int i;
__pragma_loop_unroll
for (i = 0; i < 4; i++)
sum += (__u32)saddr->in6_u.u6_addr32[i];
__pragma_loop_unroll
for (i = 0; i < 4; i++)
sum += (__u32)daddr->in6_u.u6_addr32[i];
/* Don't combine additions to avoid 32-bit overflow. */
sum += bpf_htonl(len);
sum += bpf_htonl(proto);
sum = (sum & 0xffffffff) + (sum >> 32);
sum = (sum & 0xffffffff) + (sum >> 32);
return csum_fold((__u32)sum);
}
static __always_inline __u64 tcp_clock_ns(void)
{
return bpf_ktime_get_ns();
}
Annotation
- Immediate include surface: `vmlinux.h`, `bpf/bpf_helpers.h`, `bpf/bpf_endian.h`, `asm/errno.h`, `bpf_compiler.h`.
- Detected declarations: `struct bpf_ct_opts___local`, `struct tcpopt_context`, `struct header_pointers`, `function swap_eth_addr`, `function csum_fold`, `function csum_tcpudp_magic`, `function csum_ipv6_magic`, `function tcp_clock_ns`, `function tcp_ns_to_ts`, `function tcp_clock_ms`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.