From patchwork Thu Dec 6 17:03:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Dedecker X-Patchwork-Id: 1008911 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="MM1S7X6B"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="gK3mZ7uh"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 439hkv4shqz9s55 for ; Fri, 7 Dec 2018 04:03:35 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:Message-Id:Date:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=g8x3VYXzzKhLdoIEuK0/yRCwhsy2uFbKC49bRL8GtJU=; b=MM1S7X6BHoEic+ Qyjzf/gJnssIzHDgzF9K4zSKvKNb1Ej7XB/yLrZEL20rMyU/y3Kb7j2bfrlwfwYX9sz3CZmi6mCuV t9IVNtNxg77ZXNgIMCu+BYM6xmP7Oa5YwRdKkfToJM6HHCQKvMFp0wwex7Ra+k5GRHGuuhcUchDmb u5FMVzVz0IlurJIuFMshPxo6WcxI80NDCCflyPZMH19i4oc33sMXbPIJGl+D77WYGHu3tOqVNCLsM f7khOmUKnYMZ9fy5/u36izOxRkrIZAzjyHdQLM5pGof2CxXnLr9D4d63dPYgBM0l/eHj+1c9IlL73 sMqNpwL/gmgPjOImL4Fw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gUx3l-00020f-3I; Thu, 06 Dec 2018 17:03:33 +0000 Received: from mail-ed1-x543.google.com ([2a00:1450:4864:20::543]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gUx3b-0001l7-B1 for openwrt-devel@lists.openwrt.org; Thu, 06 Dec 2018 17:03:31 +0000 Received: by mail-ed1-x543.google.com with SMTP id b14so1362217edt.6 for ; Thu, 06 Dec 2018 09:03:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=tvhDHhON6lCvA5N8zU6H+6VY+yg3F1CbWE2/9bwGpWo=; b=gK3mZ7uhzZKiEhXY5qzDmuWs/uYl9gdJTVP+fTu+XldCSnn+pPQH+cdRpVJzp/dinH kfbD0IN/3ERwuVf72p05z7nTrRc6bxFm5T+vN12kqIpJ9fw8yc4DGtARrRsjCqoUEED0 AaOgAUBZbv6iMdxf6nDBKWlbe5BkxqAcNrt2+l3VXZMpsLeaFBu/Kfkh7Itnn2VFAWLL crLaNdRpgG94aS7Ds5wp70eEn9Y+vi73MJwgImMphZWhfAJso0sf5xhzH2YtqOJZ0Tqg /B8tmJqgKbdQHOcilMAdAzsPAPKQKB8Qhf/1oUZd8vqwHGShOZQVa4qYyxnUe8mDKVRX bmrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=tvhDHhON6lCvA5N8zU6H+6VY+yg3F1CbWE2/9bwGpWo=; b=JQqPml5wscIjtz779AFFMG2aTJKpq41bDFqq4YZX7gFZsaI1xF+jIUa9JkVVsZQywj 6qEfW0oBWGX8vwnzxfOv2d0RHWiBz6rOW+ZIUP0Ih5/iaaMGi3/iWfX3U6QX8hM4jImn IQ38TUp3nYiw/V5sgvsailayIgtuiEIAO7l3esS7MIloNUUG7HKJztjhDYs/0OeSePRF fH09E9PM6NorU6l9Hzqd9dRioWOjgF6D45P9Oxr0J4Ure0ETKP/oL0GyQRTXFrCZ+aIt eQ4cPSuCpbEm0X4ssiTRWlD4Q+jfR+KvvjKoJrSaRnLUalPcOnYy6xqdhEFVBubJS74C HqXA== X-Gm-Message-State: AA+aEWZhjaeXE6YxaM2sn2Q+mQFtWSfBpDJ7ib/R8CaL3xaX49So9SHx g6eCD7eOteUedI0+Xw+kU2ia37LHKtwXtQ== X-Google-Smtp-Source: AFSGD/X3ae4Zdp1/CgjWssWyWZuA5AsI5GoNYhRFja6kTSwnP6G4FBlea86BqBNNq3HcerD8iGOkiQ== X-Received: by 2002:a50:ac47:: with SMTP id w7mr26274586edc.260.1544115790976; Thu, 06 Dec 2018 09:03:10 -0800 (PST) Received: from dedeckeh-X556UV.lan (ptr-fvl7vtbedol75xo4mh6.18120a2.ip6.access.telenet.be. [2a02:1812:1128:fb00:4054:9b70:8a2d:96ca]) by smtp.gmail.com with ESMTPSA id n16-v6sm172227eja.6.2018.12.06.09.03.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Dec 2018 09:03:10 -0800 (PST) From: Hans Dedecker To: openwrt-devel@lists.openwrt.org, jo@mein.io Date: Thu, 6 Dec 2018 18:03:06 +0100 Message-Id: <20181206170306.19060-1-dedeckeh@gmail.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181206_090323_574736_B941A1F3 X-CRM114-Status: GOOD ( 11.45 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:543 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (dedeckeh[at]gmail.com) -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid Subject: [OpenWrt-Devel] [PATCH firewall3] redirects: properly handle src_dport in SNAT rules X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hans Dedecker Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org In case of SNAT rules the src_dport parameter is used both as a rewrite parameter as well as a matching parameter which is not the expected behavior. The latter is caused by port_redir being set to src_dport in case dest_port parameter is not. As this logic is in place to mimic the old shell script based firewall behavior for DNAT only set port_redir in case the redirect rule is a DNAT rule. Signed-off-by: Hans Dedecker Acked-by: Jo-Philipp Wich --- redirects.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redirects.c b/redirects.c index 6cd09f1..ab95395 100644 --- a/redirects.c +++ b/redirects.c @@ -350,7 +350,7 @@ check_redirect(struct fw3_state *state, struct fw3_redirect *redir, struct uci_e if (!valid) return false; - if (!redir->port_redir.set) + if (redir->target == FW3_FLAG_DNAT && !redir->port_redir.set) redir->port_redir = redir->port_dest; return true;