From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92DA4C433E1 for ; Thu, 20 Aug 2020 19:00:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 746772087D for ; Thu, 20 Aug 2020 19:00:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=fb.com header.i=@fb.com header.b="TWoZZc3r" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726947AbgHTTAi (ORCPT ); Thu, 20 Aug 2020 15:00:38 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:23130 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726664AbgHTTAf (ORCPT ); Thu, 20 Aug 2020 15:00:35 -0400 Received: from pps.filterd (m0148460.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 07KJ02iB010869 for ; Thu, 20 Aug 2020 12:00:34 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=gmQUq+IojeDvaFbMMD3RuCTOTsK3YeNOZ0+N5eQs7ZY=; b=TWoZZc3r/6iK8KWSGrGZevzsdhcXQgyw/ribZUgyLbVeMl9EfA13SPg8pY49O2igZhFH SOm/m/T8Bw4cfBxz+CHfzBaMM06QKJZ1rq4F0Fye0g7hywkLPCRc2nfBkS7slsD/XOkX UVtnEEJewTFGx7n3WBF+GNLPYFnrpTfH3/k= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com with ESMTP id 3318g0pbgw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Thu, 20 Aug 2020 12:00:34 -0700 Received: from intmgw002.03.ash8.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:83::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 20 Aug 2020 12:00:33 -0700 Received: by devbig005.ftw2.facebook.com (Postfix, from userid 6611) id 57EAD2945825; Thu, 20 Aug 2020 12:00:27 -0700 (PDT) Smtp-Origin-Hostprefix: devbig From: Martin KaFai Lau Smtp-Origin-Hostname: devbig005.ftw2.facebook.com To: CC: Alexei Starovoitov , Daniel Borkmann , Eric Dumazet , , Lawrence Brakmo , Neal Cardwell , , Yuchung Cheng , John Fastabend Smtp-Origin-Cluster: ftw2c04 Subject: [PATCH v5 bpf-next 03/12] tcp: bpf: Add TCP_BPF_RTO_MIN for bpf_setsockopt Date: Thu, 20 Aug 2020 12:00:27 -0700 Message-ID: <20200820190027.2884170-1-kafai@fb.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200820190008.2883500-1-kafai@fb.com> References: <20200820190008.2883500-1-kafai@fb.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-FB-Internal: Safe Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-08-20_03:2020-08-19,2020-08-20 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 phishscore=0 spamscore=0 lowpriorityscore=0 clxscore=1015 bulkscore=0 priorityscore=1501 mlxlogscore=999 suspectscore=13 mlxscore=0 adultscore=0 malwarescore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008200151 X-FB-Internal: deliver Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org This patch adds bpf_setsockopt(TCP_BPF_RTO_MIN) to allow bpf prog to set the min rto of a connection. It could be used together with the earlier patch which has added bpf_setsockopt(TCP_BPF_DELACK_MAX)= . A later selftest patch will communicate the max delay ack in a bpf tcp header option and then the receiving side can use bpf_setsockopt(TCP_BPF_RTO_MIN) to set a shorter rto. Acked-by: John Fastabend Reviewed-by: Eric Dumazet Signed-off-by: Martin KaFai Lau --- include/net/inet_connection_sock.h | 1 + include/net/tcp.h | 2 +- include/uapi/linux/bpf.h | 1 + net/core/filter.c | 7 +++++++ net/ipv4/tcp.c | 2 ++ tools/include/uapi/linux/bpf.h | 1 + 6 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connec= tion_sock.h index da7264a1ebfc..c738abeb3265 100644 --- a/include/net/inet_connection_sock.h +++ b/include/net/inet_connection_sock.h @@ -86,6 +86,7 @@ struct inet_connection_sock { struct timer_list icsk_retransmit_timer; struct timer_list icsk_delack_timer; __u32 icsk_rto; + __u32 icsk_rto_min; __u32 icsk_delack_max; __u32 icsk_pmtu_cookie; const struct tcp_congestion_ops *icsk_ca_ops; diff --git a/include/net/tcp.h b/include/net/tcp.h index eab6c7510b5b..dda778c782fe 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -699,7 +699,7 @@ static inline void tcp_fast_path_check(struct sock *s= k) static inline u32 tcp_rto_min(struct sock *sk) { const struct dst_entry *dst =3D __sk_dst_get(sk); - u32 rto_min =3D TCP_RTO_MIN; + u32 rto_min =3D inet_csk(sk)->icsk_rto_min; =20 if (dst && dst_metric_locked(dst, RTAX_RTO_MIN)) rto_min =3D dst_metric_rtt(dst, RTAX_RTO_MIN); diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index f5d9549c52dc..4bd75c12476b 100644 --- a/include/uapi/linux/bpf.h +++ b/include/uapi/linux/bpf.h @@ -4251,6 +4251,7 @@ enum { TCP_BPF_IW =3D 1001, /* Set TCP initial congestion window */ TCP_BPF_SNDCWND_CLAMP =3D 1002, /* Set sndcwnd_clamp */ TCP_BPF_DELACK_MAX =3D 1003, /* Max delay ack in usecs */ + TCP_BPF_RTO_MIN =3D 1004, /* Min delay ack in usecs */ }; =20 struct bpf_perf_event_value { diff --git a/net/core/filter.c b/net/core/filter.c index 80fe7420f609..075ab71b985c 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -4488,6 +4488,13 @@ static int _bpf_setsockopt(struct sock *sk, int le= vel, int optname, return -EINVAL; inet_csk(sk)->icsk_delack_max =3D timeout; break; + case TCP_BPF_RTO_MIN: + timeout =3D usecs_to_jiffies(val); + if (timeout > TCP_RTO_MIN || + timeout < TCP_TIMEOUT_MIN) + return -EINVAL; + inet_csk(sk)->icsk_rto_min =3D timeout; + break; case TCP_SAVE_SYN: if (val < 0 || val > 1) ret =3D -EINVAL; diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 44c353a39ad4..6075cb091a20 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -418,6 +418,7 @@ void tcp_init_sock(struct sock *sk) INIT_LIST_HEAD(&tp->tsorted_sent_queue); =20 icsk->icsk_rto =3D TCP_TIMEOUT_INIT; + icsk->icsk_rto_min =3D TCP_RTO_MIN; icsk->icsk_delack_max =3D TCP_DELACK_MAX; tp->mdev_us =3D jiffies_to_usecs(TCP_TIMEOUT_INIT); minmax_reset(&tp->rtt_min, tcp_jiffies32, ~0U); @@ -2686,6 +2687,7 @@ int tcp_disconnect(struct sock *sk, int flags) icsk->icsk_backoff =3D 0; icsk->icsk_probes_out =3D 0; icsk->icsk_rto =3D TCP_TIMEOUT_INIT; + icsk->icsk_rto_min =3D TCP_RTO_MIN; icsk->icsk_delack_max =3D TCP_DELACK_MAX; tp->snd_ssthresh =3D TCP_INFINITE_SSTHRESH; tp->snd_cwnd =3D TCP_INIT_CWND; diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bp= f.h index f5d9549c52dc..4bd75c12476b 100644 --- a/tools/include/uapi/linux/bpf.h +++ b/tools/include/uapi/linux/bpf.h @@ -4251,6 +4251,7 @@ enum { TCP_BPF_IW =3D 1001, /* Set TCP initial congestion window */ TCP_BPF_SNDCWND_CLAMP =3D 1002, /* Set sndcwnd_clamp */ TCP_BPF_DELACK_MAX =3D 1003, /* Max delay ack in usecs */ + TCP_BPF_RTO_MIN =3D 1004, /* Min delay ack in usecs */ }; =20 struct bpf_perf_event_value { --=20 2.24.1