From nobody Tue Dec 17 10:07:47 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 4YCCDN299yz5h0L8; Tue, 17 Dec 2024 10:07:48 +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 4YCCDM5pWkz49X5; Tue, 17 Dec 2024 10:07:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734430067; 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=abqE+6Noz+JUJZwqvC3JgnO0xM0BWRt0nrERdGxm7Zw=; b=UU6DTHJNOL0YQepozNMp5x8VaNu/hT8IxCv9tS7qrfBAZ8OiZMw6UgauxC9NR7KTlFp/jZ ZdcOlEVsZUZoQUTeqnxbBhxT+6B2Iuad272q5fS1FJDAplWTFSUoiPZcH1cERTf+dyOMWz ebu982SYODMBeUItDS8T2VxO5aB+2xDeacu4y1JDAAteRxdy9NeesOmuBcxZFD+QsD3aJC qCK9Xub8R7c8trrkLDkefA2aQae5We5DaRtwhzueStxSRkRGGBUPLaNcrTvDZFG+You6nS WAyo/GDAMnFzt5+LrRr5vjepBt1npn1gXHRc6DQO6AwpCvO5nLK/qvHIxQKQQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734430067; 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=abqE+6Noz+JUJZwqvC3JgnO0xM0BWRt0nrERdGxm7Zw=; b=MkWp7iWUQER+fqjS86btIDiEEFUvhUnQcMnshOX/RF0PggnTB9xltylRamVaxaxrrLreZs 3aX/nSQRn1y7B0J+v4hnQtSLimKjbX+6up9VOhvOW4nafHGqylkvC+lJRNtMqWxn6kGzAD SC3BsaHhVPgBaVw85giLcUk9n7acIV5I0cfMFncFukDnMv8m3MM+TYHZmu5P20K7pj2n6G XC0OTWUfT5FE2kbyR/TxLUgp/58Oq2VtEyeyr1YpJb4a8p3hJwLfiYkDJsRGV/tKVxTfMJ oTfO95r47luNbFQB35imRU+PR29IalemuEerGGNP8gNDmZ7gm1WXKNz1pXRRWw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1734430067; a=rsa-sha256; cv=none; b=EXCT+MMgzpJXReS2zBL6hQqHh7rJkemdgXwauo54yKPANsoGPnkSHGuD3YjS5gdyHtBRFj by79Rs1O4vMBYdzNGH95vq53xWaK8rYiKdJqe3ARddpXMYlLFhGyutLhgg5X957clTXeMw ed5wzLnvcaEOyxAK0JshSbge3Uy4uSqeUntr3ui1XCtjNGZ7EmnD0RIxVEB1GStdGwcqGy cDd0/Qj+uBvrMh6HlX+0MP09sn6HnEQ7WNTaCLyK6DVORLQm2b3AaR76IaNLbe4baEJXJv Nd40VQWJsO312FW1LbO86GgTokqvKTkKuRCEm0Gw+G6WAUBnlYyWr2Pui0dfNA== 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 4YCCDM59wnzJvZ; Tue, 17 Dec 2024 10:07:47 +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 4BHA7l3K023597; Tue, 17 Dec 2024 10:07:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4BHA7lI3023594; Tue, 17 Dec 2024 10:07:47 GMT (envelope-from git) Date: Tue, 17 Dec 2024 10:07:47 GMT Message-Id: <202412171007.4BHA7lI3023594@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: b8e538443882 - main - pf: drop packets if they fail nat64 translation 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: b8e53844388269d87f26b106d538dcf07148bd31 Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=b8e53844388269d87f26b106d538dcf07148bd31 commit b8e53844388269d87f26b106d538dcf07148bd31 Author: Kristof Provost AuthorDate: 2024-12-06 14:29:11 +0000 Commit: Kristof Provost CommitDate: 2024-12-17 10:07:13 +0000 pf: drop packets if they fail nat64 translation If we can't map ICMPv4 onto ICMPv6 or vice versa drop the packet rather than continuing with an untranslated packet. Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/netpfil/pf/pf.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index 234cbc0854be..4c1111c6106a 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -5893,6 +5893,7 @@ nextrule: nat64 = pd->af != pd->naf; if (nat64) { struct pf_state_key *_sk; + int ret; if (sk == NULL) sk = (*sm)->key[pd->dir == PF_IN ? PF_SK_STACK : PF_SK_WIRE]; @@ -5902,12 +5903,17 @@ nextrule: _sk = sk; else _sk = nk; - rewrite += pf_translate(pd, + + ret = pf_translate(pd, &_sk->addr[pd->didx], _sk->port[pd->didx], &_sk->addr[pd->sidx], _sk->port[pd->sidx], virtual_type, icmp_dir); + if (ret < 0) + goto cleanup; + + rewrite += ret; } } else { while ((ri = SLIST_FIRST(&match_rules))) { @@ -6288,7 +6294,7 @@ pf_translate(struct pf_pdesc *pd, struct pf_addr *saddr, u_int16_t sport, if (afto) { if (pf_translate_icmp_af(AF_INET6, &pd->hdr.icmp)) - return (0); + return (-1); pd->proto = IPPROTO_ICMPV6; rewrite = 1; }