Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3425181pxb; Mon, 24 Jan 2022 09:16:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJzW3AwiPIV9DMZGH+zEzXZLeiDbdRtApeUL3OHhIxMIT84OU5AjRyw02MVinSjoxKnSoe33 X-Received: by 2002:a63:a706:: with SMTP id d6mr12418818pgf.390.1643044591766; Mon, 24 Jan 2022 09:16:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643044591; cv=none; d=google.com; s=arc-20160816; b=pZO774AdjdxhjzhoMcBj1v+RAZJoglvuTe+ARg/KA9FIuOZyKt47QnTupOWgXuK2dv 8GO5rqXmkRs8KPO8msQAlGzz2tvTZisbPtqlNlUm17bAgzT+HcXGPJFR9S+rqaNp3qj/ J9i62ji8heSl0uN7SCOfNlkdCWPMcjYSL2e+ZwmIcUf+XBDuSPsYuvt/K77OY6sQvJWb K/WDaDTEnPL/BOgGwPLfmMOYNQQSW1hB1Cr4+EMeWZgmPNSmOpDJdB8XmbOq4eiWYeXV U2KQ1K5R36bNnrW97PrEDzeDzEnoK0/1QNwDXenmRW6OOt5O0ZmF8jgRpSPewSNWWj5l Z4zg== 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:subject:cc:to:from:dkim-signature; bh=p80msPMQpJL6/ZC9j6FEhROYEhBkBcmgh8Hs1TbpcGM=; b=QK6iRleeZTqxkZMGo9QdBf2s7WeL6PweD0BJRIoa1PmwvBRxpP9UL7bp4Cmd17urJk swq7cNF4NBbuKgRYfGtz07XZ5+tjM42v9f/YTvv4DLJRovWtbfNVkV/pq7XnTMkc7gvq 162LUc1ZE63ftVi9CLJW16DJyotmlbiquIARu1nAOybTCAjllW54kP19xbUxsrAwonkW S5PT+aADRR4sbYg1KxUzeR5Duu3g+xpD9aQBcY8wiC6pnWby3EdohcNC2TvAKpGiw+xP 2W0rjlF0/dznZ7T0Ajd6L0UJ80qjK223SPnsi+7TNxFRIGO+4D5MsX4Ve2UsQjOunHW/ QiWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@126.com header.s=s110527 header.b=fHGVxNrv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=126.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ls5si17562464pjb.83.2022.01.24.09.16.19; Mon, 24 Jan 2022 09:16:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@126.com header.s=s110527 header.b=fHGVxNrv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=126.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241202AbiAXFh4 (ORCPT + 99 others); Mon, 24 Jan 2022 00:37:56 -0500 Received: from mail-m965.mail.126.com ([123.126.96.5]:36079 "EHLO mail-m965.mail.126.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229623AbiAXFhz (ORCPT ); Mon, 24 Jan 2022 00:37:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=p80ms PMQpJL6/ZC9j6FEhROYEhBkBcmgh8Hs1TbpcGM=; b=fHGVxNrvX1BiTetfV+0/K DCYQQvErSiuIaY1n1/idJq4NzfPEacfGJaqUW87XsX4aryaY8EkngrDdghWiEFcl Q3cfDwjS7h1SJF04/zVH+A/SGP99xOmCEBDCacZoVaEJFOjCVXGwqosJCtGga+eL LlECg8kyUvj8t+iLbrd14c= Received: from firebird.. (unknown [222.128.181.171]) by smtp10 (Coremail) with SMTP id NuRpCgDnJZIdO+5hZbydAw--.15673S2; Mon, 24 Jan 2022 13:37:34 +0800 (CST) From: kai zhang To: pablo@netfilter.org, kadlec@netfilter.org, fw@strlen.de, davem@davemloft.net, yoshfuji@linux-ipv6.org, dsahern@kernel.org, kuba@kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: kai zhang Subject: [PATCH] net: fix duplicate logs of iptables TRACE target Date: Mon, 24 Jan 2022 05:37:32 +0000 Message-Id: <20220124053732.55985-1-zhangkaiheb@126.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: NuRpCgDnJZIdO+5hZbydAw--.15673S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7Kr4xAFykCF48Aw43Jw4fXwb_yoW8Zw1rpF 98Kas8trs3JrWjyFs7X3WUAFyrGws3JrZxGFy3A34rKw1DtrWUKa1Skry29a10vrsIgFW5 XFWFvr4Yyws8Cw7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UaksgUUUUU= X-Originating-IP: [222.128.181.171] X-CM-SenderInfo: x2kd0wxndlxvbe6rjloofrz/1tbi2R6S-lpEDTKR-wAAsk Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Below configuration, mangle,filter and security tables have no rule: # iptables -t raw -I PREROUTING 1 -p tcp --dport 22 -j TRACE # sysctl net.netfilter.nf_log.2=nf_log_ipv4 There are 5 logs for incoming ssh packet: kernel: [ 7018.727278] TRACE: raw:PREROUTING:policy:2 IN=enp9s0 ... kernel: [ 7018.727304] TRACE: mangle:PREROUTING:policy:1 IN=enp9s0 ... kernel: [ 7018.727327] TRACE: mangle:INPUT:policy:1 IN=enp9s0 ... kernel: [ 7018.727343] TRACE: filter:INPUT:policy:1 IN=enp9s0 ... kernel: [ 7018.727359] TRACE: security:INPUT:policy:1 IN=enp9s0 ... Signed-off-by: kai zhang --- net/ipv4/netfilter/ip_tables.c | 4 +++- net/ipv6/netfilter/ip6_tables.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c index 2ed7c58b4..5f0e6096e 100644 --- a/net/ipv4/netfilter/ip_tables.c +++ b/net/ipv4/netfilter/ip_tables.c @@ -304,9 +304,11 @@ ipt_do_table(void *priv, #if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE) /* The packet is traced: log it */ - if (unlikely(skb->nf_trace)) + if (unlikely(skb->nf_trace)) { trace_packet(state->net, skb, hook, state->in, state->out, table->name, private, e); + nf_reset_trace(skb); + } #endif /* Standard target? */ if (!t->u.kernel.target->target) { diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c index 2d816277f..ae842a835 100644 --- a/net/ipv6/netfilter/ip6_tables.c +++ b/net/ipv6/netfilter/ip6_tables.c @@ -327,9 +327,11 @@ ip6t_do_table(void *priv, struct sk_buff *skb, #if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE) /* The packet is traced: log it */ - if (unlikely(skb->nf_trace)) + if (unlikely(skb->nf_trace)) { trace_packet(state->net, skb, hook, state->in, state->out, table->name, private, e); + nf_reset_trace(skb); + } #endif /* Standard target? */ if (!t->u.kernel.target->target) { -- 2.30.2