X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=flowspec-xdp;a=blobdiff_plain;f=xdp.c;h=d9aa0766f75efdec39aecb191c4a176d2ce1d862;hp=3ebec88555e37bb82ac5ca6868e8ef0e0c5d20d5;hb=c5f8e7b221515ce043779456945d45a7098d9d9e;hpb=348583843f9499b0f1c335edc684a077bb2c2710 diff --git a/xdp.c b/xdp.c index 3ebec88..d9aa076 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; + uint64_t bucket_secs; + uint64_t bucket_count; +}; +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)