aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2008-10-07 14:41:57 -0400
committerDavid S. Miller <davem@davemloft.net>2008-10-07 14:41:57 -0400
commit9a1f27c48065ce713eb47f2fd475b717e63ef239 (patch)
tree79ebeb8386b98aca595625b9d2db26bd52a8077d
parentc7004482e8dcb7c3c72666395cfa98a216a4fb70 (diff)
inet_hashtables: Add inet_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: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: KOVACS Krisztian <hidden@sch.bme.hu> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/inet6_hashtables.h11
-rw-r--r--include/net/inet_hashtables.h14
-rw-r--r--net/dccp/ipv4.c5
-rw-r--r--net/dccp/ipv6.c6
-rw-r--r--net/ipv4/tcp_ipv4.c3
-rw-r--r--net/ipv6/tcp_ipv6.c6
6 files changed, 31 insertions, 14 deletions
diff --git a/include/net/inet6_hashtables.h b/include/net/inet6_hashtables.h
index e48989f04c24..995efbb031ab 100644
--- a/include/net/inet6_hashtables.h
+++ b/include/net/inet6_hashtables.h
@@ -91,6 +91,17 @@ static inline struct sock *__inet6_lookup(struct net *net,
91 return inet6_lookup_listener(net, hashinfo, daddr, hnum, dif); 91 return inet6_lookup_listener(net, hashinfo, daddr, hnum, dif);
92} 92}
93 93
94static inline struct sock *__inet6_lookup_skb(struct inet_hashinfo *hashinfo,
95 struct sk_buff *skb,
96 const __be16 sport,
97 const __be16 dport)
98{
99 return __inet6_lookup(dev_net(skb->dst->dev), hashinfo,
100 &ipv6_hdr(skb)->saddr, sport,
101 &ipv6_hdr(skb)->daddr, ntohs(dport),
102 inet6_iif(skb));
103}
104
94extern struct sock *inet6_lookup(struct net *net, struct inet_hashinfo *hashinfo, 105extern struct sock *inet6_lookup(struct net *net, struct inet_hashinfo *hashinfo,
95 const struct in6_addr *saddr, const __be16 sport, 106 const struct in6_addr *saddr, const __be16 sport,
96 const struct in6_addr *daddr, const __be16 dport, 107 const struct in6_addr *daddr, const __be16 dport,
diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h
index bb619d80f2e2..3522bbcd546d 100644
--- a/include/net/inet_hashtables.h
+++ b/include/net/inet_hashtables.h
@@ -16,6 +16,7 @@
16 16
17 17
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/ip.h>
19#include <linux/ipv6.h> 20#include <linux/ipv6.h>
20#include <linux/list.h> 21#include <linux/list.h>
21#include <linux/slab.h> 22#include <linux/slab.h>
@@ -28,6 +29,7 @@
28#include <net/inet_connection_sock.h> 29#include <net/inet_connection_sock.h>
29#include <net/inet_sock.h> 30#include <net/inet_sock.h>
30#include <net/sock.h> 31#include <net/sock.h>
32#include <net/route.h>
31#include <net/tcp_states.h> 33#include <net/tcp_states.h>
32#include <net/netns/hash.h> 34#include <net/netns/hash.h>
33 35
@@ -371,6 +373,18 @@ static inline struct sock *inet_lookup(struct net *net,
371 return sk; 373 return sk;
372} 374}
373 375
376static inline struct sock *__inet_lookup_skb(struct inet_hashinfo *hashinfo,
377 struct sk_buff *skb,
378 const __be16 sport,
379 const __be16 dport)
380{
381 const struct iphdr *iph = ip_hdr(skb);
382
383 return __inet_lookup(dev_net(skb->dst->dev), hashinfo,
384 iph->saddr, sport,
385 iph->daddr, dport, inet_iif(skb));
386}
387
374extern int __inet_hash_connect(struct inet_timewait_death_row *death_row, 388extern int __inet_hash_connect(struct inet_timewait_death_row *death_row,
375 struct sock *sk, u32 port_offset, 389 struct sock *sk, u32 port_offset,
376 int (*check_established)(struct inet_timewait_death_row *, 390 int (*check_established)(struct inet_timewait_death_row *,
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index 882c5c4de69e..e3dfddab21cc 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -811,9 +811,8 @@ static int dccp_v4_rcv(struct sk_buff *skb)
811 811
812 /* Step 2: 812 /* Step 2:
813 * Look up flow ID in table and get corresponding socket */ 813 * Look up flow ID in table and get corresponding socket */
814 sk = __inet_lookup(dev_net(skb->dst->dev), &dccp_hashinfo, 814 sk = __inet_lookup_skb(&dccp_hashinfo, skb,
815 iph->saddr, dh->dccph_sport, 815 dh->dccph_sport, dh->dccph_dport);
816 iph->daddr, dh->dccph_dport, inet_iif(skb));
817 /* 816 /*
818 * Step 2: 817 * Step 2:
819 * If no socket ... 818 * If no socket ...
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
index 5e1ee0da2c40..caa7f3469626 100644
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -805,10 +805,8 @@ static int dccp_v6_rcv(struct sk_buff *skb)
805 805
806 /* Step 2: 806 /* Step 2:
807 * Look up flow ID in table and get corresponding socket */ 807 * Look up flow ID in table and get corresponding socket */
808 sk = __inet6_lookup(dev_net(skb->dst->dev), &dccp_hashinfo, 808 sk = __inet6_lookup_skb(&dccp_hashinfo, skb,
809 &ipv6_hdr(skb)->saddr, dh->dccph_sport, 809 dh->dccph_sport, dh->dccph_dport);
810 &ipv6_hdr(skb)->daddr, ntohs(dh->dccph_dport),
811 inet6_iif(skb));
812 /* 810 /*
813 * Step 2: 811 * Step 2:
814 * If no socket ... 812 * If no socket ...
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 8b24bd833cb4..24ffc5e1d3da 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1577,8 +1577,7 @@ int tcp_v4_rcv(struct sk_buff *skb)
1577 TCP_SKB_CB(skb)->flags = iph->tos; 1577 TCP_SKB_CB(skb)->flags = iph->tos;
1578 TCP_SKB_CB(skb)->sacked = 0; 1578 TCP_SKB_CB(skb)->sacked = 0;
1579 1579
1580 sk = __inet_lookup(net, &tcp_hashinfo, iph->saddr, 1580 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
1581 th->source, iph->daddr, th->dest, inet_iif(skb));
1582 if (!sk) 1581 if (!sk)
1583 goto no_tcp_socket; 1582 goto no_tcp_socket;
1584 1583
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index df16b68644e7..6268d266c034 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1681,11 +1681,7 @@ static int tcp_v6_rcv(struct sk_buff *skb)
1681 TCP_SKB_CB(skb)->flags = ipv6_get_dsfield(ipv6_hdr(skb)); 1681 TCP_SKB_CB(skb)->flags = ipv6_get_dsfield(ipv6_hdr(skb));
1682 TCP_SKB_CB(skb)->sacked = 0; 1682 TCP_SKB_CB(skb)->sacked = 0;
1683 1683
1684 sk = __inet6_lookup(net, &tcp_hashinfo, 1684 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
1685 &ipv6_hdr(skb)->saddr, th->source,
1686 &ipv6_hdr(skb)->daddr, ntohs(th->dest),
1687 inet6_iif(skb));
1688
1689 if (!sk) 1685 if (!sk)
1690 goto no_tcp_socket; 1686 goto no_tcp_socket;
1691 1687