get rid of struct nf_afinfo
Subsystems (3)
Pablo Neira Ayuso
maintainerv3 cover get rid of struct nf_afinfo
This patch gets rid of the struct nf_afinfo abstraction.
This adds an innecessary indirection for IPv4 since it can be replaced by direct calls.
And the IPv6 specific functions can be store in struct nf_ipv6_ops which is there to avoid IPv6 module autoload due to explicit symbol dependencies.
Previous patchset version was flawed with CONFIG_IPV6=m.
Pablo Neira Ayuso (7):
netfilter: move checksum indirection to struct nf_ipv6_ops
netfilter: move checksum_partial indirection to struct nf_ipv6_ops
netfilter: remove saveroute indirection in struct nf_afinfo
netfilter: move route indirection to struct nf_ipv6_ops
netfilter: move reroute indirection to struct nf_ipv6_ops
netfilter: remove route_key_size field in struct nf_afinfo
netfilter: core: remove struct nf_afinfo and its helper functions
include/linux/netfilter.h | 68 ++++--------------------- include/linux/netfilter_ipv4.h | 16 ++++++ include/linux/netfilter_ipv6.h | 17 +++++++ net/bridge/netfilter/nf_tables_bridge.c | 51 ++----------------- net/ipv4/netfilter.c | 62 ++++------------------- net/ipv6/netfilter.c | 44 +++------------- net/ipv6/netfilter/nft_fib_ipv6.c | 12 ++--- net/netfilter/Makefile | 2 +- net/netfilter/core.c | 22 -------- net/netfilter/nf_conntrack_h323_main.c | 30 +++++------ net/netfilter/nf_queue.c | 68 +++++++++++++++++++++---- net/netfilter/nft_rt.c | 15 ++---- net/netfilter/utils.c | 90 +++++++++++++++++++++++++++++++++ net/netfilter/xt_TCPMSS.c | 5 +- net/netfilter/xt_addrtype.c | 15 +++--- 15 files changed, 245 insertions(+), 272 deletions(-) create mode 100644 net/netfilter/utils.c
Signature · 1 line
2.11.0
Pablo Neira Ayuso
maintainerPATCH v3 1/7 netfilter: move checksum indirection to struct nf_ipv6_ops
We cannot make a direct call to nf_ip6_checksum() because that would result in autoloading the 'ipv6' module because of symbol dependencies. Therefore, define checksum indirection in nf_ipv6_ops where this really belongs to.
For IPv4, we can indeed make a direct function call, which is faster, given IPv4 is built-in in the networking code by default.
--- include/linux/netfilter.h | 19 +++---------------- include/linux/netfilter_ipv6.h | 2 ++ net/bridge/netfilter/nf_tables_bridge.c | 7 ------- net/ipv4/netfilter.c | 1 - net/ipv6/netfilter.c | 4 ++-- net/netfilter/Makefile | 2 +- net/netfilter/utils.c | 26 ++++++++++++++++++++++++++ 7 files changed, 34 insertions(+), 27 deletions(-) create mode 100644 net/netfilter/utils.c
include/linux/netfilter.h +3 -16
@@ -311,8 +311,6 @@ struct nf_queue_entry;struct nf_afinfo {unsigned short family; -__sum16 (*checksum)(struct sk_buff *skb,unsigned int hook, -unsigned int dataoff,u_int8_t protocol); __sum16 (*checksum_partial)(struct sk_buff *skb, unsigned int hook, unsigned int dataoff,
@@ -333,20 +331,9 @@ static inline const struct nf_afinfo *nf_get_afinfo(unsigned short family)return rcu_dereference (nf_afinfo[family]); } -static inline __sum16 -nf_checksum (struct sk_buff *skb,unsigned int hook,unsigned int dataoff, -u_int8_t protocol,unsigned short family) -{ -const struct nf_afinfo *afinfo; -__sum16 csum =0 ; - -rcu_read_lock (); - afinfo =nf_get_afinfo (family); -if (afinfo) - csum = afinfo->checksum (skb, hook, dataoff, protocol); -rcu_read_unlock (); -return csum; -} +__sum16 nf_checksum (struct sk_buff *skb,unsigned int hook, +unsigned int dataoff,u_int8_t protocol, +unsigned short family); static inline __sum16 nf_checksum_partial(struct sk_buff *skb, unsigned int hook,
include/linux/netfilter_ipv6.h +2 -0
@@ -19,6 +19,8 @@ struct nf_ipv6_ops {void (*route_input)(struct sk_buff *skb);int (*fragment)(struct net *net,struct sock *sk,struct sk_buff *skb,int (*output)(struct net *,struct sock *,struct sk_buff *)); +__sum16 (*checksum)(struct sk_buff *skb,unsigned int hook, +unsigned int dataoff,u_int8_t protocol); };#ifdef CONFIG_NETFILTER
net/bridge/netfilter/nf_tables_bridge.c +0 -7
@@ -106,12 +106,6 @@ static int nf_br_reroute(struct net *net, struct sk_buff *skb,return 0 ; } -static __sum16 nf_br_checksum (struct sk_buff *skb,unsigned int hook, -unsigned int dataoff,u_int8_t protocol) -{ -return 0 ; -} -static __sum16 nf_br_checksum_partial (struct sk_buff *skb,unsigned int hook,unsigned int dataoff,unsigned int len,u_int8_t protocol)
@@ -127,7 +121,6 @@ static int nf_br_route(struct net *net, struct dst_entry **dst,static const struct nf_afinfo nf_br_afinfo = { .family =AF_BRIDGE , - .checksum = nf_br_checksum, .checksum_partial = nf_br_checksum_partial, .route = nf_br_route, .saveroute = nf_br_saveroute,
net/ipv4/netfilter.c +0 -1
@@ -188,7 +188,6 @@ static int nf_ip_route(struct net *net, struct dst_entry **dst,static const struct nf_afinfo nf_ip_afinfo = { .family =AF_INET , - .checksum = nf_ip_checksum, .checksum_partial = nf_ip_checksum_partial, .route = nf_ip_route, .saveroute = nf_ip_saveroute,
net/ipv6/netfilter.c +2 -2
@@ -192,12 +192,12 @@ static __sum16 nf_ip6_checksum_partial(struct sk_buff *skb, unsigned int hook,static const struct nf_ipv6_ops ipv6ops = { .chk_addr = ipv6_chk_addr, .route_input = ip6_route_input, - .fragment = ip6_fragment + .fragment = ip6_fragment, + .checksum = nf_ip6_checksum, };static const struct nf_afinfo nf_ip6_afinfo = { .family =AF_INET6 , - .checksum = nf_ip6_checksum, .checksum_partial = nf_ip6_checksum_partial, .route = nf_ip6_route, .saveroute = nf_ip6_saveroute,
net/netfilter/Makefile +1 -1
@@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -netfilter-objs := core.o nf_log.o nf_queue.o nf_sockopt.o +netfilter-objs := core.o nf_log.o nf_queue.o nf_sockopt.o utils.o nf_conntrack-y := nf_conntrack_core.o nf_conntrack_standalone.o nf_conntrack_expect.o nf_conntrack_helper.o nf_conntrack_proto.o nf_conntrack_l3proto_generic.o nf_conntrack_proto_generic.o nf_conntrack_proto_tcp.o nf_conntrack_proto_udp.o nf_conntrack_extend.o nf_conntrack_acct.o nf_conntrack_seqadj.o nf_conntrack-$(CONFIG_NF_CONNTRACK_TIMEOUT) += nf_conntrack_timeout.o
net/netfilter/utils.c new file +26 -0
@@ -0,0 +1,26 @@ +#include <linux/kernel.h> +#include <linux/netfilter.h> +#include <linux/netfilter_ipv4.h> +#include <linux/netfilter_ipv6.h> + +__sum16 nf_checksum (struct sk_buff *skb,unsigned int hook, +unsigned int dataoff,u_int8_t protocol, +unsigned short family) +{ +const struct nf_ipv6_ops *v6ops; +__sum16 csum =0 ; + +switch (family) { +case AF_INET : + csum =nf_ip_checksum (skb, hook, dataoff, protocol); +break ; +case AF_INET6 : + v6ops =rcu_dereference (nf_ipv6_ops); +if (v6ops) + csum = v6ops->checksum (skb, hook, dataoff, protocol); +break ; + } + +return csum; +} +EXPORT_SYMBOL_GPL (nf_checksum);
Signature · 1 line
2.11.0
Pablo Neira Ayuso
maintainerPATCH v3 2/7 netfilter: move checksum_partial indirection to struct nf_ipv6_ops
In reply to Pablo Neira AyusoWe cannot make a direct call to nf_ip6_checksum_partial() because that would result in autoloading the 'ipv6' module because of symbol dependencies. Therefore, define checksum_partial indirection in nf_ipv6_ops where this really belongs to.
For IPv4, we can indeed make a direct function call, which is faster, given IPv4 is built-in in the networking code by default.
--- include/linux/netfilter.h | 24 +++--------------------- include/linux/netfilter_ipv4.h | 3 +++ include/linux/netfilter_ipv6.h | 3 +++ net/bridge/netfilter/nf_tables_bridge.c | 8 -------- net/ipv4/netfilter.c | 8 ++++---- net/ipv6/netfilter.c | 10 +++++----- net/netfilter/utils.c | 24 ++++++++++++++++++++++++ 7 files changed, 42 insertions(+), 38 deletions(-)
include/linux/netfilter.h +3 -21
@@ -311,11 +311,6 @@ struct nf_queue_entry;struct nf_afinfo {unsigned short family; -__sum16 (*checksum_partial)(struct sk_buff *skb, -unsigned int hook, -unsigned int dataoff, -unsigned int len, -u_int8_t protocol);int (*route)(struct net *net,struct dst_entry **dst,struct flowi *fl,bool strict); void (*saveroute)(const struct sk_buff *skb,
@@ -335,22 +330,9 @@ __sum16 nf_checksum(struct sk_buff *skb, unsigned int hook, unsigned int dataoff, u_int8_t protocol, unsigned short family); -static inline __sum16 -nf_checksum_partial (struct sk_buff *skb,unsigned int hook, -unsigned int dataoff,unsigned int len, -u_int8_t protocol,unsigned short family) -{ -const struct nf_afinfo *afinfo; -__sum16 csum =0 ; - -rcu_read_lock (); - afinfo =nf_get_afinfo (family); -if (afinfo) - csum = afinfo->checksum_partial (skb, hook, dataoff, len, - protocol); -rcu_read_unlock (); -return csum; -} +__sum16 nf_checksum_partial (struct sk_buff *skb,unsigned int hook, +unsigned int dataoff,unsigned int len, +u_int8_t protocol,unsigned short family);int nf_register_afinfo (const struct nf_afinfo *afinfo);void nf_unregister_afinfo (const struct nf_afinfo *afinfo);
include/linux/netfilter_ipv4.h +3 -0
@@ -9,4 +9,7 @@int ip_route_me_harder (struct net *net,struct sk_buff *skb,unsigned addr_type);__sum16 nf_ip_checksum (struct sk_buff *skb,unsigned int hook,unsigned int dataoff,u_int8_t protocol); +__sum16 nf_ip_checksum_partial (struct sk_buff *skb,unsigned int hook, +unsigned int dataoff,unsigned int len, +u_int8_t protocol);#endif /*__LINUX_IP_NETFILTER_H*/
include/linux/netfilter_ipv6.h +3 -0
@@ -21,6 +21,9 @@ struct nf_ipv6_ops { int (*output)(struct net *, struct sock *, struct sk_buff *));__sum16 (*checksum)(struct sk_buff *skb,unsigned int hook,unsigned int dataoff,u_int8_t protocol); +__sum16 (*checksum_partial)(struct sk_buff *skb,unsigned int hook, +unsigned int dataoff,unsigned int len, +u_int8_t protocol); };#ifdef CONFIG_NETFILTER
net/bridge/netfilter/nf_tables_bridge.c +0 -8
@@ -106,13 +106,6 @@ static int nf_br_reroute(struct net *net, struct sk_buff *skb,return 0 ; } -static __sum16 nf_br_checksum_partial (struct sk_buff *skb,unsigned int hook, -unsigned int dataoff,unsigned int len, -u_int8_t protocol) -{ -return 0 ; -} -static int nf_br_route (struct net *net,struct dst_entry **dst,struct flowi *fl,bool strict__always_unused ) {
@@ -121,7 +114,6 @@ static int nf_br_route(struct net *net, struct dst_entry **dst,static const struct nf_afinfo nf_br_afinfo = { .family =AF_BRIDGE , - .checksum_partial = nf_br_checksum_partial, .route = nf_br_route, .saveroute = nf_br_saveroute, .reroute = nf_br_reroute,
net/ipv4/netfilter.c +4 -4
@@ -155,9 +155,9 @@ __sum16 nf_ip_checksum(struct sk_buff *skb, unsigned int hook, }EXPORT_SYMBOL (nf_ip_checksum); -static __sum16 nf_ip_checksum_partial (struct sk_buff *skb,unsigned int hook, -unsigned int dataoff,unsigned int len, -u_int8_t protocol) +__sum16 nf_ip_checksum_partial (struct sk_buff *skb,unsigned int hook, +unsigned int dataoff,unsigned int len, +u_int8_t protocol) {const struct iphdr *iph =ip_hdr (skb);__sum16 csum =0 ;
@@ -175,6 +175,7 @@ static __sum16 nf_ip_checksum_partial(struct sk_buff *skb, unsigned int hook, }return csum; } +EXPORT_SYMBOL_GPL (nf_ip_checksum_partial);static int nf_ip_route (struct net *net,struct dst_entry **dst,struct flowi *fl,bool strict__always_unused )
@@ -188,7 +189,6 @@ static int nf_ip_route(struct net *net, struct dst_entry **dst,static const struct nf_afinfo nf_ip_afinfo = { .family =AF_INET , - .checksum_partial = nf_ip_checksum_partial, .route = nf_ip_route, .saveroute = nf_ip_saveroute, .reroute = nf_ip_reroute,
net/ipv6/netfilter.c +5 -5
@@ -190,15 +190,15 @@ static __sum16 nf_ip6_checksum_partial(struct sk_buff *skb, unsigned int hook, };static const struct nf_ipv6_ops ipv6ops = { - .chk_addr = ipv6_chk_addr, - .route_input = ip6_route_input, - .fragment = ip6_fragment, - .checksum = nf_ip6_checksum, + .chk_addr = ipv6_chk_addr, + .route_input = ip6_route_input, + .fragment = ip6_fragment, + .checksum = nf_ip6_checksum, + .checksum_partial = nf_ip6_checksum_partial, };static const struct nf_afinfo nf_ip6_afinfo = { .family =AF_INET6 , - .checksum_partial = nf_ip6_checksum_partial, .route = nf_ip6_route, .saveroute = nf_ip6_saveroute, .reroute = nf_ip6_reroute,
net/netfilter/utils.c +24 -0
@@ -24,3 +24,27 @@ __sum16 nf_checksum(struct sk_buff *skb, unsigned int hook,return csum; }EXPORT_SYMBOL_GPL (nf_checksum); + +__sum16 nf_checksum_partial (struct sk_buff *skb,unsigned int hook, +unsigned int dataoff,unsigned int len, +u_int8_t protocol,unsigned short family) +{ +const struct nf_ipv6_ops *v6ops; +__sum16 csum =0 ; + +switch (family) { +case AF_INET : + csum =nf_ip_checksum_partial (skb, hook, dataoff, len, + protocol); +break ; +case AF_INET6 : + v6ops =rcu_dereference (nf_ipv6_ops); +if (v6ops) + csum = v6ops->checksum_partial (skb, hook, dataoff, len, + protocol); +break ; + } + +return csum; +} +EXPORT_SYMBOL_GPL (nf_checksum_partial);
Signature · 1 line
2.11.0
Pablo Neira Ayuso
maintainerPATCH v3 3/7 netfilter: remove saveroute indirection in struct nf_afinfo
In reply to Pablo Neira AyusoThis is only used by nf_queue.c and this function comes with no symbol dependencies with IPv6, it just refers to structure layouts. Therefore, we can replace it by a direct function call from where it belongs.
--- include/linux/netfilter.h | 2 -- include/linux/netfilter_ipv4.h | 10 ++++++++ include/linux/netfilter_ipv6.h | 9 +++++++ net/bridge/netfilter/nf_tables_bridge.c | 6 ----- net/ipv4/netfilter.c | 28 ---------------------- net/ipv6/netfilter.c | 26 -------------------- net/netfilter/nf_queue.c | 42 ++++++++++++++++++++++++++++++++- 7 files changed, 60 insertions(+), 63 deletions(-)
include/linux/netfilter.h +0 -2
@@ -313,8 +313,6 @@ struct nf_afinfo {unsigned short family;int (*route)(struct net *net,struct dst_entry **dst,struct flowi *fl,bool strict); -void (*saveroute)(const struct sk_buff *skb, -struct nf_queue_entry *entry);int (*reroute)(struct net *net,struct sk_buff *skb,const struct nf_queue_entry *entry);int route_key_size;
include/linux/netfilter_ipv4.h +10 -0
@@ -6,6 +6,16 @@#include <uapi/linux/netfilter_ipv4.h> +/* Extra routing may needed on local out, as the QUEUE target never returns +* control to the table. +*/ +struct ip_rt_info { +__be32 daddr; +__be32 saddr; +u_int8_t tos; +u_int32_t mark; +}; +int ip_route_me_harder (struct net *net,struct sk_buff *skb,unsigned addr_type);__sum16 nf_ip_checksum (struct sk_buff *skb,unsigned int hook,unsigned int dataoff,u_int8_t protocol);
include/linux/netfilter_ipv6.h +9 -0
@@ -9,6 +9,15 @@#include <uapi/linux/netfilter_ipv6.h> +/* Extra routing may needed on local out, as the QUEUE target never returns +* control to the table. +*/ +struct ip6_rt_info { +struct in6_addr daddr; +struct in6_addr saddr; +u_int32_t mark; +}; +/* * Hook functions for ipv6 to allow xt_* modules to be built-in even * if IPv6 is a module.
net/bridge/netfilter/nf_tables_bridge.c +0 -6
@@ -95,11 +95,6 @@ static const struct nf_chain_type filter_bridge = { }, }; -static void nf_br_saveroute (const struct sk_buff *skb, -struct nf_queue_entry *entry) -{ -} -static int nf_br_reroute (struct net *net,struct sk_buff *skb,const struct nf_queue_entry *entry) {
@@ -115,7 +110,6 @@ static int nf_br_route(struct net *net, struct dst_entry **dst,static const struct nf_afinfo nf_br_afinfo = { .family =AF_BRIDGE , .route = nf_br_route, - .saveroute = nf_br_saveroute, .reroute = nf_br_reroute, .route_key_size =0 , };
net/ipv4/netfilter.c +0 -28
@@ -80,33 +80,6 @@ int ip_route_me_harder(struct net *net, struct sk_buff *skb, unsigned int addr_t }EXPORT_SYMBOL (ip_route_me_harder); -/* -* Extra routing may needed on local out, as the QUEUE target never -* returns control to the table. -*/ - -struct ip_rt_info { -__be32 daddr; -__be32 saddr; -u_int8_t tos; -u_int32_t mark; -}; - -static void nf_ip_saveroute (const struct sk_buff *skb, -struct nf_queue_entry *entry) -{ -struct ip_rt_info *rt_info =nf_queue_entry_reroute (entry); - -if (entry->state.hook ==NF_INET_LOCAL_OUT ) { -const struct iphdr *iph =ip_hdr (skb); - - rt_info->tos = iph->tos; - rt_info->daddr = iph->daddr; - rt_info->saddr = iph->saddr; - rt_info->mark = skb->mark; - } -} -static int nf_ip_reroute (struct net *net,struct sk_buff *skb,const struct nf_queue_entry *entry) {
@@ -190,7 +163,6 @@ static int nf_ip_route(struct net *net, struct dst_entry **dst,static const struct nf_afinfo nf_ip_afinfo = { .family =AF_INET , .route = nf_ip_route, - .saveroute = nf_ip_saveroute, .reroute = nf_ip_reroute, .route_key_size =sizeof (struct ip_rt_info ), };
net/ipv6/netfilter.c +0 -26
@@ -68,31 +68,6 @@ int ip6_route_me_harder(struct net *net, struct sk_buff *skb) }EXPORT_SYMBOL (ip6_route_me_harder); -/* -* Extra routing may needed on local out, as the QUEUE target never -* returns control to the table. -*/ - -struct ip6_rt_info { -struct in6_addr daddr; -struct in6_addr saddr; -u_int32_t mark; -}; - -static void nf_ip6_saveroute (const struct sk_buff *skb, -struct nf_queue_entry *entry) -{ -struct ip6_rt_info *rt_info =nf_queue_entry_reroute (entry); - -if (entry->state.hook ==NF_INET_LOCAL_OUT ) { -const struct ipv6hdr *iph =ipv6_hdr (skb); - - rt_info->daddr = iph->daddr; - rt_info->saddr = iph->saddr; - rt_info->mark = skb->mark; - } -} -static int nf_ip6_reroute (struct net *net,struct sk_buff *skb,const struct nf_queue_entry *entry) {
@@ -200,7 +175,6 @@ static const struct nf_ipv6_ops ipv6ops = {static const struct nf_afinfo nf_ip6_afinfo = { .family =AF_INET6 , .route = nf_ip6_route, - .saveroute = nf_ip6_saveroute, .reroute = nf_ip6_reroute, .route_key_size =sizeof (struct ip6_rt_info ), };
net/netfilter/nf_queue.c +41 -1
60 lines not on this page · raw message
Signature · 1 line
2.11.0
Pablo Neira Ayuso
maintainerPATCH v3 4/7 netfilter: move route indirection to struct nf_ipv6_ops
In reply to Pablo Neira AyusoWe cannot make a direct call to nf_ip6_route() because that would result in autoloading the 'ipv6' module because of symbol dependencies. Therefore, define route indirection in nf_ipv6_ops where this really belongs to.
For IPv4, we can indeed make a direct function call, which is faster, given IPv4 is built-in in the networking code by default.
--- include/linux/netfilter.h | 4 ++-- include/linux/netfilter_ipv4.h | 2 ++ include/linux/netfilter_ipv6.h | 2 ++ net/bridge/netfilter/nf_tables_bridge.c | 7 ------- net/ipv4/netfilter.c | 6 +++--- net/ipv6/netfilter.c | 2 +- net/ipv6/netfilter/nft_fib_ipv6.c | 12 +++++------- net/netfilter/nf_conntrack_h323_main.c | 30 +++++++++++++++--------------- net/netfilter/nft_rt.c | 15 +++++---------- net/netfilter/utils.c | 21 +++++++++++++++++++++ net/netfilter/xt_TCPMSS.c | 5 +---- net/netfilter/xt_addrtype.c | 15 ++++++--------- 12 files changed, 63 insertions(+), 58 deletions(-)
include/linux/netfilter.h +2 -2
@@ -311,8 +311,6 @@ struct nf_queue_entry;struct nf_afinfo {unsigned short family; -int (*route)(struct net *net,struct dst_entry **dst, -struct flowi *fl,bool strict);int (*reroute)(struct net *net,struct sk_buff *skb,const struct nf_queue_entry *entry);int route_key_size;
@@ -331,6 +329,8 @@ __sum16 nf_checksum(struct sk_buff *skb, unsigned int hook,__sum16 nf_checksum_partial (struct sk_buff *skb,unsigned int hook,unsigned int dataoff,unsigned int len,u_int8_t protocol,unsigned short family); +int nf_route (struct net *net,struct dst_entry **dst,struct flowi *fl, +bool strict,unsigned short family);int nf_register_afinfo (const struct nf_afinfo *afinfo);void nf_unregister_afinfo (const struct nf_afinfo *afinfo);
include/linux/netfilter_ipv4.h +2 -0
@@ -22,4 +22,6 @@ __sum16 nf_ip_checksum(struct sk_buff *skb, unsigned int hook,__sum16 nf_ip_checksum_partial (struct sk_buff *skb,unsigned int hook,unsigned int dataoff,unsigned int len,u_int8_t protocol); +int nf_ip_route (struct net *net,struct dst_entry **dst,struct flowi *fl, +bool strict);#endif /*__LINUX_IP_NETFILTER_H*/
include/linux/netfilter_ipv6.h +2 -0
@@ -33,6 +33,8 @@ struct nf_ipv6_ops {__sum16 (*checksum_partial)(struct sk_buff *skb,unsigned int hook,unsigned int dataoff,unsigned int len,u_int8_t protocol); +int (*route)(struct net *net,struct dst_entry **dst,struct flowi *fl, +bool strict); };#ifdef CONFIG_NETFILTER
net/bridge/netfilter/nf_tables_bridge.c +0 -7
@@ -101,15 +101,8 @@ static int nf_br_reroute(struct net *net, struct sk_buff *skb,return 0 ; } -static int nf_br_route (struct net *net,struct dst_entry **dst, -struct flowi *fl,bool strict__always_unused ) -{ -return 0 ; -} -static const struct nf_afinfo nf_br_afinfo = { .family =AF_BRIDGE , - .route = nf_br_route, .reroute = nf_br_reroute, .route_key_size =0 , };
net/ipv4/netfilter.c +3 -3
@@ -150,8 +150,8 @@ __sum16 nf_ip_checksum_partial(struct sk_buff *skb, unsigned int hook, }EXPORT_SYMBOL_GPL (nf_ip_checksum_partial); -static int nf_ip_route (struct net *net,struct dst_entry **dst, -struct flowi *fl,bool strict__always_unused ) +int nf_ip_route (struct net *net,struct dst_entry **dst,struct flowi *fl, +bool strict__always_unused ) {struct rtable *rt =ip_route_output_key (net, &fl->u.ip4);if (IS_ERR (rt))
@@ -159,10 +159,10 @@ static int nf_ip_route(struct net *net, struct dst_entry **dst, *dst = &rt->dst;return 0 ; } +EXPORT_SYMBOL_GPL (nf_ip_route);static const struct nf_afinfo nf_ip_afinfo = { .family =AF_INET , - .route = nf_ip_route, .reroute = nf_ip_reroute, .route_key_size =sizeof (struct ip_rt_info ), };
net/ipv6/netfilter.c +1 -1
@@ -170,11 +170,11 @@ static const struct nf_ipv6_ops ipv6ops = { .fragment = ip6_fragment, .checksum = nf_ip6_checksum, .checksum_partial = nf_ip6_checksum_partial, + .route = nf_ip6_route, };static const struct nf_afinfo nf_ip6_afinfo = { .family =AF_INET6 , - .route = nf_ip6_route, .reroute = nf_ip6_reroute, .route_key_size =sizeof (struct ip6_rt_info ), };
net/ipv6/netfilter/nft_fib_ipv6.c +5 -7
@@ -60,7 +60,6 @@ static u32 __nft_fib6_eval_type(const struct nft_fib *priv, {const struct net_device *dev =NULL ;const struct nf_ipv6_ops *v6ops; -const struct nf_afinfo *afinfo;int route_err, addrtype;struct rt6_info *rt;struct flowi6 fl6 = {
@@ -69,8 +68,8 @@ static u32 __nft_fib6_eval_type(const struct nft_fib *priv, };u32 ret =0 ; - afinfo =nf_get_afinfo (NFPROTO_IPV6 ); -if (!afinfo) + v6ops =nf_get_ipv6_ops (); +if (!v6ops)return RTN_UNREACHABLE ;if (priv->flags &NFTA_FIB_F_IIF )
@@ -80,12 +79,11 @@ static u32 __nft_fib6_eval_type(const struct nft_fib *priv,nft_fib6_flowi_init (&fl6, priv, pkt, dev, iph); - v6ops =nf_get_ipv6_ops (); -if (dev && v6ops && v6ops->chk_addr (nft_net (pkt), &fl6.daddr, dev, true)) +if (dev && v6ops->chk_addr (nft_net (pkt), &fl6.daddr, dev, true)) ret =RTN_LOCAL ; - route_err = afinfo->route (nft_net (pkt), (struct dst_entry **)&rt, -flowi6_to_flowi (&fl6), false); + route_err = v6ops->route (nft_net (pkt), (struct dst_entry **)&rt, +flowi6_to_flowi (&fl6), false);if (route_err) goto err;
net/netfilter/nf_conntrack_h323_main.c +15 -15
@@ -24,6 +24,7 @@#include <linux/skbuff.h> #include <net/route.h> #include <net/ip6_route.h> +#include <linux/netfilter_ipv6.h> #include <net/netfilter/nf_conntrack.h> #include <net/netfilter/nf_conntrack_core.h>
@@ -721,14 +722,8 @@ static int callforward_do_filter(struct net *net,const union nf_inet_addr *dst, u_int8_t family) { -const struct nf_afinfo *afinfo; int ret = 0; -/* rcu_read_lock()ed by nf_hook_thresh */ - afinfo =nf_get_afinfo (family); -if (!afinfo) -return 0 ; -switch (family) {case AF_INET : {struct flowi4 fl1, fl2;
@@ -739,10 +734,10 @@ static int callforward_do_filter(struct net *net,memset (&fl2,0 ,sizeof (fl2)); fl2.daddr = dst->ip; -if (!afinfo->route (net, (struct dst_entry **)&rt1, -flowi4_to_flowi (&fl1), false)) { -if (!afinfo->route (net, (struct dst_entry **)&rt2, -flowi4_to_flowi (&fl2), false)) { +if (!nf_ip_route (net, (struct dst_entry **)&rt1, +flowi4_to_flowi (&fl1), false)) { +if (!nf_ip_route (net, (struct dst_entry **)&rt2, +flowi4_to_flowi (&fl2), false)) {if (rt_nexthop (rt1, fl1.daddr) ==rt_nexthop (rt2, fl2.daddr) && rt1->dst.dev == rt2->dst.dev)
@@ -755,18 +750,23 @@ static int callforward_do_filter(struct net *net, }#if IS_ENABLED (CONFIG_NF_CONNTRACK_IPV6 )case AF_INET6 : { -struct flowi6 fl1, fl2; +const struct nf_ipv6_ops *v6ops;struct rt6_info *rt1, *rt2; +struct flowi6 fl1, fl2; + + v6ops =nf_get_ipv6_ops (); +if (!v6ops) +return 0 ;memset (&fl1,0 ,sizeof (fl1)); fl1.daddr = src->in6;memset (&fl2,0 ,sizeof (fl2)); fl2.daddr = dst->in6; -if (!afinfo->route (net, (struct dst_entry **)&rt1, -flowi6_to_flowi (&fl1), false)) { -if (!afinfo->route (net, (struct dst_entry **)&rt2, -flowi6_to_flowi (&fl2), false)) { +if (!v6ops->route (net, (struct dst_entry **)&rt1, +flowi6_to_flowi (&fl1), false)) { +if (!v6ops->route (net, (struct dst_entry **)&rt2, +flowi6_to_flowi (&fl2), false)) {if (ipv6_addr_equal (rt6_nexthop (rt1, &fl1.daddr),rt6_nexthop (rt2, &fl2.daddr)) && rt1->dst.dev == rt2->dst.dev)
net/netfilter/nft_rt.c +5 -10
@@ -27,7 +27,7 @@ static u16 get_tcpmss(const struct nft_pktinfo *pkt, const struct dst_entry *skb {u32 minlen =sizeof (struct ipv6hdr ), mtu =dst_mtu (skbdst);const struct sk_buff *skb = pkt->skb; -const struct nf_afinfo *ai; +struct dst_entry *dst =NULL ;struct flowi fl;memset (&fl,0 ,sizeof (fl));
@@ -43,15 +43,10 @@ static u16 get_tcpmss(const struct nft_pktinfo *pkt, const struct dst_entry *skbbreak ; } - ai =nf_get_afinfo (nft_pf (pkt)); -if (ai) { -struct dst_entry *dst =NULL ; - - ai->route (nft_net (pkt), &dst, &fl, false); -if (dst) { - mtu =min (mtu,dst_mtu (dst)); -dst_release (dst); - } +nf_route (nft_net (pkt), &dst, &fl, false,nft_pf (pkt)); +if (dst) { + mtu =min (mtu,dst_mtu (dst)); +dst_release (dst); }if (mtu <= minlen || mtu >0xffff )
net/netfilter/utils.c +21 -0
@@ -48,3 +48,24 @@ __sum16 nf_checksum_partial(struct sk_buff *skb, unsigned int hook,return csum; }EXPORT_SYMBOL_GPL (nf_checksum_partial); + +int nf_route (struct net *net,struct dst_entry **dst,struct flowi *fl, +bool strict,unsigned short family) +{ +const struct nf_ipv6_ops *v6ops; +int ret =0 ; + +switch (family) { +case AF_INET : + ret =nf_ip_route (net, dst, fl, strict); +break ; +case AF_INET6 : + v6ops =rcu_dereference (nf_ipv6_ops); +if (v6ops) + ret = v6ops->route (net, dst, fl, strict); +break ; + } + +return ret; +} +EXPORT_SYMBOL_GPL (nf_route);
net/netfilter/xt_TCPMSS.c +1 -4
@@ -48,7 +48,6 @@ static u_int32_t tcpmss_reverse_mtu(struct net *net, unsigned int family) {struct flowi fl; -const struct nf_afinfo *ai;struct rtable *rt =NULL ;u_int32_t mtu = ~0U ;
@@ -62,10 +61,8 @@ static u_int32_t tcpmss_reverse_mtu(struct net *net,memset (fl6,0 ,sizeof (*fl6)); fl6->daddr =ipv6_hdr (skb)->saddr; } - ai =nf_get_afinfo (family); -if (ai !=NULL ) - ai->route (net, (struct dst_entry **)&rt, &fl, false); +nf_route (net, (struct dst_entry **)&rt, &fl, false, family);if (rt !=NULL ) { mtu =dst_mtu (&rt->dst);dst_release (&rt->dst);
net/netfilter/xt_addrtype.c +6 -9
@@ -36,7 +36,7 @@ MODULE_ALIAS("ip6t_addrtype");static u32 match_lookup_rt6 (struct net *net,const struct net_device *dev,const struct in6_addr *addr,u16 mask) { -const struct nf_afinfo *afinfo; +const struct nf_ipv6_ops *v6ops;struct flowi6 flow;struct rt6_info *rt;u32 ret =0 ;
@@ -47,17 +47,14 @@ static u32 match_lookup_rt6(struct net *net, const struct net_device *dev,if (dev) flow.flowi6_oif = dev->ifindex; - afinfo =nf_get_afinfo (NFPROTO_IPV6 ); -if (afinfo !=NULL ) { -const struct nf_ipv6_ops *v6ops; - + v6ops =nf_get_ipv6_ops (); +if (v6ops) {if (dev && (mask &XT_ADDRTYPE_LOCAL )) { - v6ops =nf_get_ipv6_ops (); -if (v6ops && v6ops->chk_addr (net, addr, dev, true)) +if (v6ops->chk_addr (net, addr, dev, true)) ret =XT_ADDRTYPE_LOCAL ; } - route_err = afinfo->route (net, (struct dst_entry **)&rt, -flowi6_to_flowi (&flow), false); + route_err = v6ops->route (net, (struct dst_entry **)&rt, +flowi6_to_flowi (&flow), false); }else { route_err =1 ; }
Signature · 1 line
2.11.0
Pablo Neira Ayuso
maintainerPATCH v3 5/7 netfilter: move reroute indirection to struct nf_ipv6_ops
In reply to Pablo Neira AyusoWe cannot make a direct call to nf_ip6_reroute() because that would result in autoloading the 'ipv6' module because of symbol dependencies. Therefore, define reroute indirection in nf_ipv6_ops where this really belongs to.
For IPv4, we can indeed make a direct function call, which is faster, given IPv4 is built-in in the networking code by default.
--- include/linux/netfilter.h | 3 +-- include/linux/netfilter_ipv4.h | 1 + include/linux/netfilter_ipv6.h | 1 + net/bridge/netfilter/nf_tables_bridge.c | 7 ------- net/ipv4/netfilter.c | 8 ++++---- net/ipv6/netfilter.c | 6 +++--- net/netfilter/nf_queue.c | 4 +--- net/netfilter/utils.c | 19 +++++++++++++++++++ 8 files changed, 30 insertions(+), 19 deletions(-)
include/linux/netfilter.h +1 -2
@@ -311,8 +311,6 @@ struct nf_queue_entry;struct nf_afinfo {unsigned short family; -int (*reroute)(struct net *net,struct sk_buff *skb, -const struct nf_queue_entry *entry);int route_key_size; };
@@ -331,6 +329,7 @@ __sum16 nf_checksum_partial(struct sk_buff *skb, unsigned int hook, u_int8_t protocol, unsigned short family);int nf_route (struct net *net,struct dst_entry **dst,struct flowi *fl,bool strict,unsigned short family); +int nf_reroute (struct sk_buff *skb,struct nf_queue_entry *entry);int nf_register_afinfo (const struct nf_afinfo *afinfo);void nf_unregister_afinfo (const struct nf_afinfo *afinfo);
include/linux/netfilter_ipv4.h +1 -0
@@ -24,4 +24,5 @@ __sum16 nf_ip_checksum_partial(struct sk_buff *skb, unsigned int hook, u_int8_t protocol);int nf_ip_route (struct net *net,struct dst_entry **dst,struct flowi *fl,bool strict); +int nf_ip_reroute (struct sk_buff *skb,const struct nf_queue_entry *entry);#endif /*__LINUX_IP_NETFILTER_H*/
include/linux/netfilter_ipv6.h +1 -0
@@ -35,6 +35,7 @@ struct nf_ipv6_ops { u_int8_t protocol);int (*route)(struct net *net,struct dst_entry **dst,struct flowi *fl,bool strict); +int (*reroute)(struct sk_buff *skb,const struct nf_queue_entry *entry); };#ifdef CONFIG_NETFILTER
net/bridge/netfilter/nf_tables_bridge.c +0 -7
@@ -95,15 +95,8 @@ static const struct nf_chain_type filter_bridge = { }, }; -static int nf_br_reroute (struct net *net,struct sk_buff *skb, -const struct nf_queue_entry *entry) -{ -return 0 ; -} -static const struct nf_afinfo nf_br_afinfo = { .family =AF_BRIDGE , - .reroute = nf_br_reroute, .route_key_size =0 , };
net/ipv4/netfilter.c +4 -4
@@ -80,8 +80,7 @@ int ip_route_me_harder(struct net *net, struct sk_buff *skb, unsigned int addr_t }EXPORT_SYMBOL (ip_route_me_harder); -static int nf_ip_reroute (struct net *net,struct sk_buff *skb, -const struct nf_queue_entry *entry) +int nf_ip_reroute (struct sk_buff *skb,const struct nf_queue_entry *entry) {const struct ip_rt_info *rt_info =nf_queue_entry_reroute (entry);
@@ -92,10 +91,12 @@ static int nf_ip_reroute(struct net *net, struct sk_buff *skb, skb->mark == rt_info->mark && iph->daddr == rt_info->daddr && iph->saddr == rt_info->saddr)) -return ip_route_me_harder (net, skb,RTN_UNSPEC ); +return ip_route_me_harder (entry->state.net, skb, +RTN_UNSPEC ); }return 0 ; } +EXPORT_SYMBOL_GPL (nf_ip_reroute);__sum16 nf_ip_checksum (struct sk_buff *skb,unsigned int hook,unsigned int dataoff,u_int8_t protocol)
@@ -163,7 +164,6 @@ EXPORT_SYMBOL_GPL(nf_ip_route);static const struct nf_afinfo nf_ip_afinfo = { .family =AF_INET , - .reroute = nf_ip_reroute, .route_key_size =sizeof (struct ip_rt_info ), };
net/ipv6/netfilter.c +3 -3
@@ -68,7 +68,7 @@ int ip6_route_me_harder(struct net *net, struct sk_buff *skb) }EXPORT_SYMBOL (ip6_route_me_harder); -static int nf_ip6_reroute (struct net *net,struct sk_buff *skb, +static int nf_ip6_reroute (struct sk_buff *skb,const struct nf_queue_entry *entry) {struct ip6_rt_info *rt_info =nf_queue_entry_reroute (entry);
@@ -78,7 +78,7 @@ static int nf_ip6_reroute(struct net *net, struct sk_buff *skb,if (!ipv6_addr_equal (&iph->daddr, &rt_info->daddr) || !ipv6_addr_equal (&iph->saddr, &rt_info->saddr) || skb->mark != rt_info->mark) -return ip6_route_me_harder (net, skb); +return ip6_route_me_harder (entry->state.net, skb); }return 0 ; }
@@ -171,11 +171,11 @@ static const struct nf_ipv6_ops ipv6ops = { .checksum = nf_ip6_checksum, .checksum_partial = nf_ip6_checksum_partial, .route = nf_ip6_route, + .reroute = nf_ip6_reroute, };static const struct nf_afinfo nf_ip6_afinfo = { .family =AF_INET6 , - .reroute = nf_ip6_reroute, .route_key_size =sizeof (struct ip6_rt_info ), };
net/netfilter/nf_queue.c +1 -3
@@ -266,7 +266,6 @@ void nf_reinject(struct nf_queue_entry *entry, unsigned int verdict)const struct nf_hook_entry *hook_entry;const struct nf_hook_entries *hooks;struct sk_buff *skb = entry->skb; -const struct nf_afinfo *afinfo;const struct net *net;unsigned int i;int err;
@@ -293,8 +292,7 @@ void nf_reinject(struct nf_queue_entry *entry, unsigned int verdict) verdict =nf_hook_entry_hookfn (hook_entry, skb, &entry->state);if (verdict ==NF_ACCEPT ) { - afinfo =nf_get_afinfo (entry->state.pf); -if (!afinfo || afinfo->reroute (entry->state.net, skb, entry) <0 ) +if (nf_reroute (skb, entry) <0 ) verdict =NF_DROP ; }
net/netfilter/utils.c +19 -0
@@ -2,6 +2,7 @@#include <linux/netfilter.h> #include <linux/netfilter_ipv4.h> #include <linux/netfilter_ipv6.h> +#include <net/netfilter/nf_queue.h> __sum16 nf_checksum(struct sk_buff *skb, unsigned int hook, unsigned int dataoff, u_int8_t protocol,
@@ -69,3 +70,21 @@ int nf_route(struct net *net, struct dst_entry **dst, struct flowi *fl,return ret; }EXPORT_SYMBOL_GPL (nf_route); + +int nf_reroute (struct sk_buff *skb,struct nf_queue_entry *entry) +{ +const struct nf_ipv6_ops *v6ops; +int ret =0 ; + +switch (entry->state.pf) { +case AF_INET : + ret =nf_ip_reroute (skb, entry); +break ; +case AF_INET6 : + v6ops =rcu_dereference (nf_ipv6_ops); +if (v6ops) + ret = v6ops->reroute (skb, entry); +break ; + } +return ret; +}
Signature · 1 line
2.11.0
Pablo Neira Ayuso
maintainerPATCH v3 6/7 netfilter: remove route_key_size field in struct nf_afinfo
In reply to Pablo Neira AyusoThis is only needed by nf_queue, place this code where it belongs.
--- include/linux/netfilter.h | 1 - net/ipv4/netfilter.c | 1 - net/ipv6/netfilter.c | 1 - net/netfilter/nf_queue.c | 22 ++++++++++++++++------ 4 files changed, 16 insertions(+), 9 deletions(-)
include/linux/netfilter.h +0 -1
@@ -311,7 +311,6 @@ struct nf_queue_entry;struct nf_afinfo {unsigned short family; -int route_key_size; };extern const struct nf_afinfo __rcu *nf_afinfo[NFPROTO_NUMPROTO ];
net/ipv4/netfilter.c +0 -1
@@ -164,7 +164,6 @@ EXPORT_SYMBOL_GPL(nf_ip_route);static const struct nf_afinfo nf_ip_afinfo = { .family =AF_INET , - .route_key_size =sizeof (struct ip_rt_info ), };static int __init ipv4_netfilter_init (void )
net/ipv6/netfilter.c +0 -1
@@ -176,7 +176,6 @@ static const struct nf_ipv6_ops ipv6ops = {static const struct nf_afinfo nf_ip6_afinfo = { .family =AF_INET6 , - .route_key_size =sizeof (struct ip6_rt_info ), };int __init ipv6_netfilter_init (void )
net/netfilter/nf_queue.c +16 -6
@@ -15,6 +15,8 @@#include <linux/netfilter_bridge.h> #include <linux/seq_file.h> #include <linux/rcupdate.h> +#include <linux/netfilter_ipv4.h> +#include <linux/netfilter_ipv6.h> #include <net/protocol.h> #include <net/netfilter/nf_queue.h> #include <net/dst.h>
@@ -145,9 +147,9 @@ static int __nf_queue(struct sk_buff *skb, const struct nf_hook_state *state, {int status = -ENOENT ;struct nf_queue_entry *entry =NULL ; -const struct nf_afinfo *afinfo;const struct nf_queue_handler *qh;struct net *net = state->net; +unsigned int route_key_size;/* QUEUE == DROP if no one is waiting, to be safe. */ qh =rcu_dereference (net->nf.queue_handler);
@@ -156,11 +158,19 @@ static int __nf_queue(struct sk_buff *skb, const struct nf_hook_state *state, goto err; } - afinfo =nf_get_afinfo (state->pf); -if (!afinfo) - goto err; +switch (state->pf) { +case AF_INET : + route_key_size =sizeof (struct ip_rt_info ); +break ; +case AF_INET6 : + route_key_size =sizeof (struct ip6_rt_info ); +break ; +default : + route_key_size =0 ; +break ; + } - entry =kmalloc (sizeof (*entry) + afinfo->route_key_size,GFP_ATOMIC ); + entry =kmalloc (sizeof (*entry) + route_key_size,GFP_ATOMIC );if (!entry) { status = -ENOMEM ; goto err;
@@ -170,7 +180,7 @@ static int __nf_queue(struct sk_buff *skb, const struct nf_hook_state *state, .skb = skb, .state = *state, .hook_index = index, - .size = sizeof(*entry) + afinfo->route_key_size, + .size = sizeof(*entry) + route_key_size, };nf_queue_entry_get_refs (entry);
Signature · 1 line
2.11.0
Pablo Neira Ayuso
maintainerPATCH v3 7/7 netfilter: core: remove struct nf_afinfo and its helper functions
In reply to Pablo Neira AyusoThis abstraction has no clients anymore, remove it.
--- include/linux/netfilter.h | 13 ------------- net/bridge/netfilter/nf_tables_bridge.c | 16 ++++------------ net/ipv4/netfilter.c | 10 ---------- net/ipv6/netfilter.c | 7 +------ net/netfilter/core.c | 22 ---------------------- 5 files changed, 5 insertions(+), 63 deletions(-)
include/linux/netfilter.h +0 -13
@@ -309,16 +309,6 @@ int skb_make_writable(struct sk_buff *skb, unsigned int writable_len);struct flowi ;struct nf_queue_entry ; -struct nf_afinfo { -unsigned short family; -}; - -extern const struct nf_afinfo __rcu *nf_afinfo[NFPROTO_NUMPROTO ]; -static inline const struct nf_afinfo *nf_get_afinfo (unsigned short family) -{ -return rcu_dereference (nf_afinfo[family]); -} -__sum16 nf_checksum (struct sk_buff *skb,unsigned int hook,unsigned int dataoff,u_int8_t protocol,unsigned short family);
@@ -330,9 +320,6 @@ int nf_route(struct net *net, struct dst_entry **dst, struct flowi *fl, bool strict, unsigned short family);int nf_reroute (struct sk_buff *skb,struct nf_queue_entry *entry); -int nf_register_afinfo (const struct nf_afinfo *afinfo); -void nf_unregister_afinfo (const struct nf_afinfo *afinfo); -#include <net/flow.h> extern void (*nf_nat_decode_session_hook)(struct sk_buff *,struct flowi *);
net/bridge/netfilter/nf_tables_bridge.c +4 -12
@@ -95,30 +95,23 @@ static const struct nf_chain_type filter_bridge = { }, }; -static const struct nf_afinfo nf_br_afinfo = { - .family =AF_BRIDGE , - .route_key_size =0 , -}; -static int __init nf_tables_bridge_init (void ) {int ret; -nf_register_afinfo (&nf_br_afinfo); ret =nft_register_chain_type (&filter_bridge);if (ret <0 ) - goto err1; +return ret; ret =register_pernet_subsys (&nf_tables_bridge_net_ops);if (ret <0 ) - goto err2; + goto err_register_subsys;return ret; -err2: +err_register_subsys:nft_unregister_chain_type (&filter_bridge); -err1: -nf_unregister_afinfo (&nf_br_afinfo); +return ret; }
@@ -126,7 +119,6 @@ static void __exit nf_tables_bridge_exit(void) {unregister_pernet_subsys (&nf_tables_bridge_net_ops);nft_unregister_chain_type (&filter_bridge); -nf_unregister_afinfo (&nf_br_afinfo); }module_init (nf_tables_bridge_init);
net/ipv4/netfilter.c +0 -10
@@ -161,13 +161,3 @@ int nf_ip_route(struct net *net, struct dst_entry **dst, struct flowi *fl,return 0 ; }EXPORT_SYMBOL_GPL (nf_ip_route); - -static const struct nf_afinfo nf_ip_afinfo = { - .family =AF_INET , -}; - -static int __init ipv4_netfilter_init (void ) -{ -return nf_register_afinfo (&nf_ip_afinfo); -} -subsys_initcall (ipv4_netfilter_init);
net/ipv6/netfilter.c +1 -6
@@ -174,14 +174,10 @@ static const struct nf_ipv6_ops ipv6ops = { .reroute = nf_ip6_reroute, }; -static const struct nf_afinfo nf_ip6_afinfo = { - .family =AF_INET6 , -}; -int __init ipv6_netfilter_init (void ) {RCU_INIT_POINTER (nf_ipv6_ops, &ipv6ops); -return nf_register_afinfo (&nf_ip6_afinfo); +return 0 ; }/* This can be called from inet6_init() on errors, so it cannot
@@ -190,5 +186,4 @@ int __init ipv6_netfilter_init(void)void ipv6_netfilter_fini (void ) {RCU_INIT_POINTER (nf_ipv6_ops,NULL ); -nf_unregister_afinfo (&nf_ip6_afinfo); }
net/netfilter/core.c +0 -22
@@ -28,34 +28,12 @@#include "nf_internals.h" -static DEFINE_MUTEX (afinfo_mutex); - -const struct nf_afinfo __rcu *nf_afinfo[NFPROTO_NUMPROTO ]__read_mostly ; -EXPORT_SYMBOL (nf_afinfo);const struct nf_ipv6_ops __rcu *nf_ipv6_ops__read_mostly ;EXPORT_SYMBOL_GPL (nf_ipv6_ops);DEFINE_PER_CPU (bool, nf_skb_duplicated);EXPORT_SYMBOL_GPL (nf_skb_duplicated); -int nf_register_afinfo (const struct nf_afinfo *afinfo) -{ -mutex_lock (&afinfo_mutex); -RCU_INIT_POINTER (nf_afinfo[afinfo->family], afinfo); -mutex_unlock (&afinfo_mutex); -return 0 ; -} -EXPORT_SYMBOL_GPL (nf_register_afinfo); - -void nf_unregister_afinfo (const struct nf_afinfo *afinfo) -{ -mutex_lock (&afinfo_mutex); -RCU_INIT_POINTER (nf_afinfo[afinfo->family],NULL ); -mutex_unlock (&afinfo_mutex); -synchronize_rcu (); -} -EXPORT_SYMBOL_GPL (nf_unregister_afinfo); -#ifdef HAVE_JUMP_LABEL struct static_key nf_hooks_needed[NFPROTO_NUMPROTO ][NF_MAX_HOOKS ];EXPORT_SYMBOL (nf_hooks_needed);
Signature · 1 line
2.11.0