Skip to content

miniupnpd/nftables: keep the remote host of IPv4 port mappings - #925

Merged
miniupnp merged 1 commit into
miniupnp:masterfrom
tritsystem:fix/nft-rhost
Oct 31, 2026
Merged

miniupnp merged 1 commit into
miniupnp:masterfrom
tritsystem:fix/nft-rhost

Conversation

@tritsystem

Copy link
Copy Markdown
Contributor

Renewing an IPv4 port mapping that has a remote host returns 718 ConflictInMappingEntry with the nftables backend. add_redirect_rule2() ignores rhost, so the DNAT rule has no source match. get_nat_redirect_rule() never returns it, so the renewal check sees a different remote host and reports a conflict. This change puts the remote host into the rule as ip saddr, the same way the iptables backend already does (iptcrdr.c), and reads it back.

Tested with the real daemon and upnpc in a network namespace. On master, the renewal returned 718. With this change it is accepted, the rule shows ip saddr 198.51.100.7, and the listing returns the remote host. Renewal without a remote host and deletion behave as before. make all check passes. The patch also applies to 2.3.11.

Limitation: IPv4 only; the IPv6 pinhole path is unchanged.

I used Claude Code as my assistant to investigate/fix/verify this issue; I reviewed the analysis and the fix before submitting.

add_redirect_rule2() dropped the remote host (UNUSED), so the DNAT rule
matched any source, and get_nat_redirect_rule() never reported one
(UNUSED too). upnp_redirect() compares the remote host of the existing
mapping with the request's, so renewing a mapping that has a remote host
always failed with 718 ConflictInMappingEntry, and
GetSpecificPortMappingEntry returned an empty NewRemoteHost.

Put the remote host in the DNAT rule (ip saddr), as the iptables backend
does, and read it back from the rule.
miniupnp added a commit that referenced this pull request Oct 31, 2026
@miniupnp
miniupnp merged commit eddc864 into miniupnp:master Oct 31, 2026
34 checks passed

This branch was previously deployed

1 inactive deployment
pypi — 2e71a4bd Deployed Oct 31, 2026 by tritsystem via 🚀 Upload #645
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants