Commit 97ff7ffb authored by Paolo Abeni's avatar Paolo Abeni Committed by David S. Miller

net: use indirect calls helpers at early demux stage

So that we avoid another indirect call per RX packet, if
early demux is enabled.
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0e219ae4
...@@ -309,6 +309,8 @@ static inline bool ip_rcv_options(struct sk_buff *skb, struct net_device *dev) ...@@ -309,6 +309,8 @@ static inline bool ip_rcv_options(struct sk_buff *skb, struct net_device *dev)
return true; return true;
} }
INDIRECT_CALLABLE_DECLARE(int udp_v4_early_demux(struct sk_buff *));
INDIRECT_CALLABLE_DECLARE(int tcp_v4_early_demux(struct sk_buff *));
static int ip_rcv_finish_core(struct net *net, struct sock *sk, static int ip_rcv_finish_core(struct net *net, struct sock *sk,
struct sk_buff *skb, struct net_device *dev) struct sk_buff *skb, struct net_device *dev)
{ {
...@@ -326,7 +328,8 @@ static int ip_rcv_finish_core(struct net *net, struct sock *sk, ...@@ -326,7 +328,8 @@ static int ip_rcv_finish_core(struct net *net, struct sock *sk,
ipprot = rcu_dereference(inet_protos[protocol]); ipprot = rcu_dereference(inet_protos[protocol]);
if (ipprot && (edemux = READ_ONCE(ipprot->early_demux))) { if (ipprot && (edemux = READ_ONCE(ipprot->early_demux))) {
err = edemux(skb); err = INDIRECT_CALL_2(edemux, tcp_v4_early_demux,
udp_v4_early_demux, skb);
if (unlikely(err)) if (unlikely(err))
goto drop_error; goto drop_error;
/* must reload iph, skb->head might have changed */ /* must reload iph, skb->head might have changed */
......
...@@ -48,6 +48,8 @@ ...@@ -48,6 +48,8 @@
#include <net/inet_ecn.h> #include <net/inet_ecn.h>
#include <net/dst_metadata.h> #include <net/dst_metadata.h>
INDIRECT_CALLABLE_DECLARE(void udp_v6_early_demux(struct sk_buff *));
INDIRECT_CALLABLE_DECLARE(void tcp_v6_early_demux(struct sk_buff *));
static void ip6_rcv_finish_core(struct net *net, struct sock *sk, static void ip6_rcv_finish_core(struct net *net, struct sock *sk,
struct sk_buff *skb) struct sk_buff *skb)
{ {
...@@ -58,7 +60,8 @@ static void ip6_rcv_finish_core(struct net *net, struct sock *sk, ...@@ -58,7 +60,8 @@ static void ip6_rcv_finish_core(struct net *net, struct sock *sk,
ipprot = rcu_dereference(inet6_protos[ipv6_hdr(skb)->nexthdr]); ipprot = rcu_dereference(inet6_protos[ipv6_hdr(skb)->nexthdr]);
if (ipprot && (edemux = READ_ONCE(ipprot->early_demux))) if (ipprot && (edemux = READ_ONCE(ipprot->early_demux)))
edemux(skb); INDIRECT_CALL_2(edemux, tcp_v6_early_demux,
udp_v6_early_demux, skb);
} }
if (!skb_valid_dst(skb)) if (!skb_valid_dst(skb))
ip6_route_input(skb); ip6_route_input(skb);
......
...@@ -1655,7 +1655,7 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb) ...@@ -1655,7 +1655,7 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb)
goto discard_it; goto discard_it;
} }
static void tcp_v6_early_demux(struct sk_buff *skb) INDIRECT_CALLABLE_SCOPE void tcp_v6_early_demux(struct sk_buff *skb)
{ {
const struct ipv6hdr *hdr; const struct ipv6hdr *hdr;
const struct tcphdr *th; const struct tcphdr *th;
......
...@@ -981,7 +981,7 @@ static struct sock *__udp6_lib_demux_lookup(struct net *net, ...@@ -981,7 +981,7 @@ static struct sock *__udp6_lib_demux_lookup(struct net *net,
return NULL; return NULL;
} }
static void udp_v6_early_demux(struct sk_buff *skb) INDIRECT_CALLABLE_SCOPE void udp_v6_early_demux(struct sk_buff *skb)
{ {
struct net *net = dev_net(skb->dev); struct net *net = dev_net(skb->dev);
const struct udphdr *uh; const struct udphdr *uh;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment