From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-io1-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) by mail.toke.dk (Postfix) with ESMTPS id F1CAA9AFB26 for ; Thu, 27 Oct 2022 22:10:46 +0200 (CEST) Authentication-Results: mail.toke.dk; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=Vb1nzl9l Received: by mail-io1-xd36.google.com with SMTP id p141so2708644iod.6 for ; Thu, 27 Oct 2022 13:10:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=b7m5/Wn1VQoIT3QEOaJrd2CbN7j3NScHjsuJE5XleaQ=; b=Vb1nzl9l3hATuoemmggmsmAl24QZRTfheup9MjMXIpq4wb9w6MQ2K1QrwiKvwM90sm x3GbGcVCAEv8z6e/hxes8PsdYM4+bU5mkICCOnb9SfGCZJ5hYiKTWQyTZzmYoe3S0TxW QjUfMoYZ2DJw4J6Mt5KWAFyFKN/Ev/dH3gVocPc+McpICTuvdSMTrpKavmyitTg3qxqC hy1dg5eFjJpqiXEWwVUhqCYn6YojRkYZrQPDRCi1vXdiq1jb8mwgy5AHqIf2LJCqGsDW HZSWO/akP376vE2kOZBna2mLROX9S82i+YH/ThweFgpKsKOEsp7SmDhw4jvxo+rcSgyF 8fZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=b7m5/Wn1VQoIT3QEOaJrd2CbN7j3NScHjsuJE5XleaQ=; b=lmjPjWn8fmUPVXhjy0eZql+7FVOHwX2+BdrgF4iW8r2bpeE0J8+2T+mm6gMe5WKmdb RRCIV/RGLEPa214zsZ7RND3dvTNy+CdNKNWKjr4pXWedi46VCz6aU488oR7Vy+C2vhdX EyB05nb1Oc3n7JN2KQ/xQV+ae7j2ghog35GU4rA9crG9MWKirLRvZYozEcQnSV6+RvFE qalSDVTtATV/k0+X/YANSY2HlKpeuzpUXqo+euU4Yzd2azfZGaGovukJgpfUczTRHCR1 jI43SOzgZe+1TW3uuaqabqfcbgftV7o96vDzPSiIsvhjWq4ez1zx3imzfvY5fissvNVC vRCA== X-Gm-Message-State: ACrzQf18O0ZHbZOczJncPnTpJYVaSqksPn27cCI6Sjjm7ZuZ1I4z4Smm HaZzvXNrI+tNACKGPBuZTgZvkxexf+rAhyU0isR6TQ== X-Google-Smtp-Source: AMsMyM53fMrRH5graXVt/8fPM1BLXWdIPfu7BZ9i7KSEUcVEVWLW++jk/o/kJ3A+i0YqnhNJFItThjeFJPHQpV+4+h8= X-Received: by 2002:a5e:c80b:0:b0:6c0:8106:f229 with SMTP id y11-20020a5ec80b000000b006c08106f229mr7846062iol.49.1666901445137; Thu, 27 Oct 2022 13:10:45 -0700 (PDT) MIME-Version: 1.0 References: <20221027200019.4106375-1-sdf@google.com> <20221027200019.4106375-4-sdf@google.com> In-Reply-To: From: Stanislav Fomichev Date: Thu, 27 Oct 2022 13:10:33 -0700 Message-ID: To: Andrii Nakryiko Content-Type: text/plain; charset="UTF-8" Message-ID-Hash: 3URSF46A6I6JXSLCGRNWGMSGPXFTORMG X-Message-ID-Hash: 3URSF46A6I6JXSLCGRNWGMSGPXFTORMG X-MailFrom: sdf@google.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, song@kernel.org, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, haoluo@google.com, jolsa@kernel.org, Jakub Kicinski , Willem de Bruijn , Jesper Dangaard Brouer , Anatoly Burakov , Alexander Lobakin , Magnus Karlsson , Maryam Tahhan , xdp-hints@xdp-project.net, netdev@vger.kernel.org X-Mailman-Version: 3.3.5 Precedence: list Subject: [xdp-hints] Re: [RFC bpf-next 3/5] libbpf: Pass prog_ifindex via bpf_object_open_opts List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Thu, Oct 27, 2022 at 1:05 PM Andrii Nakryiko wrote: > > On Thu, Oct 27, 2022 at 1:00 PM Stanislav Fomichev wrote: > > > > Allow passing prog_ifindex to BPF_PROG_LOAD. This patch is > > not XDP metadata specific but it's here because we (ab)use > > prog_ifindex as "target metadata" device during loading. > > We can figure out proper UAPI story if we decide to go forward > > with the kfunc approach. > > > > Cc: Martin KaFai Lau > > Cc: Jakub Kicinski > > Cc: Willem de Bruijn > > Cc: Jesper Dangaard Brouer > > Cc: Anatoly Burakov > > Cc: Alexander Lobakin > > Cc: Magnus Karlsson > > Cc: Maryam Tahhan > > Cc: xdp-hints@xdp-project.net > > Cc: netdev@vger.kernel.org > > Signed-off-by: Stanislav Fomichev > > --- > > tools/lib/bpf/libbpf.c | 1 + > > tools/lib/bpf/libbpf.h | 6 +++++- > > 2 files changed, 6 insertions(+), 1 deletion(-) > > > > diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c > > index 5d7819edf074..61bc37006fe4 100644 > > --- a/tools/lib/bpf/libbpf.c > > +++ b/tools/lib/bpf/libbpf.c > > @@ -7190,6 +7190,7 @@ static int bpf_object_init_progs(struct bpf_object *obj, const struct bpf_object > > > > prog->type = prog->sec_def->prog_type; > > prog->expected_attach_type = prog->sec_def->expected_attach_type; > > + prog->prog_ifindex = opts->prog_ifindex; > > > > /* sec_def can have custom callback which should be called > > * after bpf_program is initialized to adjust its properties > > diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h > > index eee883f007f9..4a40b7623099 100644 > > --- a/tools/lib/bpf/libbpf.h > > +++ b/tools/lib/bpf/libbpf.h > > @@ -170,9 +170,13 @@ struct bpf_object_open_opts { > > */ > > __u32 kernel_log_level; > > > > + /* Optional ifindex of netdev for offload purposes. > > + */ > > + int prog_ifindex; > > + > > nope, don't do that, open_opts are for entire object, while this is > per-program thing > > So bpf_program__set_ifindex() setter would be more appropriate Oh, doh, not sure how I missed that. Thanks! > > > size_t :0; > > }; > > -#define bpf_object_open_opts__last_field kernel_log_level > > +#define bpf_object_open_opts__last_field prog_ifindex > > > > LIBBPF_API struct bpf_object *bpf_object__open(const char *path); > > > > -- > > 2.38.1.273.g43a17bfeac-goog > >