From nobody Wed Jan 25 11:07:37 2023 X-Original-To: pf@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 4P21Jp0VPJz3b9xp for ; Wed, 25 Jan 2023 11:07:38 +0000 (UTC) (envelope-from bugzilla-noreply@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 4P21Jn4TWfz3ty1 for ; Wed, 25 Jan 2023 11:07:37 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674644857; 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: in-reply-to:in-reply-to:references:references; bh=k9tcxjamTj1nIMAuVEuNwxowHV8MZ9yLBy6X1fzgMsQ=; b=djZtniiqIo4ZqtM/UjQakBJEVJS/rv7J1iR6buTdB6cHwJGcfQ6DOeWMt8h4xQkEOtUpeX w6Ux9dR5si+hZtoLY8LR0y9BmuCBijvzdmpG9iBl4nydPZD7LN0UEncR+H6YcJd9tlkY88 4N/bb0kcbZWWWT3fch3yyne1ncARIHhXkslmYcTAdx/noCK+dBsPxH7EcbxL2/7fuOz/AF 0vv+H91/7jRBgalryB887ng6Fvo1R0Eyx0XjIJX56TXzTl3uojdQcPr63+pvq3uj37IwuX E1bwecQcQDXBtiGKcm7yQ+eY5N8NCYz4LMHrAiOF1WnDWWvR1m+8yycW0wj6cg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674644857; a=rsa-sha256; cv=none; b=GwXb/qnJAtWWcfP6gBTEJoPG8hfBNVd4C9kiM1QTlYfdQ+PNOUwJhgRYyrft64sjRhWhlS qWKv/P73R8QweByjV6fOyAa7QTv3tUY6YvhF+NIZnGU9A8V5HZbx0XrAiJmmN+3jZXVlrj KBrzngHe1dBT5QwpC4dBMwpfFymJSUFjKAh73fKQjLY3x2ktFrtIo+x5eCLcqCtUr3WEBr Oit8MZ3w0veMH74/30k694sxhAfGjcBDednk1jk30/ayozR761xp4GLTQNjy3uvidSk7Tm 5Gnc713s8qeUeSIvzsGpOqtfs3LdlAF7avzzpDm/iFd0C3fScHz5Uem/nrQ6vQ== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (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 4P21Jn3T2hzmtb for ; Wed, 25 Jan 2023 11:07:37 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 30PB7bft057691 for ; Wed, 25 Jan 2023 11:07:37 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 30PB7bGx057690 for pf@FreeBSD.org; Wed, 25 Jan 2023 11:07:37 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: pf@FreeBSD.org Subject: [Bug 268717] [pf] rdr rules don't work for traffic originating at localhost Date: Wed, 25 Jan 2023 11:07:37 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 13.1-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: dfr@rabson.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: pf@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Technical discussion and general questions about packet filter (pf) List-Archive: https://lists.freebsd.org/archives/freebsd-pf List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-pf@freebsd.org X-BeenThere: freebsd-pf@freebsd.org MIME-Version: 1.0 X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D268717 --- Comment #16 from dfr@rabson.org --- As far as I understand the code (which is not very well TBH), both nat and = rdr rules rely on both PF_IN and PF_OUT events but differ on which event trigge= rs state creation: PF_IN for rdr and PF_OUT for nat with the opposite event matching the other direction to reverse the re-write. For connections initiated locally, this symmetry is broken since we generate PF_IN events for the SYN causing the re-write and creating the state but si= nce there is no corresponding PF_OUT for the SYN+ACK reply, the connection fail= s. This is why I think we need PF_OUT for packets which will be delivered to t= he local stack rather than routed onward. I thought about whether it makes sense for rdr state creation to happen on PF_OUT but wouldn't that have other problems since the un-redirected destination address may direct the packet to the wrong outgoing interface? I haven't looked closely at upstream OpenBSD pf but it seems they have chan= ged the rule language considerably which would likely be a problem for FreeBSD unless there is a compability mode. I seem to remember that they support ta= bles for rdr target addresses which may be useful for managing a pool of load-balanced replicas. Anyway, for now I have a workable solution for my two (related) use-cases: 'publishing' container ports to the host for podman and mapping service VIP= s to containers for kubernetes. I'm looking forward to seeing the right solution= for this merged into main (and maybe stable/13). --=20 You are receiving this mail because: You are the assignee for the bug.=