Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp10392166rwl; Wed, 11 Jan 2023 19:41:51 -0800 (PST) X-Google-Smtp-Source: AMrXdXtynu/uylHSHkpsCs2ZRUNGBkQDI6LhfqNEIlS4LjQEZT4Rg4G1940/2uaSxlWAHMbL9aj4 X-Received: by 2002:a17:902:a3c1:b0:193:2a8c:28cb with SMTP id q1-20020a170902a3c100b001932a8c28cbmr13088524plb.21.1673494911361; Wed, 11 Jan 2023 19:41:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673494911; cv=none; d=google.com; s=arc-20160816; b=ePkfB7MabY4j9bx2ZVR+wrxKynyqxBxxWTuZf7H7hFrJ3gkOGBvT3eeC640V1Rv0Pi I2L6xPPPCL8RYw18Dlr/3FoMO3NEShrp/yqxvrxyQaGQw81BHDu03EVVlS6mwFcPdk+I 3YdIpUx9uOxaQUiN8Pd/Qj//S5DPngbH37muQf/iRDecAIOh0rLLqitkzwg+WieQlQae 5QTB4v3QoIaso15FfUnjHdkRrhnL0Mm8E079r6ueZ0jdJQIjPofzoEgs8Bjntfh4qDXk dbj2bYQm3+TXtG53ElJWWnHJoWwBG65lU3v2qNTQyZ50dQLp6hyaJNQthAWXsQZwpFXA 6crw== 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=wvjXO1ifZXiCWycvQbwGoiBPX2LvP5zGq1RiV3ypU0o=; b=zVQmNndevbmC7lxboiA/XsECJ51XVuhGXnLb74t/10FBulSyQdk6zSaCvRp94xNBr2 XjsyqP9d7tzC2u7SzejQkR8uhJ/vCquuPfENP1iM46euFyLXftNc8qjP5i+iinhABbvk UU1aW82Dg4ECd2Ezluz/uB3NTL/nDcHhIt1BAvpLggtSnRgZqAUoBUiRecWask3hm1ZD L0vA+zYA1wI2oaOorY9iDbYfqISB7lx7HJROo3eo2QCV3ucQdwHWMZ/aM5RCde1KFy4J xg/OTge4llGCF531+jMaGt5bitNDeJd541/xI4kviGlqb8pV2gFar7yAVuDBidaWNlID JyjA== 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 k5-20020a170902694500b00191108745fesi14854797plt.446.2023.01.11.19.41.44; Wed, 11 Jan 2023 19:41:51 -0800 (PST) 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 S236035AbjALDRo (ORCPT + 52 others); Wed, 11 Jan 2023 22:17:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234237AbjALDRm (ORCPT ); Wed, 11 Jan 2023 22:17:42 -0500 Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [IPv6:2a0a:51c0:0:237:300::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35C13DED5; Wed, 11 Jan 2023 19:17:41 -0800 (PST) Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.92) (envelope-from ) id 1pFo5o-0008AG-45; Thu, 12 Jan 2023 04:17:28 +0100 Date: Thu, 12 Jan 2023 04:17:28 +0100 From: Florian Westphal To: Quentin Deslandes Cc: Florian Westphal , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Mykola Lysenko , Shuah Khan , Dmitrii Banshchikov , linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, Kernel Team Subject: Re: [PATCH bpf-next v3 00/16] bpfilter Message-ID: <20230112031728.GL27644@breakpoint.cc> References: <20221224000402.476079-1-qde@naccy.de> <20230103114540.GB13151@breakpoint.cc> <8773f286-74ba-4efb-4a94-0c1f91d959bd@naccy.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <8773f286-74ba-4efb-4a94-0c1f91d959bd@naccy.de> 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 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 Quentin Deslandes wrote: > Le 03/01/2023 ? 12:45, Florian Westphal a ?crit?: > > You can't make this atomic from userspace perspective, the > > get/setsockopt API of iptables uses a read-modify-write model. > > This refers to updating the programs from bpfilter's side. It won't > be atomic from iptables point of view, but currently bpfilter will > remove the program associated to a table, before installing the new > one. This means packets received in between those operations are > not filtered. I assume a better solution is possible. Ah, I see, thanks. > > Tentatively I'd try to extend libnftnl and generate bpf code there, > > since its used by both iptables(-nft) and nftables we'd automatically > > get support for both. > > That's one of the option, this could also remain in the kernel > tree or in a dedicated git repository. I don't know which one would > be the best, I'm open to suggestions. I can imagine that this will see a flurry of activity in the early phase so I think a 'semi test repo' makes sense. Provideded license allows this, useable bits and pieces can then be grafted on to libnftnl (or iptables or whatever). > > I was planning to look into "attach bpf progs to raw netfilter hooks" > > in Q1 2023, once the initial nf-bpf-codegen is merged. > > Is there any plan to support non raw hooks? That's mainly out > of curiosity, I don't even know whether that would be a good thing > or not. Not sure what 'non raw hook' is. Idea was to expose 1. protcocol family 2. hook number (prerouting, input etc) 3. priority to userspace via bpf syscall/bpf link. userspace would then provide the above info to kernel via bpf(... BPF_LINK_CREATE ) which would then end up doing: -------------- h.hook = nf_hook_run_bpf; // wrapper to call BPF_PROG_RUN h.priv = prog; // the bpf program to run h.pf = attr->netfilter.pf; h.priority = attr->netfilter.priority; h.hooknum = attr->netfilter.hooknum; nf_register_net_hook(net, &h); -------------- After that nf_hook_slow() calls the bpf program just like any other of the netfilter hooks. Does that make sense or did you have something else in mind?