From: Jeremy Sowden Date: Mon, 13 Sep 2021 19:46:07 +0000 (+0200) Subject: xt_ipp2p: fix compatibility with pre-5.1 kernels X-Git-Tag: v3.19~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a6079ae91389e11fd742c380fe21aea0a76319ee;p=thirdparty%2Fxtables-addons.git xt_ipp2p: fix compatibility with pre-5.1 kernels `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 --- diff --git a/extensions/xt_ipp2p.c b/extensions/xt_ipp2p.c index 7785b57..c2f7ee7 100644 --- a/extensions/xt_ipp2p.c +++ b/extensions/xt_ipp2p.c @@ -19,6 +19,20 @@ MODULE_AUTHOR("Eicke Friedrich/Klaus Degner "); 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;