One of the problems with the way xt_recent is implemented is that there is no efficient way to remove expired entries. Of course, one can write a rule '-m recent --remove', but you have to know beforehand which entry to delete. This commit adds reaper logic which checks the head of the LRU list when a rule is invoked that has a '--seconds' value and XT_RECENT_REAP set. If an entry ceases to accumulate time stamps, then it will eventually bubble to the top of the LRU list where it is then reaped.
Showing the changes to include/linux/netfilter (1 of 2 files). Show all
Unified · Split
| @@ -9,6 +9,7 @@ enum { · 8 unmodified lines | ||
| 9 | 9 | XT_RECENT_UPDATE = 1 << 2, |
| 10 | 10 | XT_RECENT_REMOVE = 1 << 3, |
| 11 | 11 | XT_RECENT_TTL = 1 << 4, |
| 12 | + XT_RECENT_REAP = 1 << 5, | |
| 12 | 13 | |
| 13 | 14 | XT_RECENT_SOURCE = 0, |
| 14 | 15 | XT_RECENT_DEST = 1, |
| @@ -16,6 +17,9 @@ enum { · 1 unmodified line | ||
| 16 | 17 | XT_RECENT_NAME_LEN = 200, |
| 17 | 18 | }; |
| 18 | 19 | |
| 20 | +/* Only allowed with --rcheck and --update */ | |
| 21 | +#define XT_RECENT_MODIFIERS (XT_RECENT_TTL|XT_RECENT_REAP) | |
| 22 | + | |
| 19 | 23 | struct xt_recent_mtinfo { |
| 20 | 24 | __u32 seconds; |
| 21 | 25 | __u32 hit_count; |