Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3538219rwb; Tue, 16 Aug 2022 05:03:01 -0700 (PDT) X-Google-Smtp-Source: AA6agR52uovcTX0AkIExqJfbMMFHwL8J4IqQbCd1pKvXpWMU3mIQm+EdqZcu7AFVPKE1MzI9cUNj X-Received: by 2002:a17:90b:1e45:b0:1f6:ead4:1599 with SMTP id pi5-20020a17090b1e4500b001f6ead41599mr23166360pjb.185.1660651381060; Tue, 16 Aug 2022 05:03:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660651381; cv=none; d=google.com; s=arc-20160816; b=zE8mk64yT6Oo5brTAVTja0kcqNIIHEGTmC8gFtJ/COul4FVpeGSaLcydn9p2cUW3z1 AS16dIGUhiEj3a+6Z1fRoF5mEnkOMtfJuG3zEi2sY5x3PpNshR+71Dqikr7QYDKCXhez ML6Zhw31707F8AOGbN0DCc4Wp4RVqLJJfVJphTZ898qp/08fiIsJqUhxS8XqY2udkbfH YSgVc47IfajszrAUrNU6SjNqms20A3ze4JHmsdiMT13f1jw4vRTZ6kR+EZ6jEt0IROVY 2Sr/5s+8BAGGSEg50Zh0rU7TeCYLo2Yj0dHTkU25qnCppouOKYpuKLYzQrn7T9mdkwkg 7WZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:references:in-reply-to:subject:cc:to:from :dkim-signature; bh=yqe/EMQmD3VLnGHghypui0+k7E1d1JAMjbBdNpJp/Ac=; b=hcJLKIvmgNT7GRCqjqnHn/Bq+KW1Yn4yHZ+XpvjekylzLaRs5fYKip2rc4mPvuGqQc h5AEvrK+av7q8y5ob1uIOeWTl7IosKoKy8EJ6RQPNo1omDMid9nldhmZ2FbeufgCQMjM B96WY4czFMV0s9casfH7P2Fhth9ObRDbxutH0weZeSoYDRoI/nbDHFpMcs7VG9pdJ/2t 11dkbi3SOc5BwDns10vOWieWBy09GvaMsUjb5/Jl26dJnQXSz12NH6G8oP89WJ7QG2lB /UxNvB3d2QJuWgXH/wAQpAjOEf87+0FS00VpKA1rNIPRrBKlU+osKXhSJd7h6MT2QNwM OVWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WmDtk6Cf; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b11-20020a17090a9bcb00b001f3250578ffsi13362926pjw.20.2022.08.16.05.02.46; Tue, 16 Aug 2022 05:03:01 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WmDtk6Cf; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233744AbiHPL2b (ORCPT + 99 others); Tue, 16 Aug 2022 07:28:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234125AbiHPL2E (ORCPT ); Tue, 16 Aug 2022 07:28:04 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5ADAA2CDF7; Tue, 16 Aug 2022 03:43:37 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 03D99B8165D; Tue, 16 Aug 2022 10:43:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86EA3C433C1; Tue, 16 Aug 2022 10:43:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660646614; bh=yqe/EMQmD3VLnGHghypui0+k7E1d1JAMjbBdNpJp/Ac=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=WmDtk6Cf5S1czeeVK0DAKEntmyWn/ucxbgRUOJ7EvCnJ+hlnMmXKs7d2LzLusOWjG P9BZUnyFCygTSaBGyI+/ZMRsimDcw4lKZrmIl00p7YDKYDDZRS07+VkGYYjkDQNVZE /NHOq/5udUF8/K0YgcGNQGgSV+Ea36YQkWf7qRPhQgneFDWP9m6nB5Vly8RrTfkWTj Gx54EcrUu0WWbaHKs8uubbJDflr8MXwUMFtLvri3hNPrkYfanr9K/Ae48SXOeGfelg 0y7pVw8dF2stIh5VXYLv1fnS+4FQo+ZvQ2DKZC+sGfyc7TYLSt7uY6amkS3OtqU5wE xT3sWq5r6idFg== Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id 0ED1D55F5FC; Tue, 16 Aug 2022 12:43:32 +0200 (CEST) From: Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= To: Alexei Starovoitov , Florian Westphal Cc: Daniel Xu , bpf , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Kumar Kartikeya Dwivedi , Pablo Neira Ayuso , netfilter-devel , Network Development , LKML Subject: Re: [PATCH bpf-next 2/3] bpf: Add support for writing to nf_conn:mark In-Reply-To: References: X-Clacks-Overhead: GNU Terry Pratchett Date: Tue, 16 Aug 2022 12:43:32 +0200 Message-ID: <87v8qswjsb.fsf@toke.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,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 Alexei Starovoitov writes: > On Mon, Aug 15, 2022 at 3:40 PM Florian Westphal wrote: >> >> Toke H=C3=B8iland-J=C3=B8rgensen wrote: >> > > Support direct writes to nf_conn:mark from TC and XDP prog types. Th= is >> > > is useful when applications want to store per-connection metadata. T= his >> > > is also particularly useful for applications that run both bpf and >> > > iptables/nftables because the latter can trivially access this metad= ata. >> > > >> > > One example use case would be if a bpf prog is responsible for advan= ced >> > > packet classification and iptables/nftables is later used for routing >> > > due to pre-existing/legacy code. >> > > >> > > Signed-off-by: Daniel Xu >> > >> > Didn't we agree the last time around that all field access should be >> > using helper kfuncs instead of allowing direct writes to struct nf_con= n? >> >> I don't see why ct->mark needs special handling. >> >> It might be possible we need to change accesses on nf/tc side to use >> READ/WRITE_ONCE though. > > +1 > I don't think we need to have a hard rule. > If fields is safe to access directly than it's faster > to let bpf prog read/write it. > There are no backward compat concerns. If conntrack side decides > to make that field special we can disallow direct writes in > the same kernel version. Right, I was under the impression we wanted all fields to be wrapper by helpers so that the struct owner could change their semantics without affecting users (and solve the performance issue by figuring out a generic way to inline those helpers). I guess there could also be an API consistency argument for doing this. However, I don't have a strong opinion on this, so if y'all prefer keeping these as direct field writes, that's OK with me. > These accesses, just like kfuncs, are unstable. Well, it will be interesting to see how that plays out the first time an application relying on one of these breaks on a kernel upgrade :) -Toke