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 SERV4_IP 0xc0a801feU /* 192.168.1.254 */
14 #define SERV4_PORT 4040
16 SEC("cgroup/recvmsg4")
17 int recvmsg4_prog(struct bpf_sock_addr *ctx)
25 if (sk->family != AF_INET)
28 if (ctx->type != SOCK_STREAM && ctx->type != SOCK_DGRAM)
31 if (!get_set_sk_priority(ctx))
34 ctx->user_ip4 = bpf_htonl(SERV4_IP);
35 ctx->user_port = bpf_htons(SERV4_PORT);
40 char _license[] SEC("license") = "GPL";