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 2C85D17D8BF for ; Fri, 20 Sep 2024 20:23:58 +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=1726863842; cv=none; b=PsAzkT1pigeJj4S0VljVsp6YHagpTfdziPK0608UFLdRi2tEf7Pk8oAfFKuQNu2yFMc0Y7R/kYPDRsOGaw9HmYlI0bPbb+LmVr70F2Zy9tKFCG9py+Ge4OeD+PvIygEh4GLqTnq90K2FI8FX5Xy4Y5ympBoLyQKqXwDyPhEhOe0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726863842; c=relaxed/simple; bh=PyHcQJjd0EsfJMyZEU//rHqgYY4cF+HDatJtbOT5oxA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F75sP1DoioHd4M8AuuYfklq3vgQ/9E9gKnF9YFoCCZIBFWNJKvjSch8PS7LY5aI/dqlheEgnUOA8tEcgSUHFbR5GmByMJh1VV6l66CknXzz/XH+Xr/5Ydmx+6q7hp89fnVp7QW2cRxzoKONYY2iFTdp+cDLL+0oOD7f3pBrBD54= 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=TWPeynVs; 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="TWPeynVs" 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=jEZIvT1obH40X/uvyaQoSVLAVdcmczC1yTaWFnJCCu0=; b=TWPeynVsUebCj9yELYvpuqqNJP tryf2viDM6KRCqL0H735aWW34tyJ2XVQirxC/8GGchIZNNwBPgW5ILlmJvvCxZoqFgaUTQEq8tTud lOVRNKaa64kRNGotgoXJZXBOdVtW8heF/uIIciiXgEE+bved9E1MgxybDVHcFUr4D7LohtPiqY4vA IFuxvmcX7wV+L+oEAEn/R8LhwJtwfr2Swt+BRivnrhuY8zzVW//lIbM9CRssDjaKe57nFI5w7xxK5 S7HXdgGRMmkkNrfLob4TuGSxG93MUzQ+Y4xdbHpFOqYWGX4fRXl+YfLgFOLLdWCEdF7zVHtUdgwlQ MABh3CCQ==; Received: from localhost ([::1] helo=xic) by orbyte.nwl.cc with esmtp (Exim 4.97.1) (envelope-from ) id 1srkAX-000000006J8-2H4i; Fri, 20 Sep 2024 22:23:57 +0200 From: Phil Sutter To: Pablo Neira Ayuso Cc: netfilter-devel@vger.kernel.org, Florian Westphal , Eric Garver Subject: [nf-next PATCH v4 08/16] netfilter: nf_tables: Introduce nft_register_flowtable_ops() Date: Fri, 20 Sep 2024 22:23:39 +0200 Message-ID: <20240920202347.28616-9-phil@nwl.cc> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240920202347.28616-1-phil@nwl.cc> References: <20240920202347.28616-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 8326395c5752..3721f4636e0a 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -8581,6 +8581,26 @@ static void nft_unregister_flowtable_net_hooks(struct net *net, __nft_unregister_flowtable_net_hooks(net, 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, @@ -8601,20 +8621,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.43.0