o sock: remove sk_prev

Move it to the protocols that we're using this pointers for other
purposes than a list pointer as the name implies, namely tcp and
sctp, where they are used as a pointer to the bind_hash. Shrink,
struct sock, shrink! :-)
parent 4053dd4b
......@@ -219,7 +219,7 @@ struct tcp_opt {
__u32 snd_sml; /* Last byte of the most recently transmitted small packet */
__u32 rcv_tstamp; /* timestamp of last received ACK (for keepalives) */
__u32 lsndtime; /* timestamp of last sent data packet (for restart window) */
struct tcp_bind_bucket *bind_hash;
/* Delayed ACK control data */
struct {
__u8 pending; /* ACK is pending */
......
......@@ -313,6 +313,7 @@ struct sctp_opt {
/* What is our base endpointer? */
struct sctp_endpoint *ep;
struct sctp_bind_bucket *bind_hash;
/* Various Socket Options. */
__u16 default_stream;
__u32 default_ppid;
......
......@@ -133,7 +133,6 @@ struct sock_common {
* @sk_forward_alloc - space allocated forward
* @sk_allocation - allocation mode
* @sk_sndbuf - size of send buffer in bytes
* @sk_prev - pointer to previous sock in the list this sock is in
* @sk_flags - %SO_LINGER (l_onoff), %SO_BROADCAST, %SO_KEEPALIVE, %SO_OOBINLINE settings
* @sk_no_check - %SO_NO_CHECK setting, wether or not checkup packets
* @sk_debug - %SO_DEBUG setting
......@@ -206,7 +205,6 @@ struct sock {
int sk_forward_alloc;
unsigned int sk_allocation;
int sk_sndbuf;
struct sock *sk_prev;
unsigned long sk_flags;
char sk_no_check;
unsigned char sk_debug;
......
......@@ -1475,7 +1475,8 @@ static __inline__ void tcp_set_state(struct sock *sk, int state)
TCP_INC_STATS(TcpEstabResets);
sk->sk_prot->unhash(sk);
if (sk->sk_prev && !(sk->sk_userlocks & SOCK_BINDPORT_LOCK))
if (tcp_sk(sk)->bind_hash &&
!(sk->sk_userlocks & SOCK_BINDPORT_LOCK))
tcp_put_port(sk);
/* fall through */
default:
......
......@@ -1909,7 +1909,7 @@ void tcp_destroy_sock(struct sock *sk)
BUG_TRAP(sk_unhashed(sk));
/* If it has not 0 inet_sk(sk)->num, it must be bound */
BUG_TRAP(!inet_sk(sk)->num || sk->sk_prev);
BUG_TRAP(!inet_sk(sk)->num || tcp_sk(sk)->bind_hash);
#ifdef TCP_DEBUG
if (sk->sk_zapped) {
......@@ -2164,7 +2164,7 @@ int tcp_disconnect(struct sock *sk, int flags)
tcp_sack_reset(tp);
__sk_dst_reset(sk);
BUG_TRAP(!inet->num || sk->sk_prev);
BUG_TRAP(!inet->num || tp->bind_hash);
sk->sk_error_report(sk);
return err;
......
......@@ -156,9 +156,9 @@ static __inline__ void __tcp_inherit_port(struct sock *sk, struct sock *child)
struct tcp_bind_bucket *tb;
spin_lock(&head->lock);
tb = (struct tcp_bind_bucket *)sk->sk_prev;
tb = tcp_sk(sk)->bind_hash;
sk_add_bind_node(child, &tb->owners);
child->sk_prev = (struct sock *)tb;
tcp_sk(child)->bind_hash = tb;
spin_unlock(&head->lock);
}
......@@ -174,7 +174,7 @@ void tcp_bind_hash(struct sock *sk, struct tcp_bind_bucket *tb,
{
inet_sk(sk)->num = snum;
sk_add_bind_node(sk, &tb->owners);
sk->sk_prev = (struct sock *)tb;
tcp_sk(sk)->bind_hash = tb;
}
static inline int tcp_bind_conflict(struct sock *sk, struct tcp_bind_bucket *tb)
......@@ -279,9 +279,9 @@ static int tcp_v4_get_port(struct sock *sk, unsigned short snum)
(!sk->sk_reuse || sk->sk_state == TCP_LISTEN))
tb->fastreuse = 0;
success:
if (!sk->sk_prev)
if (!tcp_sk(sk)->bind_hash)
tcp_bind_hash(sk, tb, snum);
BUG_TRAP(sk->sk_prev == (struct sock *)tb);
BUG_TRAP(tcp_sk(sk)->bind_hash == tb);
ret = 0;
fail_unlock:
......@@ -301,9 +301,9 @@ static void __tcp_put_port(struct sock *sk)
struct tcp_bind_bucket *tb;
spin_lock(&head->lock);
tb = (struct tcp_bind_bucket *)sk->sk_prev;
tb = tcp_sk(sk)->bind_hash;
__hlist_del(&sk->sk_bind_node);
sk->sk_prev = NULL;
tcp_sk(sk)->bind_hash = NULL;
inet->num = 0;
tcp_bucket_destroy(tb);
spin_unlock(&head->lock);
......@@ -730,7 +730,7 @@ static int tcp_v4_hash_connect(struct sock *sk)
}
head = &tcp_bhash[tcp_bhashfn(snum)];
tb = (struct tcp_bind_bucket *)sk->sk_prev;
tb = tcp_sk(sk)->bind_hash;
spin_lock_bh(&head->lock);
if (sk_head(&tb->owners) == sk && !sk->sk_bind_node.next) {
__tcp_v4_hash(sk, 0);
......@@ -2101,7 +2101,7 @@ static int tcp_v4_destroy_sock(struct sock *sk)
__skb_queue_purge(&tp->ucopy.prequeue);
/* Clean up a referenced TCP bind bucket. */
if (sk->sk_prev)
if (tp->bind_hash)
tcp_put_port(sk);
/* If sendmsg cached page exists, toss it. */
......
......@@ -301,8 +301,8 @@ static void __tcp_tw_hashdance(struct sock *sk, struct tcp_tw_bucket *tw)
*/
bhead = &tcp_bhash[tcp_bhashfn(inet_sk(sk)->num)];
spin_lock(&bhead->lock);
tw->tw_tb = (struct tcp_bind_bucket *)sk->sk_prev;
BUG_TRAP(sk->sk_prev);
tw->tw_tb = tcp_sk(sk)->bind_hash;
BUG_TRAP(tcp_sk(sk)->bind_hash);
tw_add_bind_node(tw, &tw->tw_tb->owners);
spin_unlock(&bhead->lock);
......@@ -620,7 +620,7 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct open_request *req,
/* SANITY */
sk_node_init(&newsk->sk_node);
newsk->sk_prev = NULL;
tcp_sk(newsk)->bind_hash = NULL;
/* Clone the TCP header template */
inet_sk(newsk)->dport = req->rmt_port;
......
......@@ -225,9 +225,9 @@ static int tcp_v6_get_port(struct sock *sk, unsigned short snum)
tb->fastreuse = 0;
success:
if (!sk->sk_prev)
if (!tcp_sk(sk)->bind_hash)
tcp_bind_hash(sk, tb, snum);
BUG_TRAP(sk->sk_prev == (struct sock *)tb);
BUG_TRAP(tcp_sk(sk)->bind_hash == tb);
ret = 0;
fail_unlock:
......@@ -1947,7 +1947,7 @@ static int tcp_v6_destroy_sock(struct sock *sk)
__skb_queue_purge(&tp->ucopy.prequeue);
/* Clean up a referenced TCP bind bucket. */
if (sk->sk_prev)
if (tcp_sk(sk)->bind_hash)
tcp_put_port(sk);
/* If sendmsg cached page exists, toss it. */
......
......@@ -209,7 +209,7 @@ void sctp_endpoint_destroy(struct sctp_endpoint *ep)
sctp_bind_addr_free(&ep->base.bind_addr);
/* Remove and free the port */
if (ep->base.sk->sk_prev)
if (sctp_sk(ep->base.sk)->bind_hash)
sctp_put_port(ep->base.sk);
/* Give up our hold on the sock. */
......
......@@ -3078,9 +3078,9 @@ static long sctp_get_port_local(struct sock *sk, union sctp_addr *addr)
*/
success:
inet_sk(sk)->num = snum;
if (!sk->sk_prev) {
if (!sctp_sk(sk)->bind_hash) {
sk_add_bind_node(sk, &pp->sk_list);
sk->sk_prev = (struct sock *) pp;
sctp_sk(sk)->bind_hash = pp;
}
ret = 0;
......@@ -3345,9 +3345,9 @@ static __inline__ void __sctp_put_port(struct sock *sk)
struct sctp_bind_bucket *pp;
sctp_spin_lock(&head->lock);
pp = (struct sctp_bind_bucket *)sk->sk_prev;
pp = sctp_sk(sk)->bind_hash;
hlist_del(&sk->sk_bind_node);
sk->sk_prev = NULL;
sctp_sk(sk)->bind_hash = NULL;
inet_sk(sk)->num = 0;
sctp_bucket_destroy(pp);
sctp_spin_unlock(&head->lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment