From a6079ae91389e11fd742c380fe21aea0a76319ee Mon Sep 17 00:00:00 2001 From: Jeremy Sowden Date: Mon, 13 Sep 2021 21:46:07 +0200 Subject: [PATCH] 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 --- extensions/xt_ipp2p.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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; -- 2.47.2