aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorBalazs Scheidler <bazsi@balabit.hu>2010-10-21 06:47:34 -0400
committerPatrick McHardy <kaber@trash.net>2010-10-21 06:47:34 -0400
commit6006db84a91838813cdad8a6622a4e39efe9ea47 (patch)
tree842b0a7efaf2d826c82e04ae5552e9b94c6de858 /net
parent106e4c26b1529e559d1aae777f11b4f8f7bafc26 (diff)
tproxy: add lookup type checks for UDP in nf_tproxy_get_sock_v4()
Also, inline this function as the lookup_type is always a literal and inlining removes branches performed at runtime. Signed-off-by: Balazs Scheidler <bazsi@balabit.hu> Signed-off-by: KOVACS Krisztian <hidden@balabit.hu> Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'net')
-rw-r--r--net/netfilter/nf_tproxy_core.c48
1 files changed, 0 insertions, 48 deletions
diff --git a/net/netfilter/nf_tproxy_core.c b/net/netfilter/nf_tproxy_core.c
index 8589e5e08115..db655638d76d 100644
--- a/net/netfilter/nf_tproxy_core.c
+++ b/net/netfilter/nf_tproxy_core.c
@@ -18,54 +18,6 @@
18#include <net/udp.h> 18#include <net/udp.h>
19#include <net/netfilter/nf_tproxy_core.h> 19#include <net/netfilter/nf_tproxy_core.h>
20 20
21struct sock *
22nf_tproxy_get_sock_v4(struct net *net, const u8 protocol,
23 const __be32 saddr, const __be32 daddr,
24 const __be16 sport, const __be16 dport,
25 const struct net_device *in, int lookup_type)
26{
27 struct sock *sk;
28
29 /* look up socket */
30 switch (protocol) {
31 case IPPROTO_TCP:
32 switch (lookup_type) {
33 case NFT_LOOKUP_ANY:
34 sk = __inet_lookup(net, &tcp_hashinfo,
35 saddr, sport, daddr, dport,
36 in->ifindex);
37 break;
38 case NFT_LOOKUP_LISTENER:
39 sk = inet_lookup_listener(net, &tcp_hashinfo,
40 daddr, dport,
41 in->ifindex);
42 break;
43 case NFT_LOOKUP_ESTABLISHED:
44 sk = inet_lookup_established(net, &tcp_hashinfo,
45 saddr, sport, daddr, dport,
46 in->ifindex);
47 break;
48 default:
49 WARN_ON(1);
50 sk = NULL;
51 break;
52 }
53 break;
54 case IPPROTO_UDP:
55 sk = udp4_lib_lookup(net, saddr, sport, daddr, dport,
56 in->ifindex);
57 break;
58 default:
59 WARN_ON(1);
60 sk = NULL;
61 }
62
63 pr_debug("tproxy socket lookup: proto %u %08x:%u -> %08x:%u, lookup type: %d, sock %p\n",
64 protocol, ntohl(saddr), ntohs(sport), ntohl(daddr), ntohs(dport), lookup_type, sk);
65
66 return sk;
67}
68EXPORT_SYMBOL_GPL(nf_tproxy_get_sock_v4);
69 21
70static void 22static void
71nf_tproxy_destructor(struct sk_buff *skb) 23nf_tproxy_destructor(struct sk_buff *skb)