tcp_input.c (cd2145358e7a5bb1798a185e5ef199ea49c69dd7) tcp_input.c (f7b3bec6f5167efaf56b756abfafb924cb1d3050)
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Implementation of the Transmission Control Protocol(TCP).
7 *
8 * Authors: Ross Biro

--- 5862 unchanged lines hidden (view full) ---

5871 * Exception: tcp_ca wants ECN. This is required for DCTCP
5872 * congestion control; it requires setting ECT on all packets,
5873 * including SYN. We inverse the test in this case: If our
5874 * local socket wants ECN, but peer only set ece/cwr (but not
5875 * ECT in IP header) its probably a non-DCTCP aware sender.
5876 */
5877static void tcp_ecn_create_request(struct request_sock *req,
5878 const struct sk_buff *skb,
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Implementation of the Transmission Control Protocol(TCP).
7 *
8 * Authors: Ross Biro

--- 5862 unchanged lines hidden (view full) ---

5871 * Exception: tcp_ca wants ECN. This is required for DCTCP
5872 * congestion control; it requires setting ECT on all packets,
5873 * including SYN. We inverse the test in this case: If our
5874 * local socket wants ECN, but peer only set ece/cwr (but not
5875 * ECT in IP header) its probably a non-DCTCP aware sender.
5876 */
5877static void tcp_ecn_create_request(struct request_sock *req,
5878 const struct sk_buff *skb,
5879 const struct sock *listen_sk)
5879 const struct sock *listen_sk,
5880 const struct dst_entry *dst)
5880{
5881 const struct tcphdr *th = tcp_hdr(skb);
5882 const struct net *net = sock_net(listen_sk);
5883 bool th_ecn = th->ece && th->cwr;
5881{
5882 const struct tcphdr *th = tcp_hdr(skb);
5883 const struct net *net = sock_net(listen_sk);
5884 bool th_ecn = th->ece && th->cwr;
5884 bool ect, need_ecn;
5885 bool ect, need_ecn, ecn_ok;
5885
5886 if (!th_ecn)
5887 return;
5888
5889 ect = !INET_ECN_is_not_ect(TCP_SKB_CB(skb)->ip_dsfield);
5890 need_ecn = tcp_ca_needs_ecn(listen_sk);
5886
5887 if (!th_ecn)
5888 return;
5889
5890 ect = !INET_ECN_is_not_ect(TCP_SKB_CB(skb)->ip_dsfield);
5891 need_ecn = tcp_ca_needs_ecn(listen_sk);
5892 ecn_ok = net->ipv4.sysctl_tcp_ecn || dst_feature(dst, RTAX_FEATURE_ECN);
5891
5893
5892 if (!ect && !need_ecn && net->ipv4.sysctl_tcp_ecn)
5894 if (!ect && !need_ecn && ecn_ok)
5893 inet_rsk(req)->ecn_ok = 1;
5894 else if (ect && need_ecn)
5895 inet_rsk(req)->ecn_ok = 1;
5896}
5897
5898int tcp_conn_request(struct request_sock_ops *rsk_ops,
5899 const struct tcp_request_sock_ops *af_ops,
5900 struct sock *sk, struct sk_buff *skb)

--- 48 unchanged lines hidden (view full) ---

5949 tmp_opt.tstamp_ok = tmp_opt.saw_tstamp;
5950 tcp_openreq_init(req, &tmp_opt, skb, sk);
5951
5952 af_ops->init_req(req, sk, skb);
5953
5954 if (security_inet_conn_request(sk, skb, req))
5955 goto drop_and_free;
5956
5895 inet_rsk(req)->ecn_ok = 1;
5896 else if (ect && need_ecn)
5897 inet_rsk(req)->ecn_ok = 1;
5898}
5899
5900int tcp_conn_request(struct request_sock_ops *rsk_ops,
5901 const struct tcp_request_sock_ops *af_ops,
5902 struct sock *sk, struct sk_buff *skb)

--- 48 unchanged lines hidden (view full) ---

5951 tmp_opt.tstamp_ok = tmp_opt.saw_tstamp;
5952 tcp_openreq_init(req, &tmp_opt, skb, sk);
5953
5954 af_ops->init_req(req, sk, skb);
5955
5956 if (security_inet_conn_request(sk, skb, req))
5957 goto drop_and_free;
5958
5957 if (!want_cookie || tmp_opt.tstamp_ok)
5958 tcp_ecn_create_request(req, skb, sk);
5959
5960 if (want_cookie) {
5961 isn = cookie_init_sequence(af_ops, sk, skb, &req->mss);
5962 req->cookie_ts = tmp_opt.tstamp_ok;
5963 } else if (!isn) {
5959 if (!want_cookie && !isn) {
5964 /* VJ's idea. We save last timestamp seen
5965 * from the destination in peer table, when entering
5966 * state TIME-WAIT, and check against it before
5967 * accepting new connection request.
5968 *
5969 * If "isn" is not zero, this request hit alive
5970 * timewait bucket, so that all the necessary checks
5971 * are made in the function processing timewait state.

--- 31 unchanged lines hidden (view full) ---

6003 isn = af_ops->init_seq(skb);
6004 }
6005 if (!dst) {
6006 dst = af_ops->route_req(sk, &fl, req, NULL);
6007 if (!dst)
6008 goto drop_and_free;
6009 }
6010
5960 /* VJ's idea. We save last timestamp seen
5961 * from the destination in peer table, when entering
5962 * state TIME-WAIT, and check against it before
5963 * accepting new connection request.
5964 *
5965 * If "isn" is not zero, this request hit alive
5966 * timewait bucket, so that all the necessary checks
5967 * are made in the function processing timewait state.

--- 31 unchanged lines hidden (view full) ---

5999 isn = af_ops->init_seq(skb);
6000 }
6001 if (!dst) {
6002 dst = af_ops->route_req(sk, &fl, req, NULL);
6003 if (!dst)
6004 goto drop_and_free;
6005 }
6006
6007 tcp_ecn_create_request(req, skb, sk, dst);
6008
6009 if (want_cookie) {
6010 isn = cookie_init_sequence(af_ops, sk, skb, &req->mss);
6011 req->cookie_ts = tmp_opt.tstamp_ok;
6012 if (!tmp_opt.tstamp_ok)
6013 inet_rsk(req)->ecn_ok = 0;
6014 }
6015
6011 tcp_rsk(req)->snt_isn = isn;
6012 tcp_openreq_init_rwin(req, sk, dst);
6013 fastopen = !want_cookie &&
6014 tcp_try_fastopen(sk, skb, req, &foc, dst);
6015 err = af_ops->send_synack(sk, dst, &fl, req,
6016 skb_get_queue_mapping(skb), &foc);
6017 if (!fastopen) {
6018 if (err || want_cookie)

--- 17 unchanged lines hidden ---
6016 tcp_rsk(req)->snt_isn = isn;
6017 tcp_openreq_init_rwin(req, sk, dst);
6018 fastopen = !want_cookie &&
6019 tcp_try_fastopen(sk, skb, req, &foc, dst);
6020 err = af_ops->send_synack(sk, dst, &fl, req,
6021 skb_get_queue_mapping(skb), &foc);
6022 if (!fastopen) {
6023 if (err || want_cookie)

--- 17 unchanged lines hidden ---