]> git.ipfire.org Git - thirdparty/xtables-addons.git/commitdiff
xt_ipp2p: fix compatibility with pre-5.1 kernels
authorJeremy Sowden <jeremy@azazel.net>
Mon, 13 Sep 2021 19:46:07 +0000 (21:46 +0200)
committerJan Engelhardt <jengelh@inai.de>
Tue, 14 Sep 2021 13:29:11 +0000 (15:29 +0200)
`ip_transport_len` and `ipv6_transport_len` were introduced in 5.1.
They are both single-statement static inline functions, so add fall-back
implementations for compatibility with older kernels.

Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
extensions/xt_ipp2p.c

index 7785b57b0365349053f7428c4d8502c1fba11b72..c2f7ee7e5585d96ed73790fff60e728bea91a639 100644 (file)
@@ -19,6 +19,20 @@ MODULE_AUTHOR("Eicke Friedrich/Klaus Degner <ipp2p@ipp2p.org>");
 MODULE_DESCRIPTION("An extension to iptables to identify P2P traffic.");
 MODULE_LICENSE("GPL");
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0)
+static inline unsigned int
+ip_transport_len(const struct sk_buff *skb)
+{
+        return ntohs(ip_hdr(skb)->tot_len) - skb_network_header_len(skb);
+}
+static inline unsigned int
+ipv6_transport_len(const struct sk_buff *skb)
+{
+        return ntohs(ipv6_hdr(skb)->payload_len) + sizeof(struct ipv6hdr) -
+               skb_network_header_len(skb);
+}
+#endif
+
 union ipp2p_addr {
        __be32 ip;
        struct in6_addr in6;