From nobody Fri Jan 27 08:59:35 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 4P3BN81wCwz3b3hY for ; Fri, 27 Jan 2023 08:59:36 +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 4P3BN801k5z3sbB for ; Fri, 27 Jan 2023 08:59:36 +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=1674809976; 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=tA7hodmLtNvfnrhr5cT5dZAeZayXuSTS2/Gt891UEWI=; b=FiRFjzmMFEeFW5ZUwFkDKip7KJvrPe5D8vMipLKCC0kUKh33oxim/FLkYRv7O3CxMwWneh x3+y3v3upqYQyzocsrV73+qD0hHXo9cq710O/NR5PtSoq0B94ItB6hcEs0EvSWJqCT+tNH eZ0XcMPJJus2OCzVA5TcQN8ZZLuacxGGB9a3+UC2j5Df0+4VApcWdgg8gMfJwJT8oXESyn LqlBwfxPc6yV3w7bsHUAAF7sIVeFOjHdF1uGrSQqPHO0Uqguugdd6Dx9a1Axl3pLwWvhiA 2XISTW0Y7WkKlH81NsG0DvJ3ehrIV4j7KJ1bN3QIzRfnAhQAePJjPksTqhCnpQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674809976; a=rsa-sha256; cv=none; b=TIitTWrkNVMMWawavBmiSwcGOA5+Qg/iVQ6tFO0SqSnaysV0GuiMWXrGT0ZqQVdFoy5qC2 NgxaOLA8PcIksCOMTYiGE+WQI3gMt9O+Hj6eO9HDjvaKNPO/IwOWZtqsuERSWai+7sPHij 1xNDKh9qPZlO1L3+6rpdBULEkSajWaeVRJmv5zehoxUgi4vbBj12SR58M0BTcY+hR0abd7 SyweZ6l9OShORl3C3Lf1CPFnsRGUJTQj+1oMjFdOm84ZDDIqpw3C4Ac3xe6Jmb6kGE/24N utMnpXy40tm2KOw4KXJniRkttcjZM18Yb2/RMD8XmFSV/5OO7qpiCqJ3fU808A== 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 4P3BN763FJz13Kd for ; Fri, 27 Jan 2023 08:59:35 +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 30R8xZxu090654 for ; Fri, 27 Jan 2023 08:59:35 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 30R8xZkB090653 for pf@FreeBSD.org; Fri, 27 Jan 2023 08:59:35 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: Fri, 27 Jan 2023 08:59:35 +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: kp@freebsd.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 #17 from Kristof Provost --- (In reply to dfr from comment #16) > As far as I understand the code (which is not very well TBH), both nat an= d rdr rules rely on both PF_IN and PF_OUT events but differ on which event = triggers state creation: PF_IN for rdr and PF_OUT for nat with the opposite= event matching the other direction to reverse the re-write. Sort of. I find it more useful to think about when the packets pass through which parts of the stack. That does imply a direction (i.e. PF_IN/PF_OUT). In the normal case, when we're thinking of rdr, we'd be dealing with incomi= ng packets, arriving through ip_input(), triggering a PF_IN pf_test(). For the failing case described here we're dealing with packets that are generated locally, and the first time they hit the firewall is from ip_outp= ut() (i.e. pf_test(PF_OUT)). > For connections initiated locally, this symmetry is broken since we gener= ate PF_IN events for the SYN causing the re-write and creating the state bu= t since there is no corresponding PF_OUT for the SYN+ACK reply, the connect= ion fails. This is why I think we need PF_OUT for packets which will be del= ivered to the local stack rather than routed onward. For locally generated connections we're only getting the PF_IN after we've already had a PF_OUT. We can't usefully do anything on SYN+ACK packets, and= if we're trying to add an artificial PF_OUT we're just papering over a problem that started earlier. > I thought about whether it makes sense for rdr state creation to happen o= n PF_OUT but wouldn't that have other problems since the un-redirected dest= ination address may direct the packet to the wrong outgoing interface? I'm not sure I follow. > I haven't looked closely at upstream OpenBSD pf but it seems they have ch= anged the rule language considerably which would likely be a problem for Fr= eeBSD unless there is a compability mode. I seem to remember that they supp= ort tables for rdr target addresses which may be useful for managing a pool= of load-balanced replicas. Kajetan intends to keep the old syntax supported, at least for a while. I s= till need to look at his work in detail, which I don't expect to be able to do before the end of February. > I'm looking forward to seeing the right solution for this merged into mai= n (and maybe stable/13). To be clear, I'm not making any promises about the time and effort I can sp= end on this. --=20 You are receiving this mail because: You are the assignee for the bug.=