aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/ip.h2
-rw-r--r--include/linux/tcp.h1
-rw-r--r--include/net/tcp.h2
-rw-r--r--net/ipv4/tcp.c4
-rw-r--r--net/ipv4/tcp_ipv4.c21
-rw-r--r--net/ipv4/tcp_minisocks.c15
-rw-r--r--net/ipv6/tcp_ipv6.c8
7 files changed, 28 insertions, 25 deletions
diff --git a/include/linux/ip.h b/include/linux/ip.h
index 33e8a19..2c54bbd 100644
--- a/include/linux/ip.h
+++ b/include/linux/ip.h
@@ -128,6 +128,7 @@ static inline struct inet_request_sock *inet_rsk(const struct request_sock *sk)
return (struct inet_request_sock *)sk;
}
+struct inet_bind_bucket;
struct ipv6_pinfo;
struct inet_sock {
@@ -157,6 +158,7 @@ struct inet_sock {
int mc_index; /* Multicast device index */
__u32 mc_addr;
struct ip_mc_socklist *mc_list; /* Group array */
+ struct inet_bind_bucket *bind_hash;
/*
* Following members are used to retain the infomation to build
* an ip header on each ip fragmentation while the socket is corked.
diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index ec580a5..e70ab19 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -258,7 +258,6 @@ struct tcp_sock {
__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 inet_bind_bucket *bind_hash;
/* Delayed ACK control data */
struct {
__u8 pending; /* ACK is pending */
diff --git a/include/net/tcp.h b/include/net/tcp.h
index ff5d30a..6c6c879 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -1266,7 +1266,7 @@ static __inline__ void tcp_set_state(struct sock *sk, int state)
TCP_INC_STATS(TCP_MIB_ESTABRESETS);
sk->sk_prot->unhash(sk);
- if (tcp_sk(sk)->bind_hash &&
+ if (inet_sk(sk)->bind_hash &&
!(sk->sk_userlocks & SOCK_BINDPORT_LOCK))
tcp_put_port(sk);
/* fall through */
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 1ec03db..e54a410 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1575,7 +1575,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 || tcp_sk(sk)->bind_hash);
+ BUG_TRAP(!inet_sk(sk)->num || inet_sk(sk)->bind_hash);
sk->sk_prot->destroy(sk);
@@ -1802,7 +1802,7 @@ int tcp_disconnect(struct sock *sk, int flags)
tcp_sack_reset(&tp->rx_opt);
__sk_dst_reset(sk);
- BUG_TRAP(!inet->num || tp->bind_hash);
+ BUG_TRAP(!inet->num || inet->bind_hash);
sk->sk_error_report(sk);
return err;
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 58e36ed..10a9b3a 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -113,9 +113,9 @@ static __inline__ void __tcp_inherit_port(struct sock *sk, struct sock *child)
struct inet_bind_bucket *tb;
spin_lock(&head->lock);
- tb = tcp_sk(sk)->bind_hash;
+ tb = inet_sk(sk)->bind_hash;
sk_add_bind_node(child, &tb->owners);
- tcp_sk(child)->bind_hash = tb;
+ inet_sk(child)->bind_hash = tb;
spin_unlock(&head->lock);
}
@@ -129,9 +129,10 @@ inline void tcp_inherit_port(struct sock *sk, struct sock *child)
void tcp_bind_hash(struct sock *sk, struct inet_bind_bucket *tb,
const unsigned short snum)
{
- inet_sk(sk)->num = snum;
+ struct inet_sock *inet = inet_sk(sk);
+ inet->num = snum;
sk_add_bind_node(sk, &tb->owners);
- tcp_sk(sk)->bind_hash = tb;
+ inet->bind_hash = tb;
}
static inline int tcp_bind_conflict(struct sock *sk, struct inet_bind_bucket *tb)
@@ -246,9 +247,9 @@ tb_not_found:
(!sk->sk_reuse || sk->sk_state == TCP_LISTEN))
tb->fastreuse = 0;
success:
- if (!tcp_sk(sk)->bind_hash)
+ if (!inet_sk(sk)->bind_hash)
tcp_bind_hash(sk, tb, snum);
- BUG_TRAP(tcp_sk(sk)->bind_hash == tb);
+ BUG_TRAP(inet_sk(sk)->bind_hash == tb);
ret = 0;
fail_unlock:
@@ -269,9 +270,9 @@ static void __tcp_put_port(struct sock *sk)
struct inet_bind_bucket *tb;
spin_lock(&head->lock);
- tb = tcp_sk(sk)->bind_hash;
+ tb = inet->bind_hash;
__sk_del_bind_node(sk);
- tcp_sk(sk)->bind_hash = NULL;
+ inet->bind_hash = NULL;
inet->num = 0;
inet_bind_bucket_destroy(tcp_bucket_cachep, tb);
spin_unlock(&head->lock);
@@ -694,7 +695,7 @@ ok:
}
head = &tcp_bhash[inet_bhashfn(snum, tcp_bhash_size)];
- tb = tcp_sk(sk)->bind_hash;
+ tb = inet_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);
@@ -1940,7 +1941,7 @@ int tcp_v4_destroy_sock(struct sock *sk)
__skb_queue_purge(&tp->ucopy.prequeue);
/* Clean up a referenced TCP bind bucket. */
- if (tp->bind_hash)
+ if (inet_sk(sk)->bind_hash)
tcp_put_port(sk);
/*
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index 1df6cd46..267cea1 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -296,17 +296,17 @@ kill:
*/
static void __tcp_tw_hashdance(struct sock *sk, struct tcp_tw_bucket *tw)
{
+ const struct inet_sock *inet = inet_sk(sk);
struct inet_ehash_bucket *ehead = &tcp_ehash[sk->sk_hashent];
struct inet_bind_hashbucket *bhead;
-
/* Step 1: Put TW into bind hash. Original socket stays there too.
- Note, that any socket with inet_sk(sk)->num != 0 MUST be bound in
+ Note, that any socket with inet->num != 0 MUST be bound in
binding cache, even if it is closed.
*/
- bhead = &tcp_bhash[inet_bhashfn(inet_sk(sk)->num, tcp_bhash_size)];
+ bhead = &tcp_bhash[inet_bhashfn(inet->num, tcp_bhash_size)];
spin_lock(&bhead->lock);
- tw->tw_tb = tcp_sk(sk)->bind_hash;
- BUG_TRAP(tcp_sk(sk)->bind_hash);
+ tw->tw_tb = inet->bind_hash;
+ BUG_TRAP(inet->bind_hash);
tw_add_bind_node(tw, &tw->tw_tb->owners);
spin_unlock(&bhead->lock);
@@ -694,6 +694,7 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct request_sock *req,
if(newsk != NULL) {
struct inet_request_sock *ireq = inet_rsk(req);
struct tcp_request_sock *treq = tcp_rsk(req);
+ struct inet_sock *newinet = inet_sk(newsk);
struct tcp_sock *newtp;
struct sk_filter *filter;
@@ -702,10 +703,10 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct request_sock *req,
/* SANITY */
sk_node_init(&newsk->sk_node);
- tcp_sk(newsk)->bind_hash = NULL;
+ newinet->bind_hash = NULL;
/* Clone the TCP header template */
- inet_sk(newsk)->dport = ireq->rmt_port;
+ newinet->dport = ireq->rmt_port;
sock_lock_init(newsk);
bh_lock_sock(newsk);
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 31f50fb..a8ca7ba 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -204,9 +204,9 @@ tb_not_found:
tb->fastreuse = 0;
success:
- if (!tcp_sk(sk)->bind_hash)
+ if (!inet_sk(sk)->bind_hash)
tcp_bind_hash(sk, tb, snum);
- BUG_TRAP(tcp_sk(sk)->bind_hash == tb);
+ BUG_TRAP(inet_sk(sk)->bind_hash == tb);
ret = 0;
fail_unlock:
@@ -613,8 +613,8 @@ ok:
goto out;
}
- head = &tcp_bhash[inet_bhashfn(snum, tcp_bhash_size)];
- tb = tcp_sk(sk)->bind_hash;
+ head = &tcp_bhash[inet_bhashfn(snum, tcp_bhash_size)];
+ tb = inet_sk(sk)->bind_hash;
spin_lock_bh(&head->lock);
if (sk_head(&tb->owners) == sk && !sk->sk_bind_node.next) {