]> git.ipfire.org Git - thirdparty/xtables-addons.git/commitdiff
build: support for Linux 6.2
authorJeremy Sowden <jeremy@azazel.net>
Thu, 29 Dec 2022 16:35:07 +0000 (17:35 +0100)
committerJan Engelhardt <jengelh@inai.de>
Fri, 30 Dec 2022 14:45:12 +0000 (15:45 +0100)
`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@azazel.net>
configure.ac
extensions/compat_xtables.h
extensions/xt_TARPIT.c

index d582ca8e92d0ee48537438733989bbb3be4ec27d..a13988ff4a4b9ce79136fd71729c2310ab3b2da4 100644 (file)
@@ -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
index 1feea880057d71ffa8521d96094de42cae72c739..848d3bff50d8706d732cc59f787f13cd140ffe57 100644 (file)
@@ -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);
index 22e61255f5ca4bb23bad4b4a5992fcfc3d855a7f..c3875bc0f47f24e6e82745badc0b10eb0b3e677f 100644 (file)
@@ -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;