From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mail.toke.dk (Postfix) with ESMTPS id 62F5E9CD450 for ; Fri, 9 Dec 2022 01:14:21 +0100 (CET) Authentication-Results: mail.toke.dk; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=UlZhENY0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670544860; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BdvlLliDTtyV2OVNdLvJq1d6SvG4Mioa9Qf7ac2fCF4=; b=UlZhENY0R46k76CF6lWXemPNih+hxsI1JUeX9tyNQPwVGFI374olTOGzQkUdU/kFe7iIXt qxLmp6wic2oimerNtjjLFpKSpmLjKbhc+FiFAeNU0jmUiIYnl3NVmb/12NofYL9SIg2o0z +iwweObTTk6q30cKLlQzPU4UqX6ugBw= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-59-kCK9TG3xOOqkv89KltzwtA-1; Thu, 08 Dec 2022 19:14:19 -0500 X-MC-Unique: kCK9TG3xOOqkv89KltzwtA-1 Received: by mail-ej1-f71.google.com with SMTP id js17-20020a17090797d100b007c0dd8018b6so2019485ejc.17 for ; Thu, 08 Dec 2022 16:14:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4T5sBCl/3CDxr25zUnGc9p87c5wEBV2/DlcV/PFZ2Ac=; b=zjgdt3d5s2OPMIAKJJuKIVCOW+I2NKHhWOUh9rnY9nqO2clTeJ7tA9v4kVrF0Tn9Io QC9rO7jw0QGvFTI8UcXe1Kc7tV/ruq6stZ305IQq0BUhJ/Dzg41g3u5em9IBywSY1CM9 By8LvZ4s8jS2Yh1IZDPGLCRx41b5E17wkTyuVoXKnsg53DPKgBqML7fsJe1AYrfl8v2D jcKqzXO/DkBxM5bqp9ZPtorhkgjqfqDt/CG17eZx2GEkh4kvHEkxkCaKRRPSWdj17sc2 6VpxTtnYv95St+Guk3u7IgrQqC+D76mdv4mvi1JfdwWTYTzj/ANWNktRDtmaYA2oEW// gOtg== X-Gm-Message-State: ANoB5pkeUkmQPfFllXde2PrY4nmgVgpmMcjnd2q/bO8ZnxhHtaJuvtU+ ARjfaSZSxU7PWmBBCO9GFJD8VoOJelhgM8U2RcXNQtfYvvfa5D3J5EEM5x0XIJL3jq/MDYgHYWg cQ97856a4xx0/ObYdjJhz X-Received: by 2002:a05:6402:3985:b0:461:3ae6:8bfc with SMTP id fk5-20020a056402398500b004613ae68bfcmr3791868edb.34.1670544856452; Thu, 08 Dec 2022 16:14:16 -0800 (PST) X-Google-Smtp-Source: AA0mqf4pGscj4T39ekLdKdM3k2JNhFGEY2EQzfwP35Z/evcQY53JRadCWkl1oFCQPRUO4A24tOytvg== X-Received: by 2002:a05:6402:3985:b0:461:3ae6:8bfc with SMTP id fk5-20020a056402398500b004613ae68bfcmr3791804edb.34.1670544854791; Thu, 08 Dec 2022 16:14:14 -0800 (PST) Received: from alrua-x1.borgediget.toke.dk ([2a0c:4d80:42:443::2]) by smtp.gmail.com with ESMTPSA id u26-20020a05640207da00b0046bc2f432dasm20515edy.22.2022.12.08.16.14.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Dec 2022 16:14:14 -0800 (PST) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id 9B62382E9C9; Fri, 9 Dec 2022 01:14:13 +0100 (CET) From: Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= To: Stanislav Fomichev In-Reply-To: References: <20221206024554.3826186-1-sdf@google.com> <87bkodleca.fsf@toke.dk> X-Clacks-Overhead: GNU Terry Pratchett Date: Fri, 09 Dec 2022 01:14:13 +0100 Message-ID: <87wn71juwa.fsf@toke.dk> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 5IM3WIXAFOQF52LYBMFUPUKJP5RTZYZY X-Message-ID-Hash: 5IM3WIXAFOQF52LYBMFUPUKJP5RTZYZY X-MailFrom: toke@redhat.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, David Ahern , 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.7 Precedence: list Subject: [xdp-hints] Re: [PATCH bpf-next v3 00/12] xdp: hints via kfuncs List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Stanislav Fomichev writes: > On Thu, Dec 8, 2022 at 2:29 PM Toke H=C3=B8iland-J=C3=B8rgensen wrote: >> >> Stanislav Fomichev writes: >> >> > Please see the first patch in the series for the overall >> > design and use-cases. >> > >> > Changes since v3: >> > >> > - Rework prog->bound_netdev refcounting (Jakub/Marin) >> > >> > Now it's based on the offload.c framework. It mostly fits, except >> > I had to automatically insert a HT entry for the netdev. In the >> > offloaded case, the netdev is added via a call to >> > bpf_offload_dev_netdev_register from the driver init path; with >> > a dev-bound programs, we have to manually add (and remove) the entry= . >> > >> > As suggested by Toke, I'm also prohibiting putting dev-bound program= s >> > into prog-array map; essentially prohibiting tail calling into it. >> > I'm also disabling freplace of the dev-bound programs. Both of those >> > restrictions can be loosened up eventually. >> >> I thought it would be a shame that we don't support at least freplace >> programs from the get-go (as that would exclude libxdp from taking >> advantage of this). So see below for a patch implementing this :) >> >> -Toke > > Damn, now I need to write a selftest :-) > But seriously, thank you for taking care of this, will try to include > preserving SoB! Cool, thanks! I just realised I made on mistake in the attach check, though: [...] >> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c >> index b345a273f7d0..606e6de5f716 100644 >> --- a/kernel/bpf/syscall.c >> +++ b/kernel/bpf/syscall.c >> @@ -3021,6 +3021,14 @@ static int bpf_tracing_prog_attach(struct bpf_pro= g *prog, >> goto out_put_prog; >> } >> >> + if (bpf_prog_is_dev_bound(tgt_prog->aux) && >> + (bpf_prog_is_offloaded(tgt_prog->aux) || >> + !bpf_prog_is_dev_bound(prog->aux) || >> + !bpf_offload_dev_match(prog, tgt_prog->aux->offload= ->netdev))) { This should switch the order of the is_dev_bound() checks, like: + if (bpf_prog_is_dev_bound(prog->aux) && + (bpf_prog_is_offloaded(tgt_prog->aux) || + !bpf_prog_is_dev_bound(tgt_prog->aux) || + !bpf_offload_dev_match(prog, tgt_prog->aux->offload->n= etdev))) { I.e., first check bpf_prog_is_dev_bound(prog->aux) (the program being attached), and only perform the other checks if we're attaching something that has been verified as being dev-bound. It should be fine to attach a non-devbound function to a devbound parent program (since that non-devbound function can't call any of the kfuncs). -Toke