Repository navigation
miniupnpd/nftables: keep the remote host of IPv4 port mappings - #925
Merged
Merged
Conversation
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
approved these changes
Oct 31, 2026
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Renewing an IPv4 port mapping that has a remote host returns 718 ConflictInMappingEntry with the nftables backend.
add_redirect_rule2()ignoresrhost, 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 asip 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 checkpasses. 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.