From patchwork Thu Dec 6 17:01:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Dedecker X-Patchwork-Id: 1008910 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="mD/6ffic"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="DUwWvMLn"; 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 439hjY0dQyz9s7h for ; Fri, 7 Dec 2018 04:02:24 +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=mD/6fficzM/w+f XdpRaa1afBl9lpBS6usNqNbaaLbod2D6h1vm/rRe4fpla5YpYpkXO/SeAxNx6v3TotANBt3+yATEP wtcj/tTPEUE5xMH694trza4cVnIXhy7V67DIPUbIQKWTGM9T9rbiWnS4LwT/JfnRJcG3biuH9qTL9 F777Kx8ro9EQIjxjPPIiPDarR+0mrtbY2lZ7tpvuZhtghne4S1c968dlZkFqNfTdS9o7M/wOEy12Q bcyRAxnsdJg/RtRXATMCoVIuf2oRutvUxHukY57vOfnMxE6dVZDvTLTjnKwcBQKHFwvDfx9LHCwNo qTJ4SZ/joXmNRFA9TYfA==; 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 1gUx2a-0001VT-6v; Thu, 06 Dec 2018 17:02:20 +0000 Received: from mail-ed1-x544.google.com ([2a00:1450:4864:20::544]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gUx2S-0001Us-In for openwrt-devel@lists.openwrt.org; Thu, 06 Dec 2018 17:02:18 +0000 Received: by mail-ed1-x544.google.com with SMTP id h15so1373791edb.4 for ; Thu, 06 Dec 2018 09:02:02 -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=DUwWvMLnw68HNDYcUJCfulqtRtYlgSCFwDVWEAaUondg3TwkKLkOoGFvInmZuZhMvz LH4s280p1GQHOmjCfiitaUWEbBxvmksxdGEfAeqKdUVZriXOevElkbHFdOuohYtdhDWO bqXiKRvn3SlvGaB2DbxHRNASZY41bYWVB0FxUMs28UPdv1bdYzMH16BbWKscKxlmrJJM ofBR7UmrVyb4diR4crUzCdaY9sSmV0oyQVYxXSW9K+8wBgHlvII0rEda3TI6KTCmZ30t mpmTLtb/JzaCYGbztffBjD3YBehF1LFFSFYWNDPaIlFLK1cHpAhiCHVMpH8g7tWoFMCK ArRA== 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=JEfVWAZtn/yseS9yZvAWcvglpZpBmBIFegZDdxrbKrK9popLDvq366aVSLp/JygKig HsjBCo0NqMG1LlZ+1Y5ATTctipXmMS89rfLYrCTh7+AgKpfeKG6nAdy206ZMZ00ynVDZ 3p4ncXgRfiiwef20K6CofnVqv2ED0eRLu4YF1TFE7Yy2RRrvYKeeUM6clc5TjApSbgPR 8IpU+hmnGQt8jKQR//JpxwXNduyJb3kYp1IsPfm2eZRobTT9wPFTtsdZwSh/nLrjUVCy x2J7W8tFO2ktYzOZ6DopPWYn0YAPQmZo54cRQIrjZNc9Ro29aoyRa6nI7GxjUOlQV8Bt 0iIA== X-Gm-Message-State: AA+aEWbfWmgfYJxa9JAVV8UyJj9fGP5/D9UTfwudRThRdkcT5FrQ/h6j 6Udx8YUB37ffqpVTY9dKqiBZI44kJBihPw== X-Google-Smtp-Source: AFSGD/VQUqEEBKai7TdmRE3OXHQwePuTIMGM6VJD8mIm9czm6vzjps9avFc+ENbBB4fs6MrKkOJQrg== X-Received: by 2002:a50:ad0b:: with SMTP id y11mr24465084edc.113.1544115720613; Thu, 06 Dec 2018 09:02:00 -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 e35sm322666eda.13.2018.12.06.09.01.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Dec 2018 09:02:00 -0800 (PST) From: Hans Dedecker To: openwrt-devel@lists.openwrt.org, jo@mein.io Date: Thu, 6 Dec 2018 18:01:55 +0100 Message-Id: <20181206170155.18982-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_090212_669435_0032240A X-CRM114-Status: GOOD ( 11.14 ) 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:544 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] 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 --- 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;