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.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 4f43537197ef..9b6460055df5 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -713,7 +713,8 @@ static const struct tcp_request_sock_ops tcp_request_sock_ipv6_ops = {
713#endif 713#endif
714 714
715static void tcp_v6_send_response(struct sk_buff *skb, u32 seq, u32 ack, u32 win, 715static void tcp_v6_send_response(struct sk_buff *skb, u32 seq, u32 ack, u32 win,
716 u32 ts, struct tcp_md5sig_key *key, int rst, u8 tclass) 716 u32 tsval, u32 tsecr,
717 struct tcp_md5sig_key *key, int rst, u8 tclass)
717{ 718{
718 const struct tcphdr *th = tcp_hdr(skb); 719 const struct tcphdr *th = tcp_hdr(skb);
719 struct tcphdr *t1; 720 struct tcphdr *t1;
@@ -725,7 +726,7 @@ static void tcp_v6_send_response(struct sk_buff *skb, u32 seq, u32 ack, u32 win,
725 struct dst_entry *dst; 726 struct dst_entry *dst;
726 __be32 *topt; 727 __be32 *topt;
727 728
728 if (ts) 729 if (tsecr)
729 tot_len += TCPOLEN_TSTAMP_ALIGNED; 730 tot_len += TCPOLEN_TSTAMP_ALIGNED;
730#ifdef CONFIG_TCP_MD5SIG 731#ifdef CONFIG_TCP_MD5SIG
731 if (key) 732 if (key)
@@ -755,11 +756,11 @@ static void tcp_v6_send_response(struct sk_buff *skb, u32 seq, u32 ack, u32 win,
755 756
756 topt = (__be32 *)(t1 + 1); 757 topt = (__be32 *)(t1 + 1);
757 758
758 if (ts) { 759 if (tsecr) {
759 *topt++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | 760 *topt++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) |
760 (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP); 761 (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP);
761 *topt++ = htonl(tcp_time_stamp); 762 *topt++ = htonl(tsval);
762 *topt++ = htonl(ts); 763 *topt++ = htonl(tsecr);
763 } 764 }
764 765
765#ifdef CONFIG_TCP_MD5SIG 766#ifdef CONFIG_TCP_MD5SIG
@@ -835,7 +836,8 @@ static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb)
835 * no RST generated if md5 hash doesn't match. 836 * no RST generated if md5 hash doesn't match.
836 */ 837 */
837 sk1 = inet6_lookup_listener(dev_net(skb_dst(skb)->dev), 838 sk1 = inet6_lookup_listener(dev_net(skb_dst(skb)->dev),
838 &tcp_hashinfo, &ipv6h->daddr, 839 &tcp_hashinfo, &ipv6h->saddr,
840 th->source, &ipv6h->daddr,
839 ntohs(th->source), inet6_iif(skb)); 841 ntohs(th->source), inet6_iif(skb));
840 if (!sk1) 842 if (!sk1)
841 return; 843 return;
@@ -859,7 +861,7 @@ static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb)
859 ack_seq = ntohl(th->seq) + th->syn + th->fin + skb->len - 861 ack_seq = ntohl(th->seq) + th->syn + th->fin + skb->len -
860 (th->doff << 2); 862 (th->doff << 2);
861 863
862 tcp_v6_send_response(skb, seq, ack_seq, 0, 0, key, 1, 0); 864 tcp_v6_send_response(skb, seq, ack_seq, 0, 0, 0, key, 1, 0);
863 865
864#ifdef CONFIG_TCP_MD5SIG 866#ifdef CONFIG_TCP_MD5SIG
865release_sk1: 867release_sk1:
@@ -870,10 +872,11 @@ release_sk1:
870#endif 872#endif
871} 873}
872 874
873static void tcp_v6_send_ack(struct sk_buff *skb, u32 seq, u32 ack, u32 win, u32 ts, 875static void tcp_v6_send_ack(struct sk_buff *skb, u32 seq, u32 ack,
876 u32 win, u32 tsval, u32 tsecr,
874 struct tcp_md5sig_key *key, u8 tclass) 877 struct tcp_md5sig_key *key, u8 tclass)
875{ 878{
876 tcp_v6_send_response(skb, seq, ack, win, ts, key, 0, tclass); 879 tcp_v6_send_response(skb, seq, ack, win, tsval, tsecr, key, 0, tclass);
877} 880}
878 881
879static void tcp_v6_timewait_ack(struct sock *sk, struct sk_buff *skb) 882static void tcp_v6_timewait_ack(struct sock *sk, struct sk_buff *skb)
@@ -883,6 +886,7 @@ static void tcp_v6_timewait_ack(struct sock *sk, struct sk_buff *skb)
883 886
884 tcp_v6_send_ack(skb, tcptw->tw_snd_nxt, tcptw->tw_rcv_nxt, 887 tcp_v6_send_ack(skb, tcptw->tw_snd_nxt, tcptw->tw_rcv_nxt,
885 tcptw->tw_rcv_wnd >> tw->tw_rcv_wscale, 888 tcptw->tw_rcv_wnd >> tw->tw_rcv_wscale,
889 tcp_time_stamp + tcptw->tw_ts_offset,
886 tcptw->tw_ts_recent, tcp_twsk_md5_key(tcptw), 890 tcptw->tw_ts_recent, tcp_twsk_md5_key(tcptw),
887 tw->tw_tclass); 891 tw->tw_tclass);
888 892
@@ -892,7 +896,8 @@ static void tcp_v6_timewait_ack(struct sock *sk, struct sk_buff *skb)
892static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb, 896static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
893 struct request_sock *req) 897 struct request_sock *req)
894{ 898{
895 tcp_v6_send_ack(skb, tcp_rsk(req)->snt_isn + 1, tcp_rsk(req)->rcv_isn + 1, req->rcv_wnd, req->ts_recent, 899 tcp_v6_send_ack(skb, tcp_rsk(req)->snt_isn + 1, tcp_rsk(req)->rcv_isn + 1,
900 req->rcv_wnd, tcp_time_stamp, req->ts_recent,
896 tcp_v6_md5_do_lookup(sk, &ipv6_hdr(skb)->daddr), 0); 901 tcp_v6_md5_do_lookup(sk, &ipv6_hdr(skb)->daddr), 0);
897} 902}
898 903
@@ -1030,7 +1035,7 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
1030 treq->rmt_addr = ipv6_hdr(skb)->saddr; 1035 treq->rmt_addr = ipv6_hdr(skb)->saddr;
1031 treq->loc_addr = ipv6_hdr(skb)->daddr; 1036 treq->loc_addr = ipv6_hdr(skb)->daddr;
1032 if (!want_cookie || tmp_opt.tstamp_ok) 1037 if (!want_cookie || tmp_opt.tstamp_ok)
1033 TCP_ECN_create_request(req, skb); 1038 TCP_ECN_create_request(req, skb, sock_net(sk));
1034 1039
1035 treq->iif = sk->sk_bound_dev_if; 1040 treq->iif = sk->sk_bound_dev_if;
1036 1041
@@ -1167,7 +1172,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
1167 newnp->opt = NULL; 1172 newnp->opt = NULL;
1168 newnp->mcast_oif = inet6_iif(skb); 1173 newnp->mcast_oif = inet6_iif(skb);
1169 newnp->mcast_hops = ipv6_hdr(skb)->hop_limit; 1174 newnp->mcast_hops = ipv6_hdr(skb)->hop_limit;
1170 newnp->rcv_tclass = ipv6_tclass(ipv6_hdr(skb)); 1175 newnp->rcv_tclass = ipv6_get_dsfield(ipv6_hdr(skb));
1171 1176
1172 /* 1177 /*
1173 * No need to charge this sock to the relevant IPv6 refcnt debug socks count 1178 * No need to charge this sock to the relevant IPv6 refcnt debug socks count
@@ -1247,7 +1252,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
1247 newnp->opt = NULL; 1252 newnp->opt = NULL;
1248 newnp->mcast_oif = inet6_iif(skb); 1253 newnp->mcast_oif = inet6_iif(skb);
1249 newnp->mcast_hops = ipv6_hdr(skb)->hop_limit; 1254 newnp->mcast_hops = ipv6_hdr(skb)->hop_limit;
1250 newnp->rcv_tclass = ipv6_tclass(ipv6_hdr(skb)); 1255 newnp->rcv_tclass = ipv6_get_dsfield(ipv6_hdr(skb));
1251 1256
1252 /* Clone native IPv6 options from listening socket (if any) 1257 /* Clone native IPv6 options from listening socket (if any)
1253 1258
@@ -1460,7 +1465,7 @@ ipv6_pktoptions:
1460 if (np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim) 1465 if (np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim)
1461 np->mcast_hops = ipv6_hdr(opt_skb)->hop_limit; 1466 np->mcast_hops = ipv6_hdr(opt_skb)->hop_limit;
1462 if (np->rxopt.bits.rxtclass) 1467 if (np->rxopt.bits.rxtclass)
1463 np->rcv_tclass = ipv6_tclass(ipv6_hdr(skb)); 1468 np->rcv_tclass = ipv6_get_dsfield(ipv6_hdr(skb));
1464 if (ipv6_opt_accepted(sk, opt_skb)) { 1469 if (ipv6_opt_accepted(sk, opt_skb)) {
1465 skb_set_owner_r(opt_skb, sk); 1470 skb_set_owner_r(opt_skb, sk);
1466 opt_skb = xchg(&np->pktoptions, opt_skb); 1471 opt_skb = xchg(&np->pktoptions, opt_skb);
@@ -1602,6 +1607,7 @@ do_time_wait:
1602 struct sock *sk2; 1607 struct sock *sk2;
1603 1608
1604 sk2 = inet6_lookup_listener(dev_net(skb->dev), &tcp_hashinfo, 1609 sk2 = inet6_lookup_listener(dev_net(skb->dev), &tcp_hashinfo,
1610 &ipv6_hdr(skb)->saddr, th->source,
1605 &ipv6_hdr(skb)->daddr, 1611 &ipv6_hdr(skb)->daddr,
1606 ntohs(th->dest), inet6_iif(skb)); 1612 ntohs(th->dest), inet6_iif(skb));
1607 if (sk2 != NULL) { 1613 if (sk2 != NULL) {