Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gerg/m68knommu
[linux-2.6-block.git] / net / l2tp / l2tp_ip6.c
index 88b397c30d86af8d6a22daeb466cedac36aac57e..8bcaa975b432e8600a60af6ec557dbe82e4cc898 100644 (file)
@@ -136,6 +136,7 @@ static int l2tp_ip6_recv(struct sk_buff *skb)
        unsigned char *ptr, *optr;
        struct l2tp_session *session;
        struct l2tp_tunnel *tunnel = NULL;
+       struct ipv6hdr *iph;
        int length;
 
        if (!pskb_may_pull(skb, 4))
@@ -192,24 +193,17 @@ pass_up:
                goto discard;
 
        tunnel_id = ntohl(*(__be32 *) &skb->data[4]);
-       tunnel = l2tp_tunnel_find(net, tunnel_id);
-       if (tunnel) {
-               sk = tunnel->sock;
-               sock_hold(sk);
-       } else {
-               struct ipv6hdr *iph = ipv6_hdr(skb);
-
-               read_lock_bh(&l2tp_ip6_lock);
-               sk = __l2tp_ip6_bind_lookup(net, &iph->daddr, &iph->saddr,
-                                           inet6_iif(skb), tunnel_id);
-               if (!sk) {
-                       read_unlock_bh(&l2tp_ip6_lock);
-                       goto discard;
-               }
+       iph = ipv6_hdr(skb);
 
-               sock_hold(sk);
+       read_lock_bh(&l2tp_ip6_lock);
+       sk = __l2tp_ip6_bind_lookup(net, &iph->daddr, &iph->saddr,
+                                   inet6_iif(skb), tunnel_id);
+       if (!sk) {
                read_unlock_bh(&l2tp_ip6_lock);
+               goto discard;
        }
+       sock_hold(sk);
+       read_unlock_bh(&l2tp_ip6_lock);
 
        if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb))
                goto discard_put;