From nobody Thu Mar 24 13:14:40 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 74E871A38F3C; Thu, 24 Mar 2022 13:14:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KPQg45Mfyz3MPP; Thu, 24 Mar 2022 13:14:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648127681; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=pakopHY3UWjViCtuuLOORmuWq/c9jqPNFImSo7fC4rg=; b=KEzpTj7HfrY0gasfvHdE0rkRIfrfaGb1VT2Fs1hwwnj3Af58WGA1588N4n4SI0SbtaVKXN DLeaiTP/UrZeGJwsxS6EiT6lT7Ts4auinsVExQaI1lODOuHg/OOSdrBlx5Y7FGRWJOQM0s yKgTMMjxRzK2ugFpcspmpGJ8ZfuKG3dmyh4IKK/d9wT9W8VVCWdtRkldDlCb5gEwRFgxJY czryHS4ZVV+IUxgc3sBznLzwHG6j7FVSg/2nqwsDzxAulphgJ4Kf4XmO9J4i92IJ7hMSLI XSg+vsXcHwis+i/h/32CMEYxkEmnytK383pEgbfQNi/GpVCC/m4fdYMvv0kN5A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6A36918987; Thu, 24 Mar 2022 13:14:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 22ODEeJ6032074; Thu, 24 Mar 2022 13:14:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22ODEeNI032073; Thu, 24 Mar 2022 13:14:40 GMT (envelope-from git) Date: Thu, 24 Mar 2022 13:14:40 GMT Message-Id: <202203241314.22ODEeNI032073@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 837aa87ff4f0 - stable/12 - pfctl: fix retrieving nested nat-anchors List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 837aa87ff4f0957b8a7151b31cfb04a1a7f21bbb Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648127681; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=pakopHY3UWjViCtuuLOORmuWq/c9jqPNFImSo7fC4rg=; b=TtiPZdMT1B7HBJuWSrWMEqKO/imqVrNblXJ5KE82y5r0gG+h5iwt0Hb/GdVWom61fAPqoj L7/fMtlxhTD8zHn7PzhlN2F1Rp7MIm9C8VnPf8P3GKWUuB+Vv5Zuf7ocUyIjXQyNvOTW2z 8xN0mME+tiZ+HGNvXF0APHRrgpYo1Qub62vAt9hmDXiwrrjpcileHPw42dXBj9A8V0T3f1 ztXvCPAnR0BVEehjR85G14L1gwCFQiCqyArpZ2ztgtlMxLxzZ3I89CrLVgrta2+YaG/qPZ +67WesgU4GSPx8QxZxOo6Va3KNtCKNwsrGFSFknWz78FtLHCUFrwxcSZtzjRJg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1648127681; a=rsa-sha256; cv=none; b=BWzcjmEWJ0mmOKyMHdhBzi1v66635ulsK5qIH6uRpgy2KatvtIuS02qcEsQVnRGlGSxIWP JnXFQBWf/tjGJOIWnS39iQLBfFtvi29rxuEETxMkHDvXf964c6zWm+KgSBgBFMx8lKu/uu Fsnvrb+vOYhHk9oqvTGxsqEN0PpidOMBc9MjMh1EgNraO/fqWxKTbN1K2YYYBwYHh4TQ1t Zl2IwcqvuAJ2R4Z29ZGeVNDhyMbyepqvieZUzWbRpDKm6pTaiW+7q0CWbFxdtoO3lQgu25 hNo3rt6h8YUWMjIvC3hYy/lPonftwZUGn62NUztRxfytW6RbYdYLNQ8ggJOEYg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=837aa87ff4f0957b8a7151b31cfb04a1a7f21bbb commit 837aa87ff4f0957b8a7151b31cfb04a1a7f21bbb Author: Kristof Provost AuthorDate: 2022-03-17 17:31:37 +0000 Commit: Kristof Provost CommitDate: 2022-03-24 09:44:48 +0000 pfctl: fix retrieving nested nat-anchors When retrieving nat rules in anchors we need to set the path just like we do for regular rules. MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit a632d9e3601272c0157dce6633fc9a23ad6ae45b) --- sbin/pfctl/pfctl.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c index 17bd61fbccb2..eccfe319207e 100644 --- a/sbin/pfctl/pfctl.c +++ b/sbin/pfctl/pfctl.c @@ -1187,10 +1187,16 @@ pfctl_show_nat(int dev, char *path, int opts, char *anchorname, int depth) static int nattype[3] = { PF_NAT, PF_RDR, PF_BINAT }; int i, dotitle = opts & PF_OPT_SHOWALL; int brace, ret; + int len = strlen(path); char *p; + if (path[0]) + snprintf(&path[len], MAXPATHLEN - len, "/%s", anchorname); + else + snprintf(&path[len], MAXPATHLEN - len, "%s", anchorname); + for (i = 0; i < 3; i++) { - ret = pfctl_get_rules_info(dev, &ri, nattype[i], anchorname); + ret = pfctl_get_rules_info(dev, &ri, nattype[i], path); if (ret != 0) { warn("DIOCGETRULES"); return (-1); @@ -1199,13 +1205,13 @@ pfctl_show_nat(int dev, char *path, int opts, char *anchorname, int depth) brace = 0; INDENT(depth, !(opts & PF_OPT_VERBOSE)); - if (pfctl_get_rule(dev, nr, ri.ticket, anchorname, + if (pfctl_get_rule(dev, nr, ri.ticket, path, nattype[i], &rule, anchor_call)) { warn("DIOCGETRULE"); return (-1); } if (pfctl_get_pool(dev, &rule.rpool, nr, - ri.ticket, nattype[i], anchorname) != 0) + ri.ticket, nattype[i], path) != 0) return (-1); if (anchor_call[0] &&