Skip to content

Commit 5cbabee

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: nat: remove nf_nat_l4proto struct
This removes the (now empty) nf_nat_l4proto struct, all its instances and all the no longer needed runtime (un)register functionality. nf_nat_need_gre() can be axed as well: the module that calls it (to load the no-longer-existing nat_gre module) also calls other nat core functions. GRE nat is now always available if kernel is built with it. Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent faec18d commit 5cbabee

18 files changed

Lines changed: 10 additions & 390 deletions

‎include/linux/netfilter/nf_conntrack_proto_gre.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,5 @@ int nf_ct_gre_keymap_add(struct nf_conn *ct, enum ip_conntrack_dir dir,
2828
/* delete keymap entries */
2929
void nf_ct_gre_keymap_destroy(struct nf_conn *ct);
3030

31-
void nf_nat_need_gre(void);
32-
3331
#endif /* __KERNEL__ */
3432
#endif /* _CONNTRACK_PROTO_GRE_H */

‎include/net/netfilter/nf_nat_l3proto.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22
#ifndef _NF_NAT_L3PROTO_H
33
#define _NF_NAT_L3PROTO_H
44

5-
struct nf_nat_l4proto;
65
struct nf_nat_l3proto {
76
u8 l3proto;
87

98
bool (*manip_pkt)(struct sk_buff *skb,
109
unsigned int iphdroff,
11-
const struct nf_nat_l4proto *l4proto,
1210
const struct nf_conntrack_tuple *target,
1311
enum nf_nat_manip_type maniptype);
1412

‎include/net/netfilter/nf_nat_l4proto.h‎

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,12 @@
55
#include <net/netfilter/nf_nat.h>
66
#include <linux/netfilter/nfnetlink_conntrack.h>
77

8-
struct nf_nat_range;
98
struct nf_nat_l3proto;
109

11-
struct nf_nat_l4proto {
12-
/* Protocol number. */
13-
u8 l4proto;
14-
15-
};
16-
17-
/* Protocol registration. */
18-
int nf_nat_l4proto_register(u8 l3proto, const struct nf_nat_l4proto *l4proto);
19-
void nf_nat_l4proto_unregister(u8 l3proto,
20-
const struct nf_nat_l4proto *l4proto);
21-
22-
const struct nf_nat_l4proto *__nf_nat_l4proto_find(u8 l3proto, u8 l4proto);
23-
2410
/* Translate a packet to the target according to manip type. Return on success. */
2511
bool nf_nat_l4proto_manip_pkt(struct sk_buff *skb,
2612
const struct nf_nat_l3proto *l3proto,
2713
unsigned int iphdroff, unsigned int hdroff,
2814
const struct nf_conntrack_tuple *tuple,
2915
enum nf_nat_manip_type maniptype);
30-
31-
/* Built-in protocols. */
32-
extern const struct nf_nat_l4proto nf_nat_l4proto_tcp;
33-
extern const struct nf_nat_l4proto nf_nat_l4proto_udp;
34-
extern const struct nf_nat_l4proto nf_nat_l4proto_icmp;
35-
extern const struct nf_nat_l4proto nf_nat_l4proto_icmpv6;
36-
extern const struct nf_nat_l4proto nf_nat_l4proto_unknown;
37-
#ifdef CONFIG_NF_NAT_PROTO_DCCP
38-
extern const struct nf_nat_l4proto nf_nat_l4proto_dccp;
39-
#endif
40-
#ifdef CONFIG_NF_NAT_PROTO_SCTP
41-
extern const struct nf_nat_l4proto nf_nat_l4proto_sctp;
42-
#endif
43-
#ifdef CONFIG_NF_NAT_PROTO_UDPLITE
44-
extern const struct nf_nat_l4proto nf_nat_l4proto_udplite;
45-
#endif
46-
4716
#endif /*_NF_NAT_L4PROTO_H*/

‎net/ipv4/netfilter/Makefile‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Makefile for the netfilter modules on top of IPv4.
44
#
55

6-
nf_nat_ipv4-y := nf_nat_l3proto_ipv4.o nf_nat_proto_icmp.o
6+
nf_nat_ipv4-y := nf_nat_l3proto_ipv4.o
77
nf_nat_ipv4-$(CONFIG_NF_NAT_MASQUERADE_IPV4) += nf_nat_masquerade_ipv4.o
88
obj-$(CONFIG_NF_NAT_IPV4) += nf_nat_ipv4.o
99

@@ -28,9 +28,6 @@ nf_nat_snmp_basic-y := nf_nat_snmp_basic.asn1.o nf_nat_snmp_basic_main.o
2828
$(obj)/nf_nat_snmp_basic_main.o: $(obj)/nf_nat_snmp_basic.asn1.h
2929
obj-$(CONFIG_NF_NAT_SNMP_BASIC) += nf_nat_snmp_basic.o
3030

31-
# NAT protocols (nf_nat)
32-
obj-$(CONFIG_NF_NAT_PROTO_GRE) += nf_nat_proto_gre.o
33-
3431
obj-$(CONFIG_NFT_CHAIN_ROUTE_IPV4) += nft_chain_route_ipv4.o
3532
obj-$(CONFIG_NFT_CHAIN_NAT_IPV4) += nft_chain_nat_ipv4.o
3633
obj-$(CONFIG_NFT_REJECT_IPV4) += nft_reject_ipv4.o

‎net/ipv4/netfilter/nf_nat_l3proto_ipv4.c‎

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ static void nf_nat_ipv4_decode_session(struct sk_buff *skb,
6464

6565
static bool nf_nat_ipv4_manip_pkt(struct sk_buff *skb,
6666
unsigned int iphdroff,
67-
const struct nf_nat_l4proto *l4proto,
6867
const struct nf_conntrack_tuple *target,
6968
enum nf_nat_manip_type maniptype)
7069
{
@@ -171,7 +170,6 @@ int nf_nat_icmp_reply_translation(struct sk_buff *skb,
171170
enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
172171
enum nf_nat_manip_type manip = HOOK2MANIP(hooknum);
173172
unsigned int hdrlen = ip_hdrlen(skb);
174-
const struct nf_nat_l4proto *l4proto;
175173
struct nf_conntrack_tuple target;
176174
unsigned long statusbit;
177175

@@ -202,9 +200,8 @@ int nf_nat_icmp_reply_translation(struct sk_buff *skb,
202200
if (!(ct->status & statusbit))
203201
return 1;
204202

205-
l4proto = __nf_nat_l4proto_find(NFPROTO_IPV4, inside->ip.protocol);
206203
if (!nf_nat_ipv4_manip_pkt(skb, hdrlen + sizeof(inside->icmp),
207-
l4proto, &ct->tuplehash[!dir].tuple, !manip))
204+
&ct->tuplehash[!dir].tuple, !manip))
208205
return 0;
209206

210207
if (skb->ip_summed != CHECKSUM_PARTIAL) {
@@ -218,8 +215,7 @@ int nf_nat_icmp_reply_translation(struct sk_buff *skb,
218215

219216
/* Change outer to look like the reply to an incoming packet */
220217
nf_ct_invert_tuplepr(&target, &ct->tuplehash[!dir].tuple);
221-
l4proto = __nf_nat_l4proto_find(NFPROTO_IPV4, 0);
222-
if (!nf_nat_ipv4_manip_pkt(skb, 0, l4proto, &target, manip))
218+
if (!nf_nat_ipv4_manip_pkt(skb, 0, &target, manip))
223219
return 0;
224220

225221
return 1;
@@ -376,26 +372,12 @@ EXPORT_SYMBOL_GPL(nf_nat_l3proto_ipv4_unregister_fn);
376372

377373
static int __init nf_nat_l3proto_ipv4_init(void)
378374
{
379-
int err;
380-
381-
err = nf_nat_l4proto_register(NFPROTO_IPV4, &nf_nat_l4proto_icmp);
382-
if (err < 0)
383-
goto err1;
384-
err = nf_nat_l3proto_register(&nf_nat_l3proto_ipv4);
385-
if (err < 0)
386-
goto err2;
387-
return err;
388-
389-
err2:
390-
nf_nat_l4proto_unregister(NFPROTO_IPV4, &nf_nat_l4proto_icmp);
391-
err1:
392-
return err;
375+
return nf_nat_l3proto_register(&nf_nat_l3proto_ipv4);
393376
}
394377

395378
static void __exit nf_nat_l3proto_ipv4_exit(void)
396379
{
397380
nf_nat_l3proto_unregister(&nf_nat_l3proto_ipv4);
398-
nf_nat_l4proto_unregister(NFPROTO_IPV4, &nf_nat_l4proto_icmp);
399381
}
400382

401383
MODULE_LICENSE("GPL");

‎net/ipv4/netfilter/nf_nat_proto_gre.c‎

Lines changed: 0 additions & 61 deletions
This file was deleted.

‎net/ipv4/netfilter/nf_nat_proto_icmp.c‎

Lines changed: 0 additions & 21 deletions
This file was deleted.

‎net/ipv6/netfilter/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ obj-$(CONFIG_IP6_NF_RAW) += ip6table_raw.o
1111
obj-$(CONFIG_IP6_NF_SECURITY) += ip6table_security.o
1212
obj-$(CONFIG_IP6_NF_NAT) += ip6table_nat.o
1313

14-
nf_nat_ipv6-y := nf_nat_l3proto_ipv6.o nf_nat_proto_icmpv6.o
14+
nf_nat_ipv6-y := nf_nat_l3proto_ipv6.o
1515
nf_nat_ipv6-$(CONFIG_NF_NAT_MASQUERADE_IPV6) += nf_nat_masquerade_ipv6.o
1616
obj-$(CONFIG_NF_NAT_IPV6) += nf_nat_ipv6.o
1717

‎net/ipv6/netfilter/nf_nat_l3proto_ipv6.c‎

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ static void nf_nat_ipv6_decode_session(struct sk_buff *skb,
6363

6464
static bool nf_nat_ipv6_manip_pkt(struct sk_buff *skb,
6565
unsigned int iphdroff,
66-
const struct nf_nat_l4proto *l4proto,
6766
const struct nf_conntrack_tuple *target,
6867
enum nf_nat_manip_type maniptype)
6968
{
@@ -181,7 +180,6 @@ int nf_nat_icmpv6_reply_translation(struct sk_buff *skb,
181180
} *inside;
182181
enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
183182
enum nf_nat_manip_type manip = HOOK2MANIP(hooknum);
184-
const struct nf_nat_l4proto *l4proto;
185183
struct nf_conntrack_tuple target;
186184
unsigned long statusbit;
187185

@@ -212,9 +210,8 @@ int nf_nat_icmpv6_reply_translation(struct sk_buff *skb,
212210
if (!(ct->status & statusbit))
213211
return 1;
214212

215-
l4proto = __nf_nat_l4proto_find(NFPROTO_IPV6, inside->ip6.nexthdr);
216213
if (!nf_nat_ipv6_manip_pkt(skb, hdrlen + sizeof(inside->icmp6),
217-
l4proto, &ct->tuplehash[!dir].tuple, !manip))
214+
&ct->tuplehash[!dir].tuple, !manip))
218215
return 0;
219216

220217
if (skb->ip_summed != CHECKSUM_PARTIAL) {
@@ -229,8 +226,7 @@ int nf_nat_icmpv6_reply_translation(struct sk_buff *skb,
229226
}
230227

231228
nf_ct_invert_tuplepr(&target, &ct->tuplehash[!dir].tuple);
232-
l4proto = __nf_nat_l4proto_find(NFPROTO_IPV6, IPPROTO_ICMPV6);
233-
if (!nf_nat_ipv6_manip_pkt(skb, 0, l4proto, &target, manip))
229+
if (!nf_nat_ipv6_manip_pkt(skb, 0, &target, manip))
234230
return 0;
235231

236232
return 1;
@@ -400,26 +396,12 @@ EXPORT_SYMBOL_GPL(nf_nat_l3proto_ipv6_unregister_fn);
400396

401397
static int __init nf_nat_l3proto_ipv6_init(void)
402398
{
403-
int err;
404-
405-
err = nf_nat_l4proto_register(NFPROTO_IPV6, &nf_nat_l4proto_icmpv6);
406-
if (err < 0)
407-
goto err1;
408-
err = nf_nat_l3proto_register(&nf_nat_l3proto_ipv6);
409-
if (err < 0)
410-
goto err2;
411-
return err;
412-
413-
err2:
414-
nf_nat_l4proto_unregister(NFPROTO_IPV6, &nf_nat_l4proto_icmpv6);
415-
err1:
416-
return err;
399+
return nf_nat_l3proto_register(&nf_nat_l3proto_ipv6);
417400
}
418401

419402
static void __exit nf_nat_l3proto_ipv6_exit(void)
420403
{
421404
nf_nat_l3proto_unregister(&nf_nat_l3proto_ipv6);
422-
nf_nat_l4proto_unregister(NFPROTO_IPV6, &nf_nat_l4proto_icmpv6);
423405
}
424406

425407
MODULE_LICENSE("GPL");

‎net/ipv6/netfilter/nf_nat_proto_icmpv6.c‎

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)