Commit 607c4aaf authored by KOVACS Krisztian's avatar KOVACS Krisztian Committed by David S. Miller

inet: Add udplib_lookup_skb() helpers

To be able to use the cached socket reference in the skb during input
processing we add a new set of lookup functions that receive the skb on
their argument list.
Signed-off-by: default avatarKOVACS Krisztian <hidden@sch.bme.hu>
Acked-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9a1f27c4
...@@ -302,6 +302,17 @@ static struct sock *__udp4_lib_lookup(struct net *net, __be32 saddr, ...@@ -302,6 +302,17 @@ static struct sock *__udp4_lib_lookup(struct net *net, __be32 saddr,
return result; return result;
} }
static inline struct sock *__udp4_lib_lookup_skb(struct sk_buff *skb,
__be16 sport, __be16 dport,
struct hlist_head udptable[])
{
const struct iphdr *iph = ip_hdr(skb);
return __udp4_lib_lookup(dev_net(skb->dst->dev), iph->saddr, sport,
iph->daddr, dport, inet_iif(skb),
udptable);
}
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) __be32 daddr, __be16 dport, int dif)
{ {
...@@ -1208,8 +1219,7 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[], ...@@ -1208,8 +1219,7 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[],
return __udp4_lib_mcast_deliver(net, skb, uh, return __udp4_lib_mcast_deliver(net, skb, uh,
saddr, daddr, udptable); saddr, daddr, udptable);
sk = __udp4_lib_lookup(net, saddr, uh->source, daddr, sk = __udp4_lib_lookup_skb(skb, uh->source, uh->dest, udptable);
uh->dest, inet_iif(skb), udptable);
if (sk != NULL) { if (sk != NULL) {
int ret = udp_queue_rcv_skb(sk, skb); int ret = udp_queue_rcv_skb(sk, skb);
......
...@@ -107,6 +107,17 @@ static struct sock *__udp6_lib_lookup(struct net *net, ...@@ -107,6 +107,17 @@ static struct sock *__udp6_lib_lookup(struct net *net,
return result; return result;
} }
static struct sock *__udp6_lib_lookup_skb(struct sk_buff *skb,
__be16 sport, __be16 dport,
struct hlist_head udptable[])
{
struct ipv6hdr *iph = ipv6_hdr(skb);
return __udp6_lib_lookup(dev_net(skb->dst->dev), &iph->saddr, sport,
&iph->daddr, dport, inet6_iif(skb),
udptable);
}
/* /*
* This should be easy, if there is something there we * This should be easy, if there is something there we
* return it, otherwise we block. * return it, otherwise we block.
...@@ -488,8 +499,7 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[], ...@@ -488,8 +499,7 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[],
* check socket cache ... must talk to Alan about his plans * check socket cache ... must talk to Alan about his plans
* for sock caches... i'll skip this for now. * for sock caches... i'll skip this for now.
*/ */
sk = __udp6_lib_lookup(net, saddr, uh->source, sk = __udp6_lib_lookup_skb(skb, uh->source, uh->dest, udptable);
daddr, uh->dest, inet6_iif(skb), udptable);
if (sk == NULL) { if (sk == NULL) {
if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb))
......
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