From: Tom Herbert <tom@herbertland.com>
To: <davem@davemloft.net>, <netdev@vger.kernel.org>
Cc: <kernel-team@fb.com>
Subject: [PATCH net-next 2/8] udp: Add udp6_lib_lookup_skb and udp4_lib_lookup_skb
Date: Tue, 5 Apr 2016 08:22:50 -0700 [thread overview]
Message-ID: <1459869776-2090500-3-git-send-email-tom@herbertland.com> (raw)
In-Reply-To: <1459869776-2090500-1-git-send-email-tom@herbertland.com>
Add externally visible functions to lookup a UDP socket by skb. This
will be used for GRO in UDP sockets. These functions also check
if skb->dst is set, and if it is not skb->dev is used to get dev_net.
This allows calling lookup functions before dst has been set on the
skbuff.
Signed-off-by: Tom Herbert <tom@herbertland.com>
---
include/net/udp.h | 4 ++++
net/ipv4/udp.c | 13 +++++++++++++
net/ipv6/udp.c | 13 +++++++++++++
3 files changed, 30 insertions(+)
diff --git a/include/net/udp.h b/include/net/udp.h
index d870ec1..e2e3803 100644
--- a/include/net/udp.h
+++ b/include/net/udp.h
@@ -260,6 +260,8 @@ struct sock *udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport,
struct sock *__udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport,
__be32 daddr, __be16 dport, int dif,
struct udp_table *tbl, struct sk_buff *skb);
+struct sock *udp4_lib_lookup_skb(struct sk_buff *skb,
+ __be16 sport, __be16 dport);
struct sock *udp6_lib_lookup(struct net *net,
const struct in6_addr *saddr, __be16 sport,
const struct in6_addr *daddr, __be16 dport,
@@ -269,6 +271,8 @@ struct sock *__udp6_lib_lookup(struct net *net,
const struct in6_addr *daddr, __be16 dport,
int dif, struct udp_table *tbl,
struct sk_buff *skb);
+struct sock *udp6_lib_lookup_skb(struct sk_buff *skb,
+ __be16 sport, __be16 dport);
/*
* SNMP statistics for UDP and UDP-Lite
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 355bdb2..b39c566 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -604,6 +604,19 @@ static inline struct sock *__udp4_lib_lookup_skb(struct sk_buff *skb,
udptable, skb);
}
+struct sock *udp4_lib_lookup_skb(struct sk_buff *skb,
+ __be16 sport, __be16 dport)
+{
+ const struct iphdr *iph = ip_hdr(skb);
+ const struct net_device *dev =
+ skb_dst(skb) ? skb_dst(skb)->dev : skb->dev;
+
+ return __udp4_lib_lookup(dev_net(dev), iph->saddr, sport,
+ iph->daddr, dport, inet_iif(skb),
+ &udp_table, skb);
+}
+EXPORT_SYMBOL_GPL(udp4_lib_lookup_skb);
+
/* Must be called under rcu_read_lock().
* Does increment socket refcount.
*/
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 78a7dfd..33a58eb 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -326,6 +326,19 @@ static struct sock *__udp6_lib_lookup_skb(struct sk_buff *skb,
udptable, skb);
}
+struct sock *udp6_lib_lookup_skb(struct sk_buff *skb,
+ __be16 sport, __be16 dport)
+{
+ const struct ipv6hdr *iph = ipv6_hdr(skb);
+ const struct net_device *dev =
+ skb_dst(skb) ? skb_dst(skb)->dev : skb->dev;
+
+ return __udp6_lib_lookup(dev_net(dev), &iph->saddr, sport,
+ &iph->daddr, dport, inet6_iif(skb),
+ &udp_table, skb);
+}
+EXPORT_SYMBOL_GPL(udp6_lib_lookup_skb);
+
/* Must be called under rcu_read_lock().
* Does increment socket refcount.
*/
--
2.8.0.rc2
next prev parent reply other threads:[~2016-04-05 15:23 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-05 15:22 [PATCH net-next 0/8] udp: GRO in UDP sockets Tom Herbert
2016-04-05 15:22 ` [PATCH net-next 1/8] net: Checks skb_dst to be NULL in inet_iif Tom Herbert
2016-04-05 15:22 ` Tom Herbert [this message]
2016-04-05 15:22 ` [PATCH net-next 3/8] udp: Add GRO functions to UDP socket Tom Herbert
2016-04-05 15:22 ` [PATCH net-next 4/8] udp: Add socket based GRO and config Tom Herbert
2016-04-05 15:22 ` [PATCH net-next 5/8] vxlan: change vxlan to use UDP socket GRO Tom Herbert
2016-04-05 15:22 ` [PATCH net-next 6/8] fou: change " Tom Herbert
2016-04-05 15:22 ` [PATCH net-next 7/8] geneve: " Tom Herbert
2016-04-05 15:22 ` [PATCH net-next 8/8] udp: Remove udp_offloads Tom Herbert
2016-04-07 20:54 ` [PATCH net-next 0/8] udp: GRO in UDP sockets David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1459869776-2090500-3-git-send-email-tom@herbertland.com \
--to=tom@herbertland.com \
--cc=davem@davemloft.net \
--cc=kernel-team@fb.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).