1 // SPDX-License-Identifier: GPL-2.0
3 #include <linux/stddef.h>
6 #include <sys/socket.h>
8 #include <bpf/bpf_helpers.h>
9 #include <bpf/bpf_endian.h>
11 #include <bpf_sockopt_helpers.h>
13 #define SERV6_IP_0 0xfaceb00c /* face:b00c:1234:5678::abcd */
14 #define SERV6_IP_1 0x12345678
15 #define SERV6_IP_2 0x00000000
16 #define SERV6_IP_3 0x0000abcd
17 #define SERV6_PORT 6060
19 SEC("cgroup/recvmsg6")
20 int recvmsg6_prog(struct bpf_sock_addr *ctx)
28 if (sk->family != AF_INET6)
31 if (ctx->type != SOCK_STREAM && ctx->type != SOCK_DGRAM)
34 if (!get_set_sk_priority(ctx))
37 ctx->user_ip6[0] = bpf_htonl(SERV6_IP_0);
38 ctx->user_ip6[1] = bpf_htonl(SERV6_IP_1);
39 ctx->user_ip6[2] = bpf_htonl(SERV6_IP_2);
40 ctx->user_ip6[3] = bpf_htonl(SERV6_IP_3);
41 ctx->user_port = bpf_htons(SERV6_PORT);
46 char _license[] SEC("license") = "GPL";