[xtables-addons] xt_ipp2p: fix compatibility with pre-5.1 kernels

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



`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@xxxxxxxxxx>
---
 extensions/xt_ipp2p.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/extensions/xt_ipp2p.c b/extensions/xt_ipp2p.c
index 74f7d18fc04b..696318551649 100644
--- a/extensions/xt_ipp2p.c
+++ b/extensions/xt_ipp2p.c
@@ -19,6 +19,20 @@ MODULE_AUTHOR("Eicke Friedrich/Klaus Degner <ipp2p@xxxxxxxxx>");
 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.33.0




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux