`prandom_u32_max` was deprecated in favour of `get_random_u32_below`, and removed in 6.2-rc1. Replace the three occurrences of it in the TARPIT extension, and ad compat support for earlier kernels. Signed-off-by: Jeremy Sowden <jeremy@xxxxxxxxxx> --- configure.ac | 2 +- extensions/compat_xtables.h | 4 ++++ extensions/xt_TARPIT.c | 6 +++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index d582ca8e92d0..a13988ff4a4b 100644 --- a/configure.ac +++ b/configure.ac @@ -58,7 +58,7 @@ AS_IF([test -n "$kbuilddir"], [ yoff ], [ echo "$kmajor.$kminor.$kmicro.$kstable in $kbuilddir"; - if test "$kmajor" -gt 6 -o "$kmajor" -eq 6 -a "$kminor" -gt 1; then + if test "$kmajor" -gt 6 -o "$kmajor" -eq 6 -a "$kminor" -gt 2; then yon echo "WARNING: That kernel version is not officially supported yet. Continue at own luck."; yoff diff --git a/extensions/compat_xtables.h b/extensions/compat_xtables.h index 1feea880057d..848d3bff50d8 100644 --- a/extensions/compat_xtables.h +++ b/extensions/compat_xtables.h @@ -48,4 +48,8 @@ static inline struct net *par_net(const struct xt_action_param *par) # define proc_release release #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 2, 0) +# define get_random_u32_below prandom_u32_max +#endif + extern void *HX_memmem(const void *, size_t, const void *, size_t); diff --git a/extensions/xt_TARPIT.c b/extensions/xt_TARPIT.c index 22e61255f5ca..c3875bc0f47f 100644 --- a/extensions/xt_TARPIT.c +++ b/extensions/xt_TARPIT.c @@ -107,8 +107,8 @@ static bool xttarpit_honeypot(struct tcphdr *tcph, const struct tcphdr *oth, tcph->syn = true; tcph->ack = true; tcph->window = oth->window & - (prandom_u32_max(0x20) - 0xf); - tcph->seq = htonl(prandom_u32_max(~oth->seq + 1)); + (get_random_u32_below(0x20) - 0xf); + tcph->seq = htonl(get_random_u32_below(~oth->seq + 1)); tcph->ack_seq = htonl(ntohl(oth->seq) + oth->syn); } @@ -117,7 +117,7 @@ static bool xttarpit_honeypot(struct tcphdr *tcph, const struct tcphdr *oth, tcph->syn = false; tcph->ack = true; tcph->window = oth->window & - (prandom_u32_max(0x20) - 0xf); + (get_random_u32_below(0x20) - 0xf); tcph->ack_seq = payload > 100 ? htonl(ntohl(oth->seq) + payload) : oth->seq; -- 2.39.0