Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2874138pxb; Tue, 19 Jan 2021 08:08:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJxzJdzzqZmwu15EoMbdvG3jCe7veck3Kcb+vd2vDHAJ1vbNsmNm9Yz4iFKS+NCBAgeDBH0o X-Received: by 2002:a17:906:2c4e:: with SMTP id f14mr3528864ejh.432.1611072487162; Tue, 19 Jan 2021 08:08:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611072487; cv=none; d=google.com; s=arc-20160816; b=bx5g8KqE9gRRPfaVquui7ltj/QUCMGt/BZuTFlgskdMxczAmXH1b+VS1XjFsvQ8ZBo qfOukty8tI+dTBAacnbKUyI8Kt9QNq+k9OMaXKU1vC7bBMa6G2F38QyrVAz9SsGc047O SgbfM6yWm+zrNOGvkNSkhzesPLCJA3FdlAAo3SqqIiANdm1Rmm67Wo4xLIKh632jehMz i3YfvmlnfzqM+hOeFT4PkppUElTItL8Hv3IRGzvN0bMfhMEGmOpOaUJdqPMz65V1wJkS kztlFqBWmem69M5Gx7PdEur4ajDWB+OW+8IRAX8MEZtt/gI+5XSw4ehMOV6397Ys0eJO orIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=xnSHKTtadAAW6f/V6v1P54dpn5XhZcWC2sCdL18R9nM=; b=XlkcX7xmIl/KG66bA06dIkQB02jBlOU+GBr4Ta1tNih64+K049PEPkFoeW+W0+ZR1T KnvqUTECMU0Bx7hJnMT0ythUWAN13ffZ0YXvIsP8Edv8rYZoODwgDuV1a18IbnKjSufD XkthS7woH2QMu+63XUtxUR4RpxXFrztK7GU6MCFLXrT2PVbzHxxZtFWXbJhttfPQPSch URSmDiPjEhJgNRTblECu28l4narU+0guuKNuV/Jlr357IZ3BHg6KQRwEwdHCH17VISg1 74y6sAjI5tgjwTPnWaWBYUUMaKA5Zzi3Th2pfw10QPc89AMRjoCwzFBwOBIzqCr8fyay x7Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="BCz/IO67"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t5si8298809ejy.497.2021.01.19.08.07.43; Tue, 19 Jan 2021 08:08:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="BCz/IO67"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391602AbhASQFA (ORCPT + 99 others); Tue, 19 Jan 2021 11:05:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391226AbhASQA3 (ORCPT ); Tue, 19 Jan 2021 11:00:29 -0500 Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70012C061574 for ; Tue, 19 Jan 2021 07:59:49 -0800 (PST) Received: by mail-io1-xd30.google.com with SMTP id w18so40555761iot.0 for ; Tue, 19 Jan 2021 07:59:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xnSHKTtadAAW6f/V6v1P54dpn5XhZcWC2sCdL18R9nM=; b=BCz/IO67zgT9CdPUsNFpVQqiCBjOVaMK/Pax9eNFPRuTiMeljI8vVrfwgwPLLQjAS4 Tikti9KuYz6SSyNawS4HSnT31Tysbz2DTAYV+HiWMN2c5lswqB2gOQ1HOjDuXgOl0D4E 4z5lBRztA4DJSLN/+W/OVX/rw5LoMqUxnWuA0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xnSHKTtadAAW6f/V6v1P54dpn5XhZcWC2sCdL18R9nM=; b=J40VGDMUpoz4O6Nm5tO0NmjgyNyGtIE87xCm6LVEeEIrwMriCQkpLPuxazG6StDYSo lCSvpXZLZ1pcsdGRGvPkmPJbXP5GKUPMA2DctNO/Ewz/vB35pvgpGUvolyZlFjVXKrHh z6P3KrxJs6pDDs3ctlHn4Scs2l3/Htv79b8h8RzXStUVIjgXXybvJ5u9rU90NvTkfG6H DGc5Q7NOE2JuXlnVSqL6OUqT5zlYqOzPB0u06mWo0hFvkQtS+8GM05WjZMMh127etFdC GmQqCCBf3a4lfWHz/T3cGMZ0vL4Ek60+RKzAJTnwWWG55PVPH7Jj6zV6oEMYhh1HhUzQ vBkA== X-Gm-Message-State: AOAM530Fx74OO14TlDZ9Er6GvrfhH6htRj3MsXVkb9/3HSZLW1ae1h8S oVP4cRaYxIh1BQ6T44ekmRAIEpeqAQzAzE8WdSEJJA== X-Received: by 2002:a5e:8d03:: with SMTP id m3mr3547547ioj.130.1611071988858; Tue, 19 Jan 2021 07:59:48 -0800 (PST) MIME-Version: 1.0 References: <20201209132636.1545761-1-revest@chromium.org> <20201209132636.1545761-2-revest@chromium.org> In-Reply-To: From: Florent Revest Date: Tue, 19 Jan 2021 16:59:38 +0100 Message-ID: Subject: Re: [PATCH bpf-next v4 2/4] bpf: Expose bpf_get_socket_cookie to tracing programs To: Daniel Borkmann Cc: bpf , Alexei Starovoitov , Andrii Nakryiko , KP Singh , Martin KaFai Lau , open list Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 9, 2020 at 5:35 PM Daniel Borkmann wrote: > > On 12/9/20 2:26 PM, Florent Revest wrote: > > This needs two new helpers, one that works in a sleepable context (using > > sock_gen_cookie which disables/enables preemption) and one that does not > > (for performance reasons). Both take a struct sock pointer and need to > > check it for NULLness. > > > > This helper could also be useful to other BPF program types such as LSM. > > Looks like this commit description is now stale and needs to be updated > since we only really add one helper? > > > Signed-off-by: Florent Revest > > --- > > include/linux/bpf.h | 1 + > > include/uapi/linux/bpf.h | 7 +++++++ > > kernel/trace/bpf_trace.c | 2 ++ > > net/core/filter.c | 12 ++++++++++++ > > tools/include/uapi/linux/bpf.h | 7 +++++++ > > 5 files changed, 29 insertions(+) > > > > diff --git a/include/linux/bpf.h b/include/linux/bpf.h > > index 07cb5d15e743..5a858e8c3f1a 100644 > > --- a/include/linux/bpf.h > > +++ b/include/linux/bpf.h > > @@ -1860,6 +1860,7 @@ extern const struct bpf_func_proto bpf_per_cpu_ptr_proto; > > extern const struct bpf_func_proto bpf_this_cpu_ptr_proto; > > extern const struct bpf_func_proto bpf_ktime_get_coarse_ns_proto; > > extern const struct bpf_func_proto bpf_sock_from_file_proto; > > +extern const struct bpf_func_proto bpf_get_socket_ptr_cookie_proto; > > > > const struct bpf_func_proto *bpf_tracing_func_proto( > > enum bpf_func_id func_id, const struct bpf_prog *prog); > > diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h > > index ba59309f4d18..9ac66cf25959 100644 > > --- a/include/uapi/linux/bpf.h > > +++ b/include/uapi/linux/bpf.h > > @@ -1667,6 +1667,13 @@ union bpf_attr { > > * Return > > * A 8-byte long unique number. > > * > > + * u64 bpf_get_socket_cookie(void *sk) > > + * Description > > + * Equivalent to **bpf_get_socket_cookie**\ () helper that accepts > > + * *sk*, but gets socket from a BTF **struct sock**. > > Maybe add a small comment that this one also works for sleepable [tracing] progs? > > > + * Return > > + * A 8-byte long unique number. > > ... or 0 if *sk* is NULL. Argh, I somehow missed this email during my holidays, I'm sending a v5. Thank you Daniel!