Skip to content

Commit aaa5d90

Browse files
Paolo Abenidavem330
authored andcommitted
net: use indirect call wrappers at GRO network layer
This avoids an indirect calls for L3 GRO receive path, both for ipv4 and ipv6, if the latter is not compiled as a module. Note that when IPv6 is compiled as builtin, it will be checked first, so we have a single additional compare for the more common path. v1 -> v2: - adapted to INDIRECT_CALL_ changes Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 283c16a commit aaa5d90

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

include/net/inet_common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#ifndef _INET_COMMON_H
33
#define _INET_COMMON_H
44

5+
#include <linux/indirect_call_wrapper.h>
6+
57
extern const struct proto_ops inet_stream_ops;
68
extern const struct proto_ops inet_dgram_ops;
79

net/core/dev.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@
145145
#include <linux/sctp.h>
146146
#include <net/udp_tunnel.h>
147147
#include <linux/net_namespace.h>
148+
#include <linux/indirect_call_wrapper.h>
148149

149150
#include "net-sysfs.h"
150151

@@ -5338,6 +5339,8 @@ static void flush_all_backlogs(void)
53385339
put_online_cpus();
53395340
}
53405341

5342+
INDIRECT_CALLABLE_DECLARE(int inet_gro_complete(struct sk_buff *, int));
5343+
INDIRECT_CALLABLE_DECLARE(int ipv6_gro_complete(struct sk_buff *, int));
53415344
static int napi_gro_complete(struct sk_buff *skb)
53425345
{
53435346
struct packet_offload *ptype;
@@ -5357,7 +5360,9 @@ static int napi_gro_complete(struct sk_buff *skb)
53575360
if (ptype->type != type || !ptype->callbacks.gro_complete)
53585361
continue;
53595362

5360-
err = ptype->callbacks.gro_complete(skb, 0);
5363+
err = INDIRECT_CALL_INET(ptype->callbacks.gro_complete,
5364+
ipv6_gro_complete, inet_gro_complete,
5365+
skb, 0);
53615366
break;
53625367
}
53635368
rcu_read_unlock();
@@ -5504,6 +5509,10 @@ static void gro_flush_oldest(struct list_head *head)
55045509
napi_gro_complete(oldest);
55055510
}
55065511

5512+
INDIRECT_CALLABLE_DECLARE(struct sk_buff *inet_gro_receive(struct list_head *,
5513+
struct sk_buff *));
5514+
INDIRECT_CALLABLE_DECLARE(struct sk_buff *ipv6_gro_receive(struct list_head *,
5515+
struct sk_buff *));
55075516
static enum gro_result dev_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
55085517
{
55095518
u32 hash = skb_get_hash_raw(skb) & (GRO_HASH_BUCKETS - 1);
@@ -5553,7 +5562,9 @@ static enum gro_result dev_gro_receive(struct napi_struct *napi, struct sk_buff
55535562
NAPI_GRO_CB(skb)->csum_valid = 0;
55545563
}
55555564

5556-
pp = ptype->callbacks.gro_receive(gro_head, skb);
5565+
pp = INDIRECT_CALL_INET(ptype->callbacks.gro_receive,
5566+
ipv6_gro_receive, inet_gro_receive,
5567+
gro_head, skb);
55575568
break;
55585569
}
55595570
rcu_read_unlock();

net/ipv6/ip6_offload.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ static int ipv6_exthdrs_len(struct ipv6hdr *iph,
164164
return len;
165165
}
166166

167-
static struct sk_buff *ipv6_gro_receive(struct list_head *head,
168-
struct sk_buff *skb)
167+
INDIRECT_CALLABLE_SCOPE struct sk_buff *ipv6_gro_receive(struct list_head *head,
168+
struct sk_buff *skb)
169169
{
170170
const struct net_offload *ops;
171171
struct sk_buff *pp = NULL;
@@ -301,7 +301,7 @@ static struct sk_buff *ip4ip6_gro_receive(struct list_head *head,
301301
return inet_gro_receive(head, skb);
302302
}
303303

304-
static int ipv6_gro_complete(struct sk_buff *skb, int nhoff)
304+
INDIRECT_CALLABLE_SCOPE int ipv6_gro_complete(struct sk_buff *skb, int nhoff)
305305
{
306306
const struct net_offload *ops;
307307
struct ipv6hdr *iph = (struct ipv6hdr *)(skb->data + nhoff);

0 commit comments

Comments
 (0)