netfilter: ipv6: avoid indirect calls for IPV6=y case
indirect calls are only needed if ipv6 is a module. Add helpers to abstract the v6ops indirections and use them instead. fragment, reroute and route_input are kept as indirect calls. The first two are not not used in hot path and route_input is only used by bridge netfilter. Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
This commit is contained in:

committed by
Pablo Neira Ayuso

parent
960587285a
commit
ac02bcf9cc
@@ -84,8 +84,8 @@ static int nf_ip6_reroute(struct sk_buff *skb,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int nf_ip6_route(struct net *net, struct dst_entry **dst,
|
||||
struct flowi *fl, bool strict)
|
||||
int __nf_ip6_route(struct net *net, struct dst_entry **dst,
|
||||
struct flowi *fl, bool strict)
|
||||
{
|
||||
static const struct ipv6_pinfo fake_pinfo;
|
||||
static const struct inet_sock fake_sk = {
|
||||
@@ -105,17 +105,18 @@ static int nf_ip6_route(struct net *net, struct dst_entry **dst,
|
||||
*dst = result;
|
||||
return err;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(__nf_ip6_route);
|
||||
|
||||
static const struct nf_ipv6_ops ipv6ops = {
|
||||
.chk_addr = ipv6_chk_addr,
|
||||
.route_input = ip6_route_input,
|
||||
.fragment = ip6_fragment,
|
||||
.route = nf_ip6_route,
|
||||
.reroute = nf_ip6_reroute,
|
||||
#if IS_MODULE(CONFIG_IPV6)
|
||||
.chk_addr = ipv6_chk_addr,
|
||||
.route_me_harder = ip6_route_me_harder,
|
||||
.dev_get_saddr = ipv6_dev_get_saddr,
|
||||
.route = __nf_ip6_route,
|
||||
#endif
|
||||
.route_input = ip6_route_input,
|
||||
.fragment = ip6_fragment,
|
||||
.reroute = nf_ip6_reroute,
|
||||
};
|
||||
|
||||
int __init ipv6_netfilter_init(void)
|
||||
|
@@ -59,7 +59,6 @@ static u32 __nft_fib6_eval_type(const struct nft_fib *priv,
|
||||
struct ipv6hdr *iph)
|
||||
{
|
||||
const struct net_device *dev = NULL;
|
||||
const struct nf_ipv6_ops *v6ops;
|
||||
int route_err, addrtype;
|
||||
struct rt6_info *rt;
|
||||
struct flowi6 fl6 = {
|
||||
@@ -68,10 +67,6 @@ static u32 __nft_fib6_eval_type(const struct nft_fib *priv,
|
||||
};
|
||||
u32 ret = 0;
|
||||
|
||||
v6ops = nf_get_ipv6_ops();
|
||||
if (!v6ops)
|
||||
return RTN_UNREACHABLE;
|
||||
|
||||
if (priv->flags & NFTA_FIB_F_IIF)
|
||||
dev = nft_in(pkt);
|
||||
else if (priv->flags & NFTA_FIB_F_OIF)
|
||||
@@ -79,10 +74,10 @@ static u32 __nft_fib6_eval_type(const struct nft_fib *priv,
|
||||
|
||||
nft_fib6_flowi_init(&fl6, priv, pkt, dev, iph);
|
||||
|
||||
if (dev && v6ops->chk_addr(nft_net(pkt), &fl6.daddr, dev, true))
|
||||
if (dev && nf_ipv6_chk_addr(nft_net(pkt), &fl6.daddr, dev, true))
|
||||
ret = RTN_LOCAL;
|
||||
|
||||
route_err = v6ops->route(nft_net(pkt), (struct dst_entry **)&rt,
|
||||
route_err = nf_ip6_route(nft_net(pkt), (struct dst_entry **)&rt,
|
||||
flowi6_to_flowi(&fl6), false);
|
||||
if (route_err)
|
||||
goto err;
|
||||
|
Reference in New Issue
Block a user