Received: from orbyte.nwl.cc (orbyte.nwl.cc [151.80.46.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ABB502673BA for ; Wed, 21 May 2025 20:44:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=151.80.46.58 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747860284; cv=none; b=uB/eorsxWX3ZFOu2DWWRInVoL0TZ2QbYMBD04TLWgmVvPzFevwv4IMUVGBni3GKwVEcud4iMWu/8qs1lMsLVPDKjgD0eEfLEj9JQRicA7TvB5HupCBDfsa+NhAIa1hUyXoDFS+VmDaiZgDfXoOATwfyFcutkl1yed8A+PKNp5RI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747860284; c=relaxed/simple; bh=fWwCLpIIXS+eu+RVEi8AydWbM78zacQJFpFrqM+7+Nk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XAiAlu90QpyhcrvIPh+3dtvNwJL2c+FaxLFrxDfSEJSHzWAAcMbibD+YJCTufqkykyVhfNU1PdtuKEcfua5LnZt4jEBl8T6ICU9Vs8W8O6ie6lBuYib6o7EKOUhOlPJ8srwYR0/pZELZVVA6xOgtSfgz1R+slKnlO1rpiekuDLM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nwl.cc; spf=pass smtp.mailfrom=nwl.cc; dkim=pass (2048-bit key) header.d=nwl.cc header.i=@nwl.cc header.b=m/752XNm; arc=none smtp.client-ip=151.80.46.58 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nwl.cc Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nwl.cc Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nwl.cc header.i=@nwl.cc header.b="m/752XNm" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nwl.cc; s=mail2022; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=hyP1GArz8E34WaaX6rx70mixq4SCW7UKuH7BgCuxdW4=; b=m/752XNmVSMu2Xir9zaszE8PAH 4HP+C8b0jwKxXdZShQPEzrabT1OrIyoozNE3PXvJ5NrCeQw/S3dylnrIS6OVtbd+spS7tneBlheAC hSUmRmnyreW63rAO67S7fXE7poSD0hCj2RnxrRCm2XldSwIcFwF8+MgKDWeUZslrpf/ebqjd70Yy3 3ATKaQELPRGGRxM6dCvBQiEZZaYmzUA3dE/g5lffwgnRSneC1pE5znGGe+PGWit6rFsSpx5bhvah7 J3idxnCqkC9oAaBvZuHCj3ea/BwSxSXVtylEdtUlnQWM71CdB2Zv0PTR5gmoz29RC3aD8ZOJBjjgF h5X69clQ==; Authentication-Results: mail.nwl.cc; iprev=pass (localhost) smtp.remote-ip=::1 Received: from localhost ([::1] helo=xic) by orbyte.nwl.cc with esmtp (Exim 4.97.1) (envelope-from ) id 1uHqIq-000000007QQ-2Pnr; Wed, 21 May 2025 22:44:40 +0200 From: Phil Sutter To: Pablo Neira Ayuso Cc: netfilter-devel@vger.kernel.org, Florian Westphal , Eric Garver Subject: [nf-next PATCH v7 03/13] netfilter: nf_tables: Introduce nft_register_flowtable_ops() Date: Wed, 21 May 2025 22:44:24 +0200 Message-ID: <20250521204434.13210-4-phil@nwl.cc> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250521204434.13210-1-phil@nwl.cc> References: <20250521204434.13210-1-phil@nwl.cc> Precedence: bulk X-Mailing-List: netfilter-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Facilitate binding and registering of a flowtable hook via a single function call. Signed-off-by: Phil Sutter --- net/netfilter/nf_tables_api.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index c5b7922ca5bf..a1d705796282 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -8929,6 +8929,26 @@ static void nft_unregister_flowtable_net_hooks(struct net *net, __nft_unregister_flowtable_net_hooks(net, flowtable, hook_list, false); } +static int nft_register_flowtable_ops(struct net *net, + struct nft_flowtable *flowtable, + struct nf_hook_ops *ops) +{ + int err; + + err = flowtable->data.type->setup(&flowtable->data, + ops->dev, FLOW_BLOCK_BIND); + if (err < 0) + return err; + + err = nf_register_net_hook(net, ops); + if (!err) + return 0; + + flowtable->data.type->setup(&flowtable->data, + ops->dev, FLOW_BLOCK_UNBIND); + return err; +} + static int nft_register_flowtable_net_hooks(struct net *net, struct nft_table *table, struct list_head *hook_list, @@ -8949,20 +8969,10 @@ static int nft_register_flowtable_net_hooks(struct net *net, } } - err = flowtable->data.type->setup(&flowtable->data, - hook->ops.dev, - FLOW_BLOCK_BIND); + err = nft_register_flowtable_ops(net, flowtable, &hook->ops); if (err < 0) goto err_unregister_net_hooks; - err = nf_register_net_hook(net, &hook->ops); - if (err < 0) { - flowtable->data.type->setup(&flowtable->data, - hook->ops.dev, - FLOW_BLOCK_UNBIND); - goto err_unregister_net_hooks; - } - i++; } -- 2.49.0