inet_hashtables: Add inet_lookup_skb helpers
authorArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 7 Oct 2008 18:41:57 +0000 (11:41 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 7 Oct 2008 18:41:57 +0000 (11:41 -0700)
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>
include/net/inet6_hashtables.h
include/net/inet_hashtables.h
net/dccp/ipv4.c
net/dccp/ipv6.c
net/ipv4/tcp_ipv4.c
net/ipv6/tcp_ipv6.c

index e48989f04c2451e6301db0e519376ea90cbe62ab..995efbb031ab1676ade9f5e560916843737bfc26 100644 (file)
@@ -91,6 +91,17 @@ static inline struct sock *__inet6_lookup(struct net *net,
        return inet6_lookup_listener(net, hashinfo, daddr, hnum, dif);
 }
 
+static inline struct sock *__inet6_lookup_skb(struct inet_hashinfo *hashinfo,
+                                             struct sk_buff *skb,
+                                             const __be16 sport,
+                                             const __be16 dport)
+{
+       return __inet6_lookup(dev_net(skb->dst->dev), hashinfo,
+                             &ipv6_hdr(skb)->saddr, sport,
+                             &ipv6_hdr(skb)->daddr, ntohs(dport),
+                             inet6_iif(skb));
+}
+
 extern struct sock *inet6_lookup(struct net *net, struct inet_hashinfo *hashinfo,
                                 const struct in6_addr *saddr, const __be16 sport,
                                 const struct in6_addr *daddr, const __be16 dport,
index bb619d80f2e2c21d8027a54cb0d634258105a710..3522bbcd546d8aae3be44fbba48a5f315750212d 100644 (file)
@@ -16,6 +16,7 @@
 
 
 #include <linux/interrupt.h>
+#include <linux/ip.h>
 #include <linux/ipv6.h>
 #include <linux/list.h>
 #include <linux/slab.h>
@@ -28,6 +29,7 @@
 #include <net/inet_connection_sock.h>
 #include <net/inet_sock.h>
 #include <net/sock.h>
+#include <net/route.h>
 #include <net/tcp_states.h>
 #include <net/netns/hash.h>
 
@@ -371,6 +373,18 @@ static inline struct sock *inet_lookup(struct net *net,
        return sk;
 }
 
+static inline struct sock *__inet_lookup_skb(struct inet_hashinfo *hashinfo,
+                                            struct sk_buff *skb,
+                                            const __be16 sport,
+                                            const __be16 dport)
+{
+       const struct iphdr *iph = ip_hdr(skb);
+
+       return __inet_lookup(dev_net(skb->dst->dev), hashinfo,
+                            iph->saddr, sport,
+                            iph->daddr, dport, inet_iif(skb));
+}
+
 extern int __inet_hash_connect(struct inet_timewait_death_row *death_row,
                struct sock *sk, u32 port_offset,
                int (*check_established)(struct inet_timewait_death_row *,
index 882c5c4de69e69ef390f73059fba96b3cad23799..e3dfddab21cc233e929ff2a6cc81a7d3a4284ce2 100644 (file)
@@ -811,9 +811,8 @@ static int dccp_v4_rcv(struct sk_buff *skb)
 
        /* Step 2:
         *      Look up flow ID in table and get corresponding socket */
-       sk = __inet_lookup(dev_net(skb->dst->dev), &dccp_hashinfo,
-                          iph->saddr, dh->dccph_sport,
-                          iph->daddr, dh->dccph_dport, inet_iif(skb));
+       sk = __inet_lookup_skb(&dccp_hashinfo, skb,
+                              dh->dccph_sport, dh->dccph_dport);
        /*
         * Step 2:
         *      If no socket ...
index 5e1ee0da2c40cab9c7f44ffd431e4df4455e08f5..caa7f3469626a05969440ae788555afdfe459e40 100644 (file)
@@ -805,10 +805,8 @@ static int dccp_v6_rcv(struct sk_buff *skb)
 
        /* Step 2:
         *      Look up flow ID in table and get corresponding socket */
-       sk = __inet6_lookup(dev_net(skb->dst->dev), &dccp_hashinfo,
-                           &ipv6_hdr(skb)->saddr, dh->dccph_sport,
-                           &ipv6_hdr(skb)->daddr, ntohs(dh->dccph_dport),
-                           inet6_iif(skb));
+       sk = __inet6_lookup_skb(&dccp_hashinfo, skb,
+                               dh->dccph_sport, dh->dccph_dport);
        /*
         * Step 2:
         *      If no socket ...
index 8b24bd833cb446fb84b927d38a0c815ebb0f6f50..24ffc5e1d3dab2aabe8eaea47e0ca1198bf302c7 100644 (file)
@@ -1577,8 +1577,7 @@ int tcp_v4_rcv(struct sk_buff *skb)
        TCP_SKB_CB(skb)->flags   = iph->tos;
        TCP_SKB_CB(skb)->sacked  = 0;
 
-       sk = __inet_lookup(net, &tcp_hashinfo, iph->saddr,
-                       th->source, iph->daddr, th->dest, inet_iif(skb));
+       sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
        if (!sk)
                goto no_tcp_socket;
 
index df16b68644e79dc5a52801ddc5334d866860223e..6268d266c0349f8ea42a6b4c4c4f4d672f715c2b 100644 (file)
@@ -1681,11 +1681,7 @@ static int tcp_v6_rcv(struct sk_buff *skb)
        TCP_SKB_CB(skb)->flags = ipv6_get_dsfield(ipv6_hdr(skb));
        TCP_SKB_CB(skb)->sacked = 0;
 
-       sk = __inet6_lookup(net, &tcp_hashinfo,
-                       &ipv6_hdr(skb)->saddr, th->source,
-                       &ipv6_hdr(skb)->daddr, ntohs(th->dest),
-                       inet6_iif(skb));
-
+       sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
        if (!sk)
                goto no_tcp_socket;