Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp20731808rwd; Thu, 29 Jun 2023 06:25:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ693yJUwuWWsI0cs/a6Reaf7Lrkmnx7tvrr8OSCZGmXXHUBpst29ALvAZgtPiOAm7EFEcz0 X-Received: by 2002:a17:90a:656:b0:259:343:86b5 with SMTP id q22-20020a17090a065600b00259034386b5mr28576893pje.47.1688045121988; Thu, 29 Jun 2023 06:25:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688045121; cv=none; d=google.com; s=arc-20160816; b=lEOuYYC/fr5XMgnuh90SoBv9C2td5y0YihIONrUEk1YNvKIds0xxWwAKWI48PgS9Bd NM5Ce1gWYUnlPE4LssaiOu2IgD28trI+uqDpaUXW6y0vSV9hLYBZxQftkg9p/YIifQrQ U+oLp1ipHcJXu+6K7vh4pE5bdo+SURB9/dVDj5mk8AGWjDOgnL/7HrFwKCcolrtX2esY M3SkjA40pnZlaoU7eizV3ZdWUfbACUi6waZ3NO2pwP4v4PmPd7iFBviAW9Z4eX8mHWQL pYzQyNgoYmPw0KG4puVhbw0e2NwDKzQzg71lhki+hTiMq+aKhvQLcOh+QpKMBLL0Zx39 /xvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=/J6ViMEOWY2+DgMeWtj2SFBq3NTJ6J28cqEIdjbu6Kg=; fh=oVf9TI+FYVsUQD+3/A0yoMFq5QSfPlOsm4+U6mQmVC0=; b=Tq52N+6IyeJpRLOU2t85h6dowqN9KCMb6dZBOz8O2CDDTMybJdy6JBoY/XSmvgHaZN +v03JBkpnuToJM2qEuMEUAr6N6XYHthZ+flL/aonOxSgeDN94laXmgKYt54+g20gIN5f cDPLMxHupjT3e6yA+v28JqzHGlplN+p3FmBxuF13kXXd+R3zwqPUK4NE8/n0cZrbiGD5 uMeQZY8vfzFoiWcz5KTmxrUuLCucrTGviKYbWJTB1pB3lO/t4tZtljFbeuewRwY4jgf1 ra6Yg/xwgKTnQcXG3dDAI/rHMYyS2BTMEEv6oAAD/NJJzrIRbzU8WYdKM9GslCrBzYd5 ClXg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q15-20020a170902dacf00b001b678455757si11014363plx.303.2023.06.29.06.25.05; Thu, 29 Jun 2023 06:25:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231633AbjF2NVu (ORCPT + 99 others); Thu, 29 Jun 2023 09:21:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229494AbjF2NVt (ORCPT ); Thu, 29 Jun 2023 09:21:49 -0400 Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [IPv6:2a0a:51c0:0:237:300::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4258F2707; Thu, 29 Jun 2023 06:21:47 -0700 (PDT) Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.92) (envelope-from ) id 1qEraf-0006iS-KY; Thu, 29 Jun 2023 15:21:41 +0200 Date: Thu, 29 Jun 2023 15:21:41 +0200 From: Florian Westphal To: Toke =?iso-8859-15?Q?H=F8iland-J=F8rgensen?= Cc: Florian Westphal , Daniel Xu , bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, coreteam@netfilter.org, netfilter-devel@vger.kernel.org, daniel@iogearbox.net, dsahern@kernel.org Subject: Re: [PATCH bpf-next 0/7] Support defragmenting IPv(4|6) packets in BPF Message-ID: <20230629132141.GA10165@breakpoint.cc> References: <874jmthtiu.fsf@toke.dk> <20230627154439.GA18285@breakpoint.cc> <87o7kyfoqf.fsf@toke.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87o7kyfoqf.fsf@toke.dk> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Toke H?iland-J?rgensen wrote: > Florian Westphal writes: > > For bpf a flag during link attachment seemed like the best way > > to go. > > Right, I wasn't disputing that having a flag to load a module was a good > idea. On the contrary, I was thinking we'd need many more of these > if/when BPF wants to take advantage of more netfilter code. Say, if a > BPF module wants to call into TPROXY, that module would also need go be > loaded and kept around, no? That seems to be a different topic that has nothing to do with either bpf_link or netfilter? If the program calls into say, TPROXY, then I'd expect that this needs to be handled via kfuncs, no? Or if I misunderstand, what do you mean by "call into TPROXY"? And if so, thats already handled at bpf_prog load time, not at link creation time, or do I miss something here? AFAIU, if prog uses such kfuncs, verifier will grab needed module ref and if module isn't loaded the kfuncs won't be found and program load fails. > I was thinking something along the lines of just having a field > 'netfilter_modules[]' where userspace could put an arbitrary number of > module names into, and we'd load all of them and put a ref into the > bpf_link. Why? I fail to understand the connection between bpf_link, netfilter and modules. What makes netfilter so special that we need such a module array, and what does that have to do with bpf_link interface? > In principle, we could just have that be a string array f > module names, but that's probably a bit cumbersome (and, well, building > a generic module loader interface into the bpf_like API is not > desirable either). But maybe with an explicit ENUM? What functionality does that provide? I can't think of a single module where this functionality is needed. Either we're talking about future kfuncs, then, as far as i understand how kfuncs work, this is handled at bpf_prog load time, not when the bpf_link is created. Or we are talking about implicit dependencies, where program doesn't call function X but needs functionality handled earlier in the pipeline? The only two instances I know where this is the case for netfilter is defrag + conntrack. > > For conntrack, we MIGHT be able to not need a flag but > > maybe verifier could "guess" based on kfuncs used. > > If the verifier can just identify the modules from the kfuncs and do the > whole thing automatically, that would of course be even better from an > ease-of-use PoV. Not sure what that would take, though? I seem to recall > having discussions around these lines before that fell down on various > points. AFAICS the conntrack kfuncs are wired to nf_conntrack already, so I would expect that the module has to be loaded already for the verifier to accept the program. Those kfuncs are not yet exposed to NETFILTER program types. Once they are, all that would be needed is for the netfilter bpf_link to be able tp detect that the prog is calling into those kfuncs, and then make the needed register/unregister calls to enable the conntrack hooks. Wheter thats better than using an explicit "please turn on conntrack for me", I don't know. Perhaps future bpf programs could access skb->_nfct directly without kfuncs so I'd say the flag is a better approach from an uapi point of view.