X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=xdp.c;h=8003b89e0066b4311fd8eb482a922718914166e4;hb=ce7cb6545f4fd8872f08263733cb2188530e9420;hp=3ebec88555e37bb82ac5ca6868e8ef0e0c5d20d5;hpb=348583843f9499b0f1c335edc684a077bb2c2710;p=flowspec-xdp diff --git a/xdp.c b/xdp.c index 3ebec88..8003b89 100644 --- a/xdp.c +++ b/xdp.c @@ -162,6 +162,20 @@ struct bpf_map_def SEC("maps") drop_cnt_map = { *value += 1; \ } +#ifdef RATE_CNT +struct ratelimit { + struct bpf_spin_lock lock; + int64_t sent_bytes; + int64_t sent_time; +}; +struct { + __uint(type, BPF_MAP_TYPE_ARRAY); + __uint(max_entries, RATE_CNT); + __u32 *key; + struct ratelimit *value; +} rate_map SEC(".maps"); +#endif + SEC("xdp_drop") #endif int xdp_drop_prog(struct xdp_md *ctx)