Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp8575037ybi; Thu, 6 Jun 2019 15:05:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqxXHD/PI7c4O7ntudRGMp82vZoPKscWEuc1bAHHHIvhS8rZ9Su2vH4G4T1rtLRJo+NPSD0u X-Received: by 2002:a63:8449:: with SMTP id k70mr36343pgd.208.1559858711883; Thu, 06 Jun 2019 15:05:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559858711; cv=none; d=google.com; s=arc-20160816; b=aF61skAEuERxf7dur19IHiegWB7kuZa++8KSb/tCNYKf9pzXJdGjebBmcMTbw/pPza NhdPVIwZSHWrA4cA5gLWSsOtRo15nPgLaoaFCd36fOYYJlnj2RJRn2Z57f2ZoSeVgn3M mrP0XA8xvGwMDHmIra4yovMH2NgNsTcJiiyCFWgZ7L/1Y20LFPV1XJZ9HDWVStZIIIso JYsyEqOIYN/AuMLIdyYfUX3LmholEG/7mtwLzTSPwQnyyNT+col0+XIDsBu50pi3iyu4 9LIjz3cZfzUwP6vIg3OMayvRxfX5WmyaC/2oUtVGiQFAksl6451h9mKLKIQf4XsOVI6S Dzbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=+oinAj2JQpBdLbAfKKT+cfQr+/9E9d6Km4RyjfTSDPI=; b=eCnpIoFvkH6JEBL5gIQjU59tqJKIQHMjTLzWxkaDG3wS1Dh63LhJRQbn2ATwbBltTP j8tPFibxa47RYL1ayEoT9GuaqV8OY78DJx0hKiesELQZ0D/YI1e7DWmv0Pm9Sra7DyBf v/kwHjkElNBE2+oY3u/HMOSo6bbBVJmzcQc5bdKCrCSikdKdX/G5avqxZ4DgVce+NXtU KNIr+BxWfP7QtIJnBxNCeL5fmn29v8x1y13Vdau0h8ogvi4Nyzp57PvL/icARu5v/euC wpJgzwvXb0B2KZ2EKg+JRBtksMmWqfp9R4vDQCb792ipo6Nhc3edxyBvM/FoqXcKxZay WgWw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o3si254024pld.102.2019.06.06.15.04.54; Thu, 06 Jun 2019 15:05:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728156AbfFFT7S (ORCPT + 99 others); Thu, 6 Jun 2019 15:59:18 -0400 Received: from www62.your-server.de ([213.133.104.62]:53858 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727082AbfFFT7S (ORCPT ); Thu, 6 Jun 2019 15:59:18 -0400 Received: from [78.46.172.3] (helo=sslproxy06.your-server.de) by www62.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1hYyXa-0003SN-8P; Thu, 06 Jun 2019 21:59:14 +0200 Received: from [178.197.249.21] (helo=linux.home) by sslproxy06.your-server.de with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1hYyXa-000UzF-0V; Thu, 06 Jun 2019 21:59:14 +0200 Subject: Re: [PATCH bpf-next] bpf: allow CGROUP_SKB programs to use bpf_get_current_cgroup_id() helper To: Roman Gushchin Cc: Alexei Starovoitov , "bpf@vger.kernel.org" , Kernel Team , "linux-kernel@vger.kernel.org" , Yonghong Song References: <20190606185911.4089151-1-guro@fb.com> <20190606190752.GA28743@tower.DHCP.thefacebook.com> <20190606195317.GA22965@tower.DHCP.thefacebook.com> From: Daniel Borkmann Message-ID: Date: Thu, 6 Jun 2019 21:59:13 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20190606195317.GA22965@tower.DHCP.thefacebook.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.100.3/25472/Thu Jun 6 10:09:59 2019) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/06/2019 09:53 PM, Roman Gushchin wrote: > On Thu, Jun 06, 2019 at 09:39:35PM +0200, Daniel Borkmann wrote: >> On 06/06/2019 09:08 PM, Roman Gushchin wrote: >>> On Thu, Jun 06, 2019 at 11:59:11AM -0700, Roman Gushchin wrote: >>>> Currently bpf_get_current_cgroup_id() is not supported for >>>> CGROUP_SKB programs. An attempt to load such a program generates an >>>> error like this: >>>> libbpf: >>>> 0: (b7) r6 = 0 >>>> ... >>>> 8: (63) *(u32 *)(r10 -28) = r6 >>>> 9: (85) call bpf_get_current_cgroup_id#80 >>>> unknown func bpf_get_current_cgroup_id#80 >>>> >>>> There are no particular reasons for denying it, >>>> and we have some use cases where it might be useful. >>> >>> Ah, sorry, it's not so simple, as we probably need to take >>> the cgroup pointer from the socket, not from current. >>> >>> So the implementation of the helper should be different >>> for this type of programs. >>> >>> So I wonder if it's better to introduce a new helper >>> bpf_get_sock_cgroup_id()? >>> >>> What do you think? >> >> We do have bpf_skb_cgroup_id(), did you give that a try? > > It also isn't supported for CGROUP_SKB, but other than that looks > exactly what I need. > > Thank you for pointing at it! Yes, the helper would need to be enabled there. Cheers, Daniel