Bug 261802 - net/mpd5: set nat red-port with an alias_addr of 0.0.0.0 does not work anymore
Summary: net/mpd5: set nat red-port with an alias_addr of 0.0.0.0 does not work anymore
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Eugene Grosbein
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-02-08 20:53 UTC by Martin Birgmeier
Modified: 2022-02-14 16:45 UTC (History)
0 users

See Also:
eugen: maintainer-feedback+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Birgmeier 2022-02-08 20:53:39 UTC
Scenario:
- FreeBSD 12.3 latest
- ports latest
- using mpd5 with the following statement:

        # set nat red-port proto alias_addr alias_port local_addr local_port [ remote_addr remote_port ]
        set nat red-port tcp 0.0.0.0 8765 192.168.1.5 12345 11.12.13.14 0

- The intention is that whenever the remote host 11.12.13.14 connects from any source port to the aliased port 8765, regardless of alias_addr, the connection is redirected to the local port 12345 on the local address 192.168.1.5.
- The alias_addr is dynamically assigned and may change, therefore 0.0.0.0 is used as a wildcard. See LibAliasRedirectPort() in libalias(3).

Result:
- This worked until a few weeks ago.
- Now the rule does not seem to work anymore, i.e., the aliasing does not take place, and the TCP destination stays at <alias_addr>:8765 instead of being redirected to 192.168.1.5:12345.

Note:
- This might actually be an issue in the base system, with ng_nat and libalias.

-- Martin
Comment 1 Eugene Grosbein freebsd_committer freebsd_triage 2022-02-09 06:08:34 UTC
(In reply to Martin Birgmeier from comment #0)

Please specify last correctly working versions of mpd5 package and FreeBSD.
Also, specify exact mpd5 version as per "pkg info -x mpd5", and output of "uname -rmUK", too.
Comment 2 Eugene Grosbein freebsd_committer freebsd_triage 2022-02-09 06:11:33 UTC
(In reply to Martin Birgmeier from comment #0)

Also, please specify which protocol do you use mpd5 for (PPPoE, L2TP etc.)?
Comment 3 Eugene Grosbein freebsd_committer freebsd_triage 2022-02-09 10:18:31 UTC
Note that base system libalias(3) ABI was broken in stable/12 and later restored. If you used official mpd5 package or built the port in between and then upgraded your 12.x system again (f.e. moving to 12.3), you could end up with mpd5 binary built for incompatible ABI.

You can easily verify and fix it forcibly reinstalling mpd5 either from official package repository of using ports as mpd5 revision was bumped since then.
Comment 4 Martin Birgmeier 2022-02-09 18:29:55 UTC
The last time it was working was on Dec. 13.

At that time it was already the same version as now, installed on Dec. 5:
Dec  5 13:57:33 gandalf pkg-static[99888]: mpd5-5.9_4 deinstalled
Dec  5 13:57:34 gandalf pkg-static[99890]: mpd5-5.9_6 installed

The upgrade of that system from FreeBSD 12.2 to 12.3 happened on Dec. 30. The latest patchset was installed on Jan. 13.

[0]# pkg info -x mpd5
mpd5-5.9_6
[0]# uname -rmUK
12.3-RELEASE-p1 amd64 1203000 1203000
[0]# 

One important note: I am running mpd5 with this additional patch (put it in net/mpd5/files):

--- ./src/nat.c.ORIG    2013-06-11 11:00:00.000000000 +0200
+++ ./src/nat.c 2014-04-18 17:52:06.000000000 +0200
@@ -185,7 +185,7 @@
          if (!inet_aton (av[5], &r_addr))
            Error("bad remote IP address \"%s\"", av[5]);
          rp = atoi(av[6]);
-         if (rp <= 0 || rp > 65535)
+         if (rp < 0 || rp > 65535)
            Error("Incorrect remote port number \"%s\"", av[6]);
        }
        /* OK */

Otherwise a remote_port of 0 cannot be specified, but this is allowed according to libalias(3) and specifies "any" port.

I was aware of that breakage but did not think it applied here. The last installkernel of 12.2 before Dec. 5 (the date of the latest mpd5 installation) was Nov. 7, it must have been due to the advisories sent out on Nov. 4. But I think the breakage does not apply here as I do not see the error mentioned in bug #250722. Do you think it does? Should I indeed recompile?

Final note: I am building both src and ports myself because of a few small patches I keep.

-- Martin
Comment 5 Martin Birgmeier 2022-02-09 18:32:35 UTC
Forgot to mention the protocol: it is pppoe ("create link static L1 pppoe").

-- Martin
Comment 6 Eugene Grosbein freebsd_committer freebsd_triage 2022-02-09 22:53:54 UTC
(In reply to Martin Birgmeier from comment #5)

> Should I indeed recompile?

libalias ABI was broken stable/12 between April 7, 2020 and November 10, 2020.
FreeBSD 12.2 was released on October 27, 2020. Hence, ABI was changed back after that release and it happened for stable/12 only, not for the security branch releng/12.2.

If you moved from 12.2-pX to 12.3 and did not rebuild mpd5 binary since then, you should do it now.
Comment 7 Eugene Grosbein freebsd_committer freebsd_triage 2022-02-11 08:00:55 UTC
(In reply to Martin Birgmeier from comment #4)

> One important note: I am running mpd5 with this additional patch

I'm going to include the patch to the port. Do you use any other patches for mpd5?
Comment 8 Martin Birgmeier 2022-02-11 10:13:52 UTC
No, this is the only patch I use for mpd5.

I have already rebuilt and reinstalled, but it will take me a while to test the effect.

-- Martin
Comment 9 commit-hook freebsd_committer freebsd_triage 2022-02-11 13:36:51 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=fcba5123c1263e2bb2ddc6f6b7e71424f62377d2

commit fcba5123c1263e2bb2ddc6f6b7e71424f62377d2
Author:     Eugene Grosbein <eugen@FreeBSD.org>
AuthorDate: 2022-02-11 13:31:47 +0000
Commit:     Eugene Grosbein <eugen@FreeBSD.org>
CommitDate: 2022-02-11 13:31:47 +0000

    net/mpd5: let "red-port" accept zero remote port value

    Import upstream r2446: allow to configre "any" remote port
    for port redirection rule as supported by libalias(3).

    PR:             261802
    Reported by:    Martin Birgmeier

 net/mpd5/Makefile                |  2 +-
 net/mpd5/files/patch-nat.c (new) | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)
Comment 10 Martin Birgmeier 2022-02-14 16:45:25 UTC
This issue was indeed fixed by recompiling mpd5.

Thank you for your support.

-- Martin