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=-0.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED 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 F381AC4360F for ; Sun, 24 Feb 2019 01:32:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C226A20855 for ; Sun, 24 Feb 2019 01:32:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="oum9P+/Y" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728048AbfBXBcS (ORCPT ); Sat, 23 Feb 2019 20:32:18 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:39382 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727915AbfBXBcR (ORCPT ); Sat, 23 Feb 2019 20:32:17 -0500 Received: by mail-pl1-f193.google.com with SMTP id 101so2829274pld.6 for ; Sat, 23 Feb 2019 17:32:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=6R3pe0srYOB9mdtjKPoYsmE4dM733Jl00BtoJuFG7wg=; b=oum9P+/YEIfUkVUYeZN9he1l1l2FoE5cLuyTZ15RYvRPB/F4Qknf2ZHc1AgC0GERmW /jaGxlH6QY8aeWbIuUOyy4902ms06xGq2B4pmnpS6vY8MmiN/6fZPve5pMlXl0ib+G9I 5l8CBQY5+Kx2Dxe33XvPQL4rlSG0urM2OLY/x/XwtTmTc+C7AtX2TzeHlpGK0GBvdkYl CDR44VFCFZB8ZG6Qgx2L4//16zsEwtcgTHMBPtVkGIK1cXmE+ySNWlhE5RUMEW5qGuoc 3kzofjDY9lgl1li7pBB9Q8n4mvrEEzwu4P2eD+1RKkkROUP/0FE48Eoo51ELmKImXtsZ uJzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=6R3pe0srYOB9mdtjKPoYsmE4dM733Jl00BtoJuFG7wg=; b=kFYWhf4BKdRQpDLJzqlBwM1Yt1iirXMXMXH9PaNLhJGOc7SOeOueH1n6F6C/9IgXxY Br+tRmedoEO9Xp1gSUba+dpiNi2c9XiWMbiU9xum6w8SzkSX2HFlvg3S4TAnzsRB4DXN +NN/75BvqBSbmApXFoV13fZzTDzvk9Piicg6mFVnP0eVtnJKSshHMvHPCnbkf/vWkFFr SOOPQUovMnHF95/9kPTbGhusjJsRYepjyJNkss+rQFLih4RVfyLzre0n8joszHnpnbse Ee5TRLtxbXWTdg1KHhATG0tqrTKNVLDyMlC53RR8mPfTTw6HtIo1maYr8pXVnW4LylSa yRXQ== X-Gm-Message-State: AHQUAuYjK2f9x1LbTxpqV/XBzrz4DEcimVNeyYT8QBQ8QZDWLtJ3sVJH PhJfFmUHCqMpZDrtWVwGydMBue45 X-Google-Smtp-Source: AHgI3IYbYdnovoeh22Joqr1P8QDS+el6K+51cdTqA+IK97I687v2sf9LPZFVsceB4RzL+1kpDIv2Ig== X-Received: by 2002:a17:902:8d8e:: with SMTP id v14mr11745094plo.133.1550971937083; Sat, 23 Feb 2019 17:32:17 -0800 (PST) Received: from [192.168.86.235] (c-73-241-150-70.hsd1.ca.comcast.net. [73.241.150.70]) by smtp.gmail.com with ESMTPSA id o76sm11658287pfa.156.2019.02.23.17.32.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 23 Feb 2019 17:32:15 -0800 (PST) Subject: Re: [PATCH v2 bpf-next 2/9] bpf: Add bpf helper bpf_tcp_enter_cwr To: brakmo , netdev Cc: Martin Lau , Alexei Starovoitov , Daniel Borkmann , Eric Dumazet , Kernel Team References: <20190223010703.678070-1-brakmo@fb.com> <20190223010703.678070-3-brakmo@fb.com> From: Eric Dumazet Message-ID: <2a218060-8a62-150c-c05e-5433df18aaab@gmail.com> Date: Sat, 23 Feb 2019 17:32:14 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20190223010703.678070-3-brakmo@fb.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 02/22/2019 05:06 PM, brakmo wrote: > From: Martin KaFai Lau > > This patch adds a new bpf helper BPF_FUNC_tcp_enter_cwr > "int bpf_tcp_enter_cwr(struct bpf_tcp_sock *tp)". > It is added to BPF_PROG_TYPE_CGROUP_SKB which can be attached > to the egress path where the bpf prog is called by > ip_finish_output() or ip6_finish_output(). The verifier > ensures that the parameter must be a tcp_sock. > > This helper makes a tcp_sock enter CWR state. It can be used > by a bpf_prog to manage egress network bandwidth limit per > cgroupv2. A later patch will have a sample program to > show how it can be used to limit bandwidth usage per cgroupv2. > > To ensure it is only called from BPF_CGROUP_INET_EGRESS, the > attr->expected_attach_type must be specified as BPF_CGROUP_INET_EGRESS > during load time if the prog uses this new helper. > The newly added prog->enforce_expected_attach_type bit will also be set > if this new helper is used. This bit is for backward compatibility reason > because currently prog->expected_attach_type has been ignored in > BPF_PROG_TYPE_CGROUP_SKB. During attach time, > prog->expected_attach_type is only enforced if the > prog->enforce_expected_attach_type bit is set. > i.e. prog->expected_attach_type is only enforced if this new helper > is used by the prog. > BTW, it seems to me that BPF_CGROUP_INET_EGRESS can be used while the socket lock is not held. Maybe we should fix :/