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

netfilter: nat: remove l3proto struct

All l3proto function pointers have been removed.

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
d6c4c8ff dac3fe72

-100
-8
include/net/netfilter/nf_nat_l3proto.h
··· 2 2 #ifndef _NF_NAT_L3PROTO_H 3 3 #define _NF_NAT_L3PROTO_H 4 4 5 - struct nf_nat_l3proto { 6 - u8 l3proto; 7 - }; 8 - 9 5 unsigned int nf_nat_manip_pkt(struct sk_buff *skb, struct nf_conn *ct, 10 6 enum nf_nat_manip_type mtype, 11 7 enum ip_conntrack_dir dir); 12 8 void nf_nat_csum_recalc(struct sk_buff *skb, 13 9 u8 nfproto, u8 proto, void *data, __sum16 *check, 14 10 int datalen, int oldlen); 15 - 16 - int nf_nat_l3proto_register(const struct nf_nat_l3proto *); 17 - void nf_nat_l3proto_unregister(const struct nf_nat_l3proto *); 18 - const struct nf_nat_l3proto *__nf_nat_l3proto_find(u8 l3proto); 19 11 20 12 int nf_nat_icmp_reply_translation(struct sk_buff *skb, struct nf_conn *ct, 21 13 enum ip_conntrack_info ctinfo,
-54
net/netfilter/nf_nat_core.c
··· 35 35 static spinlock_t nf_nat_locks[CONNTRACK_LOCKS]; 36 36 37 37 static DEFINE_MUTEX(nf_nat_proto_mutex); 38 - static const struct nf_nat_l3proto __rcu *nf_nat_l3protos[NFPROTO_NUMPROTO] 39 - __read_mostly; 40 38 static unsigned int nat_net_id __read_mostly; 41 39 42 40 static struct hlist_head *nf_nat_bysource __read_mostly; ··· 55 57 struct nat_net { 56 58 struct nf_nat_hooks_net nat_proto_net[NFPROTO_NUMPROTO]; 57 59 }; 58 - 59 - inline const struct nf_nat_l3proto * 60 - __nf_nat_l3proto_find(u8 family) 61 - { 62 - return rcu_dereference(nf_nat_l3protos[family]); 63 - } 64 60 65 61 #ifdef CONFIG_XFRM 66 62 static void nf_nat_ipv4_decode_session(struct sk_buff *skb, ··· 841 849 return 0; 842 850 } 843 851 844 - static void nf_nat_l3proto_clean(u8 l3proto) 845 - { 846 - struct nf_nat_proto_clean clean = { 847 - .l3proto = l3proto, 848 - }; 849 - 850 - nf_ct_iterate_destroy(nf_nat_proto_remove, &clean); 851 - } 852 - 853 - int nf_nat_l3proto_register(const struct nf_nat_l3proto *l3proto) 854 - { 855 - RCU_INIT_POINTER(nf_nat_l3protos[l3proto->l3proto], l3proto); 856 - return 0; 857 - } 858 - EXPORT_SYMBOL_GPL(nf_nat_l3proto_register); 859 - 860 - void nf_nat_l3proto_unregister(const struct nf_nat_l3proto *l3proto) 861 - { 862 - mutex_lock(&nf_nat_proto_mutex); 863 - RCU_INIT_POINTER(nf_nat_l3protos[l3proto->l3proto], NULL); 864 - mutex_unlock(&nf_nat_proto_mutex); 865 - synchronize_rcu(); 866 - 867 - nf_nat_l3proto_clean(l3proto->l3proto); 868 - } 869 - EXPORT_SYMBOL_GPL(nf_nat_l3proto_unregister); 870 - 871 852 /* No one using conntrack by the time this called. */ 872 853 static void nf_nat_cleanup_conntrack(struct nf_conn *ct) 873 854 { ··· 1087 1122 mutex_unlock(&nf_nat_proto_mutex); 1088 1123 return ret; 1089 1124 } 1090 - EXPORT_SYMBOL_GPL(nf_nat_register_fn); 1091 1125 1092 1126 void nf_nat_unregister_fn(struct net *net, const struct nf_hook_ops *ops, 1093 1127 unsigned int ops_count) ··· 1135 1171 unlock: 1136 1172 mutex_unlock(&nf_nat_proto_mutex); 1137 1173 } 1138 - EXPORT_SYMBOL_GPL(nf_nat_unregister_fn); 1139 1174 1140 1175 static struct pernet_operations nat_net_ops = { 1141 1176 .id = &nat_net_id, ··· 1149 1186 .manip_pkt = nf_nat_manip_pkt, 1150 1187 }; 1151 1188 1152 - int nf_nat_l3proto_init(void); 1153 - void nf_nat_l3proto_exit(void); 1154 1189 static int __init nf_nat_init(void) 1155 1190 { 1156 1191 int ret, i; ··· 1183 1222 WARN_ON(nf_nat_hook != NULL); 1184 1223 RCU_INIT_POINTER(nf_nat_hook, &nat_hook); 1185 1224 1186 - ret = nf_nat_l3proto_init(); 1187 - if (ret) { 1188 - nf_ct_extend_unregister(&nat_extend); 1189 - nf_ct_helper_expectfn_unregister(&follow_master_nat); 1190 - RCU_INIT_POINTER(nf_nat_hook, NULL); 1191 - 1192 - synchronize_net(); 1193 - kvfree(nf_nat_bysource); 1194 - unregister_pernet_subsys(&nat_net_ops); 1195 - 1196 - return ret; 1197 - } 1198 - 1199 1225 return 0; 1200 1226 } 1201 1227 ··· 1191 1243 struct nf_nat_proto_clean clean = {}; 1192 1244 1193 1245 nf_ct_iterate_destroy(nf_nat_proto_clean, &clean); 1194 - 1195 - nf_nat_l3proto_exit(); 1196 1246 1197 1247 nf_ct_extend_unregister(&nat_extend); 1198 1248 nf_ct_helper_expectfn_unregister(&follow_master_nat);
-38
net/netfilter/nf_nat_proto.c
··· 35 35 #include <net/netfilter/nf_conntrack.h> 36 36 #include <linux/netfilter/nfnetlink_conntrack.h> 37 37 38 - static const struct nf_nat_l3proto nf_nat_l3proto_ipv4; 39 - #if IS_ENABLED(CONFIG_IPV6) 40 - static const struct nf_nat_l3proto nf_nat_l3proto_ipv6; 41 - #endif 42 - 43 38 static void nf_csum_update(struct sk_buff *skb, 44 39 unsigned int iphdroff, __sum16 *check, 45 40 const struct nf_conntrack_tuple *t, ··· 550 555 WARN_ON_ONCE(1); 551 556 } 552 557 553 - static const struct nf_nat_l3proto nf_nat_l3proto_ipv4 = { 554 - .l3proto = NFPROTO_IPV4, 555 - }; 556 - 557 558 int nf_nat_icmp_reply_translation(struct sk_buff *skb, 558 559 struct nf_conn *ct, 559 560 enum ip_conntrack_info ctinfo, ··· 770 779 } 771 780 EXPORT_SYMBOL_GPL(nf_nat_l3proto_ipv4_unregister_fn); 772 781 773 - int nf_nat_l3proto_init(void) 774 - { 775 - int ret = nf_nat_l3proto_register(&nf_nat_l3proto_ipv4); 776 - 777 782 #if IS_ENABLED(CONFIG_IPV6) 778 - if (ret) 779 - return ret; 780 - 781 - ret = nf_nat_l3proto_register(&nf_nat_l3proto_ipv6); 782 - if (ret == 0) 783 - return ret; 784 - 785 - nf_nat_l3proto_unregister(&nf_nat_l3proto_ipv4); 786 - #endif 787 - return ret; 788 - } 789 - 790 - void nf_nat_l3proto_exit(void) 791 - { 792 - #if IS_ENABLED(CONFIG_IPV6) 793 - nf_nat_l3proto_unregister(&nf_nat_l3proto_ipv6); 794 - #endif 795 - nf_nat_l3proto_unregister(&nf_nat_l3proto_ipv4); 796 - } 797 - 798 - #if IS_ENABLED(CONFIG_IPV6) 799 - static const struct nf_nat_l3proto nf_nat_l3proto_ipv6 = { 800 - .l3proto = NFPROTO_IPV6, 801 - }; 802 - 803 783 int nf_nat_icmpv6_reply_translation(struct sk_buff *skb, 804 784 struct nf_conn *ct, 805 785 enum ip_conntrack_info ctinfo,