diff options
author | KOVACS Krisztian <hidden@sch.bme.hu> | 2008-10-07 15:38:32 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-10-07 15:38:32 -0400 |
commit | 607c4aaf03041c8bd81555a0218050c0f895088e (patch) | |
tree | 130cfcfca74eccb135592a883000a319e94cd7e2 | |
parent | 9a1f27c48065ce713eb47f2fd475b717e63ef239 (diff) |
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: KOVACS Krisztian <hidden@sch.bme.hu>
Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/ipv4/udp.c | 14 | ||||
-rw-r--r-- | net/ipv6/udp.c | 14 |
2 files changed, 24 insertions, 4 deletions
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index c83d0ef469c9..c7a90b546b21 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c | |||
@@ -302,6 +302,17 @@ static struct sock *__udp4_lib_lookup(struct net *net, __be32 saddr, | |||
302 | return result; | 302 | return result; |
303 | } | 303 | } |
304 | 304 | ||
305 | static inline struct sock *__udp4_lib_lookup_skb(struct sk_buff *skb, | ||
306 | __be16 sport, __be16 dport, | ||
307 | struct hlist_head udptable[]) | ||
308 | { | ||
309 | const struct iphdr *iph = ip_hdr(skb); | ||
310 | |||
311 | return __udp4_lib_lookup(dev_net(skb->dst->dev), iph->saddr, sport, | ||
312 | iph->daddr, dport, inet_iif(skb), | ||
313 | udptable); | ||
314 | } | ||
315 | |||
305 | struct sock *udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport, | 316 | struct sock *udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport, |
306 | __be32 daddr, __be16 dport, int dif) | 317 | __be32 daddr, __be16 dport, int dif) |
307 | { | 318 | { |
@@ -1208,8 +1219,7 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[], | |||
1208 | return __udp4_lib_mcast_deliver(net, skb, uh, | 1219 | return __udp4_lib_mcast_deliver(net, skb, uh, |
1209 | saddr, daddr, udptable); | 1220 | saddr, daddr, udptable); |
1210 | 1221 | ||
1211 | sk = __udp4_lib_lookup(net, saddr, uh->source, daddr, | 1222 | sk = __udp4_lib_lookup_skb(skb, uh->source, uh->dest, udptable); |
1212 | uh->dest, inet_iif(skb), udptable); | ||
1213 | 1223 | ||
1214 | if (sk != NULL) { | 1224 | if (sk != NULL) { |
1215 | int ret = udp_queue_rcv_skb(sk, skb); | 1225 | int ret = udp_queue_rcv_skb(sk, skb); |
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index a6aecf76a71b..ce26c41d157d 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c | |||
@@ -107,6 +107,17 @@ static struct sock *__udp6_lib_lookup(struct net *net, | |||
107 | return result; | 107 | return result; |
108 | } | 108 | } |
109 | 109 | ||
110 | static struct sock *__udp6_lib_lookup_skb(struct sk_buff *skb, | ||
111 | __be16 sport, __be16 dport, | ||
112 | struct hlist_head udptable[]) | ||
113 | { | ||
114 | struct ipv6hdr *iph = ipv6_hdr(skb); | ||
115 | |||
116 | return __udp6_lib_lookup(dev_net(skb->dst->dev), &iph->saddr, sport, | ||
117 | &iph->daddr, dport, inet6_iif(skb), | ||
118 | udptable); | ||
119 | } | ||
120 | |||
110 | /* | 121 | /* |
111 | * This should be easy, if there is something there we | 122 | * This should be easy, if there is something there we |
112 | * return it, otherwise we block. | 123 | * return it, otherwise we block. |
@@ -488,8 +499,7 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[], | |||
488 | * check socket cache ... must talk to Alan about his plans | 499 | * check socket cache ... must talk to Alan about his plans |
489 | * for sock caches... i'll skip this for now. | 500 | * for sock caches... i'll skip this for now. |
490 | */ | 501 | */ |
491 | sk = __udp6_lib_lookup(net, saddr, uh->source, | 502 | sk = __udp6_lib_lookup_skb(skb, uh->source, uh->dest, udptable); |
492 | daddr, uh->dest, inet6_iif(skb), udptable); | ||
493 | 503 | ||
494 | if (sk == NULL) { | 504 | if (sk == NULL) { |
495 | if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) | 505 | if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) |