Merge branch 'fixes-davem' of git://git.kernel.org/pub/scm/linux/kernel/git/linville...
[sfrench/cifs-2.6.git] / net / ipv4 / tcp_ipv4.c
index ad759f1c377734bf252a25422e136c275f132312..e566f3c676772d6a7141bb50213d7eb0430135d3 100644 (file)
@@ -858,16 +858,16 @@ int tcp_v4_md5_do_add(struct sock *sk, __be32 addr,
                      u8 *newkey, u8 newkeylen)
 {
        /* Add Key to the list */
-       struct tcp4_md5sig_key *key;
+       struct tcp_md5sig_key *key;
        struct tcp_sock *tp = tcp_sk(sk);
        struct tcp4_md5sig_key *keys;
 
-       key = (struct tcp4_md5sig_key *)tcp_v4_md5_do_lookup(sk, addr);
+       key = tcp_v4_md5_do_lookup(sk, addr);
        if (key) {
                /* Pre-existing entry - just update that one. */
-               kfree(key->base.key);
-               key->base.key = newkey;
-               key->base.keylen = newkeylen;
+               kfree(key->key);
+               key->key = newkey;
+               key->keylen = newkeylen;
        } else {
                struct tcp_md5sig_info *md5sig;
 
@@ -1083,7 +1083,7 @@ static int tcp_v4_do_calc_md5_hash(char *md5_hash, struct tcp_md5sig_key *key,
        sg_set_buf(&sg[block++], key->key, key->keylen);
        nbytes += key->keylen;
 
-       sg_mark_end(sg, block);
+       sg_mark_end(&sg[block - 1]);
 
        /* Now store the Hash into the packet */
        err = crypto_hash_init(desc);
@@ -2049,8 +2049,9 @@ static void *established_get_first(struct seq_file *seq)
                struct sock *sk;
                struct hlist_node *node;
                struct inet_timewait_sock *tw;
+               rwlock_t *lock = inet_ehash_lockp(&tcp_hashinfo, st->bucket);
 
-               read_lock_bh(&tcp_hashinfo.ehash[st->bucket].lock);
+               read_lock_bh(lock);
                sk_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
                        if (sk->sk_family != st->family) {
                                continue;
@@ -2067,7 +2068,7 @@ static void *established_get_first(struct seq_file *seq)
                        rc = tw;
                        goto out;
                }
-               read_unlock_bh(&tcp_hashinfo.ehash[st->bucket].lock);
+               read_unlock_bh(lock);
                st->state = TCP_SEQ_STATE_ESTABLISHED;
        }
 out:
@@ -2094,11 +2095,11 @@ get_tw:
                        cur = tw;
                        goto out;
                }
-               read_unlock_bh(&tcp_hashinfo.ehash[st->bucket].lock);
+               read_unlock_bh(inet_ehash_lockp(&tcp_hashinfo, st->bucket));
                st->state = TCP_SEQ_STATE_ESTABLISHED;
 
                if (++st->bucket < tcp_hashinfo.ehash_size) {
-                       read_lock_bh(&tcp_hashinfo.ehash[st->bucket].lock);
+                       read_lock_bh(inet_ehash_lockp(&tcp_hashinfo, st->bucket));
                        sk = sk_head(&tcp_hashinfo.ehash[st->bucket].chain);
                } else {
                        cur = NULL;
@@ -2206,7 +2207,7 @@ static void tcp_seq_stop(struct seq_file *seq, void *v)
        case TCP_SEQ_STATE_TIME_WAIT:
        case TCP_SEQ_STATE_ESTABLISHED:
                if (v)
-                       read_unlock_bh(&tcp_hashinfo.ehash[st->bucket].lock);
+                       read_unlock_bh(inet_ehash_lockp(&tcp_hashinfo, st->bucket));
                break;
        }
 }
@@ -2417,6 +2418,8 @@ void tcp4_proc_exit(void)
 }
 #endif /* CONFIG_PROC_FS */
 
+DEFINE_PROTO_INUSE(tcp)
+
 struct proto tcp_prot = {
        .name                   = "TCP",
        .owner                  = THIS_MODULE,
@@ -2451,6 +2454,7 @@ struct proto tcp_prot = {
        .compat_setsockopt      = compat_tcp_setsockopt,
        .compat_getsockopt      = compat_tcp_getsockopt,
 #endif
+       REF_PROTO_INUSE(tcp)
 };
 
 void __init tcp_v4_init(struct net_proto_family *ops)