From nobody Tue Dec 17 10:08:13 2024 X-Original-To: dev-commits-src-main@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 4YCCDt0Ftfz5h0p6; Tue, 17 Dec 2024 10:08:14 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YCCDs55XKz4BxF; Tue, 17 Dec 2024 10:08:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734430093; 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=WNp483xuLeNqbUqI26VPj5UZcxtl/e633cxNeCtge/w=; b=ijNAY/pcn6s0AzPsSt2yrPq9ZJxZfIzIt1RfLXPw4ZfZ9LyPAFGAyqATmHgG0wwexBAcp2 0e3CtGIC9jdwNtP4G9p7Hu70c/7mx2Rx+m5OtjC9Sh/nH1BmFgVedCEXtMN4MZzbu/uWp1 A97viWQrfcqEHUno85NRZogBww/JqzgqsNBhqTXNBF8q92cEsz17IuV3BazHvobottJHM5 oIQ0+zwuITZhFceplRZ6hbV9qNoPaZd/l3QbLId01mGJCZ37pqIWXVi91bXkZYM1MOQeax j/ltB04Gr3edX0c1dztZN6Eyq9OJaroMVqawlJugsZjAst0QhNAVwaf+CMM4RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734430093; 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=WNp483xuLeNqbUqI26VPj5UZcxtl/e633cxNeCtge/w=; b=C/OC4+9UNxxAO4xHIPMcIr1XO/zxJssdo+u4UN26LOTBPbqALTE/8jhMwErafJ6ATUG2vm 2e+lfY1mi0QZC/r/eC+I5n7ZMbL4iEAXkhS9jC7UVAe6JB934kMlFVRclE9SOSDhdFEPu7 6YcR6LYOR4Wy76uGWijYqXwy5uoH6/C07FPntz5CTAG4ujVGwUfZzXE0EqUmF6uo4Xq+aq WU7l/qJzdta6Yh3jlPWvqef3xQFbv4Q8Rjsj/ZAFw5Nqwl6RMQGaSvNlCGYY+ZAbVaIgEX zjJFjDsOybMYFE9pfClsSPwFdZ9O5jBBx5GfOypoZRU3EbvbkXmbjzxoQW/0Ow== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1734430093; a=rsa-sha256; cv=none; b=iAGws8e82Y496O9RhWGCLWIRVkZoLEXqmi34/U0z4p5IrHXNqsg1mD9nZeNTwZQkHREoc+ iLizPrnxyglLkuXMnva+halPJL1utTO0pNSFNm/jBRa1eZquPmVdjYKraY9xSrhFfo7j+u OukOgf7BFuR1Nw52Vfdo1264PnnQFOu6rOOonSRrUTSCitLYsxwwyUTLobCebYyinaWbej Tah56ptDHl/hEFv2yANKPLZC18euEQMgaVBQwLmLG4BbrPCF2rspGV3FS359UpGowlXxOz 9dJ57qCCKaOHnPu6MGDsi/ajAjBkKnbaACRlYc5nsM0ExHzTVKTxoACiFK5uLg== 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 4YCCDs4gvVzJjn; Tue, 17 Dec 2024 10:08:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4BHA8Dwk024882; Tue, 17 Dec 2024 10:08:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4BHA8DZM024879; Tue, 17 Dec 2024 10:08:13 GMT (envelope-from git) Date: Tue, 17 Dec 2024 10:08:13 GMT Message-Id: <202412171008.4BHA8DZM024879@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: e0dcc51ddb43 - main - pfctl: do not allow af-to tables without round-robin List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: e0dcc51ddb43201e58f15645f000e27f061df081 Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=e0dcc51ddb43201e58f15645f000e27f061df081 commit e0dcc51ddb43201e58f15645f000e27f061df081 Author: Kristof Provost AuthorDate: 2024-12-10 11:00:06 +0000 Commit: Kristof Provost CommitDate: 2024-12-17 10:07:17 +0000 pfctl: do not allow af-to tables without round-robin Tables can only be used as a redirspec (i.e. in pf_map_addr()) in round-robin mode. Enforce this for af-to tables as well. Add a test case to verify. Sponsored by: Rubicon Communications, LLC ("Netgate") --- sbin/pfctl/parse.y | 14 +++++++++++--- tests/sys/netpfil/pf/nat64.sh | 23 +++++++++++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y index fc24cbc238ba..fc9cf86081f6 100644 --- a/sbin/pfctl/parse.y +++ b/sbin/pfctl/parse.y @@ -2827,11 +2827,19 @@ pfrule : action dir logquick interface route af proto fromto r.free_flags |= PFRULE_DN_IS_QUEUE; } - if ($9.marker & FOM_AFTO) + if ($9.marker & FOM_AFTO) { r.naf = $9.nat.af; - r.nat.opts = $9.nat.pool_opts.type; - r.nat.opts |= $9.nat.pool_opts.opts; + r.nat.opts = $9.nat.pool_opts.type; + r.nat.opts |= $9.nat.pool_opts.opts; + + if ((r.nat.opts & PF_POOL_TYPEMASK) != + PF_POOL_ROUNDROBIN && + disallow_table($9.nat.rdr->host, "tables are only " + "supported in round-robin pools")) + YYERROR; + } + expand_rule(&r, $4, $5.host, $9.nat.rdr ? $9.nat.rdr->host : NULL, $7, $8.src_os, $8.src.host, $8.src.port, $8.dst.host, $8.dst.port, $9.uid, $9.gid, $9.rcv, $9.icmpspec, ""); diff --git a/tests/sys/netpfil/pf/nat64.sh b/tests/sys/netpfil/pf/nat64.sh index 827891373903..b0559ac1f98c 100644 --- a/tests/sys/netpfil/pf/nat64.sh +++ b/tests/sys/netpfil/pf/nat64.sh @@ -341,6 +341,28 @@ pool_cleanup() pft_cleanup } + +atf_test_case "table" +table_head() +{ + atf_set descr 'Tables require round-robin' + atf_set require.user root +} + +table_body() +{ + pft_init + + echo "pass in on epair inet6 from any to 64:ff9b::/96 af-to inet from " | \ + atf_check -s exit:1 \ + -e match:"tables are only supported in round-robin pools" \ + pfctl -f - +} + +table_cleanup() +{ + pft_cleanup +} atf_test_case "table_round_robin" "cleanup" table_round_robin_head() { @@ -417,5 +439,6 @@ atf_init_test_cases() atf_add_test_case "tos" atf_add_test_case "no_v4" atf_add_test_case "pool" + atf_add_test_case "table" atf_add_test_case "table_round_robin" }