提交 9a1f27c4 编写于 作者: A Arnaldo Carvalho de Melo 提交者: David S. Miller

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: NArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: NKOVACS Krisztian <hidden@sch.bme.hu>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 c7004482
...@@ -91,6 +91,17 @@ static inline struct sock *__inet6_lookup(struct net *net, ...@@ -91,6 +91,17 @@ static inline struct sock *__inet6_lookup(struct net *net,
return inet6_lookup_listener(net, hashinfo, daddr, hnum, dif); 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, extern struct sock *inet6_lookup(struct net *net, struct inet_hashinfo *hashinfo,
const struct in6_addr *saddr, const __be16 sport, const struct in6_addr *saddr, const __be16 sport,
const struct in6_addr *daddr, const __be16 dport, const struct in6_addr *daddr, const __be16 dport,
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/ip.h>
#include <linux/ipv6.h> #include <linux/ipv6.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -28,6 +29,7 @@ ...@@ -28,6 +29,7 @@
#include <net/inet_connection_sock.h> #include <net/inet_connection_sock.h>
#include <net/inet_sock.h> #include <net/inet_sock.h>
#include <net/sock.h> #include <net/sock.h>
#include <net/route.h>
#include <net/tcp_states.h> #include <net/tcp_states.h>
#include <net/netns/hash.h> #include <net/netns/hash.h>
...@@ -371,6 +373,18 @@ static inline struct sock *inet_lookup(struct net *net, ...@@ -371,6 +373,18 @@ static inline struct sock *inet_lookup(struct net *net,
return sk; 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, extern int __inet_hash_connect(struct inet_timewait_death_row *death_row,
struct sock *sk, u32 port_offset, struct sock *sk, u32 port_offset,
int (*check_established)(struct inet_timewait_death_row *, int (*check_established)(struct inet_timewait_death_row *,
......
...@@ -811,9 +811,8 @@ static int dccp_v4_rcv(struct sk_buff *skb) ...@@ -811,9 +811,8 @@ static int dccp_v4_rcv(struct sk_buff *skb)
/* Step 2: /* Step 2:
* Look up flow ID in table and get corresponding socket */ * Look up flow ID in table and get corresponding socket */
sk = __inet_lookup(dev_net(skb->dst->dev), &dccp_hashinfo, sk = __inet_lookup_skb(&dccp_hashinfo, skb,
iph->saddr, dh->dccph_sport, dh->dccph_sport, dh->dccph_dport);
iph->daddr, dh->dccph_dport, inet_iif(skb));
/* /*
* Step 2: * Step 2:
* If no socket ... * If no socket ...
......
...@@ -805,10 +805,8 @@ static int dccp_v6_rcv(struct sk_buff *skb) ...@@ -805,10 +805,8 @@ static int dccp_v6_rcv(struct sk_buff *skb)
/* Step 2: /* Step 2:
* Look up flow ID in table and get corresponding socket */ * Look up flow ID in table and get corresponding socket */
sk = __inet6_lookup(dev_net(skb->dst->dev), &dccp_hashinfo, sk = __inet6_lookup_skb(&dccp_hashinfo, skb,
&ipv6_hdr(skb)->saddr, dh->dccph_sport, dh->dccph_sport, dh->dccph_dport);
&ipv6_hdr(skb)->daddr, ntohs(dh->dccph_dport),
inet6_iif(skb));
/* /*
* Step 2: * Step 2:
* If no socket ... * If no socket ...
......
...@@ -1577,8 +1577,7 @@ int tcp_v4_rcv(struct sk_buff *skb) ...@@ -1577,8 +1577,7 @@ int tcp_v4_rcv(struct sk_buff *skb)
TCP_SKB_CB(skb)->flags = iph->tos; TCP_SKB_CB(skb)->flags = iph->tos;
TCP_SKB_CB(skb)->sacked = 0; TCP_SKB_CB(skb)->sacked = 0;
sk = __inet_lookup(net, &tcp_hashinfo, iph->saddr, sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
th->source, iph->daddr, th->dest, inet_iif(skb));
if (!sk) if (!sk)
goto no_tcp_socket; goto no_tcp_socket;
......
...@@ -1681,11 +1681,7 @@ static int tcp_v6_rcv(struct sk_buff *skb) ...@@ -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)->flags = ipv6_get_dsfield(ipv6_hdr(skb));
TCP_SKB_CB(skb)->sacked = 0; TCP_SKB_CB(skb)->sacked = 0;
sk = __inet6_lookup(net, &tcp_hashinfo, sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
&ipv6_hdr(skb)->saddr, th->source,
&ipv6_hdr(skb)->daddr, ntohs(th->dest),
inet6_iif(skb));
if (!sk) if (!sk)
goto no_tcp_socket; goto no_tcp_socket;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册