From patchwork Wed Oct 23 14:57:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Sutter X-Patchwork-Id: 2001153 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=nwl.cc header.i=@nwl.cc header.a=rsa-sha256 header.s=mail2022 header.b=COzOykgi; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=139.178.88.99; helo=sv.mirrors.kernel.org; envelope-from=netfilter-devel+bounces-4661-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [139.178.88.99]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XYXSz0LDVz1xwf for ; Thu, 24 Oct 2024 02:06:58 +1100 (AEDT) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 9AFD12816B9 for ; Wed, 23 Oct 2024 15:06:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2732B1C305A; Wed, 23 Oct 2024 14:57:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=nwl.cc header.i=@nwl.cc header.b="COzOykgi" X-Original-To: netfilter-devel@vger.kernel.org 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 A413815B99D for ; Wed, 23 Oct 2024 14:57:40 +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=1729695463; cv=none; b=pfUz55Z/oaKSTZ0p5aZ2sSWDnQ3boHRRKvlB7r/xLD5uTWpM8SprZXTNhaHROe2QornUThOXvKeVCksx1kNJ39qkEmSZRmdV/Atl/msgV0JOhlFrdMsdcINd35C9AyHQ5Nlb3BIrhvHK3yOjrkTMecOdt9IvFnhasdxncx5IOWU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729695463; c=relaxed/simple; bh=BORdh8ZhWKZ3/xZ7LPhe6fSux9SI+cPvTYXQxLAjTnE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cO9jZwb7QEfUh44q4kFjuZb8923lp0H+oC9XtJq2FNZhmyP46O3r+DSBtEwc8WblUpKGLcHY04udPnTMZ3qQWPKnHeoZvoxEH5f//8Tqc6sqM8M0ZUI9jYByIRnNlCsiaCkNJlujFRzZ4P8R3s+SfWlDsQwC7tEaI9wG+52oz+w= 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=COzOykgi; 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 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=1FyTMvcf0lAYejdUM5VbVDdyBsfOZCzlzUsd/l0c7uI=; b=COzOykgitmfBJW5gXUb/9gV7UW m2eVHDZuRZQOMVVSMsaRz0IBWGzEF0qZ35wU13MfjJIpPv/XW2bDHTUYihyNwhBYAJXBkT3qVyLp8 y/bzmHv3WSOCNYiQFvQ4BXRJprgoR9zusYSGwmYkJXl6Kmn9X6DmbBOhVoPvlqsgTGPX5ZaYBaamO Lr7I32m5nKukhSwxZjZA0UUNrj1aP1b6AxzFb0/caX7Ml2mfI/clMOjt7jF432IJmDnsC+KG138fe JmNPJlu6i7zGlO3cv3vQYbK0ygoStlkCgwW66BZ2eXYCXp9rEmcYklyHy6NxWPMp/GK3REaA0XpsE fCwnSRwg==; Received: from localhost ([::1] helo=xic) by orbyte.nwl.cc with esmtp (Exim 4.97.1) (envelope-from ) id 1t3cnk-000000003sQ-1pw3; Wed, 23 Oct 2024 16:57:32 +0200 From: Phil Sutter To: Pablo Neira Ayuso Cc: Florian Westphal , netfilter-devel@vger.kernel.org, Eric Garver Subject: [nf-next PATCH v6 1/7] netfilter: nf_tables: Flowtable hook's pf value never varies Date: Wed, 23 Oct 2024 16:57:24 +0200 Message-ID: <20241023145730.16896-2-phil@nwl.cc> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241023145730.16896-1-phil@nwl.cc> References: <20241023145730.16896-1-phil@nwl.cc> Precedence: bulk X-Mailing-List: netfilter-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When checking for duplicate hooks in nft_register_flowtable_net_hooks(), comparing ops.pf value is pointless as it is always NFPROTO_NETDEV with flowtable hooks. Dropping the check leaves the search identical to the one in nft_hook_list_find() so call that function instead of open coding. Signed-off-by: Phil Sutter --- net/netfilter/nf_tables_api.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index 30331688301e..d4563313d5e0 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -8569,7 +8569,7 @@ static int nft_register_flowtable_net_hooks(struct net *net, struct list_head *hook_list, struct nft_flowtable *flowtable) { - struct nft_hook *hook, *hook2, *next; + struct nft_hook *hook, *next; struct nft_flowtable *ft; int err, i = 0; @@ -8578,12 +8578,9 @@ static int nft_register_flowtable_net_hooks(struct net *net, if (!nft_is_active_next(net, ft)) continue; - list_for_each_entry(hook2, &ft->hook_list, list) { - if (hook->ops.dev == hook2->ops.dev && - hook->ops.pf == hook2->ops.pf) { - err = -EEXIST; - goto err_unregister_net_hooks; - } + if (nft_hook_list_find(&ft->hook_list, hook)) { + err = -EEXIST; + goto err_unregister_net_hooks; } }