opnsense / plugins

OPNsense plugin collection
https://opnsense.org/
BSD 2-Clause "Simplified" License
845 stars 641 forks source link

net/upnp: IPv6 pinhole renewal fails #4010

Closed Sjors closed 5 months ago

Sjors commented 5 months ago

Important notices Before you add a new report, we ask you kindly to acknowledge the following:

Describe the bug

I'm able to open an IPv6 pinhole. I'm also able to close it, by renewing with a lease time of 0. But when I attempt to do a regular renewal it fails with NO_RESOURCES.

For more details and things I tried, see: https://github.com/bitcoin/bitcoin/pull/30043#issuecomment-2133381489

Someone else tried it with TurrisOS (openwrt) with the miniupnpd 2.3.3 and could not reproduce. This suggest the problem may not be in upstream miniupnpd. Though it might be in upstream FreeBSD.

(I'll update this issue later with more details, have to leave now)

To Reproduce

Probably not the easiest way, but you could compile https://github.com/bitcoin/bitcoin/pull/30043 start src/bitcoind -signet -natpmp -debug=net -nomempool, watch as it opens a pinhole, wait 10-15 minutes and then watch as the renewal fails. Optionally change PORT_MAPPING_REANNOUNCE_PERIOD to 2mins to see it faster.

It's best to turn on verbose logging #4004

If there's an easier tool to debug this behavior let me know, that way I can also rule out a client implementation error.

Expected behavior Pinhole should renew

Screenshots

Relevant log files

tail -f /var/log/routing/latest.log

Plugin starts:

<30>1 2024-05-28T18:12:43+02:00 OPNsense.localdomain miniupnpd 68411 - [meta sequenceId="2"] version 2.3.3 starting NAT-PMP/PCP ext if pppoe1 BOOTID=1716912763
<29>1 2024-05-28T18:12:43+02:00 OPNsense.localdomain miniupnpd 68411 - [meta sequenceId="3"] Listening for NAT-PMP/PCP traffic on port 5351

Adding PCP mapping on port 1234:

...

(will expand later)

Additional context

Environment

miniupnpd v2.3.3

OPNsense 24.1.7_4-amd64 FreeBSD 13.2-RELEASE-p11 OpenSSL 3.0.13

Client: most testing done from Intel macOS 14.5, but I've observed the same on Ubuntu and Windows.

laanwj commented 5 months ago

Apparently this is due to the PF implementation of pinholing in miniupnpd not implementing update_pinhole at all https://github.com/miniupnp/miniupnp/blob/master/miniupnpd/pf/pfpinhole.c#L379 This will also affect UPnP as it uses the same underlying function.

It doesn't affect Linux iptables on openwrt because that functionality is implemented for that: https://github.com/miniupnp/miniupnp/blob/master/miniupnpd/netfilter/iptpinhole.c#L379.

Sjors commented 5 months ago

@laanwj great find! I opened a upstream issue: https://github.com/miniupnp/miniupnp/issues/747