Skip to content

Commit

Permalink
netfilter: xt_recent: Lift restrictions on max hitcount value
Browse files Browse the repository at this point in the history
Support tracking of up to 65535 packets per table entry instead of just
255 to better facilitate longer term tracking or higher throughput
scenarios.

Note how this aligns sizes of struct recent_entry's 'nstamps' and
'index' fields when 'nstamps' was larger before. This is unnecessary as
the value of 'nstamps' grows along with that of 'index' after being
initialized to 1 (see recent_entry_update()). Its value will thus never
exceed that of 'index' and therefore does not need to provide space for
larger values.

Requested-by: Fabio <[email protected]>
Link: https://bugzilla.netfilter.org/show_bug.cgi?id=1745
Signed-off-by: Phil Sutter <[email protected]>
Signed-off-by: Pablo Neira Ayuso <[email protected]>
  • Loading branch information
Phil Sutter authored and ummakynes committed Jun 28, 2024
1 parent 742ad97 commit f4ebd03
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions net/netfilter/xt_recent.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,17 @@ MODULE_PARM_DESC(ip_list_gid, "default owning group of /proc/net/xt_recent/* fil
/* retained for backwards compatibility */
static unsigned int ip_pkt_list_tot __read_mostly;
module_param(ip_pkt_list_tot, uint, 0400);
MODULE_PARM_DESC(ip_pkt_list_tot, "number of packets per IP address to remember (max. 255)");
MODULE_PARM_DESC(ip_pkt_list_tot, "number of packets per IP address to remember (max. 65535)");

#define XT_RECENT_MAX_NSTAMPS 256
#define XT_RECENT_MAX_NSTAMPS 65536

struct recent_entry {
struct list_head list;
struct list_head lru_list;
union nf_inet_addr addr;
u_int16_t family;
u_int8_t ttl;
u_int8_t index;
u_int16_t index;
u_int16_t nstamps;
unsigned long stamps[];
};
Expand All @@ -80,7 +80,7 @@ struct recent_table {
union nf_inet_addr mask;
unsigned int refcnt;
unsigned int entries;
u8 nstamps_max_mask;
u_int16_t nstamps_max_mask;
struct list_head lru_list;
struct list_head iphash[];
};
Expand Down

0 comments on commit f4ebd03

Please sign in to comment.