aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/tcp_ipv6.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv6/tcp_ipv6.c')
-rw-r--r--net/ipv6/tcp_ipv6.c54
1 files changed, 29 insertions, 25 deletions
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index af8ad5bb273b..b9c7003b7f8b 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -207,9 +207,9 @@ tb_not_found:
207 tb->fastreuse = 0; 207 tb->fastreuse = 0;
208 208
209success: 209success:
210 if (!inet_sk(sk)->bind_hash) 210 if (!inet_csk(sk)->icsk_bind_hash)
211 inet_bind_hash(sk, tb, snum); 211 inet_bind_hash(sk, tb, snum);
212 BUG_TRAP(inet_sk(sk)->bind_hash == tb); 212 BUG_TRAP(inet_csk(sk)->icsk_bind_hash == tb);
213 ret = 0; 213 ret = 0;
214 214
215fail_unlock: 215fail_unlock:
@@ -381,7 +381,7 @@ EXPORT_SYMBOL_GPL(tcp_v6_lookup);
381 * Open request hash tables. 381 * Open request hash tables.
382 */ 382 */
383 383
384static u32 tcp_v6_synq_hash(struct in6_addr *raddr, u16 rport, u32 rnd) 384static u32 tcp_v6_synq_hash(const struct in6_addr *raddr, const u16 rport, const u32 rnd)
385{ 385{
386 u32 a, b, c; 386 u32 a, b, c;
387 387
@@ -401,14 +401,15 @@ static u32 tcp_v6_synq_hash(struct in6_addr *raddr, u16 rport, u32 rnd)
401 return c & (TCP_SYNQ_HSIZE - 1); 401 return c & (TCP_SYNQ_HSIZE - 1);
402} 402}
403 403
404static struct request_sock *tcp_v6_search_req(struct tcp_sock *tp, 404static struct request_sock *tcp_v6_search_req(const struct sock *sk,
405 struct request_sock ***prevp, 405 struct request_sock ***prevp,
406 __u16 rport, 406 __u16 rport,
407 struct in6_addr *raddr, 407 struct in6_addr *raddr,
408 struct in6_addr *laddr, 408 struct in6_addr *laddr,
409 int iif) 409 int iif)
410{ 410{
411 struct listen_sock *lopt = tp->accept_queue.listen_opt; 411 const struct inet_connection_sock *icsk = inet_csk(sk);
412 struct listen_sock *lopt = icsk->icsk_accept_queue.listen_opt;
412 struct request_sock *req, **prev; 413 struct request_sock *req, **prev;
413 414
414 for (prev = &lopt->syn_table[tcp_v6_synq_hash(raddr, rport, lopt->hash_rnd)]; 415 for (prev = &lopt->syn_table[tcp_v6_synq_hash(raddr, rport, lopt->hash_rnd)];
@@ -619,7 +620,7 @@ ok:
619 } 620 }
620 621
621 head = &tcp_hashinfo.bhash[inet_bhashfn(snum, tcp_hashinfo.bhash_size)]; 622 head = &tcp_hashinfo.bhash[inet_bhashfn(snum, tcp_hashinfo.bhash_size)];
622 tb = inet_sk(sk)->bind_hash; 623 tb = inet_csk(sk)->icsk_bind_hash;
623 spin_lock_bh(&head->lock); 624 spin_lock_bh(&head->lock);
624 625
625 if (sk_head(&tb->owners) == sk && !sk->sk_bind_node.next) { 626 if (sk_head(&tb->owners) == sk && !sk->sk_bind_node.next) {
@@ -925,7 +926,7 @@ static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
925 if (sock_owned_by_user(sk)) 926 if (sock_owned_by_user(sk))
926 goto out; 927 goto out;
927 928
928 req = tcp_v6_search_req(tp, &prev, th->dest, &hdr->daddr, 929 req = tcp_v6_search_req(sk, &prev, th->dest, &hdr->daddr,
929 &hdr->saddr, tcp_v6_iif(skb)); 930 &hdr->saddr, tcp_v6_iif(skb));
930 if (!req) 931 if (!req)
931 goto out; 932 goto out;
@@ -940,7 +941,7 @@ static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
940 goto out; 941 goto out;
941 } 942 }
942 943
943 tcp_synq_drop(sk, req, prev); 944 inet_csk_reqsk_queue_drop(sk, req, prev);
944 goto out; 945 goto out;
945 946
946 case TCP_SYN_SENT: 947 case TCP_SYN_SENT:
@@ -1245,11 +1246,10 @@ static struct sock *tcp_v6_hnd_req(struct sock *sk,struct sk_buff *skb)
1245{ 1246{
1246 struct request_sock *req, **prev; 1247 struct request_sock *req, **prev;
1247 struct tcphdr *th = skb->h.th; 1248 struct tcphdr *th = skb->h.th;
1248 struct tcp_sock *tp = tcp_sk(sk);
1249 struct sock *nsk; 1249 struct sock *nsk;
1250 1250
1251 /* Find possible connection requests. */ 1251 /* Find possible connection requests. */
1252 req = tcp_v6_search_req(tp, &prev, th->source, &skb->nh.ipv6h->saddr, 1252 req = tcp_v6_search_req(sk, &prev, th->source, &skb->nh.ipv6h->saddr,
1253 &skb->nh.ipv6h->daddr, tcp_v6_iif(skb)); 1253 &skb->nh.ipv6h->daddr, tcp_v6_iif(skb));
1254 if (req) 1254 if (req)
1255 return tcp_check_req(sk, skb, req, prev); 1255 return tcp_check_req(sk, skb, req, prev);
@@ -1278,12 +1278,12 @@ static struct sock *tcp_v6_hnd_req(struct sock *sk,struct sk_buff *skb)
1278 1278
1279static void tcp_v6_synq_add(struct sock *sk, struct request_sock *req) 1279static void tcp_v6_synq_add(struct sock *sk, struct request_sock *req)
1280{ 1280{
1281 struct tcp_sock *tp = tcp_sk(sk); 1281 struct inet_connection_sock *icsk = inet_csk(sk);
1282 struct listen_sock *lopt = tp->accept_queue.listen_opt; 1282 struct listen_sock *lopt = icsk->icsk_accept_queue.listen_opt;
1283 u32 h = tcp_v6_synq_hash(&tcp6_rsk(req)->rmt_addr, inet_rsk(req)->rmt_port, lopt->hash_rnd); 1283 const u32 h = tcp_v6_synq_hash(&tcp6_rsk(req)->rmt_addr, inet_rsk(req)->rmt_port, lopt->hash_rnd);
1284 1284
1285 reqsk_queue_hash_req(&tp->accept_queue, h, req, TCP_TIMEOUT_INIT); 1285 reqsk_queue_hash_req(&icsk->icsk_accept_queue, h, req, TCP_TIMEOUT_INIT);
1286 tcp_synq_added(sk); 1286 inet_csk_reqsk_queue_added(sk, TCP_TIMEOUT_INIT);
1287} 1287}
1288 1288
1289 1289
@@ -1308,13 +1308,13 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
1308 /* 1308 /*
1309 * There are no SYN attacks on IPv6, yet... 1309 * There are no SYN attacks on IPv6, yet...
1310 */ 1310 */
1311 if (tcp_synq_is_full(sk) && !isn) { 1311 if (inet_csk_reqsk_queue_is_full(sk) && !isn) {
1312 if (net_ratelimit()) 1312 if (net_ratelimit())
1313 printk(KERN_INFO "TCPv6: dropping request, synflood is possible\n"); 1313 printk(KERN_INFO "TCPv6: dropping request, synflood is possible\n");
1314 goto drop; 1314 goto drop;
1315 } 1315 }
1316 1316
1317 if (sk_acceptq_is_full(sk) && tcp_synq_young(sk) > 1) 1317 if (sk_acceptq_is_full(sk) && inet_csk_reqsk_queue_young(sk) > 1)
1318 goto drop; 1318 goto drop;
1319 1319
1320 req = reqsk_alloc(&tcp6_request_sock_ops); 1320 req = reqsk_alloc(&tcp6_request_sock_ops);
@@ -2015,7 +2015,7 @@ static int tcp_v6_init_sock(struct sock *sk)
2015 tcp_init_xmit_timers(sk); 2015 tcp_init_xmit_timers(sk);
2016 tcp_prequeue_init(tp); 2016 tcp_prequeue_init(tp);
2017 2017
2018 tp->rto = TCP_TIMEOUT_INIT; 2018 inet_csk(sk)->icsk_rto = TCP_TIMEOUT_INIT;
2019 tp->mdev = TCP_TIMEOUT_INIT; 2019 tp->mdev = TCP_TIMEOUT_INIT;
2020 2020
2021 /* So many TCP implementations out there (incorrectly) count the 2021 /* So many TCP implementations out there (incorrectly) count the
@@ -2098,18 +2098,20 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)
2098 unsigned long timer_expires; 2098 unsigned long timer_expires;
2099 struct inet_sock *inet = inet_sk(sp); 2099 struct inet_sock *inet = inet_sk(sp);
2100 struct tcp_sock *tp = tcp_sk(sp); 2100 struct tcp_sock *tp = tcp_sk(sp);
2101 const struct inet_connection_sock *icsk = inet_csk(sp);
2101 struct ipv6_pinfo *np = inet6_sk(sp); 2102 struct ipv6_pinfo *np = inet6_sk(sp);
2102 2103
2103 dest = &np->daddr; 2104 dest = &np->daddr;
2104 src = &np->rcv_saddr; 2105 src = &np->rcv_saddr;
2105 destp = ntohs(inet->dport); 2106 destp = ntohs(inet->dport);
2106 srcp = ntohs(inet->sport); 2107 srcp = ntohs(inet->sport);
2107 if (tp->pending == TCP_TIME_RETRANS) { 2108
2109 if (icsk->icsk_pending == ICSK_TIME_RETRANS) {
2108 timer_active = 1; 2110 timer_active = 1;
2109 timer_expires = tp->timeout; 2111 timer_expires = icsk->icsk_timeout;
2110 } else if (tp->pending == TCP_TIME_PROBE0) { 2112 } else if (icsk->icsk_pending == ICSK_TIME_PROBE0) {
2111 timer_active = 4; 2113 timer_active = 4;
2112 timer_expires = tp->timeout; 2114 timer_expires = icsk->icsk_timeout;
2113 } else if (timer_pending(&sp->sk_timer)) { 2115 } else if (timer_pending(&sp->sk_timer)) {
2114 timer_active = 2; 2116 timer_active = 2;
2115 timer_expires = sp->sk_timer.expires; 2117 timer_expires = sp->sk_timer.expires;
@@ -2130,12 +2132,14 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)
2130 tp->write_seq-tp->snd_una, tp->rcv_nxt-tp->copied_seq, 2132 tp->write_seq-tp->snd_una, tp->rcv_nxt-tp->copied_seq,
2131 timer_active, 2133 timer_active,
2132 jiffies_to_clock_t(timer_expires - jiffies), 2134 jiffies_to_clock_t(timer_expires - jiffies),
2133 tp->retransmits, 2135 icsk->icsk_retransmits,
2134 sock_i_uid(sp), 2136 sock_i_uid(sp),
2135 tp->probes_out, 2137 tp->probes_out,
2136 sock_i_ino(sp), 2138 sock_i_ino(sp),
2137 atomic_read(&sp->sk_refcnt), sp, 2139 atomic_read(&sp->sk_refcnt), sp,
2138 tp->rto, tp->ack.ato, (tp->ack.quick<<1)|tp->ack.pingpong, 2140 icsk->icsk_rto,
2141 icsk->icsk_ack.ato,
2142 (icsk->icsk_ack.quick << 1 ) | icsk->icsk_ack.pingpong,
2139 tp->snd_cwnd, tp->snd_ssthresh>=0xFFFF?-1:tp->snd_ssthresh 2143 tp->snd_cwnd, tp->snd_ssthresh>=0xFFFF?-1:tp->snd_ssthresh
2140 ); 2144 );
2141} 2145}
@@ -2227,7 +2231,7 @@ struct proto tcpv6_prot = {
2227 .close = tcp_close, 2231 .close = tcp_close,
2228 .connect = tcp_v6_connect, 2232 .connect = tcp_v6_connect,
2229 .disconnect = tcp_disconnect, 2233 .disconnect = tcp_disconnect,
2230 .accept = tcp_accept, 2234 .accept = inet_csk_accept,
2231 .ioctl = tcp_ioctl, 2235 .ioctl = tcp_ioctl,
2232 .init = tcp_v6_init_sock, 2236 .init = tcp_v6_init_sock,
2233 .destroy = tcp_v6_destroy_sock, 2237 .destroy = tcp_v6_destroy_sock,