netfilter: nat: Avoid ABI change in 4.13.13
authorBen Hutchings <ben@decadent.org.uk>
Thu, 16 Nov 2017 21:00:59 +0000 (21:00 +0000)
committerBen Hutchings <ben@decadent.org.uk>
Thu, 16 Nov 2017 21:04:10 +0000 (21:04 +0000)
Commit e1bf1687740c ("netfilter: nat: Revert "netfilter: nat: convert
nat bysrc hash to rhashtable") changed the type of
nf_conn::nat_bysource.  Thankfully the two types are the same size,
and nothing outside of nf_nat_core touches this field directly.  Hide
the change from genksyms but add compile-time assertions to make sure
that this isn't an ABI change.

Gbp-Pq: Topic debian
Gbp-Pq: Name netfilter-nat-avoid-abi-change-in-4.13.13.patch

include/net/netfilter/nf_conntrack.h
include/net/netfilter/nf_nat.h
net/netfilter/nf_nat_core.c

index a7c2cee39570c3444632f92d76914249695d8e91..3fa5220521e3448786bc75a7a5981ac30f1d0a00 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/bitops.h>
 #include <linux/compiler.h>
 #include <linux/atomic.h>
+#include <linux/rhashtable.h>
 
 #include <linux/netfilter/nf_conntrack_tcp.h>
 #include <linux/netfilter/nf_conntrack_dccp.h>
@@ -82,7 +83,11 @@ struct nf_conn {
        possible_net_t ct_net;
 
 #if IS_ENABLED(CONFIG_NF_NAT)
+#ifndef __GENKSYMS__
        struct hlist_node       nat_bysource;
+#else
+       struct rhlist_head      nat_bysource;
+#endif
 #endif
        /* all members below initialized via memset */
        u8 __nfct_init_offset[0];
index b71701302e6176720a0ac8faf52b48e23bdb2fa9..05c82a1a42679cf336c4ecc2addc30bdaceecbbe 100644 (file)
@@ -1,5 +1,6 @@
 #ifndef _NF_NAT_H
 #define _NF_NAT_H
+#include <linux/rhashtable.h>
 #include <linux/netfilter_ipv4.h>
 #include <linux/netfilter/nf_nat.h>
 #include <net/netfilter/nf_conntrack_tuple.h>
index 2fb80a4bfb34c6525e325e1f1ed72142a60085b0..2a46bc1aee8d6cba4a5c2f9e322461107581f3ea 100644 (file)
@@ -796,6 +796,11 @@ static int __init nf_nat_init(void)
 {
        int ret;
 
+       /* bwh: Assert that nat_bysource hasn't changed size or alignment */
+       BUILD_BUG_ON(sizeof(struct hlist_node) != sizeof(struct rhlist_head));
+       BUILD_BUG_ON(__alignof__(struct hlist_node) !=
+                    __alignof__(struct rhlist_head));
+
        /* Leave them the same for the moment. */
        nf_nat_htable_size = nf_conntrack_htable_size;