From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pablo Neira Ayuso Subject: Re: [PATCH] netfilter: use fwmark_reflect in nf_send_reset Date: Fri, 23 Dec 2016 15:16:28 +0100 Message-ID: <20161223141628.GA20986@salvia> References: <1481805823-32636-1-git-send-email-pau.espin@tessares.net> <1481882607-461-1-git-send-email-pau.espin@tessares.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: netfilter-devel@vger.kernel.org, pespin.shar@gmail.com, Lorenzo Colitti To: Pau Espin Pedrol Return-path: Received: from mail.us.es ([193.147.175.20]:36992 "EHLO mail.us.es" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753255AbcLWOQm (ORCPT ); Fri, 23 Dec 2016 09:16:42 -0500 Received: from antivirus1-rhel7.int (unknown [192.168.2.11]) by mail.us.es (Postfix) with ESMTP id B50962519A5 for ; Fri, 23 Dec 2016 15:16:39 +0100 (CET) Received: from antivirus1-rhel7.int (localhost [127.0.0.1]) by antivirus1-rhel7.int (Postfix) with ESMTP id A828296213 for ; Fri, 23 Dec 2016 15:16:39 +0100 (CET) Received: from antivirus1-rhel7.int (localhost [127.0.0.1]) by antivirus1-rhel7.int (Postfix) with ESMTP id 8CB1696210 for ; Fri, 23 Dec 2016 15:16:37 +0100 (CET) Content-Disposition: inline In-Reply-To: <1481882607-461-1-git-send-email-pau.espin@tessares.net> Sender: netfilter-devel-owner@vger.kernel.org List-ID: Hi Pau, On Fri, Dec 16, 2016 at 11:03:27AM +0100, Pau Espin Pedrol wrote: > Otherwise, RST packets generated by ipt_REJECT always have mark 0 when > the routing is checked later in the same code path. Your patch works fine, I can see mark is reflected to TCP RST for packets that are generated by netfilter. However, it seems fwmark_reflect is broken here for TCP RST that are generated by the stack, or at least I don't manage to trigger the reflection with current git tree. Using this simple ruleset to mark input packets: # nft list ruleset table ip x { chain y { type filter hook output priority 0; policy accept; log prefix "output: " } chain z { type filter hook input priority 0; policy accept; mark set 0x00000001 log prefix "input: " } } Note input packets shows mark 0x1: Dec 23 15:07:37 salvia kernel: [14895.204591] input: IN=eth0 OUT= MAC=... SRC=192.168.12.1 DST=192.168.12.195 LEN=60 TOS=0x00 PREC=0x00 TTL=64 ID=27691 DF PROTO=TCP SPT=36341 DPT=24 WINDOW=14600 RES=0x00 SYN URGP=0 MARK=0x1 however, output shows no mark, so no reflection is going on: Dec 23 15:07:37 salvia kernel: [14895.204643] output: IN= OUT=eth0 SRC=192.168.12.195 DST=192.168.12.1 LEN=40 TOS=0x00 PREC=0x00 TTL=64 ID=52846 DF PROTO=TCP SPT=24 DPT=36341 WINDOW=0 RES=0x00 ACK RST URGP=0 fwmark_reflect works perfectly fine with ICMP: Dec 23 15:11:21 salvia kernel: [15119.556780] input: IN=eth0 OUT= MAC=... SRC=192.168.12.1 DST=192.168.12.195 LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=ICMP TYPE=8 CODE=0 ID=5429 SEQ=2 MARK=0x1 Dec 23 15:11:21 salvia kernel: [15119.556822] output: IN= OUT=eth0 SRC=192.168.2.195 DST=192.168.2.1 LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=25617 PROTO=ICMP TYPE=0 CODE=0 ID=5429 SEQ=2 MARK=0x1 Thanks.