1 // SPDX-License-Identifier: GPL-2.0
3 #include <linux/stddef.h>
6 #include <sys/socket.h>
7 #include <bpf/bpf_helpers.h>
8 #include <bpf/bpf_endian.h>
10 static __always_inline int bind_prog(struct bpf_sock_addr *ctx, int family)
18 if (sk->family != family)
21 if (ctx->type != SOCK_STREAM)
24 /* Return 1 OR'ed with the first bit set to indicate
25 * that CAP_NET_BIND_SERVICE should be bypassed.
27 if (ctx->user_port == bpf_htons(111))
34 int bind_v4_prog(struct bpf_sock_addr *ctx)
36 return bind_prog(ctx, AF_INET);
40 int bind_v6_prog(struct bpf_sock_addr *ctx)
42 return bind_prog(ctx, AF_INET6);
45 char _license[] SEC("license") = "GPL";