From patchwork Thu Sep 10 19:20:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neal Cardwell X-Patchwork-Id: 261123 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.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 5D3FAC43461 for ; Thu, 10 Sep 2020 19:21:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2306F20882 for ; Thu, 10 Sep 2020 19:21:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HeThdFtS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727101AbgIJTVj (ORCPT ); Thu, 10 Sep 2020 15:21:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727791AbgIJTU5 (ORCPT ); Thu, 10 Sep 2020 15:20:57 -0400 Received: from mail-qv1-xf41.google.com (mail-qv1-xf41.google.com [IPv6:2607:f8b0:4864:20::f41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68610C0613ED for ; Thu, 10 Sep 2020 12:20:57 -0700 (PDT) Received: by mail-qv1-xf41.google.com with SMTP id cr8so3904569qvb.10 for ; Thu, 10 Sep 2020 12:20:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rtUwEGlyH5UHD/xn4fGHTquuooXbAFvvo/KaYXsXfQ4=; b=HeThdFtSTJrPXrn73TX6TnROS9e2JMbtLXl3GdKwZLryJajLSMlxp2jsMJSY3y1Dbw xm90EeqoEzh2R/cVsYp/3QAAJeJCIiCV4ZcAWWOoWsJCwXvHgaCVtARYbeDcpy+rMrAq lPYbASs2LIw/Wypkqg0gOxYmJuUIJezylz8U0RZnzyczk15iT082gJSw0XaXIEotHcGz r96vjDNA8cxJL03HdOVWk9gW9yZKt66DwJ6Kcd9B7qmVGAEtthfXKci9B/tFeOf9h/W6 Ndl2bnqwKcvz1JjWLSab55Pmn9USp2Gi2cVbbO7zZjKc1OLgkKIMav/aWxdmF8Qs1bKD guNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rtUwEGlyH5UHD/xn4fGHTquuooXbAFvvo/KaYXsXfQ4=; b=ean5NPPs+Ik86lrJoMuHwkL0aCVKPqjjNsVXAGox5+0U6YO66XKXxPf4Vv20+qGNwa fWlejxxvnSRi072BLzWMuC+yOzZtaqpmsZqK61sqykBatc35c1mc2PDin22CAfQX4Cap WzOnHA7rhnq6sgqoWK/tghTWpu7m1JlEM+8U9RooWaKfT8qTXL7hHb+/y6n0f7tPx5Q0 vNx9/lnbxeJhTjgQKaNjw0TMXbSHItotUlDydZ89qYrIXb6haNyU3UPfJE5iInL51z6l JzhzI8Zu9Du8sbpuzszRUqPMBSW1f9e5wfq+xDuI96zLzC9H9ieJwqWpdcrU9KDN/R2n ZGpQ== X-Gm-Message-State: AOAM530XaAIi8vH0TiBwzXfRSIWkC8qvoubqzKhuvHW35NEXfvMQeMNL pKwA5urQpUHZYz3+QpHl7a8= X-Google-Smtp-Source: ABdhPJz14IH219PDpcoRZ1ntvCIYL47a1omErsakj3DEBvxmHhMT4m7jQ3PpEdrNn9b6Boc4IPz0Hg== X-Received: by 2002:ad4:56a6:: with SMTP id bd6mr10308669qvb.29.1599765656651; Thu, 10 Sep 2020 12:20:56 -0700 (PDT) Received: from soy.nyc.corp.google.com ([2620:0:1003:312:7220:84ff:fe09:3008]) by smtp.gmail.com with ESMTPSA id z6sm7315158qkl.39.2020.09.10.12.20.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2020 12:20:56 -0700 (PDT) From: Neal Cardwell To: Alexei Starovoitov Cc: netdev@vger.kernel.org, Neal Cardwell , Yuchung Cheng , Kevin Yang , Eric Dumazet , Lawrence Brakmo Subject: [PATCH bpf-next v2 2/5] tcp: simplify EBPF TCP_CONGESTION to always init CC Date: Thu, 10 Sep 2020 15:20:53 -0400 Message-Id: <20200910192053.2884884-3-ncardwell.kernel@gmail.com> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog In-Reply-To: <20200910192053.2884884-1-ncardwell.kernel@gmail.com> References: <20200910192053.2884884-1-ncardwell.kernel@gmail.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Neal Cardwell Now that the previous patch ensures we don't initialize the congestion control twice, when EBPF sets the congestion control algorithm at connection establishment we can simplify the code by simply initializing the congestion control module at that time. Signed-off-by: Neal Cardwell Acked-by: Yuchung Cheng Acked-by: Kevin Yang Signed-off-by: Eric Dumazet Cc: Lawrence Brakmo --- net/core/filter.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/net/core/filter.c b/net/core/filter.c index 47eef9a0be6a..067f6759a68f 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -4313,8 +4313,6 @@ static const struct bpf_func_proto bpf_get_socket_uid_proto = { .arg1_type = ARG_PTR_TO_CTX, }; -#define SOCKOPT_CC_REINIT (1 << 0) - static int _bpf_setsockopt(struct sock *sk, int level, int optname, char *optval, int optlen, u32 flags) { @@ -4449,13 +4447,12 @@ static int _bpf_setsockopt(struct sock *sk, int level, int optname, sk->sk_prot->setsockopt == tcp_setsockopt) { if (optname == TCP_CONGESTION) { char name[TCP_CA_NAME_MAX]; - bool reinit = flags & SOCKOPT_CC_REINIT; strncpy(name, optval, min_t(long, optlen, TCP_CA_NAME_MAX-1)); name[TCP_CA_NAME_MAX-1] = 0; ret = tcp_set_congestion_control(sk, name, false, - reinit, true); + true, true); } else { struct inet_connection_sock *icsk = inet_csk(sk); struct tcp_sock *tp = tcp_sk(sk); @@ -4652,8 +4649,6 @@ BPF_CALL_5(bpf_sock_ops_setsockopt, struct bpf_sock_ops_kern *, bpf_sock, int, level, int, optname, char *, optval, int, optlen) { u32 flags = 0; - if (bpf_sock->op > BPF_SOCK_OPS_NEEDS_ECN) - flags |= SOCKOPT_CC_REINIT; return _bpf_setsockopt(bpf_sock->sk, level, optname, optval, optlen, flags); } From patchwork Thu Sep 10 19:18:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neal Cardwell X-Patchwork-Id: 261124 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.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 F2E13C07548 for ; Thu, 10 Sep 2020 19:19:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B4F2C214F1 for ; Thu, 10 Sep 2020 19:19:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RZTd/hTz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727113AbgIJTSz (ORCPT ); Thu, 10 Sep 2020 15:18:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727032AbgIJTSl (ORCPT ); Thu, 10 Sep 2020 15:18:41 -0400 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5F48C061573 for ; Thu, 10 Sep 2020 12:18:40 -0700 (PDT) Received: by mail-qk1-x741.google.com with SMTP id w16so7255584qkj.7 for ; Thu, 10 Sep 2020 12:18:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=YGm/soZLl1bn+sbVRybjYRZ/1L0c9JD9QdtdQnC5uSA=; b=RZTd/hTzvCAOXXKWq+3RHc7eTDwyVhdsrfB1xz9CONVK+V+hobTP3Vazx0ZSxxNtrc SIOhOO4LB0LKUO8b/0/j6dUMrPDSnoI5tND7ouNxwtG1NmgZaTvwfjGZ1GboE7ktoru6 qjk5G25oQjnC3iILTTdlFGJQndEuZ6YFzqGWLUKPhlZ2aQZJtwDi8pfe7Vl0+I1UjWc0 6+dzzUPst/uD8NT3xnI7afsxn7Kkw77MMIVy2gQKXIMy/VZ02PaFbOf5BtIrtr5u5uFs llsMOV5Va2Yruyj6JBlWeGLFhPce3Zg3DNNwez5gHR1PONO8d3QpVD2qRAN9uOs0zgEL sK/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=YGm/soZLl1bn+sbVRybjYRZ/1L0c9JD9QdtdQnC5uSA=; b=QzptseK8iTHEZEcEh4QLbO74nr0jfijiC3ko9A9Z74bRx0xM9RYahdtBGLc9bhdqn+ iC/QwUC4O78yaKOXn4PPBgKuhESmjnci1+ICvd/IpKy+tl7j6v0Qo8ngjncGeAL9R9Wx obTEESWjRD6dlo6HJJLxIzjE7Mndx0eCGnSQIN+qORvpWaXiI3wNgzTiZsrPL5eQH2PE VX7yNSIWzOvgKNer7Vv15+3fAsW9C+gBOJYoob0v4bw0QCGV9HtSS1tIFIBBKG+og21e YYRTu+w5+3GuFDnxsIq09Vjzz84MVInkGwPKwBxLEeNH9AcnMstMPpPRnNvg5Atneipe BD3g== X-Gm-Message-State: AOAM532M04fH+QR7Nj16Y/oRNYcrmNV90kfDyZ0f6lctaB5bbJRZSkI+ AiMJd51U5vBf9ldLJ3u3ntIP4hjYO5rUEnDy X-Google-Smtp-Source: ABdhPJwTeRj+TKOR65/XXRHtkYAAyWNQjucG72kH1t685JlG/yJVknwFI65siofuJjk1vPjy/FyyBA== X-Received: by 2002:a37:a88a:: with SMTP id r132mr9073929qke.270.1599765520131; Thu, 10 Sep 2020 12:18:40 -0700 (PDT) Received: from soy.nyc.corp.google.com ([2620:0:1003:312:7220:84ff:fe09:3008]) by smtp.gmail.com with ESMTPSA id v131sm1917623qkb.15.2020.09.10.12.18.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2020 12:18:39 -0700 (PDT) From: Neal Cardwell To: Alexei Starovoitov Cc: netdev@vger.kernel.org, Neal Cardwell , Yuchung Cheng , Kevin Yang , Eric Dumazet , Lawrence Brakmo Subject: [PATCH bpf-next v2 4/5] tcp: simplify _bpf_setsockopt(): remove flags argument Date: Thu, 10 Sep 2020 15:18:38 -0400 Message-Id: <20200910191838.2870445-1-ncardwell.kernel@gmail.com> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Neal Cardwell Now that the previous patches have removed the code that uses the flags argument to _bpf_setsockopt(), we can remove that argument. Signed-off-by: Neal Cardwell Acked-by: Yuchung Cheng Acked-by: Kevin Yang Signed-off-by: Eric Dumazet Cc: Lawrence Brakmo --- net/core/filter.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/net/core/filter.c b/net/core/filter.c index e89d6d7da03c..d266c6941967 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -4314,7 +4314,7 @@ static const struct bpf_func_proto bpf_get_socket_uid_proto = { }; static int _bpf_setsockopt(struct sock *sk, int level, int optname, - char *optval, int optlen, u32 flags) + char *optval, int optlen) { char devname[IFNAMSIZ]; int val, valbool; @@ -4611,9 +4611,7 @@ static int _bpf_getsockopt(struct sock *sk, int level, int optname, BPF_CALL_5(bpf_sock_addr_setsockopt, struct bpf_sock_addr_kern *, ctx, int, level, int, optname, char *, optval, int, optlen) { - u32 flags = 0; - return _bpf_setsockopt(ctx->sk, level, optname, optval, optlen, - flags); + return _bpf_setsockopt(ctx->sk, level, optname, optval, optlen); } static const struct bpf_func_proto bpf_sock_addr_setsockopt_proto = { @@ -4647,9 +4645,7 @@ static const struct bpf_func_proto bpf_sock_addr_getsockopt_proto = { BPF_CALL_5(bpf_sock_ops_setsockopt, struct bpf_sock_ops_kern *, bpf_sock, int, level, int, optname, char *, optval, int, optlen) { - u32 flags = 0; - return _bpf_setsockopt(bpf_sock->sk, level, optname, optval, optlen, - flags); + return _bpf_setsockopt(bpf_sock->sk, level, optname, optval, optlen); } static const struct bpf_func_proto bpf_sock_ops_setsockopt_proto = {