}
 EXPORT_SYMBOL(tcp_v4_md5_hash_skb);
 
-static bool tcp_v4_inbound_md5_hash(struct sock *sk, const struct sk_buff *skb)
+static bool __tcp_v4_inbound_md5_hash(struct sock *sk,
+                                     const struct sk_buff *skb)
 {
        /*
         * This gets called for each TCP segment that arrives
        return false;
 }
 
+static bool tcp_v4_inbound_md5_hash(struct sock *sk, const struct sk_buff *skb)
+{
+       bool ret;
+
+       rcu_read_lock();
+       ret = __tcp_v4_inbound_md5_hash(sk, skb);
+       rcu_read_unlock();
+
+       return ret;
+}
+
 #endif
 
 static void tcp_v4_init_req(struct request_sock *req, struct sock *sk,
 int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
 {
        struct sock *rsk;
-#ifdef CONFIG_TCP_MD5SIG
-       /*
-        * We really want to reject the packet as early as possible
-        * if:
-        *  o We're expecting an MD5'd packet and this is no MD5 tcp option
-        *  o There is an MD5 option and we're not expecting one
-        */
-       if (tcp_v4_inbound_md5_hash(sk, skb))
-               goto discard;
-#endif
 
        if (sk->sk_state == TCP_ESTABLISHED) { /* Fast path */
                struct dst_entry *dst = sk->sk_rx_dst;
 
        if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb))
                goto discard_and_relse;
+
+#ifdef CONFIG_TCP_MD5SIG
+       /*
+        * We really want to reject the packet as early as possible
+        * if:
+        *  o We're expecting an MD5'd packet and this is no MD5 tcp option
+        *  o There is an MD5 option and we're not expecting one
+        */
+       if (tcp_v4_inbound_md5_hash(sk, skb))
+               goto discard_and_relse;
+#endif
+
        nf_reset(skb);
 
        if (sk_filter(sk, skb))
 
        return 1;
 }
 
-static int tcp_v6_inbound_md5_hash(struct sock *sk, const struct sk_buff *skb)
+static int __tcp_v6_inbound_md5_hash(struct sock *sk,
+                                    const struct sk_buff *skb)
 {
        const __u8 *hash_location = NULL;
        struct tcp_md5sig_key *hash_expected;
        }
        return 0;
 }
+
+static int tcp_v6_inbound_md5_hash(struct sock *sk, const struct sk_buff *skb)
+{
+       int ret;
+
+       rcu_read_lock();
+       ret = __tcp_v6_inbound_md5_hash(sk, skb);
+       rcu_read_unlock();
+
+       return ret;
+}
+
 #endif
 
 static void tcp_v6_init_req(struct request_sock *req, struct sock *sk,
        if (skb->protocol == htons(ETH_P_IP))
                return tcp_v4_do_rcv(sk, skb);
 
-#ifdef CONFIG_TCP_MD5SIG
-       if (tcp_v6_inbound_md5_hash(sk, skb))
-               goto discard;
-#endif
-
        if (sk_filter(sk, skb))
                goto discard;
 
        if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb))
                goto discard_and_relse;
 
+#ifdef CONFIG_TCP_MD5SIG
+       if (tcp_v6_inbound_md5_hash(sk, skb))
+               goto discard_and_relse;
+#endif
+
        if (sk_filter(sk, skb))
                goto discard_and_relse;