1 From: Pablo Neira Ayuso <pablo@netfilter.org>
2 Date: Fri, 3 Nov 2017 16:26:32 +0100
3 Subject: [PATCH] netfilter: conntrack: move nf_ct_netns_{get,put}() to core
5 So we can call this from other expression that need conntrack in place
8 Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
9 Acked-by: Florian Westphal <fw@strlen.de>
12 --- a/net/netfilter/nf_conntrack_proto.c
13 +++ b/net/netfilter/nf_conntrack_proto.c
14 @@ -125,7 +125,7 @@ void nf_ct_l3proto_module_put(unsigned s
16 EXPORT_SYMBOL_GPL(nf_ct_l3proto_module_put);
18 -int nf_ct_netns_get(struct net *net, u8 nfproto)
19 +static int nf_ct_netns_do_get(struct net *net, u8 nfproto)
21 const struct nf_conntrack_l3proto *l3proto;
23 @@ -150,9 +150,33 @@ int nf_ct_netns_get(struct net *net, u8
28 +int nf_ct_netns_get(struct net *net, u8 nfproto)
32 + if (nfproto == NFPROTO_INET) {
33 + err = nf_ct_netns_do_get(net, NFPROTO_IPV4);
36 + err = nf_ct_netns_do_get(net, NFPROTO_IPV6);
40 + err = nf_ct_netns_do_get(net, nfproto);
47 + nf_ct_netns_put(net, NFPROTO_IPV4);
51 EXPORT_SYMBOL_GPL(nf_ct_netns_get);
53 -void nf_ct_netns_put(struct net *net, u8 nfproto)
54 +static void nf_ct_netns_do_put(struct net *net, u8 nfproto)
56 const struct nf_conntrack_l3proto *l3proto;
58 @@ -171,6 +195,15 @@ void nf_ct_netns_put(struct net *net, u8
60 nf_ct_l3proto_module_put(nfproto);
63 +void nf_ct_netns_put(struct net *net, uint8_t nfproto)
65 + if (nfproto == NFPROTO_INET) {
66 + nf_ct_netns_do_put(net, NFPROTO_IPV4);
67 + nf_ct_netns_do_put(net, NFPROTO_IPV6);
69 + nf_ct_netns_do_put(net, nfproto);
71 EXPORT_SYMBOL_GPL(nf_ct_netns_put);
73 const struct nf_conntrack_l4proto *
74 --- a/net/netfilter/nft_ct.c
75 +++ b/net/netfilter/nft_ct.c
76 @@ -312,39 +312,6 @@ static const struct nla_policy nft_ct_po
77 [NFTA_CT_SREG] = { .type = NLA_U32 },
80 -static int nft_ct_netns_get(struct net *net, uint8_t family)
84 - if (family == NFPROTO_INET) {
85 - err = nf_ct_netns_get(net, NFPROTO_IPV4);
88 - err = nf_ct_netns_get(net, NFPROTO_IPV6);
92 - err = nf_ct_netns_get(net, family);
99 - nf_ct_netns_put(net, NFPROTO_IPV4);
104 -static void nft_ct_netns_put(struct net *net, uint8_t family)
106 - if (family == NFPROTO_INET) {
107 - nf_ct_netns_put(net, NFPROTO_IPV4);
108 - nf_ct_netns_put(net, NFPROTO_IPV6);
110 - nf_ct_netns_put(net, family);
113 #ifdef CONFIG_NF_CONNTRACK_ZONES
114 static void nft_ct_tmpl_put_pcpu(void)
116 @@ -489,7 +456,7 @@ static int nft_ct_get_init(const struct
120 - err = nft_ct_netns_get(ctx->net, ctx->afi->family);
121 + err = nf_ct_netns_get(ctx->net, ctx->afi->family);
125 @@ -583,7 +550,7 @@ static int nft_ct_set_init(const struct
129 - err = nft_ct_netns_get(ctx->net, ctx->afi->family);
130 + err = nf_ct_netns_get(ctx->net, ctx->afi->family);
134 @@ -606,7 +573,7 @@ static void nft_ct_set_destroy(const str
135 struct nft_ct *priv = nft_expr_priv(expr);
137 __nft_ct_set_destroy(ctx, priv);
138 - nft_ct_netns_put(ctx->net, ctx->afi->family);
139 + nf_ct_netns_put(ctx->net, ctx->afi->family);
142 static int nft_ct_get_dump(struct sk_buff *skb, const struct nft_expr *expr)