0001
0002
0003 #include <string.h>
0004
0005 #include <linux/stddef.h>
0006 #include <linux/bpf.h>
0007
0008 #include <sys/socket.h>
0009
0010 #include <bpf/bpf_helpers.h>
0011 #include <bpf/bpf_endian.h>
0012
0013 #define VERDICT_REJECT 0
0014 #define VERDICT_PROCEED 1
0015
0016 SEC("cgroup/connect4")
0017 int connect_v4_dropper(struct bpf_sock_addr *ctx)
0018 {
0019 if (ctx->type != SOCK_STREAM)
0020 return VERDICT_PROCEED;
0021 if (ctx->user_port == bpf_htons(60120))
0022 return VERDICT_REJECT;
0023 return VERDICT_PROCEED;
0024 }
0025
0026 char _license[] SEC("license") = "GPL";