Make defines psd specific so they dont redefine in-kernel defines like HASH_SIZE. [moved header to uapi for kernel-4.12.4 / tmb] Signed-off-by Thomas Backlund <tmb@mageia.org> --- include/uapi/linux/netfilter_ipv4/ipt_psd.h | 14 +++++++------- net/ipv4/netfilter/ipt_psd.c | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff -Nurp linux-psd/include/uapi/linux/netfilter_ipv4/ipt_psd.h linux-psd-fix/include/uapi/linux/netfilter_ipv4/ipt_psd.h --- linux-psd/include/uapi/linux/netfilter_ipv4/ipt_psd.h +++ linux-psd-fix/include/uapi/linux/netfilter_ipv4/ipt_psd.h @@ -21,14 +21,14 @@ #define SCAN_DELAY_THRESHOLD (300) /* old usage of HZ here was erroneously and broke under uml */ /* - * Keep track of up to LIST_SIZE source addresses, using a hash table of - * HASH_SIZE entries for faster lookups, but limiting hash collisions to - * HASH_MAX source addresses per the same hash value. + * Keep track of up to PSD_LIST_SIZE source addresses, using a hash table of + * PSD_HASH_SIZE entries for faster lookups, but limiting hash collisions to + * PSD_HASH_MAX source addresses per the same hash value. */ -#define LIST_SIZE 0x100 -#define HASH_LOG 9 -#define HASH_SIZE (1 << HASH_LOG) -#define HASH_MAX 0x10 +#define PSD_LIST_SIZE 0x100 +#define PSD_HASH_LOG 9 +#define PSD_HASH_SIZE (1 << PSD_HASH_LOG) +#define PSD_HASH_MAX 0x10 struct ipt_psd_info { unsigned int weight_threshold; diff -Nurp linux-4.9.5-psd/net/ipv4/netfilter/ipt_psd.c linux-4.9.5-psd-fix/net/ipv4/netfilter/ipt_psd.c --- linux-4.9.5-psd/net/ipv4/netfilter/ipt_psd.c 2017-01-20 21:47:19.792931402 +0200 +++ linux-4.9.5-psd-fix/net/ipv4/netfilter/ipt_psd.c 2017-01-20 21:58:09.998871253 +0200 @@ -74,8 +74,8 @@ struct host { */ static struct { spinlock_t lock; - struct host list[LIST_SIZE]; /* List of source addresses */ - struct host *hash[HASH_SIZE]; /* Hash: pointers into the list */ + struct host list[PSD_LIST_SIZE]; /* List of source addresses */ + struct host *hash[PSD_HASH_SIZE]; /* Hash: pointers into the list */ int index; /* Oldest entry to be replaced */ } state; @@ -91,9 +91,9 @@ static inline int hashfunc(struct in_add hash = 0; do { hash ^= value; - } while ((value >>= HASH_LOG)); + } while ((value >>= PSD_HASH_LOG)); - return hash & (HASH_SIZE - 1); + return hash & (PSD_HASH_SIZE - 1); } static bool @@ -245,11 +245,11 @@ ipt_psd_match(const struct sk_buff *pskb /* Got too many source addresses with the same hash value? Then remove the * oldest one from the hash table, so that they can't take too much of our * CPU time even with carefully chosen spoofed IP addresses. */ - if (count >= HASH_MAX && last) last->next = NULL; + if (count >= PSD_HASH_MAX && last) last->next = NULL; /* We're going to re-use the oldest list entry, so remove it from the hash * table first (if it is really already in use, and isn't removed from the - * hash table already because of the HASH_MAX check above). */ + * hash table already because of the PSD_HASH_MAX check above). */ /* First, find it */ if (state.list[state.index].src_addr.s_addr) @@ -273,7 +273,7 @@ ipt_psd_match(const struct sk_buff *pskb /* Get our list entry */ curr = &state.list[state.index++]; - if (state.index >= LIST_SIZE) state.index = 0; + if (state.index >= PSD_LIST_SIZE) state.index = 0; /* Link it into the hash table */ head = &state.hash[hash];