1*6f52b16cSGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 294d0ec58SDavid Howells #ifndef _UAPI_XT_HASHLIMIT_H 394d0ec58SDavid Howells #define _UAPI_XT_HASHLIMIT_H 494d0ec58SDavid Howells 594d0ec58SDavid Howells #include <linux/types.h> 6f2168273SDmitry V. Levin #include <linux/limits.h> 71ffad83dSMikko Rapeli #include <linux/if.h> 894d0ec58SDavid Howells 994d0ec58SDavid Howells /* timings are in milliseconds. */ 1094d0ec58SDavid Howells #define XT_HASHLIMIT_SCALE 10000 1111d5f157SVishwanath Pai #define XT_HASHLIMIT_SCALE_v2 1000000llu 1294d0ec58SDavid Howells /* 1/10,000 sec period => max of 10,000/sec. Min rate is then 429490 1394d0ec58SDavid Howells * seconds, or one packet every 59 hours. 1494d0ec58SDavid Howells */ 1594d0ec58SDavid Howells 1694d0ec58SDavid Howells /* packet length accounting is done in 16-byte steps */ 1794d0ec58SDavid Howells #define XT_HASHLIMIT_BYTE_SHIFT 4 1894d0ec58SDavid Howells 1994d0ec58SDavid Howells /* details of this structure hidden by the implementation */ 2094d0ec58SDavid Howells struct xt_hashlimit_htable; 2194d0ec58SDavid Howells 2294d0ec58SDavid Howells enum { 2394d0ec58SDavid Howells XT_HASHLIMIT_HASH_DIP = 1 << 0, 2494d0ec58SDavid Howells XT_HASHLIMIT_HASH_DPT = 1 << 1, 2594d0ec58SDavid Howells XT_HASHLIMIT_HASH_SIP = 1 << 2, 2694d0ec58SDavid Howells XT_HASHLIMIT_HASH_SPT = 1 << 3, 2794d0ec58SDavid Howells XT_HASHLIMIT_INVERT = 1 << 4, 2894d0ec58SDavid Howells XT_HASHLIMIT_BYTES = 1 << 5, 29bea74641SVishwanath Pai XT_HASHLIMIT_RATE_MATCH = 1 << 6, 3094d0ec58SDavid Howells }; 3194d0ec58SDavid Howells 3294d0ec58SDavid Howells struct hashlimit_cfg { 3394d0ec58SDavid Howells __u32 mode; /* bitmask of XT_HASHLIMIT_HASH_* */ 3494d0ec58SDavid Howells __u32 avg; /* Average secs between packets * scale */ 3594d0ec58SDavid Howells __u32 burst; /* Period multiplier for upper limit. */ 3694d0ec58SDavid Howells 3794d0ec58SDavid Howells /* user specified */ 3894d0ec58SDavid Howells __u32 size; /* how many buckets */ 3994d0ec58SDavid Howells __u32 max; /* max number of entries */ 4094d0ec58SDavid Howells __u32 gc_interval; /* gc interval */ 4194d0ec58SDavid Howells __u32 expire; /* when do entries expire? */ 4294d0ec58SDavid Howells }; 4394d0ec58SDavid Howells 4494d0ec58SDavid Howells struct xt_hashlimit_info { 4594d0ec58SDavid Howells char name [IFNAMSIZ]; /* name */ 4694d0ec58SDavid Howells struct hashlimit_cfg cfg; 4794d0ec58SDavid Howells 4894d0ec58SDavid Howells /* Used internally by the kernel */ 4994d0ec58SDavid Howells struct xt_hashlimit_htable *hinfo; 5094d0ec58SDavid Howells union { 5194d0ec58SDavid Howells void *ptr; 5294d0ec58SDavid Howells struct xt_hashlimit_info *master; 5394d0ec58SDavid Howells } u; 5494d0ec58SDavid Howells }; 5594d0ec58SDavid Howells 5694d0ec58SDavid Howells struct hashlimit_cfg1 { 5794d0ec58SDavid Howells __u32 mode; /* bitmask of XT_HASHLIMIT_HASH_* */ 5894d0ec58SDavid Howells __u32 avg; /* Average secs between packets * scale */ 5994d0ec58SDavid Howells __u32 burst; /* Period multiplier for upper limit. */ 6094d0ec58SDavid Howells 6194d0ec58SDavid Howells /* user specified */ 6294d0ec58SDavid Howells __u32 size; /* how many buckets */ 6394d0ec58SDavid Howells __u32 max; /* max number of entries */ 6494d0ec58SDavid Howells __u32 gc_interval; /* gc interval */ 6594d0ec58SDavid Howells __u32 expire; /* when do entries expire? */ 6694d0ec58SDavid Howells 6794d0ec58SDavid Howells __u8 srcmask, dstmask; 6894d0ec58SDavid Howells }; 6994d0ec58SDavid Howells 7011d5f157SVishwanath Pai struct hashlimit_cfg2 { 7111d5f157SVishwanath Pai __u64 avg; /* Average secs between packets * scale */ 7211d5f157SVishwanath Pai __u64 burst; /* Period multiplier for upper limit. */ 7311d5f157SVishwanath Pai __u32 mode; /* bitmask of XT_HASHLIMIT_HASH_* */ 7411d5f157SVishwanath Pai 7511d5f157SVishwanath Pai /* user specified */ 7611d5f157SVishwanath Pai __u32 size; /* how many buckets */ 7711d5f157SVishwanath Pai __u32 max; /* max number of entries */ 7811d5f157SVishwanath Pai __u32 gc_interval; /* gc interval */ 7911d5f157SVishwanath Pai __u32 expire; /* when do entries expire? */ 8011d5f157SVishwanath Pai 8111d5f157SVishwanath Pai __u8 srcmask, dstmask; 8211d5f157SVishwanath Pai }; 8311d5f157SVishwanath Pai 84bea74641SVishwanath Pai struct hashlimit_cfg3 { 85bea74641SVishwanath Pai __u64 avg; /* Average secs between packets * scale */ 86bea74641SVishwanath Pai __u64 burst; /* Period multiplier for upper limit. */ 87bea74641SVishwanath Pai __u32 mode; /* bitmask of XT_HASHLIMIT_HASH_* */ 88bea74641SVishwanath Pai 89bea74641SVishwanath Pai /* user specified */ 90bea74641SVishwanath Pai __u32 size; /* how many buckets */ 91bea74641SVishwanath Pai __u32 max; /* max number of entries */ 92bea74641SVishwanath Pai __u32 gc_interval; /* gc interval */ 93bea74641SVishwanath Pai __u32 expire; /* when do entries expire? */ 94bea74641SVishwanath Pai 95bea74641SVishwanath Pai __u32 interval; 96bea74641SVishwanath Pai __u8 srcmask, dstmask; 97bea74641SVishwanath Pai }; 98bea74641SVishwanath Pai 9994d0ec58SDavid Howells struct xt_hashlimit_mtinfo1 { 10094d0ec58SDavid Howells char name[IFNAMSIZ]; 10194d0ec58SDavid Howells struct hashlimit_cfg1 cfg; 10294d0ec58SDavid Howells 10394d0ec58SDavid Howells /* Used internally by the kernel */ 10494d0ec58SDavid Howells struct xt_hashlimit_htable *hinfo __attribute__((aligned(8))); 10594d0ec58SDavid Howells }; 10694d0ec58SDavid Howells 10711d5f157SVishwanath Pai struct xt_hashlimit_mtinfo2 { 10811d5f157SVishwanath Pai char name[NAME_MAX]; 10911d5f157SVishwanath Pai struct hashlimit_cfg2 cfg; 11011d5f157SVishwanath Pai 11111d5f157SVishwanath Pai /* Used internally by the kernel */ 11211d5f157SVishwanath Pai struct xt_hashlimit_htable *hinfo __attribute__((aligned(8))); 11311d5f157SVishwanath Pai }; 11411d5f157SVishwanath Pai 115bea74641SVishwanath Pai struct xt_hashlimit_mtinfo3 { 116bea74641SVishwanath Pai char name[NAME_MAX]; 117bea74641SVishwanath Pai struct hashlimit_cfg3 cfg; 118bea74641SVishwanath Pai 119bea74641SVishwanath Pai /* Used internally by the kernel */ 120bea74641SVishwanath Pai struct xt_hashlimit_htable *hinfo __attribute__((aligned(8))); 121bea74641SVishwanath Pai }; 122bea74641SVishwanath Pai 12394d0ec58SDavid Howells #endif /* _UAPI_XT_HASHLIMIT_H */ 124