Skip to content

Commit d82bd12

Browse files
Florian Westphaldavem330
authored andcommitted
tcp: move TCP_ECN_create_request out of header
After Octavian Purdilas tcp ipv4/ipv6 unification work this helper only has a single callsite. While at it, convert name to lowercase, suggested by Stephen. Suggested-by: Stephen Hemminger <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2b7fc47 commit d82bd12

File tree

2 files changed

+35
-35
lines changed

2 files changed

+35
-35
lines changed

include/net/tcp.h

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -861,40 +861,6 @@ static inline void tcp_ca_event(struct sock *sk, const enum tcp_ca_event event)
861861
icsk->icsk_ca_ops->cwnd_event(sk, event);
862862
}
863863

864-
/* RFC3168 : 6.1.1 SYN packets must not have ECT/ECN bits set
865-
*
866-
* If we receive a SYN packet with these bits set, it means a
867-
* network is playing bad games with TOS bits. In order to
868-
* avoid possible false congestion notifications, we disable
869-
* TCP ECN negociation.
870-
*
871-
* Exception: tcp_ca wants ECN. This is required for DCTCP
872-
* congestion control; it requires setting ECT on all packets,
873-
* including SYN. We inverse the test in this case: If our
874-
* local socket wants ECN, but peer only set ece/cwr (but not
875-
* ECT in IP header) its probably a non-DCTCP aware sender.
876-
*/
877-
static inline void
878-
TCP_ECN_create_request(struct request_sock *req, const struct sk_buff *skb,
879-
const struct sock *listen_sk)
880-
{
881-
const struct tcphdr *th = tcp_hdr(skb);
882-
const struct net *net = sock_net(listen_sk);
883-
bool th_ecn = th->ece && th->cwr;
884-
bool ect, need_ecn;
885-
886-
if (!th_ecn)
887-
return;
888-
889-
ect = !INET_ECN_is_not_ect(TCP_SKB_CB(skb)->ip_dsfield);
890-
need_ecn = tcp_ca_needs_ecn(listen_sk);
891-
892-
if (!ect && !need_ecn && net->ipv4.sysctl_tcp_ecn)
893-
inet_rsk(req)->ecn_ok = 1;
894-
else if (ect && need_ecn)
895-
inet_rsk(req)->ecn_ok = 1;
896-
}
897-
898864
/* These functions determine how the current flow behaves in respect of SACK
899865
* handling. SACK is negotiated with the peer, and therefore it can vary
900866
* between different flows.

net/ipv4/tcp_input.c

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5906,6 +5906,40 @@ static inline void pr_drop_req(struct request_sock *req, __u16 port, int family)
59065906
#endif
59075907
}
59085908

5909+
/* RFC3168 : 6.1.1 SYN packets must not have ECT/ECN bits set
5910+
*
5911+
* If we receive a SYN packet with these bits set, it means a
5912+
* network is playing bad games with TOS bits. In order to
5913+
* avoid possible false congestion notifications, we disable
5914+
* TCP ECN negociation.
5915+
*
5916+
* Exception: tcp_ca wants ECN. This is required for DCTCP
5917+
* congestion control; it requires setting ECT on all packets,
5918+
* including SYN. We inverse the test in this case: If our
5919+
* local socket wants ECN, but peer only set ece/cwr (but not
5920+
* ECT in IP header) its probably a non-DCTCP aware sender.
5921+
*/
5922+
static void tcp_ecn_create_request(struct request_sock *req,
5923+
const struct sk_buff *skb,
5924+
const struct sock *listen_sk)
5925+
{
5926+
const struct tcphdr *th = tcp_hdr(skb);
5927+
const struct net *net = sock_net(listen_sk);
5928+
bool th_ecn = th->ece && th->cwr;
5929+
bool ect, need_ecn;
5930+
5931+
if (!th_ecn)
5932+
return;
5933+
5934+
ect = !INET_ECN_is_not_ect(TCP_SKB_CB(skb)->ip_dsfield);
5935+
need_ecn = tcp_ca_needs_ecn(listen_sk);
5936+
5937+
if (!ect && !need_ecn && net->ipv4.sysctl_tcp_ecn)
5938+
inet_rsk(req)->ecn_ok = 1;
5939+
else if (ect && need_ecn)
5940+
inet_rsk(req)->ecn_ok = 1;
5941+
}
5942+
59095943
int tcp_conn_request(struct request_sock_ops *rsk_ops,
59105944
const struct tcp_request_sock_ops *af_ops,
59115945
struct sock *sk, struct sk_buff *skb)
@@ -5966,7 +6000,7 @@ int tcp_conn_request(struct request_sock_ops *rsk_ops,
59666000
goto drop_and_free;
59676001

59686002
if (!want_cookie || tmp_opt.tstamp_ok)
5969-
TCP_ECN_create_request(req, skb, sk);
6003+
tcp_ecn_create_request(req, skb, sk);
59706004

59716005
if (want_cookie) {
59726006
isn = cookie_init_sequence(af_ops, sk, skb, &req->mss);

0 commit comments

Comments
 (0)