From patchwork Thu Sep 10 16:53:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neal Cardwell X-Patchwork-Id: 1361713 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20161025 header.b=YNttQCF+; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4BnQ732pzjz9sTq for ; Fri, 11 Sep 2020 02:57:51 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725986AbgIJQ5s (ORCPT ); Thu, 10 Sep 2020 12:57:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727095AbgIJQzd (ORCPT ); Thu, 10 Sep 2020 12:55:33 -0400 Received: from mail-qk1-x74a.google.com (mail-qk1-x74a.google.com [IPv6:2607:f8b0:4864:20::74a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14508C061388 for ; Thu, 10 Sep 2020 09:53:20 -0700 (PDT) Received: by mail-qk1-x74a.google.com with SMTP id u23so3970598qku.17 for ; Thu, 10 Sep 2020 09:53:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=S6AuheHIRwyrJQTuUfR58Qd8kmBi7CvFbpaQ8Qcutxg=; b=YNttQCF+B1/hAzcl2uJhy37rwLZYHlOQYNDWR7L0rIRoNo4K5glk919Fqj886W3LSZ 3E3jSggf3TItjZqgO5lxnXTe7JAI6ASWuA+vtqWN1ZwYak2iuIwDABkWmxc9z1HHTFpv He5gZnY90DhbgiR7qgK06Cotnn4fXxP2EIZjsz69P81rt4R/6SPuqspmh5opXE5yfmuG k3X9GqC1ouQ55OdRYHXFmGdFE7X8Y5n51ByIuhjwXTXaPOIT6WMv+jDshS5xPXssKxRw J3lgYK4gRVrDeidtxKiQyZarGR0ntT0U+M5TkESpOqw3oJPDUv7GNBpebCh0+acqOG6v DHyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=S6AuheHIRwyrJQTuUfR58Qd8kmBi7CvFbpaQ8Qcutxg=; b=ITJXL8R6g5X9xAPjqSnLyu2DNIqwlQ8RE5P3xynG8Iizzrce2JXCTDnAweyNPLbGEX +X0QpP9IaZOjwGnDMsMEUSefeHysQD4zq29Msz+Ykb5P09QNjbLYsayjeWFg2rB2CSVx WKnE/FDs8Cvw2GypP/V8JOAhNHcw18zsS2iYQCNpTBQ3P4OYrjC4OT9xyXzN9lNsgODQ ayhVoShSwwxacFbqere/Ptj2h98TMDmay1VrAu2qEZZUeOfJN/RJrIbtYeHoLt4PvK92 MiD4bzNdXEjbrJQ4U1VZKqZ0BTYkB5xuPCxoJIQ4OvPZgznYGUJ8v/d68cTp3HhSl7lo /rwQ== X-Gm-Message-State: AOAM530gIBVk0c0uETz5OL3zJgQun/Q94XTfH9Q5kxUfPryFS7F33uen h90RgW927hASS9E+WZqIZAKsakAJU5CU01Y= X-Google-Smtp-Source: ABdhPJyrz9ZaTwIBkNvZxIjwvnbVIynOzP3cfbLTpgTDUROl0innMbtXgRZiAm3O4eiCFpYLebjPrA+i+Oqh0+8= X-Received: from soy.nyc.corp.google.com ([2620:0:1003:312:7220:84ff:fe09:3008]) (user=ncardwell job=sendgmr) by 2002:ad4:4891:: with SMTP id bv17mr9572494qvb.27.1599756799211; Thu, 10 Sep 2020 09:53:19 -0700 (PDT) Date: Thu, 10 Sep 2020 12:53:17 -0400 Message-Id: <20200910165317.2024700-1-ncardwell@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.526.ge36021eeef-goog Subject: [PATCH bpf-next v2 3/5] tcp: simplify tcp_set_congestion_control(): always reinitialize From: Neal Cardwell To: Alexei Starovoitov Cc: netdev@vger.kernel.org, Neal Cardwell , Yuchung Cheng , Kevin Yang , Eric Dumazet , Lawrence Brakmo Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Now that the previous patches ensure that all call sites for tcp_set_congestion_control() want to initialize congestion control, we can simplify tcp_set_congestion_control() by removing the reinit argument and the code to support it. Signed-off-by: Neal Cardwell Acked-by: Yuchung Cheng Acked-by: Kevin Yang Signed-off-by: Eric Dumazet Cc: Lawrence Brakmo --- include/net/tcp.h | 2 +- net/core/filter.c | 3 +-- net/ipv4/tcp.c | 2 +- net/ipv4/tcp_cong.c | 11 ++--------- 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index e85d564446c6..f857146c17a5 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -1104,7 +1104,7 @@ void tcp_get_available_congestion_control(char *buf, size_t len); void tcp_get_allowed_congestion_control(char *buf, size_t len); int tcp_set_allowed_congestion_control(char *allowed); int tcp_set_congestion_control(struct sock *sk, const char *name, bool load, - bool reinit, bool cap_net_admin); + bool cap_net_admin); u32 tcp_slow_start(struct tcp_sock *tp, u32 acked); void tcp_cong_avoid_ai(struct tcp_sock *tp, u32 w, u32 acked); diff --git a/net/core/filter.c b/net/core/filter.c index 067f6759a68f..e89d6d7da03c 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -4451,8 +4451,7 @@ static int _bpf_setsockopt(struct sock *sk, int level, int optname, 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, - true, true); + ret = tcp_set_congestion_control(sk, name, false, true); } else { struct inet_connection_sock *icsk = inet_csk(sk); struct tcp_sock *tp = tcp_sk(sk); diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 7360d3db2b61..e58ab9db73ff 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -3050,7 +3050,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level, int optname, name[val] = 0; lock_sock(sk); - err = tcp_set_congestion_control(sk, name, true, true, + err = tcp_set_congestion_control(sk, name, true, ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN)); release_sock(sk); diff --git a/net/ipv4/tcp_cong.c b/net/ipv4/tcp_cong.c index d18d7a1ce4ce..a9b0fb52a1ec 100644 --- a/net/ipv4/tcp_cong.c +++ b/net/ipv4/tcp_cong.c @@ -341,7 +341,7 @@ int tcp_set_allowed_congestion_control(char *val) * already initialized. */ int tcp_set_congestion_control(struct sock *sk, const char *name, bool load, - bool reinit, bool cap_net_admin) + bool cap_net_admin) { struct inet_connection_sock *icsk = inet_csk(sk); const struct tcp_congestion_ops *ca; @@ -365,15 +365,8 @@ int tcp_set_congestion_control(struct sock *sk, const char *name, bool load, if (!ca) { err = -ENOENT; } else if (!load) { - const struct tcp_congestion_ops *old_ca = icsk->icsk_ca_ops; - if (bpf_try_module_get(ca, ca->owner)) { - if (reinit) { - tcp_reinit_congestion_control(sk, ca); - } else { - icsk->icsk_ca_ops = ca; - bpf_module_put(old_ca, old_ca->owner); - } + tcp_reinit_congestion_control(sk, ca); } else { err = -EBUSY; } From patchwork Thu Sep 10 16:53: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: 1361712 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20161025 header.b=iM/I39na; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4BnQ6l0ng5z9sTq for ; Fri, 11 Sep 2020 02:57:35 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726882AbgIJQ5a (ORCPT ); Thu, 10 Sep 2020 12:57:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727099AbgIJQzd (ORCPT ); Thu, 10 Sep 2020 12:55:33 -0400 Received: from mail-qv1-xf49.google.com (mail-qv1-xf49.google.com [IPv6:2607:f8b0:4864:20::f49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AEA9C06138B for ; Thu, 10 Sep 2020 09:53:41 -0700 (PDT) Received: by mail-qv1-xf49.google.com with SMTP id y2so3665064qvs.14 for ; Thu, 10 Sep 2020 09:53:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=2TlvW+gem47oqaiPgHzk63tIxcSfaHdErY8i/BUbrtQ=; b=iM/I39naYyxAQmYqXuZeCKrhjethDVQAF0s8c+2VrWZyIVjRMbqKqcXkV29lYbE/at q1IHSjw+ihK/APwEmPgkXhn0aAi0cS6r8GpXpB7HoVDxAvh1MenL9epaAx/zhzmeKdR0 FuqzUu/uvTkVodkEZxOmIZmBFuBOOM95Jh6y+gvB0g/igFO/LfcX28uikZhggJECNoAL JaH9IQgva2zWMMueZb+1FGoTLSX3AlswN9egtg0qYxqHdoFUrAuyYvePDDL6rAwt1XsP 8bLHSf2EF0+0SI5Lxot07NzQ4xZSK5K4YS4JVobcSlN1ZE6xRh2Ih7gBv40E5kbWrhr1 dwYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=2TlvW+gem47oqaiPgHzk63tIxcSfaHdErY8i/BUbrtQ=; b=YjLAbyqeqQgy+zAqbjDmgR0lRWdzIqB/sghOZ7pgIg1kSjovIBb4I6Y1SDZaLOyVbC jCp9xSHWd9u4DoIZK05hyBh0cnwspSWJBf8+hnevNkPO56gmXGp3Q3lSNMRx7bcjzs55 gSKL6C/hjC+iisijRRgfvwj2JCwOrPjnLED7s0/6C4FZKwjfeAzVO1t5VsrAcsnuJqVa N8hUWOuQA49dHjSC1pTFhC3qAIa0rGCLTq2XSiAJfqCIEob0X2NjcZYNUMb81OM+za25 21yxIcFwZYXxUxr1gXOYt32aFkdSUdKQEdk+2Dw0JnSumf702+v4M2LQYnHQ4rxdgmeo iymg== X-Gm-Message-State: AOAM533BdsnzdDfuSk6huX7d8hgoN+tl2nl7z/vdNclem7fL+NI+Tkyc s8BnoxIZpe7X/vW78n1kvRWovBUjco2jGtg= X-Google-Smtp-Source: ABdhPJwS1tZJXOWOtK5Hicfb93xr6uuu+KoS/XWorGuy8+cTG4VxGS7yXX55dv2WmaIkv5SsBJHxRZxmXNtzl5E= X-Received: from soy.nyc.corp.google.com ([2620:0:1003:312:7220:84ff:fe09:3008]) (user=ncardwell job=sendgmr) by 2002:a0c:fbca:: with SMTP id n10mr9462501qvp.123.1599756820524; Thu, 10 Sep 2020 09:53:40 -0700 (PDT) Date: Thu, 10 Sep 2020 12:53:38 -0400 Message-Id: <20200910165338.2028737-1-ncardwell@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.526.ge36021eeef-goog Subject: [PATCH bpf-next v2 4/5] tcp: simplify _bpf_setsockopt(): remove flags argument From: Neal Cardwell To: Alexei Starovoitov Cc: netdev@vger.kernel.org, Neal Cardwell , Yuchung Cheng , Kevin Yang , Eric Dumazet , Lawrence Brakmo Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 = { From patchwork Thu Sep 10 16:53:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neal Cardwell X-Patchwork-Id: 1361711 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20161025 header.b=XUdbLo5f; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4BnQ6c05fnz9sTq for ; Fri, 11 Sep 2020 02:57:28 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726979AbgIJQ5V (ORCPT ); Thu, 10 Sep 2020 12:57:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727101AbgIJQzd (ORCPT ); Thu, 10 Sep 2020 12:55:33 -0400 Received: from mail-qk1-x74a.google.com (mail-qk1-x74a.google.com [IPv6:2607:f8b0:4864:20::74a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52E4EC06138E for ; Thu, 10 Sep 2020 09:53:50 -0700 (PDT) Received: by mail-qk1-x74a.google.com with SMTP id u23so3971616qku.17 for ; Thu, 10 Sep 2020 09:53:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=xA7IbJ3yaVDET7+RE99G6nvD4sMERSruE+q/sYEPOkY=; b=XUdbLo5fsRgZxPVP3yAbJSxea+yI+YdMMlXPmCsLu6nvZaC820S6+Ma9TgXnOBM0oE swVMorBF8bUP0ga/WUl0G2Ob7Bxgv2ILom+8SJCIy8/e0MIvEPzQGSO4nKpkCzuflKeU WUB+MJWFPVMl8CVuWWPK71IBigF6+xz1sphE46moJcDAykXOllvHEOzZGzQQQhnPpl/a YqQxAhj9Uih0gVyrxmQBHIzVgURklPTk+54IE/LIOuCZQfW+MqGW15aoEeeuQiZ9zyyz GMqnn63Lj+WeYTaUK648r1PglgSct1b7SJZQ5QHm6XcOFgU2g+0+780gS1ZAG3FFcdmm xWhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=xA7IbJ3yaVDET7+RE99G6nvD4sMERSruE+q/sYEPOkY=; b=TRdZcYCJnbmiOUf1Uj/tjNTO3tlQ+ywiTXSg03SM9ISmLLfyUzLAnym0BnjfIiVQb1 gAt9LMFPQYb/xSuo20Tcu2G/AH8cryQoC4H7BNTo5ip3O2umNbQ33y2GW22ddjlGNX15 wVJdzrYDb/4esY3DW0pc8fbp8/lJ9AYHR8J+4s2+037zxTA71eEfMDOJmvQ+GraoESix 7PH3tcH9Vnhh67fiuso+zdziJN1nbncUfNbBCE6WqXELCzBtb8rg9Fx8DbXrnyygYaTW ErnUZZJI/F8+LKlWT16dF+4Iq81L91aF6JYLcaa2OYgB2v6Md3Pk6TLnOH2MIcbRYa/s h0QQ== X-Gm-Message-State: AOAM531PdT0AFzbdwqMAu3R8SUkdDjJGjjWeMX8E58rsN8DZwsp1Eq6X 8ND+6jgjW/iboy8AMVXmc9nHmezje351Nuc= X-Google-Smtp-Source: ABdhPJxfeJSqv6PfZ0s3RbzjlJhevlrx5pwRq2o6VFCC621ttCF37+geB+RKjG77fA+A4MdokQzuas4NszsjRzc= X-Received: from soy.nyc.corp.google.com ([2620:0:1003:312:7220:84ff:fe09:3008]) (user=ncardwell job=sendgmr) by 2002:a0c:9c84:: with SMTP id i4mr8922353qvf.112.1599756829425; Thu, 10 Sep 2020 09:53:49 -0700 (PDT) Date: Thu, 10 Sep 2020 12:53:47 -0400 Message-Id: <20200910165347.2031665-1-ncardwell@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.526.ge36021eeef-goog Subject: [PATCH bpf-next v2 5/5] tcp: simplify tcp_set_congestion_control() load=false case From: Neal Cardwell To: Alexei Starovoitov Cc: netdev@vger.kernel.org, Neal Cardwell , Martin KaFai Lau , Lawrence Brakmo , Eric Dumazet , Yuchung Cheng , Kevin Yang Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Simplify tcp_set_congestion_control() by removing the initialization code path for the !load case. There are only two call sites for tcp_set_congestion_control(). The EBPF call site is the only one that passes load=false; it also passes cap_net_admin=true. Because of that, the exact same behavior can be achieved by removing the special if (!load) branch of the logic. Both before and after this commit, the EBPF case will call bpf_try_module_get(), and if that succeeds then call tcp_reinit_congestion_control() or if that fails then return EBUSY. Note that this returns the logic to a structure very similar to the structure before: commit 91b5b21c7c16 ("bpf: Add support for changing congestion control") except that the CAP_NET_ADMIN status is passed in as a function argument. This clean-up was suggested by Martin KaFai Lau. Signed-off-by: Neal Cardwell Suggested-by: Martin KaFai Lau Cc: Lawrence Brakmo Cc: Eric Dumazet Cc: Yuchung Cheng Cc: Kevin Yang --- net/ipv4/tcp_cong.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/net/ipv4/tcp_cong.c b/net/ipv4/tcp_cong.c index a9b0fb52a1ec..db47ac24d057 100644 --- a/net/ipv4/tcp_cong.c +++ b/net/ipv4/tcp_cong.c @@ -362,21 +362,14 @@ int tcp_set_congestion_control(struct sock *sk, const char *name, bool load, goto out; } - if (!ca) { + if (!ca) err = -ENOENT; - } else if (!load) { - if (bpf_try_module_get(ca, ca->owner)) { - tcp_reinit_congestion_control(sk, ca); - } else { - err = -EBUSY; - } - } else if (!((ca->flags & TCP_CONG_NON_RESTRICTED) || cap_net_admin)) { + else if (!((ca->flags & TCP_CONG_NON_RESTRICTED) || cap_net_admin)) err = -EPERM; - } else if (!bpf_try_module_get(ca, ca->owner)) { + else if (!bpf_try_module_get(ca, ca->owner)) err = -EBUSY; - } else { + else tcp_reinit_congestion_control(sk, ca); - } out: rcu_read_unlock(); return err;