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, 28 insertions, 26 deletions
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 2dea4bb7b54a..906c7ca43542 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -62,6 +62,7 @@
62#include <net/netdma.h> 62#include <net/netdma.h>
63#include <net/inet_common.h> 63#include <net/inet_common.h>
64#include <net/secure_seq.h> 64#include <net/secure_seq.h>
65#include <net/tcp_memcontrol.h>
65 66
66#include <asm/uaccess.h> 67#include <asm/uaccess.h>
67 68
@@ -153,7 +154,7 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
153 flowlabel = fl6_sock_lookup(sk, fl6.flowlabel); 154 flowlabel = fl6_sock_lookup(sk, fl6.flowlabel);
154 if (flowlabel == NULL) 155 if (flowlabel == NULL)
155 return -EINVAL; 156 return -EINVAL;
156 ipv6_addr_copy(&usin->sin6_addr, &flowlabel->dst); 157 usin->sin6_addr = flowlabel->dst;
157 fl6_sock_release(flowlabel); 158 fl6_sock_release(flowlabel);
158 } 159 }
159 } 160 }
@@ -195,7 +196,7 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
195 tp->write_seq = 0; 196 tp->write_seq = 0;
196 } 197 }
197 198
198 ipv6_addr_copy(&np->daddr, &usin->sin6_addr); 199 np->daddr = usin->sin6_addr;
199 np->flow_label = fl6.flowlabel; 200 np->flow_label = fl6.flowlabel;
200 201
201 /* 202 /*
@@ -244,9 +245,8 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
244 saddr = &np->rcv_saddr; 245 saddr = &np->rcv_saddr;
245 246
246 fl6.flowi6_proto = IPPROTO_TCP; 247 fl6.flowi6_proto = IPPROTO_TCP;
247 ipv6_addr_copy(&fl6.daddr, &np->daddr); 248 fl6.daddr = np->daddr;
248 ipv6_addr_copy(&fl6.saddr, 249 fl6.saddr = saddr ? *saddr : np->saddr;
249 (saddr ? saddr : &np->saddr));
250 fl6.flowi6_oif = sk->sk_bound_dev_if; 250 fl6.flowi6_oif = sk->sk_bound_dev_if;
251 fl6.flowi6_mark = sk->sk_mark; 251 fl6.flowi6_mark = sk->sk_mark;
252 fl6.fl6_dport = usin->sin6_port; 252 fl6.fl6_dport = usin->sin6_port;
@@ -264,11 +264,11 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
264 264
265 if (saddr == NULL) { 265 if (saddr == NULL) {
266 saddr = &fl6.saddr; 266 saddr = &fl6.saddr;
267 ipv6_addr_copy(&np->rcv_saddr, saddr); 267 np->rcv_saddr = *saddr;
268 } 268 }
269 269
270 /* set the source address */ 270 /* set the source address */
271 ipv6_addr_copy(&np->saddr, saddr); 271 np->saddr = *saddr;
272 inet->inet_rcv_saddr = LOOPBACK4_IPV6; 272 inet->inet_rcv_saddr = LOOPBACK4_IPV6;
273 273
274 sk->sk_gso_type = SKB_GSO_TCPV6; 274 sk->sk_gso_type = SKB_GSO_TCPV6;
@@ -398,8 +398,8 @@ static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
398 */ 398 */
399 memset(&fl6, 0, sizeof(fl6)); 399 memset(&fl6, 0, sizeof(fl6));
400 fl6.flowi6_proto = IPPROTO_TCP; 400 fl6.flowi6_proto = IPPROTO_TCP;
401 ipv6_addr_copy(&fl6.daddr, &np->daddr); 401 fl6.daddr = np->daddr;
402 ipv6_addr_copy(&fl6.saddr, &np->saddr); 402 fl6.saddr = np->saddr;
403 fl6.flowi6_oif = sk->sk_bound_dev_if; 403 fl6.flowi6_oif = sk->sk_bound_dev_if;
404 fl6.flowi6_mark = sk->sk_mark; 404 fl6.flowi6_mark = sk->sk_mark;
405 fl6.fl6_dport = inet->inet_dport; 405 fl6.fl6_dport = inet->inet_dport;
@@ -489,8 +489,8 @@ static int tcp_v6_send_synack(struct sock *sk, struct request_sock *req,
489 489
490 memset(&fl6, 0, sizeof(fl6)); 490 memset(&fl6, 0, sizeof(fl6));
491 fl6.flowi6_proto = IPPROTO_TCP; 491 fl6.flowi6_proto = IPPROTO_TCP;
492 ipv6_addr_copy(&fl6.daddr, &treq->rmt_addr); 492 fl6.daddr = treq->rmt_addr;
493 ipv6_addr_copy(&fl6.saddr, &treq->loc_addr); 493 fl6.saddr = treq->loc_addr;
494 fl6.flowlabel = 0; 494 fl6.flowlabel = 0;
495 fl6.flowi6_oif = treq->iif; 495 fl6.flowi6_oif = treq->iif;
496 fl6.flowi6_mark = sk->sk_mark; 496 fl6.flowi6_mark = sk->sk_mark;
@@ -512,7 +512,7 @@ static int tcp_v6_send_synack(struct sock *sk, struct request_sock *req,
512 if (skb) { 512 if (skb) {
513 __tcp_v6_send_check(skb, &treq->loc_addr, &treq->rmt_addr); 513 __tcp_v6_send_check(skb, &treq->loc_addr, &treq->rmt_addr);
514 514
515 ipv6_addr_copy(&fl6.daddr, &treq->rmt_addr); 515 fl6.daddr = treq->rmt_addr;
516 err = ip6_xmit(sk, skb, &fl6, opt, np->tclass); 516 err = ip6_xmit(sk, skb, &fl6, opt, np->tclass);
517 err = net_xmit_eval(err); 517 err = net_xmit_eval(err);
518 } 518 }
@@ -617,8 +617,7 @@ static int tcp_v6_md5_do_add(struct sock *sk, const struct in6_addr *peer,
617 tp->md5sig_info->alloced6++; 617 tp->md5sig_info->alloced6++;
618 } 618 }
619 619
620 ipv6_addr_copy(&tp->md5sig_info->keys6[tp->md5sig_info->entries6].addr, 620 tp->md5sig_info->keys6[tp->md5sig_info->entries6].addr = *peer;
621 peer);
622 tp->md5sig_info->keys6[tp->md5sig_info->entries6].base.key = newkey; 621 tp->md5sig_info->keys6[tp->md5sig_info->entries6].base.key = newkey;
623 tp->md5sig_info->keys6[tp->md5sig_info->entries6].base.keylen = newkeylen; 622 tp->md5sig_info->keys6[tp->md5sig_info->entries6].base.keylen = newkeylen;
624 623
@@ -750,8 +749,8 @@ static int tcp_v6_md5_hash_pseudoheader(struct tcp_md5sig_pool *hp,
750 749
751 bp = &hp->md5_blk.ip6; 750 bp = &hp->md5_blk.ip6;
752 /* 1. TCP pseudo-header (RFC2460) */ 751 /* 1. TCP pseudo-header (RFC2460) */
753 ipv6_addr_copy(&bp->saddr, saddr); 752 bp->saddr = *saddr;
754 ipv6_addr_copy(&bp->daddr, daddr); 753 bp->daddr = *daddr;
755 bp->protocol = cpu_to_be32(IPPROTO_TCP); 754 bp->protocol = cpu_to_be32(IPPROTO_TCP);
756 bp->len = cpu_to_be32(nbytes); 755 bp->len = cpu_to_be32(nbytes);
757 756
@@ -1039,8 +1038,8 @@ static void tcp_v6_send_response(struct sk_buff *skb, u32 seq, u32 ack, u32 win,
1039#endif 1038#endif
1040 1039
1041 memset(&fl6, 0, sizeof(fl6)); 1040 memset(&fl6, 0, sizeof(fl6));
1042 ipv6_addr_copy(&fl6.daddr, &ipv6_hdr(skb)->saddr); 1041 fl6.daddr = ipv6_hdr(skb)->saddr;
1043 ipv6_addr_copy(&fl6.saddr, &ipv6_hdr(skb)->daddr); 1042 fl6.saddr = ipv6_hdr(skb)->daddr;
1044 1043
1045 buff->ip_summed = CHECKSUM_PARTIAL; 1044 buff->ip_summed = CHECKSUM_PARTIAL;
1046 buff->csum = 0; 1045 buff->csum = 0;
@@ -1250,8 +1249,8 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
1250 tcp_openreq_init(req, &tmp_opt, skb); 1249 tcp_openreq_init(req, &tmp_opt, skb);
1251 1250
1252 treq = inet6_rsk(req); 1251 treq = inet6_rsk(req);
1253 ipv6_addr_copy(&treq->rmt_addr, &ipv6_hdr(skb)->saddr); 1252 treq->rmt_addr = ipv6_hdr(skb)->saddr;
1254 ipv6_addr_copy(&treq->loc_addr, &ipv6_hdr(skb)->daddr); 1253 treq->loc_addr = ipv6_hdr(skb)->daddr;
1255 if (!want_cookie || tmp_opt.tstamp_ok) 1254 if (!want_cookie || tmp_opt.tstamp_ok)
1256 TCP_ECN_create_request(req, tcp_hdr(skb)); 1255 TCP_ECN_create_request(req, tcp_hdr(skb));
1257 1256
@@ -1381,7 +1380,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
1381 1380
1382 ipv6_addr_set_v4mapped(newinet->inet_saddr, &newnp->saddr); 1381 ipv6_addr_set_v4mapped(newinet->inet_saddr, &newnp->saddr);
1383 1382
1384 ipv6_addr_copy(&newnp->rcv_saddr, &newnp->saddr); 1383 newnp->rcv_saddr = newnp->saddr;
1385 1384
1386 inet_csk(newsk)->icsk_af_ops = &ipv6_mapped; 1385 inet_csk(newsk)->icsk_af_ops = &ipv6_mapped;
1387 newsk->sk_backlog_rcv = tcp_v4_do_rcv; 1386 newsk->sk_backlog_rcv = tcp_v4_do_rcv;
@@ -1445,9 +1444,9 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
1445 1444
1446 memcpy(newnp, np, sizeof(struct ipv6_pinfo)); 1445 memcpy(newnp, np, sizeof(struct ipv6_pinfo));
1447 1446
1448 ipv6_addr_copy(&newnp->daddr, &treq->rmt_addr); 1447 newnp->daddr = treq->rmt_addr;
1449 ipv6_addr_copy(&newnp->saddr, &treq->loc_addr); 1448 newnp->saddr = treq->loc_addr;
1450 ipv6_addr_copy(&newnp->rcv_saddr, &treq->loc_addr); 1449 newnp->rcv_saddr = treq->loc_addr;
1451 newsk->sk_bound_dev_if = treq->iif; 1450 newsk->sk_bound_dev_if = treq->iif;
1452 1451
1453 /* Now IPv6 options... 1452 /* Now IPv6 options...
@@ -1996,7 +1995,8 @@ static int tcp_v6_init_sock(struct sock *sk)
1996 sk->sk_rcvbuf = sysctl_tcp_rmem[1]; 1995 sk->sk_rcvbuf = sysctl_tcp_rmem[1];
1997 1996
1998 local_bh_disable(); 1997 local_bh_disable();
1999 percpu_counter_inc(&tcp_sockets_allocated); 1998 sock_update_memcg(sk);
1999 sk_sockets_allocated_inc(sk);
2000 local_bh_enable(); 2000 local_bh_enable();
2001 2001
2002 return 0; 2002 return 0;
@@ -2215,7 +2215,6 @@ struct proto tcpv6_prot = {
2215 .memory_allocated = &tcp_memory_allocated, 2215 .memory_allocated = &tcp_memory_allocated,
2216 .memory_pressure = &tcp_memory_pressure, 2216 .memory_pressure = &tcp_memory_pressure,
2217 .orphan_count = &tcp_orphan_count, 2217 .orphan_count = &tcp_orphan_count,
2218 .sysctl_mem = sysctl_tcp_mem,
2219 .sysctl_wmem = sysctl_tcp_wmem, 2218 .sysctl_wmem = sysctl_tcp_wmem,
2220 .sysctl_rmem = sysctl_tcp_rmem, 2219 .sysctl_rmem = sysctl_tcp_rmem,
2221 .max_header = MAX_TCP_HEADER, 2220 .max_header = MAX_TCP_HEADER,
@@ -2229,6 +2228,9 @@ struct proto tcpv6_prot = {
2229 .compat_setsockopt = compat_tcp_setsockopt, 2228 .compat_setsockopt = compat_tcp_setsockopt,
2230 .compat_getsockopt = compat_tcp_getsockopt, 2229 .compat_getsockopt = compat_tcp_getsockopt,
2231#endif 2230#endif
2231#ifdef CONFIG_CGROUP_MEM_RES_CTLR_KMEM
2232 .proto_cgroup = tcp_proto_cgroup,
2233#endif
2232}; 2234};
2233 2235
2234static const struct inet6_protocol tcpv6_protocol = { 2236static const struct inet6_protocol tcpv6_protocol = {