brintos

brintos / linux-shallow public Read only

0
0
Text · 509 B · d3f4c5e Raw
27 lines · c
1// SPDX-License-Identifier: GPL-2.02 3#include <string.h>4 5#include <linux/stddef.h>6#include <linux/bpf.h>7 8#include <sys/socket.h>9 10#include <bpf/bpf_helpers.h>11#include <bpf/bpf_endian.h>12 13#define VERDICT_REJECT	014#define VERDICT_PROCEED	115 16SEC("cgroup/connect4")17int connect_v4_dropper(struct bpf_sock_addr *ctx)18{19	if (ctx->type != SOCK_STREAM)20		return VERDICT_PROCEED;21	if (ctx->user_port == bpf_htons(60120))22		return VERDICT_REJECT;23	return VERDICT_PROCEED;24}25 26char _license[] SEC("license") = "GPL";27