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 { ...@@ -219,7 +219,7 @@ struct tcp_opt {
__u32 snd_sml; /* Last byte of the most recently transmitted small packet */ __u32 snd_sml; /* Last byte of the most recently transmitted small packet */
__u32 rcv_tstamp; /* timestamp of last received ACK (for keepalives) */ __u32 rcv_tstamp; /* timestamp of last received ACK (for keepalives) */
__u32 lsndtime; /* timestamp of last sent data packet (for restart window) */ __u32 lsndtime; /* timestamp of last sent data packet (for restart window) */
struct tcp_bind_bucket *bind_hash;
/* Delayed ACK control data */ /* Delayed ACK control data */
struct { struct {
__u8 pending; /* ACK is pending */ __u8 pending; /* ACK is pending */
......
...@@ -313,6 +313,7 @@ struct sctp_opt { ...@@ -313,6 +313,7 @@ struct sctp_opt {
/* What is our base endpointer? */ /* What is our base endpointer? */
struct sctp_endpoint *ep; struct sctp_endpoint *ep;
struct sctp_bind_bucket *bind_hash;
/* Various Socket Options. */ /* Various Socket Options. */
__u16 default_stream; __u16 default_stream;
__u32 default_ppid; __u32 default_ppid;
......
...@@ -133,7 +133,6 @@ struct sock_common { ...@@ -133,7 +133,6 @@ struct sock_common {
* @sk_forward_alloc - space allocated forward * @sk_forward_alloc - space allocated forward
* @sk_allocation - allocation mode * @sk_allocation - allocation mode
* @sk_sndbuf - size of send buffer in bytes * @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_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_no_check - %SO_NO_CHECK setting, wether or not checkup packets
* @sk_debug - %SO_DEBUG setting * @sk_debug - %SO_DEBUG setting
...@@ -206,7 +205,6 @@ struct sock { ...@@ -206,7 +205,6 @@ struct sock {
int sk_forward_alloc; int sk_forward_alloc;
unsigned int sk_allocation; unsigned int sk_allocation;
int sk_sndbuf; int sk_sndbuf;
struct sock *sk_prev;
unsigned long sk_flags; unsigned long sk_flags;
char sk_no_check; char sk_no_check;
unsigned char sk_debug; unsigned char sk_debug;
......
...@@ -1475,7 +1475,8 @@ static __inline__ void tcp_set_state(struct sock *sk, int state) ...@@ -1475,7 +1475,8 @@ static __inline__ void tcp_set_state(struct sock *sk, int state)
TCP_INC_STATS(TcpEstabResets); TCP_INC_STATS(TcpEstabResets);
sk->sk_prot->unhash(sk); 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); tcp_put_port(sk);
/* fall through */ /* fall through */
default: default:
......
...@@ -1909,7 +1909,7 @@ void tcp_destroy_sock(struct sock *sk) ...@@ -1909,7 +1909,7 @@ void tcp_destroy_sock(struct sock *sk)
BUG_TRAP(sk_unhashed(sk)); BUG_TRAP(sk_unhashed(sk));
/* If it has not 0 inet_sk(sk)->num, it must be bound */ /* 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 #ifdef TCP_DEBUG
if (sk->sk_zapped) { if (sk->sk_zapped) {
...@@ -2164,7 +2164,7 @@ int tcp_disconnect(struct sock *sk, int flags) ...@@ -2164,7 +2164,7 @@ int tcp_disconnect(struct sock *sk, int flags)
tcp_sack_reset(tp); tcp_sack_reset(tp);
__sk_dst_reset(sk); __sk_dst_reset(sk);
BUG_TRAP(!inet->num || sk->sk_prev); BUG_TRAP(!inet->num || tp->bind_hash);
sk->sk_error_report(sk); sk->sk_error_report(sk);
return err; return err;
......
...@@ -156,9 +156,9 @@ static __inline__ void __tcp_inherit_port(struct sock *sk, struct sock *child) ...@@ -156,9 +156,9 @@ static __inline__ void __tcp_inherit_port(struct sock *sk, struct sock *child)
struct tcp_bind_bucket *tb; struct tcp_bind_bucket *tb;
spin_lock(&head->lock); 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); sk_add_bind_node(child, &tb->owners);
child->sk_prev = (struct sock *)tb; tcp_sk(child)->bind_hash = tb;
spin_unlock(&head->lock); spin_unlock(&head->lock);
} }
...@@ -174,7 +174,7 @@ void tcp_bind_hash(struct sock *sk, struct tcp_bind_bucket *tb, ...@@ -174,7 +174,7 @@ void tcp_bind_hash(struct sock *sk, struct tcp_bind_bucket *tb,
{ {
inet_sk(sk)->num = snum; inet_sk(sk)->num = snum;
sk_add_bind_node(sk, &tb->owners); 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) 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) ...@@ -279,9 +279,9 @@ static int tcp_v4_get_port(struct sock *sk, unsigned short snum)
(!sk->sk_reuse || sk->sk_state == TCP_LISTEN)) (!sk->sk_reuse || sk->sk_state == TCP_LISTEN))
tb->fastreuse = 0; tb->fastreuse = 0;
success: success:
if (!sk->sk_prev) if (!tcp_sk(sk)->bind_hash)
tcp_bind_hash(sk, tb, snum); tcp_bind_hash(sk, tb, snum);
BUG_TRAP(sk->sk_prev == (struct sock *)tb); BUG_TRAP(tcp_sk(sk)->bind_hash == tb);
ret = 0; ret = 0;
fail_unlock: fail_unlock:
...@@ -301,9 +301,9 @@ static void __tcp_put_port(struct sock *sk) ...@@ -301,9 +301,9 @@ static void __tcp_put_port(struct sock *sk)
struct tcp_bind_bucket *tb; struct tcp_bind_bucket *tb;
spin_lock(&head->lock); spin_lock(&head->lock);
tb = (struct tcp_bind_bucket *)sk->sk_prev; tb = tcp_sk(sk)->bind_hash;
__hlist_del(&sk->sk_bind_node); __hlist_del(&sk->sk_bind_node);
sk->sk_prev = NULL; tcp_sk(sk)->bind_hash = NULL;
inet->num = 0; inet->num = 0;
tcp_bucket_destroy(tb); tcp_bucket_destroy(tb);
spin_unlock(&head->lock); spin_unlock(&head->lock);
...@@ -730,7 +730,7 @@ static int tcp_v4_hash_connect(struct sock *sk) ...@@ -730,7 +730,7 @@ static int tcp_v4_hash_connect(struct sock *sk)
} }
head = &tcp_bhash[tcp_bhashfn(snum)]; 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); spin_lock_bh(&head->lock);
if (sk_head(&tb->owners) == sk && !sk->sk_bind_node.next) { if (sk_head(&tb->owners) == sk && !sk->sk_bind_node.next) {
__tcp_v4_hash(sk, 0); __tcp_v4_hash(sk, 0);
...@@ -2101,7 +2101,7 @@ static int tcp_v4_destroy_sock(struct sock *sk) ...@@ -2101,7 +2101,7 @@ static int tcp_v4_destroy_sock(struct sock *sk)
__skb_queue_purge(&tp->ucopy.prequeue); __skb_queue_purge(&tp->ucopy.prequeue);
/* Clean up a referenced TCP bind bucket. */ /* Clean up a referenced TCP bind bucket. */
if (sk->sk_prev) if (tp->bind_hash)
tcp_put_port(sk); tcp_put_port(sk);
/* If sendmsg cached page exists, toss it. */ /* If sendmsg cached page exists, toss it. */
......
...@@ -301,8 +301,8 @@ static void __tcp_tw_hashdance(struct sock *sk, struct tcp_tw_bucket *tw) ...@@ -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)]; bhead = &tcp_bhash[tcp_bhashfn(inet_sk(sk)->num)];
spin_lock(&bhead->lock); spin_lock(&bhead->lock);
tw->tw_tb = (struct tcp_bind_bucket *)sk->sk_prev; tw->tw_tb = tcp_sk(sk)->bind_hash;
BUG_TRAP(sk->sk_prev); BUG_TRAP(tcp_sk(sk)->bind_hash);
tw_add_bind_node(tw, &tw->tw_tb->owners); tw_add_bind_node(tw, &tw->tw_tb->owners);
spin_unlock(&bhead->lock); spin_unlock(&bhead->lock);
...@@ -620,7 +620,7 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct open_request *req, ...@@ -620,7 +620,7 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct open_request *req,
/* SANITY */ /* SANITY */
sk_node_init(&newsk->sk_node); sk_node_init(&newsk->sk_node);
newsk->sk_prev = NULL; tcp_sk(newsk)->bind_hash = NULL;
/* Clone the TCP header template */ /* Clone the TCP header template */
inet_sk(newsk)->dport = req->rmt_port; inet_sk(newsk)->dport = req->rmt_port;
......
...@@ -225,9 +225,9 @@ static int tcp_v6_get_port(struct sock *sk, unsigned short snum) ...@@ -225,9 +225,9 @@ static int tcp_v6_get_port(struct sock *sk, unsigned short snum)
tb->fastreuse = 0; tb->fastreuse = 0;
success: success:
if (!sk->sk_prev) if (!tcp_sk(sk)->bind_hash)
tcp_bind_hash(sk, tb, snum); tcp_bind_hash(sk, tb, snum);
BUG_TRAP(sk->sk_prev == (struct sock *)tb); BUG_TRAP(tcp_sk(sk)->bind_hash == tb);
ret = 0; ret = 0;
fail_unlock: fail_unlock:
...@@ -1947,7 +1947,7 @@ static int tcp_v6_destroy_sock(struct sock *sk) ...@@ -1947,7 +1947,7 @@ static int tcp_v6_destroy_sock(struct sock *sk)
__skb_queue_purge(&tp->ucopy.prequeue); __skb_queue_purge(&tp->ucopy.prequeue);
/* Clean up a referenced TCP bind bucket. */ /* Clean up a referenced TCP bind bucket. */
if (sk->sk_prev) if (tcp_sk(sk)->bind_hash)
tcp_put_port(sk); tcp_put_port(sk);
/* If sendmsg cached page exists, toss it. */ /* If sendmsg cached page exists, toss it. */
......
...@@ -209,7 +209,7 @@ void sctp_endpoint_destroy(struct sctp_endpoint *ep) ...@@ -209,7 +209,7 @@ void sctp_endpoint_destroy(struct sctp_endpoint *ep)
sctp_bind_addr_free(&ep->base.bind_addr); sctp_bind_addr_free(&ep->base.bind_addr);
/* Remove and free the port */ /* 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); sctp_put_port(ep->base.sk);
/* Give up our hold on the sock. */ /* Give up our hold on the sock. */
......
...@@ -3078,9 +3078,9 @@ static long sctp_get_port_local(struct sock *sk, union sctp_addr *addr) ...@@ -3078,9 +3078,9 @@ static long sctp_get_port_local(struct sock *sk, union sctp_addr *addr)
*/ */
success: success:
inet_sk(sk)->num = snum; inet_sk(sk)->num = snum;
if (!sk->sk_prev) { if (!sctp_sk(sk)->bind_hash) {
sk_add_bind_node(sk, &pp->sk_list); sk_add_bind_node(sk, &pp->sk_list);
sk->sk_prev = (struct sock *) pp; sctp_sk(sk)->bind_hash = pp;
} }
ret = 0; ret = 0;
...@@ -3345,9 +3345,9 @@ static __inline__ void __sctp_put_port(struct sock *sk) ...@@ -3345,9 +3345,9 @@ static __inline__ void __sctp_put_port(struct sock *sk)
struct sctp_bind_bucket *pp; struct sctp_bind_bucket *pp;
sctp_spin_lock(&head->lock); 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); hlist_del(&sk->sk_bind_node);
sk->sk_prev = NULL; sctp_sk(sk)->bind_hash = NULL;
inet_sk(sk)->num = 0; inet_sk(sk)->num = 0;
sctp_bucket_destroy(pp); sctp_bucket_destroy(pp);
sctp_spin_unlock(&head->lock); 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