From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oa1-x31.google.com (mail-oa1-x31.google.com [IPv6:2001:4860:4864:20::31]) by mail.toke.dk (Postfix) with ESMTPS id 2C0049C529F for ; Wed, 23 Nov 2022 19:43:23 +0100 (CET) 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=idwkY7GH Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-141ca09c2fbso21817432fac.6 for ; Wed, 23 Nov 2022 10:43:23 -0800 (PST) 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=c0t74MXl6nH5L2C+5sw1H3tquYD8JkWEtFmdTJPjP08=; b=idwkY7GHLVQ7hCCiDDUZmTd/EmSOwEt3N8+LRgjoF2Z//xfKlM4bQzfhWuGuErqyj+ +tBUabl8xTyvc2upUjZ4Nede/EG/5NwvW2EleDlupjRZ1ySfAKD2BQjtQI2sK9Qz/kks IC4XjKevOqpTMjw7Vch9Imd3lsbsOeJf45NwRbwixhvBiQJXlzbCBimbVUai7V6ZdyI/ 98S2IiO+fkHjtnRB4l165Bku0ur/RoRDAH31KvtzeNnklsDv+gkZATMoh+JFG8B5Ozz2 k5W6tBzMLSdNZQMiXHZyR4f21gcIHOHQ4gD/3geOvSy6aHLhxyv7YJbSvo1LQh81H2X3 t/ug== 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=c0t74MXl6nH5L2C+5sw1H3tquYD8JkWEtFmdTJPjP08=; b=fOOTxukY2ioxLkm9E+SUF+cDNMWgzVYfCiUJ0M1OooIuq/9NXLiMabISR94mTmW4Zl z3Ql/t/9nXdLIR+WGEqVEylNyJLS9AwVWJQDNk710agPVAa273vjUjn7ZsijVrsLzFvk 57dmxZewQ4SYD9w6JerEF5q/Fp/nY5tzHLphr8Bz43s+zq4hqDbjBfhCHGoyU9QezbtM TW43n5fcsScZqXKR8EHCQz6B294mfXh56CaX9bUxAWnQTXYza9VkSY3PTHh7sQJ72Dje K4ACQMSWRljimkA3tCmQ01Wn4+HNT+spne0R3pRogxcpBZKFN3FBeQGNycX4BukUsl6B YFhQ== X-Gm-Message-State: ANoB5plnCfQuWez3cmBtm1RwwLGMW7nk0PP9v3F8Gy9fCUmVX/mTSgDn Phts1wdjrYnMpVoy7yywWUZhChrg+MndzghCguWwXg== X-Google-Smtp-Source: AA0mqf77/PfMjTc7v4fLoFhXlO1WYQyFM3Eqep7QyKuDK32wM4Biw21WEAObp0qsqrz/4tlg0n6/6VHW0YtDnySK6Bk= X-Received: by 2002:a05:6870:c18a:b0:142:870e:bd06 with SMTP id h10-20020a056870c18a00b00142870ebd06mr13974912oad.181.1669228999660; Wed, 23 Nov 2022 10:43:19 -0800 (PST) MIME-Version: 1.0 References: <20221121182552.2152891-1-sdf@google.com> <20221121182552.2152891-3-sdf@google.com> In-Reply-To: From: Stanislav Fomichev Date: Wed, 23 Nov 2022 10:43:08 -0800 Message-ID: To: Martin KaFai Lau Content-Type: text/plain; charset="UTF-8" Message-ID-Hash: J4SCH2EYL33TKA2RIAXZV5P2WVIP2H3J X-Message-ID-Hash: J4SCH2EYL33TKA2RIAXZV5P2WVIP2H3J 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: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, 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, bpf@vger.kernel.org X-Mailman-Version: 3.3.7 Precedence: list Subject: [xdp-hints] Re: [PATCH bpf-next v2 2/8] bpf: XDP metadata RX kfuncs List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Tue, Nov 22, 2022 at 10:34 PM Martin KaFai Lau wrote: > > On 11/21/22 10:25 AM, Stanislav Fomichev wrote: > > --- a/kernel/bpf/core.c > > +++ b/kernel/bpf/core.c > > @@ -2576,6 +2576,7 @@ static void bpf_prog_free_deferred(struct work_struct *work) > > } else { > > bpf_jit_free(aux->prog); > > } > > + dev_put(aux->xdp_netdev); > > I think dev_put needs to be done during unregister_netdevice event also. > Otherwise, a loaded bpf prog may hold the dev for a long time. May be there is > ideas in offload.c. Let me try to play with a veth pair to make sure the proper cleanup triggers. I see your point that we now seemingly have to detach/unload the program to trigger netdev cleanup.. > [ ... ] > > > diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c > > index 35972afb6850..ece7f9234b2d 100644 > > --- a/kernel/bpf/syscall.c > > +++ b/kernel/bpf/syscall.c > > @@ -2491,7 +2491,8 @@ static int bpf_prog_load(union bpf_attr *attr, bpfptr_t uattr) > > BPF_F_TEST_STATE_FREQ | > > BPF_F_SLEEPABLE | > > BPF_F_TEST_RND_HI32 | > > - BPF_F_XDP_HAS_FRAGS)) > > + BPF_F_XDP_HAS_FRAGS | > > + BPF_F_XDP_HAS_METADATA)) > > return -EINVAL; > > > > if (!IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && > > @@ -2579,6 +2580,20 @@ static int bpf_prog_load(union bpf_attr *attr, bpfptr_t uattr) > > prog->aux->sleepable = attr->prog_flags & BPF_F_SLEEPABLE; > > prog->aux->xdp_has_frags = attr->prog_flags & BPF_F_XDP_HAS_FRAGS; > > > > + if (attr->prog_flags & BPF_F_XDP_HAS_METADATA) { > > + /* Reuse prog_ifindex to bind to the device > > + * for XDP metadata kfuncs. > > + */ > > + prog->aux->offload_requested = false; > > + > > + prog->aux->xdp_netdev = dev_get_by_index(current->nsproxy->net_ns, > > + attr->prog_ifindex); > > + if (!prog->aux->xdp_netdev) { > > + err = -EINVAL; > > + goto free_prog; > > + } > > + } >