Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netfilter: nat: remove nf_nat_l3proto.h and nf_nat_core.h

The l3proto name is gone, its header file is the last trace.
While at it, also remove nf_nat_core.h, its very small and all users
include nf_nat.h too.

before:
text data bss dec hex filename
22948 1612 4136 28696 7018 nf_nat.ko

after removal of l3proto register/unregister functions:
text data bss dec hex filename
22196 1516 4136 27848 6cc8 nf_nat.ko

checkpatch complains about overly long lines, but line breaks
do not make things more readable and the line length gets smaller
here, not larger.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>

authored by

Florian Westphal and committed by
Pablo Neira Ayuso
d2c5c103 d6c4c8ff

+60 -95
+39
include/net/netfilter/nf_nat.h
··· 73 73 const struct nf_hook_ops *nat_ops, unsigned int ops_count); 74 74 void nf_nat_unregister_fn(struct net *net, const struct nf_hook_ops *ops, 75 75 unsigned int ops_count); 76 + 77 + unsigned int nf_nat_packet(struct nf_conn *ct, enum ip_conntrack_info ctinfo, 78 + unsigned int hooknum, struct sk_buff *skb); 79 + 80 + unsigned int nf_nat_manip_pkt(struct sk_buff *skb, struct nf_conn *ct, 81 + enum nf_nat_manip_type mtype, 82 + enum ip_conntrack_dir dir); 83 + void nf_nat_csum_recalc(struct sk_buff *skb, 84 + u8 nfproto, u8 proto, void *data, __sum16 *check, 85 + int datalen, int oldlen); 86 + 87 + int nf_nat_icmp_reply_translation(struct sk_buff *skb, struct nf_conn *ct, 88 + enum ip_conntrack_info ctinfo, 89 + unsigned int hooknum); 90 + 91 + int nf_nat_icmpv6_reply_translation(struct sk_buff *skb, struct nf_conn *ct, 92 + enum ip_conntrack_info ctinfo, 93 + unsigned int hooknum, unsigned int hdrlen); 94 + 95 + int nf_nat_ipv4_register_fn(struct net *net, const struct nf_hook_ops *ops); 96 + void nf_nat_ipv4_unregister_fn(struct net *net, const struct nf_hook_ops *ops); 97 + 98 + int nf_nat_ipv6_register_fn(struct net *net, const struct nf_hook_ops *ops); 99 + void nf_nat_ipv6_unregister_fn(struct net *net, const struct nf_hook_ops *ops); 100 + 101 + unsigned int 102 + nf_nat_inet_fn(void *priv, struct sk_buff *skb, 103 + const struct nf_hook_state *state); 104 + 105 + int nf_xfrm_me_harder(struct net *n, struct sk_buff *s, unsigned int family); 106 + 107 + static inline int nf_nat_initialized(struct nf_conn *ct, 108 + enum nf_nat_manip_type manip) 109 + { 110 + if (manip == NF_NAT_MANIP_SRC) 111 + return ct->status & IPS_SRC_NAT_DONE; 112 + else 113 + return ct->status & IPS_DST_NAT_DONE; 114 + } 76 115 #endif
-29
include/net/netfilter/nf_nat_core.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef _NF_NAT_CORE_H 3 - #define _NF_NAT_CORE_H 4 - #include <linux/list.h> 5 - #include <net/netfilter/nf_conntrack.h> 6 - #include <net/netfilter/nf_nat.h> 7 - 8 - /* This header used to share core functionality between the standalone 9 - NAT module, and the compatibility layer's use of NAT for masquerading. */ 10 - 11 - unsigned int nf_nat_packet(struct nf_conn *ct, enum ip_conntrack_info ctinfo, 12 - unsigned int hooknum, struct sk_buff *skb); 13 - 14 - unsigned int 15 - nf_nat_inet_fn(void *priv, struct sk_buff *skb, 16 - const struct nf_hook_state *state); 17 - 18 - int nf_xfrm_me_harder(struct net *net, struct sk_buff *skb, unsigned int family); 19 - 20 - static inline int nf_nat_initialized(struct nf_conn *ct, 21 - enum nf_nat_manip_type manip) 22 - { 23 - if (manip == NF_NAT_MANIP_SRC) 24 - return ct->status & IPS_SRC_NAT_DONE; 25 - else 26 - return ct->status & IPS_DST_NAT_DONE; 27 - } 28 - 29 - #endif /* _NF_NAT_CORE_H */
-26
include/net/netfilter/nf_nat_l3proto.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef _NF_NAT_L3PROTO_H 3 - #define _NF_NAT_L3PROTO_H 4 - 5 - unsigned int nf_nat_manip_pkt(struct sk_buff *skb, struct nf_conn *ct, 6 - enum nf_nat_manip_type mtype, 7 - enum ip_conntrack_dir dir); 8 - void nf_nat_csum_recalc(struct sk_buff *skb, 9 - u8 nfproto, u8 proto, void *data, __sum16 *check, 10 - int datalen, int oldlen); 11 - 12 - int nf_nat_icmp_reply_translation(struct sk_buff *skb, struct nf_conn *ct, 13 - enum ip_conntrack_info ctinfo, 14 - unsigned int hooknum); 15 - 16 - int nf_nat_icmpv6_reply_translation(struct sk_buff *skb, struct nf_conn *ct, 17 - enum ip_conntrack_info ctinfo, 18 - unsigned int hooknum, unsigned int hdrlen); 19 - 20 - int nf_nat_l3proto_ipv4_register_fn(struct net *net, const struct nf_hook_ops *ops); 21 - void nf_nat_l3proto_ipv4_unregister_fn(struct net *net, const struct nf_hook_ops *ops); 22 - 23 - int nf_nat_l3proto_ipv6_register_fn(struct net *net, const struct nf_hook_ops *ops); 24 - void nf_nat_l3proto_ipv6_unregister_fn(struct net *net, const struct nf_hook_ops *ops); 25 - 26 - #endif /* _NF_NAT_L3PROTO_H */
+3 -5
net/ipv4/netfilter/iptable_nat.c
··· 15 15 #include <net/ip.h> 16 16 17 17 #include <net/netfilter/nf_nat.h> 18 - #include <net/netfilter/nf_nat_core.h> 19 - #include <net/netfilter/nf_nat_l3proto.h> 20 18 21 19 static int __net_init iptable_nat_table_init(struct net *net); 22 20 ··· 68 70 int i, ret; 69 71 70 72 for (i = 0; i < ARRAY_SIZE(nf_nat_ipv4_ops); i++) { 71 - ret = nf_nat_l3proto_ipv4_register_fn(net, &nf_nat_ipv4_ops[i]); 73 + ret = nf_nat_ipv4_register_fn(net, &nf_nat_ipv4_ops[i]); 72 74 if (ret) { 73 75 while (i) 74 - nf_nat_l3proto_ipv4_unregister_fn(net, &nf_nat_ipv4_ops[--i]); 76 + nf_nat_ipv4_unregister_fn(net, &nf_nat_ipv4_ops[--i]); 75 77 76 78 return ret; 77 79 } ··· 85 87 int i; 86 88 87 89 for (i = 0; i < ARRAY_SIZE(nf_nat_ipv4_ops); i++) 88 - nf_nat_l3proto_ipv4_unregister_fn(net, &nf_nat_ipv4_ops[i]); 90 + nf_nat_ipv4_unregister_fn(net, &nf_nat_ipv4_ops[i]); 89 91 } 90 92 91 93 static int __net_init iptable_nat_table_init(struct net *net)
+2 -4
net/ipv4/netfilter/nft_chain_nat_ipv4.c
··· 20 20 #include <linux/netfilter/nf_tables.h> 21 21 #include <net/netfilter/nf_conntrack.h> 22 22 #include <net/netfilter/nf_nat.h> 23 - #include <net/netfilter/nf_nat_core.h> 24 23 #include <net/netfilter/nf_tables.h> 25 24 #include <net/netfilter/nf_tables_ipv4.h> 26 - #include <net/netfilter/nf_nat_l3proto.h> 27 25 #include <net/ip.h> 28 26 29 27 static unsigned int nft_nat_do_chain(void *priv, ··· 38 40 39 41 static int nft_nat_ipv4_reg(struct net *net, const struct nf_hook_ops *ops) 40 42 { 41 - return nf_nat_l3proto_ipv4_register_fn(net, ops); 43 + return nf_nat_ipv4_register_fn(net, ops); 42 44 } 43 45 44 46 static void nft_nat_ipv4_unreg(struct net *net, const struct nf_hook_ops *ops) 45 47 { 46 - nf_nat_l3proto_ipv4_unregister_fn(net, ops); 48 + nf_nat_ipv4_unregister_fn(net, ops); 47 49 } 48 50 49 51 static const struct nft_chain_type nft_chain_nat_ipv4 = {
+3 -5
net/ipv6/netfilter/ip6table_nat.c
··· 17 17 #include <net/ipv6.h> 18 18 19 19 #include <net/netfilter/nf_nat.h> 20 - #include <net/netfilter/nf_nat_core.h> 21 - #include <net/netfilter/nf_nat_l3proto.h> 22 20 23 21 static int __net_init ip6table_nat_table_init(struct net *net); 24 22 ··· 70 72 int i, ret; 71 73 72 74 for (i = 0; i < ARRAY_SIZE(nf_nat_ipv6_ops); i++) { 73 - ret = nf_nat_l3proto_ipv6_register_fn(net, &nf_nat_ipv6_ops[i]); 75 + ret = nf_nat_ipv6_register_fn(net, &nf_nat_ipv6_ops[i]); 74 76 if (ret) { 75 77 while (i) 76 - nf_nat_l3proto_ipv6_unregister_fn(net, &nf_nat_ipv6_ops[--i]); 78 + nf_nat_ipv6_unregister_fn(net, &nf_nat_ipv6_ops[--i]); 77 79 78 80 return ret; 79 81 } ··· 87 89 int i; 88 90 89 91 for (i = 0; i < ARRAY_SIZE(nf_nat_ipv6_ops); i++) 90 - nf_nat_l3proto_ipv6_unregister_fn(net, &nf_nat_ipv6_ops[i]); 92 + nf_nat_ipv6_unregister_fn(net, &nf_nat_ipv6_ops[i]); 91 93 } 92 94 93 95 static int __net_init ip6table_nat_table_init(struct net *net)
+2 -4
net/ipv6/netfilter/nft_chain_nat_ipv6.c
··· 18 18 #include <linux/netfilter/nf_tables.h> 19 19 #include <net/netfilter/nf_conntrack.h> 20 20 #include <net/netfilter/nf_nat.h> 21 - #include <net/netfilter/nf_nat_core.h> 22 21 #include <net/netfilter/nf_tables.h> 23 22 #include <net/netfilter/nf_tables_ipv6.h> 24 - #include <net/netfilter/nf_nat_l3proto.h> 25 23 #include <net/ipv6.h> 26 24 27 25 static unsigned int nft_nat_do_chain(void *priv, ··· 36 38 37 39 static int nft_nat_ipv6_reg(struct net *net, const struct nf_hook_ops *ops) 38 40 { 39 - return nf_nat_l3proto_ipv6_register_fn(net, ops); 41 + return nf_nat_ipv6_register_fn(net, ops); 40 42 } 41 43 42 44 static void nft_nat_ipv6_unreg(struct net *net, const struct nf_hook_ops *ops) 43 45 { 44 - nf_nat_l3proto_ipv6_unregister_fn(net, ops); 46 + nf_nat_ipv6_unregister_fn(net, ops); 45 47 } 46 48 47 49 static const struct nft_chain_type nft_chain_nat_ipv6 = {
-1
net/netfilter/nf_conntrack_core.c
··· 51 51 #include <net/netfilter/nf_conntrack_labels.h> 52 52 #include <net/netfilter/nf_conntrack_synproxy.h> 53 53 #include <net/netfilter/nf_nat.h> 54 - #include <net/netfilter/nf_nat_core.h> 55 54 #include <net/netfilter/nf_nat_helper.h> 56 55 #include <net/netns/hash.h> 57 56 #include <net/ip.h>
+1 -1
net/netfilter/nf_conntrack_netlink.c
··· 46 46 #include <net/netfilter/nf_conntrack_labels.h> 47 47 #include <net/netfilter/nf_conntrack_synproxy.h> 48 48 #ifdef CONFIG_NF_NAT_NEEDED 49 - #include <net/netfilter/nf_nat_core.h> 49 + #include <net/netfilter/nf_nat.h> 50 50 #include <net/netfilter/nf_nat_helper.h> 51 51 #endif 52 52
-2
net/netfilter/nf_nat_core.c
··· 22 22 #include <net/netfilter/nf_conntrack.h> 23 23 #include <net/netfilter/nf_conntrack_core.h> 24 24 #include <net/netfilter/nf_nat.h> 25 - #include <net/netfilter/nf_nat_l3proto.h> 26 - #include <net/netfilter/nf_nat_core.h> 27 25 #include <net/netfilter/nf_nat_helper.h> 28 26 #include <net/netfilter/nf_conntrack_helper.h> 29 27 #include <net/netfilter/nf_conntrack_seqadj.h>
-2
net/netfilter/nf_nat_helper.c
··· 22 22 #include <net/netfilter/nf_conntrack_expect.h> 23 23 #include <net/netfilter/nf_conntrack_seqadj.h> 24 24 #include <net/netfilter/nf_nat.h> 25 - #include <net/netfilter/nf_nat_l3proto.h> 26 - #include <net/netfilter/nf_nat_core.h> 27 25 #include <net/netfilter/nf_nat_helper.h> 28 26 29 27 /* Frobs data inside this packet, which is linear. */
+8 -10
net/netfilter/nf_nat_proto.c
··· 20 20 21 21 #include <linux/netfilter.h> 22 22 #include <net/netfilter/nf_nat.h> 23 - #include <net/netfilter/nf_nat_core.h> 24 - #include <net/netfilter/nf_nat_l3proto.h> 25 23 26 24 #include <linux/ipv6.h> 27 25 #include <linux/netfilter_ipv6.h> ··· 756 758 }, 757 759 }; 758 760 759 - int nf_nat_l3proto_ipv4_register_fn(struct net *net, const struct nf_hook_ops *ops) 761 + int nf_nat_ipv4_register_fn(struct net *net, const struct nf_hook_ops *ops) 760 762 { 761 763 return nf_nat_register_fn(net, ops, nf_nat_ipv4_ops, ARRAY_SIZE(nf_nat_ipv4_ops)); 762 764 } 763 - EXPORT_SYMBOL_GPL(nf_nat_l3proto_ipv4_register_fn); 765 + EXPORT_SYMBOL_GPL(nf_nat_ipv4_register_fn); 764 766 765 - void nf_nat_l3proto_ipv4_unregister_fn(struct net *net, const struct nf_hook_ops *ops) 767 + void nf_nat_ipv4_unregister_fn(struct net *net, const struct nf_hook_ops *ops) 766 768 { 767 769 nf_nat_unregister_fn(net, ops, ARRAY_SIZE(nf_nat_ipv4_ops)); 768 770 } 769 - EXPORT_SYMBOL_GPL(nf_nat_l3proto_ipv4_unregister_fn); 771 + EXPORT_SYMBOL_GPL(nf_nat_ipv4_unregister_fn); 770 772 771 773 #if IS_ENABLED(CONFIG_IPV6) 772 774 int nf_nat_icmpv6_reply_translation(struct sk_buff *skb, ··· 1008 1010 }, 1009 1011 }; 1010 1012 1011 - int nf_nat_l3proto_ipv6_register_fn(struct net *net, const struct nf_hook_ops *ops) 1013 + int nf_nat_ipv6_register_fn(struct net *net, const struct nf_hook_ops *ops) 1012 1014 { 1013 1015 return nf_nat_register_fn(net, ops, nf_nat_ipv6_ops, 1014 1016 ARRAY_SIZE(nf_nat_ipv6_ops)); 1015 1017 } 1016 - EXPORT_SYMBOL_GPL(nf_nat_l3proto_ipv6_register_fn); 1018 + EXPORT_SYMBOL_GPL(nf_nat_ipv6_register_fn); 1017 1019 1018 - void nf_nat_l3proto_ipv6_unregister_fn(struct net *net, const struct nf_hook_ops *ops) 1020 + void nf_nat_ipv6_unregister_fn(struct net *net, const struct nf_hook_ops *ops) 1019 1021 { 1020 1022 nf_nat_unregister_fn(net, ops, ARRAY_SIZE(nf_nat_ipv6_ops)); 1021 1023 } 1022 - EXPORT_SYMBOL_GPL(nf_nat_l3proto_ipv6_unregister_fn); 1024 + EXPORT_SYMBOL_GPL(nf_nat_ipv6_unregister_fn); 1023 1025 #endif /* CONFIG_IPV6 */
-2
net/netfilter/nft_nat.c
··· 21 21 #include <linux/netfilter/nf_tables.h> 22 22 #include <net/netfilter/nf_conntrack.h> 23 23 #include <net/netfilter/nf_nat.h> 24 - #include <net/netfilter/nf_nat_core.h> 25 24 #include <net/netfilter/nf_tables.h> 26 - #include <net/netfilter/nf_nat_l3proto.h> 27 25 #include <net/ip.h> 28 26 29 27 struct nft_nat {
+1 -1
net/netfilter/xt_nat.c
··· 14 14 #include <linux/skbuff.h> 15 15 #include <linux/netfilter.h> 16 16 #include <linux/netfilter/x_tables.h> 17 - #include <net/netfilter/nf_nat_core.h> 17 + #include <net/netfilter/nf_nat.h> 18 18 19 19 static int xt_nat_checkentry_v0(const struct xt_tgchk_param *par) 20 20 {
+1 -3
net/openvswitch/conntrack.c
··· 29 29 #include <net/ipv6_frag.h> 30 30 31 31 #ifdef CONFIG_NF_NAT_NEEDED 32 - #include <linux/netfilter/nf_nat.h> 33 - #include <net/netfilter/nf_nat_core.h> 34 - #include <net/netfilter/nf_nat_l3proto.h> 32 + #include <net/netfilter/nf_nat.h> 35 33 #endif 36 34 37 35 #include "datapath.h"