DrahtBot added the label
Build system
on Feb 5, 2020
DrahtBot added the label
GUI
on Feb 5, 2020
DrahtBot added the label
P2P
on Feb 5, 2020
DrahtBot
commented at 11:18 pm on February 5, 2020:
member
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Conflicts
Reviewers, this pull request conflicts with the following ones:
#20864 (net: Move SocketSendData lock annotation to header by MarcoFalke)
#20744 ([POC] Use std::filesystem. Remove Boost Filesystem & System by fanquake)
#20487 (draft: Add syscall sandboxing using seccomp-bpf (Linux secure computing mode) by practicalswift)
#20201 (build: pkg-config related cleanup by hebasto)
#20196 (net: fix GetListenPort() to derive the proper port by vasild)
#19683 (depends: Pin clang search paths for darwin host by dongcarl)
#19064 (refactor: Cleanup thread ctor calls by hebasto)
#17920 (guix: Build support for macOS by dongcarl)
#16546 (External signer support - Wallet Box edition by Sjors)
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
laanwj
commented at 11:22 am on February 6, 2020:
member
Thanks for picking this up again. I hope we manage to do this this time.
DrahtBot removed the label
Needs rebase
on Feb 10, 2020
dongcarl assigned dongcarl
on Feb 10, 2020
dongcarl
commented at 7:26 pm on February 10, 2020:
member
Concept ACK, will test on my home router.
MarcoFalke removed the label
Build system
on Feb 10, 2020
MarcoFalke removed the label
GUI
on Feb 10, 2020
Sjors
commented at 5:57 pm on February 11, 2020:
member
Concept ACK. Lightly tested configure / build on macOS.
Unfortunately I’m behind a IPv6 DS-Lite router, I can’t test the IPv4 port forward. Perhaps -7 could be replaced by something more readable.
02020-02-11T17:48:27Z natpmp thread start
12020-02-11T17:48:27Z Bound to [::]:8333
22020-02-11T17:48:27Z Bound to 0.0.0.0:8333
32020-02-11T17:48:27Z init message: Loading P2P addresses...
42020-02-11T17:48:27Z NAT-PMP: readnatpmpresponseorretry() for public address failed with -7 error.
52020-02-11T17:48:27Z NAT-PMP: readnatpmpresponseorretry() for port mapping failed with -7 error.
I looked up the error code, and it’s what I would expect given my setup:
0/* NATPMP_ERR_NOGATEWAYSUPPORT : the gateway does not support NAT-PMP */
1#define NATPMP_ERR_NOGATEWAYSUPPORT (-7)
Two suggesitons for followups, or this PR:
add checkbox in QT Settings (above UPNP)
add support for IPv6 pinhole if the library supports it, see #17012 (looks like it doesn’t)
hebasto
commented at 7:11 pm on February 11, 2020:
member
I looked up the error code, and it’s what I would expect given my setup:
0/* NATPMP_ERR_NOGATEWAYSUPPORT : the gateway does not support NAT-PMP */
1#define NATPMP_ERR_NOGATEWAYSUPPORT (-7)
Agree.
But in this initial PR I intentionally do not provide user-friendly error messages in order to keep ThreadNatpmp() dense and tight for easier reviewing ;)
In followups every library call (initnatpmp(), sendpublicaddressrequest() and sendnewportmappingrequest()) with the following readnatpmpresponseorretry() loops could be refactored out to separate functions with user-friendly error messages.
Two suggesitons for followups, or this PR:
* add checkbox in QT Settings (above UPNP)
Agree. From the OP:
Some follow-ups are out of this PR’s scope:
* mention NAT-PMP library in the version message
* integrate NAT-PMP into the GUI
I wouldn’t use them simultaneously, but one fails it makes sense to try the other. Though I believe our long plan is to remove UPnP, if NAT-PMP does the job.
hebasto
commented at 1:01 pm on February 12, 2020:
I wouldn’t use them simultaneously, but one fails it makes sense to try the other.
Good suggestion for a followup.
Though I believe our long plan is to remove UPnP, if NAT-PMP does the job.
Not all routers with stock software have NAT-PMP port mapping feature.
luke-jr
commented at 1:04 pm on February 12, 2020:
Users who don’t know what their router supports should be able to just flip both on. And laptops might very well migrate between different routers using each protocol.
Agree with @hebasto that NAT-PMP can’t be a complete substitute for UPnP since routers might not support both.
hebasto
commented at 4:00 pm on February 16, 2020:
Addressed in the latest push.
hebasto force-pushed
on Feb 16, 2020
hebasto
commented at 3:59 pm on February 16, 2020:
member
Perhaps -7 could be replaced by something more readable.
Done.
If both are enabled, would you try to open de port with NAT_PMP first and if that fails UPNP?
I wouldn’t use them simultaneously, but one fails it makes sense to try the other.
Done.
in
src/init.cpp:455
in
dc228d6db8outdated
451 #ifdef USE_UPNP
452 #if USE_UPNP
453 gArgs.AddArg("-upnp", "Use UPnP to map the listening port (default: 1 when listening and no -proxy)", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
454 #else
455- gArgs.AddArg("-upnp", strprintf("Use UPnP to map the listening port (default: %u)", 0), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
456+ gArgs.AddArg("-upnp", "Use UPnP to map the listening port (default: 0)", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
luke-jr
commented at 2:09 am on February 17, 2020:
Prefer to leave this alone (and use %s in the new options)
hebasto
commented at 6:25 am on February 17, 2020:
Agree. It will be fixed.
hebasto
commented at 4:56 pm on February 17, 2020:
Done.
luke-jr
commented at 2:13 am on February 17, 2020:
member
The logic here still seems broken. Again, consider that users may migrate between different routers each with NAT-PMP or UPnP support. So there should be a common thread main that at each refresh (which ideally should trigger when network availability changes, but that can be another PR) checks for which protocol to use and does the right thing.
hebasto
commented at 6:28 am on February 17, 2020:
member
The logic here still seems broken. Again, consider that users may migrate between different routers each with NAT-PMP or UPnP support. So there should be a common thread main that at each refresh (which ideally should trigger when network availability changes, but that can be another PR) checks for which protocol to use and does the right thing.
ThreadAnyAvailable() does almost the same:
if a used protocol becomes unavailable, ThreadAnyAvailable() switches to another one, no?
luke-jr
commented at 2:23 pm on February 17, 2020:
member
Yes, re-reading it, you’re right, it does. I saw the loops in the per-protocol functions and missed the outer one.
hebasto force-pushed
on Feb 17, 2020
hebasto
commented at 4:55 pm on February 17, 2020:
member
luke-jr
commented at 8:16 pm on February 17, 2020:
Suggest just making this StartMapPort(bool use_upnp, bool use_natpmp)
luke-jr
commented at 9:26 pm on February 17, 2020:
Or better yet: Just check gArgs inside StartMapPort…
hebasto
commented at 10:01 pm on February 18, 2020:
Reworked in the latest push.
in
src/qt/optionsmodel.cpp:367
in
2d5d98ce0aoutdated
361@@ -350,9 +362,13 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
362 fMinimizeToTray = value.toBool();
363 settings.setValue("fMinimizeToTray", fMinimizeToTray);
364 break;
365+ case MapPortNatpmp: // core option - can be changed on-the-fly
366+ settings.setValue("fUseNatpmp", value.toBool());
367+ m_node.mapPort(value.toBool(), MapPort::NAT_PMP);
luke-jr
commented at 8:17 pm on February 17, 2020:
This logic won’t work if the thread is already running…
hebasto
commented at 8:42 am on February 18, 2020:
Going to fix it.
hebasto
commented at 10:01 pm on February 18, 2020:
Fixed in the latest push.
luke-jr changes_requested
in
src/init.cpp:446
in
2d5d98ce0aoutdated
438@@ -438,6 +439,15 @@ void SetupServerArgs()
439 gArgs.AddArg("-torcontrol=<ip>:<port>", strprintf("Tor control port to use if onion listening enabled (default: %s)", DEFAULT_TOR_CONTROL), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
440 gArgs.AddArg("-torpassword=<pass>", "Tor control port password (default: empty)", ArgsManager::ALLOW_ANY | ArgsManager::SENSITIVE, OptionsCategory::CONNECTION);
441 gArgs.AddArg("-asmap=<file>", "Specify asn mapping used for bucketing of the peers. Path should be relative to the -datadir path.", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
442+#ifdef USE_NATPMP
443+#if USE_NATPMP
444+ gArgs.AddArg("-natpmp", "Use NAT-PMP to map the listening port (default: 1 when listening and no -proxy)", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
445+#else
446+ gArgs.AddArg("-natpmp", strprintf("Use NAT-PMP to map the listening port (default: %u)", 0), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
luke-jr
commented at 8:54 pm on February 17, 2020:
%s > %u
hebasto
commented at 8:46 am on February 18, 2020:
%s > %u
What is the rationale? We already use the %u specifier for unsigned integers in tfm::format().
luke-jr
commented at 0:08 am on February 19, 2020:
%s doesn’t care what type the value is.
You can use the same format string above, with a value of "1 when listening and no -proxy"
hebasto
commented at 8:05 pm on February 19, 2020:
Done in the latest push.
hebasto force-pushed
on Feb 18, 2020
hebasto
commented at 10:01 pm on February 18, 2020:
member
dongcarl
commented at 11:11 pm on February 18, 2020:
member
Hi all, did some testing on ccb4a7ea18c38914f084b7c070303d020adad326. What I did:
Installed natpmpd on my OpenBSD gateway router
Started natpmpd, added relevant pf.conf line, reloaded pf
Configure and compile bitcoind with --without-miniupnpc --disable-bench --disable-wallet --without-gui --with-natpmp
Start bitcoind with -natpmp
Saw the following lines:
02020-02-18T22:26:26Z NAT-PMP: Public address = 108.21.84.253
12020-02-18T22:26:26Z AddLocal(108.21.84.253:8333,3)
22020-02-18T22:26:26Z NAT-PMP: Port mapping failed.
32020-02-18T22:26:26Z NAT-PMP: Port mapping removed successfully.
Checked my natpmpd anchored pfctl rules:
0$ doas pfctl -a natpmpd -s rules
1pass in quick on rdomain 0 inet proto tcp from any to <my-egress-ip> port = 62774 flags any rdr-to 192.168.0.5 port 8333
I believe this means that natpmpd successfully allocated a port 62774 to bitcoind, but since that port does not equal our private port, this check failed: https://github.com/bitcoin/bitcoin/pull/18077/files#diff-161ad6a962291e0bbafeb83ddc8a977cR109. I believe this is because natpmpd ignores our “Suggested External Port”, which is perfectly valid, and we should probably account for that possibility.
luke-jr
commented at 0:19 am on February 19, 2020:
member
If NAT-PMP allows ignoring the suggested port, then we probably should handle that by advertising the correct port for the external IP in addrman.
hebasto
commented at 9:29 am on February 19, 2020:
member
@dongcarl
Thank you for testing this PR with natpmpd on OpenBSD (I’ve tested with miniupnpd on OpenWrt).
I believe this is because natpmpd ignores our “Suggested External Port”, which is perfectly valid, and we should probably account for that possibility.
The external TCP or UDP port assigned to the client is always randomised rather than giving the first client the port it actually requested and then trying to work out what to do for additional clients that want the same external port.
If the client would prefer to have a high-numbered “anonymous” external port assigned, then it should set the Suggested External Port to zero, which indicates to the gateway that it should allocate a high-numbered port of its choosing. If the client would prefer instead to have the mapped external port be the same as its local internal port if possible (e.g., a web server listening on port 80 that would ideally like to have external port 80), then it should set the Suggested External Port to the desired value. However, the gateway is not obliged to assign the port suggested, and may choose not to, either for policy reasons (e.g., port 80 is reserved and clients may not request it) or because that port has already been assigned to some other client.
Also, since NAT-PMP apparently maps random ports often, I think we should prefer UPnP…
Does this behavior of NAT-PMP gateways hurt the entire p2p network?
OTOH, NAT-PMP seems more secure than UPnP (for example, one could compare numbers of CVEs for each protocol).
luke-jr
commented at 11:52 pm on February 20, 2020:
member
Does this behavior of NAT-PMP gateways hurt the entire p2p network?
DNS seeds can’t provide port numbers, so using anything other than 8333 reduces the list of nodes we can advertise. Currently, mine (which is IIRC more restrictive than others) has 3090 eligible nodes, so it’s not a big deal, but it’d be nicer to have a wider selection available than a narrower selection.
OTOH, NAT-PMP seems more secure than UPnP (for example, one could compare numbers of CVEs for each protocol).
The CVEs AFAIK are for the implementations, not the protocol.
In any case, when we are using either, I think we’re reduced to the weakest no matter which we prefer (a hostile router could block NAT-PMP to force fallback to UPnP).
luke-jr
commented at 6:59 pm on February 21, 2020:
This will exit if it get the interrupt, causing target changes to shut off port mapping entirely.
hebasto
commented at 10:51 am on February 22, 2020:
If the protocol switch is initiated by a user, the g_mapport_interrupt() call will end the internal protocol-specific loop in the ThreadNatpmp() or in the ThreadUpnp(), ok == true and g_mapport_interrupt.sleep_for(PORT_MAPPING_RETRY_PERIOD) will not call at all.
If the protocol switch is initiated by a protocol failure, ok == false and g_mapport_interrupt.sleep_for(PORT_MAPPING_RETRY_PERIOD) will behave as intended.
Setting g_mapport_target_proto variable to MapPortProto::NONE also causes shutting off port mapping entirely.
luke-jr changes_requested
luke-jr
commented at 7:01 pm on February 21, 2020:
member
Re NAT-PMP preference: Also, with the port number changing every startup, it will be hard for peers to reconnect or meaningfully pass on addr messages for you…
I think cd7a0f689c5 should get split up. It’s too hard to follow what it’s doing.
hebasto
commented at 8:43 am on February 22, 2020:
member
Re NAT-PMP preference: Also, with the port number changing every startup, it will be hard for peers to reconnect or meaningfully pass on addr messages for you…
Only natpmpd on OpenBSD will change external port number on every startup.
miniupnpd assigns suggested one, i.e. 8333.
luke-jr
commented at 4:00 pm on February 22, 2020:
member
Yes, but UPnP is reliably using the same/requested port if it works.
hebasto force-pushed
on Feb 23, 2020
hebasto
commented at 1:00 am on February 23, 2020:
member
All changes are submitted to the model in the mapper->submit() call before the QDialog::accepted() signal is emitted when the dialog has been accepted by calling accept().
ryanofsky
commented at 6:09 pm on January 19, 2021:
In commit “gui: Apply port mapping changes on dialog exit” (58e8364dcdc4e57b0caac09f8402e6535301de9b)
@hebasto It seems like this commit has a bug and will incorrectly overwrite command line and config file -upnp and -natpmp options. I think this might have happened before, but previously only if these settings were changed, now if the dialog is just opened and closed.
Would you have an opinion on reverting this change? Aside from the bug, it seems simpler to go back to fully applying settings in OptionsModel, instead of using half-using OptionsModel to apply the setting, and then reading the setting later in a different code path and QSettings instance in dialog code outside of OptionsModel.
It seems like this commit has a bug and will incorrectly overwrite command line and config file -upnp and -natpmp options.
The concerns about user-friendly and correct behavior were raised in #18184. Now users are able to switch -upnp and -natpmp on/off on-the-fly via the GUI. Should we drop this feature?
I think this might have happened before, but previously only if these settings were changed, now if the dialog is just opened and closed.
Exiting the dialog via the “Cancel” push button or pressing the “Esc” key should not trigger that code path.
Anyway, I’ll happy to revert (or enhance) that change in a proper way.
in
src/init.cpp:452
in
de19f109c7outdated
446@@ -447,7 +447,12 @@ void SetupServerArgs()
447 #endif
448 #else
449 hidden_args.emplace_back("-upnp");
450-#endif
451+#endif // #ifdef USE_UPNP
452+#ifdef USE_NATPMP
453+ gArgs.AddArg("-natpmp", strprintf("Use NAT-PMP to map the listening port (default: %s)", DEFAULT_NATPMP ? "1 when listening and no -proxy" : 0), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
luke-jr
commented at 8:14 pm on February 23, 2020:
Pretty sure a?b:c requires b and c to have the same type.
luke-jr
commented at 8:18 pm on February 23, 2020:
Pretty sure a?b:c requires b and c to have the same type.
hebasto
commented at 5:30 pm on February 25, 2020:
Fixed.
hebasto
commented at 5:30 pm on February 25, 2020:
Fixed.
luke-jr changes_requested
hebasto force-pushed
on Feb 25, 2020
hebasto
commented at 5:27 pm on February 25, 2020:
member
DrahtBot removed the label
Needs rebase
on Mar 11, 2020
DrahtBot added the label
Needs rebase
on Mar 25, 2020
hebasto force-pushed
on Mar 28, 2020
hebasto
commented at 6:50 pm on March 28, 2020:
member
Rebased 4be5c3c72d98b616367d1aa3de22702e6f9f81ee -> 1bf61f0557637b5bedd670a4fba7bb11bf42ac6a due to the conflicts with #18134 and #18438.
DrahtBot removed the label
Needs rebase
on Mar 28, 2020
DrahtBot added the label
Needs rebase
on Apr 6, 2020
hebasto force-pushed
on Apr 11, 2020
hebasto
commented at 1:13 pm on April 11, 2020:
member
Rebased 1bf61f0557637b5bedd670a4fba7bb11bf42ac6a -> 607144bab1aecb8b970e17aeb145d62175d58c4c (pr18077.17 -> pr18077.18) due to the conflicts with #18514 and #16367.
DrahtBot removed the label
Needs rebase
on Apr 11, 2020
hebasto force-pushed
on Apr 11, 2020
hebasto
commented at 2:43 pm on April 11, 2020:
member
Rebased 607144bab1aecb8b970e17aeb145d62175d58c4c -> a388fae1dca9b4983bc95d50d07503aae527f29e (pr18077.18 -> pr18077.19) due to the conflict with #18588.
laanwj added this to the milestone 0.21.0
on Apr 11, 2020
DrahtBot added the label
Needs rebase
on Apr 15, 2020
hebasto force-pushed
on Apr 16, 2020
hebasto
commented at 4:51 pm on April 16, 2020:
member
Rebased a388fae1dca9b4983bc95d50d07503aae527f29e -> 95e943cb1855dca3ed5fb4fd98b357515d1a3646 (pr18077.19 -> pr18077.20) due to the conflict with #18571.
DrahtBot removed the label
Needs rebase
on Apr 16, 2020
DrahtBot added the label
Needs rebase
on Apr 20, 2020
hebasto force-pushed
on Apr 20, 2020
hebasto
commented at 7:10 pm on April 20, 2020:
member
Rebased 95e943cb1855dca3ed5fb4fd98b357515d1a3646 -> f4a4643712eca819a5b7ed0a143216e06125d1a9 (pr18077.20 -> pr18077.21) due to the conflicts with #18676 and #18705.
DrahtBot removed the label
Needs rebase
on Apr 20, 2020
tryphe
commented at 4:28 am on May 17, 2020:
contributor
tACKf4a4643712eca819a5b7ed0a143216e06125d1a9 on Debian 9
02020-05-17T04:14:52Z NAT-PMP: Port mapping successful. External address = [redacted]:8333
12020-05-17T04:22:05Z NAT-PMP: Port mapping removed successfully.
The port is accessible externally without any other forwarding rules.
DrahtBot added the label
Needs rebase
on May 19, 2020
hebasto force-pushed
on May 19, 2020
hebasto
commented at 4:24 pm on May 19, 2020:
member
Rebased f4a4643712eca819a5b7ed0a143216e06125d1a9 -> 2f7a01708482ad9f8fede1d7b7a9d59901370aa1 (pr18077.21 -> pr18077.22) due to the conflict with #19008.
DrahtBot removed the label
Needs rebase
on May 19, 2020
DrahtBot added the label
Needs rebase
on May 21, 2020
hebasto force-pushed
on May 22, 2020
hebasto
commented at 5:33 am on May 22, 2020:
member
Rebased 2f7a01708482ad9f8fede1d7b7a9d59901370aa1 -> f0cf6523c9fb4c3bb0bc64af72cdcadfa7747748 (pr18077.22 -> pr18077.23) due to the conflict with #18677.
DrahtBot removed the label
Needs rebase
on May 22, 2020
DrahtBot added the label
Needs rebase
on May 22, 2020
hebasto force-pushed
on May 22, 2020
hebasto
commented at 11:38 am on May 22, 2020:
member
Rebased f0cf6523c9fb4c3bb0bc64af72cdcadfa7747748 -> 1b006d618d02eac38bd434937d6d5c42084992bf (pr18077.23 -> pr18077.24) due to the conflict with #19014.
DrahtBot removed the label
Needs rebase
on May 22, 2020
DrahtBot added the label
Needs rebase
on Jun 3, 2020
hebasto force-pushed
on Jun 4, 2020
hebasto
commented at 7:09 am on June 4, 2020:
member
Rebased 1b006d618d02eac38bd434937d6d5c42084992bf -> 0692bed243adb8d4f3aa8192e9d1952d1de4a2ad (pr18077.24 -> pr18077.25) due to the conflict with #19041.
DrahtBot removed the label
Needs rebase
on Jun 4, 2020
DrahtBot added the label
Needs rebase
on Jun 8, 2020
hebasto force-pushed
on Jun 8, 2020
hebasto
commented at 3:06 pm on June 8, 2020:
member
Rebased 0692bed243adb8d4f3aa8192e9d1952d1de4a2ad -> 5a29078b373f5ffecb452317a1bd6fb165b08b42 (pr18077.25 -> pr18077.26) due to the conflict with #19180.
DrahtBot removed the label
Needs rebase
on Jun 8, 2020
hebasto closed this
on Jun 15, 2020
hebasto reopened this
on Jun 15, 2020
DrahtBot added the label
Needs rebase
on Jun 19, 2020
hebasto force-pushed
on Jun 20, 2020
hebasto
commented at 8:01 am on June 20, 2020:
member
Rebased 5a29078b373f5ffecb452317a1bd6fb165b08b42 -> 570c1060058d7f52286107df217b66d28d0b1f91 (pr18077.26 -> pr18077.27) due to the conflict with #19267.
DrahtBot removed the label
Needs rebase
on Jun 20, 2020
DrahtBot added the label
Needs rebase
on Jul 1, 2020
hebasto force-pushed
on Jul 3, 2020
hebasto
commented at 7:16 am on July 3, 2020:
member
Rebased 570c1060058d7f52286107df217b66d28d0b1f91 -> a660ecc26e691ed9b931d6fe27c26899ef66be64 (pr18077.27 -> pr18077.28) due to the conflict with #19331.
DrahtBot removed the label
Needs rebase
on Jul 3, 2020
hebasto force-pushed
on Jul 5, 2020
hebasto
commented at 9:06 am on July 5, 2020:
member
fixed dependency libnatpmp build with the custom CC variable.
DrahtBot added the label
Needs rebase
on Jul 9, 2020
hebasto force-pushed
on Jul 10, 2020
hebasto
commented at 7:55 am on July 10, 2020:
member
Rebased d4a143ae233fc5fd0cb3c08ce7c388434d256574 -> b61233d7ab4afe6cd7875b178e923fab59f0534a (pr18077.29 -> pr18077.30) due to the conflicts with #19191 and #19314.
DrahtBot removed the label
Needs rebase
on Jul 10, 2020
DrahtBot added the label
Needs rebase
on Jul 14, 2020
hebasto force-pushed
on Jul 14, 2020
hebasto
commented at 8:17 am on July 14, 2020:
member
Rebased b61233d7ab4afe6cd7875b178e923fab59f0534a -> 1c4bfdb46d48fed6c3f43bbdd7973069cdd21baf (pr18077.30 -> pr18077.31) due to the conflict with #19495.
DrahtBot removed the label
Needs rebase
on Jul 14, 2020
DrahtBot added the label
Needs rebase
on Jul 16, 2020
hebasto force-pushed
on Jul 16, 2020
hebasto
commented at 6:42 pm on July 16, 2020:
member
Rebased 1c4bfdb46d48fed6c3f43bbdd7973069cdd21baf -> 155d87877c11a32abe1ed91799776691b5977a31 (pr18077.31 -> pr18077.32) due to the conflict with #17919.
DrahtBot removed the label
Needs rebase
on Jul 16, 2020
DrahtBot added the label
Needs rebase
on Jul 30, 2020
hebasto force-pushed
on Jul 31, 2020
hebasto
commented at 12:14 pm on July 31, 2020:
member
Rebased 155d87877c11a32abe1ed91799776691b5977a31 -> 88b1f0357c332bc67fa20450dda9f77fa449576e (pr18077.32 -> pr18077.33) due to the conflict with #19561.
DrahtBot removed the label
Needs rebase
on Jul 31, 2020
DrahtBot added the label
Needs rebase
on Aug 7, 2020
hebasto force-pushed
on Aug 8, 2020
hebasto
commented at 7:19 am on August 8, 2020:
member
Rebased 88b1f0357c332bc67fa20450dda9f77fa449576e -> 225f512438f4391f6af255f851131358e3c466a2 (pr18077.33 -> pr18077.34) due to the conflict with #19098.
DrahtBot removed the label
Needs rebase
on Aug 8, 2020
adamjonas
commented at 2:02 pm on August 10, 2020:
member
For those looking to review or revisit:
(All pre-rebase)
There are concept ACKs from: luke-jr, dongcarl, Sjors, Sipa
a tACK from tryphe
with no NACKs or blocking issues
dongcarl
commented at 7:11 pm on August 20, 2020:
member
02020-08-20T19:07:08Z NAT-PMP: Port mapping successful. External address = <redacted>
Did not read code yet
in
doc/release-notes-18077.md:9
in
225f512438outdated
0@@ -0,0 +1,9 @@
1+P2P and network changes
2+-----------------------
3+
4+- Added NAT-PMP port mapping support via [`libnatpmp`](https://miniupnp.tuxfamily.org/libnatpmp.html)
5+
6+Command-line options
7+--------------------
8+
9+- The `-natpmp` option has been added to use NAT-PMP to map the listening port. If both `-upnp` and `-natpmp` options are provided, the former prevails.
Neither should prevail - one should be attempted before the other, but both should work.
dongcarl
commented at 5:20 pm on October 30, 2020:
Perhaps I’m reading the code wrong, but it seems like “If both UPnP and NAT-PMP are enabled, a successful allocation from UPnP prevails over one from NAT-PMP” is a more accurate description here?
I’m thinking about the case where both UPnP and NAT-PMP are enabled, but the gateway box is not responding to UPnP, in that case, a NAT-PMP allocation would still be accepted, right?
Perhaps I’m reading the code wrong, but it seems like “If both UPnP and NAT-PMP are enabled, a successful allocation from UPnP prevails over one from NAT-PMP” is a more accurate description here?
Thanks! It remained from the initial version of the PR :)
Updated.
I’m thinking about the case where both UPnP and NAT-PMP are enabled, but the gateway box is not responding to UPnP, in that case, a NAT-PMP allocation would still be accepted, right
The do loop introduced in the c01073db04e94a8d67f29de3daead0e2574b1c26 commit is responsible for that.
hebasto
commented at 11:59 pm on October 30, 2020:
Simultaneously?
DrahtBot added the label
Needs rebase
on Aug 26, 2020
hebasto force-pushed
on Aug 26, 2020
hebasto
commented at 9:13 am on August 26, 2020:
member
Rebased 225f512438f4391f6af255f851131358e3c466a2 -> 22cbf4eefaa7333a3e2bf94fbf4d3e7b4bf379cb (pr18077.34 -> pr18077.35) due to the conflict with #19779.
DrahtBot removed the label
Needs rebase
on Aug 26, 2020
DrahtBot added the label
Needs rebase
on Aug 26, 2020
hebasto force-pushed
on Aug 26, 2020
hebasto
commented at 5:01 pm on August 26, 2020:
member
DrahtBot removed the label
Needs rebase
on Aug 26, 2020
DrahtBot added the label
Needs rebase
on Sep 15, 2020
hebasto force-pushed
on Sep 15, 2020
hebasto
commented at 2:34 pm on September 15, 2020:
member
Rebased 2b6bd32e915d13928577b038c18194ac4024fc10 -> 62601a5a158b8c3710fde7cac8aadaa71a72f110 (pr18077.36 -> pr18077.37) due to the conflict with #19558.
DrahtBot removed the label
Needs rebase
on Sep 15, 2020
jonatack
commented at 10:09 am on September 17, 2020:
member
Concept ACK
laanwj removed this from the milestone 0.21.0
on Oct 8, 2020
laanwj added this to the milestone 0.22.0
on Oct 8, 2020
DrahtBot added the label
Needs rebase
on Oct 12, 2020
gmaxwell
commented at 7:03 pm on October 12, 2020:
contributor
I performed basic functional testing against this branch (but not master with this applied due to rebase hell) against http://www.nongnu.org/natpmp/.
I don’t really like the natpmp default being set by configure. I see the UPNP is currently handled that way, but I think that is an artefact of the fact that UPNP is disabled for implementation specific security reasons. Otherwise, no other bitcoin setting has its default set by configure. That said, this could easily be something changed after getting the functionality merged or even in a subsequent release.
I found that it successfully mapped 8333 and released the mapping on shutdown.
I restricted the port range at the pmp-daemon and found that it successfully mapped a different port and correctly learned the other port number.
I killed the pmp-daemon while bitcoind was running then shutdown and verified that it didn’t hang up waiting for some unmap confirmation or anything like that.
I did not change my external IP to confirm that it learned about the IP change (as I couldn’t do that without disrupting other people). I think this would be a useful thing to test, but even if it didn’t work right I don’t think it would block merging this.
Looks to me like it works!
hebasto force-pushed
on Oct 13, 2020
hebasto
commented at 5:47 am on October 13, 2020:
member
Rebased 62601a5a158b8c3710fde7cac8aadaa71a72f110 -> 44a697619d3fc3d9311c3d099cae04b21de071f3 (pr18077.37 -> pr18077.38) due to the conflict with #19998.
DrahtBot removed the label
Needs rebase
on Oct 13, 2020
gmaxwell
commented at 9:41 am on October 15, 2020:
contributor
ultra minor nit, ignore if you like: I didn’t like that the logs calls it “NAT-PMP” but the configuration option is natpmp, so I had to go read the code to figure out what I should be looking for. I’d prefer to see logs say “natpmp” for optimum greppability.
hebasto force-pushed
on Oct 15, 2020
hebasto
commented at 10:26 am on October 15, 2020:
member
Rebased 44a697619d3fc3d9311c3d099cae04b21de071f3 -> 81a791d88d68e64968e52d8ff6ec20879bd5fad1 (pr18077.38 -> pr18077.39) due to the conflict with #19077, and addressed @gmaxwell’s comment:
ultra minor nit, ignore if you like: I didn’t like that the logs calls it “NAT-PMP” but the configuration option is natpmp, so I had to go read the code to figure out what I should be looking for. I’d prefer to see logs say “natpmp” for optimum greppability.
gmaxwell
commented at 9:54 pm on October 15, 2020:
contributor
Still works. Looks good to me.
jamesob
commented at 4:52 pm on October 19, 2020:
member
Concept ACK - reviewing this shortly
in
depends/packages/libnatpmp.mk:5
in
81a791d88doutdated
The “net: Keep trying to use UPnP when -upnp=1” commit (5b6af780967c428ec38fa18ae68a193d2d036f57) is a prerequisite for the “net: Add NAT-PMP to port mapping loop” commit (c329ae5b6834e8dae6d178bc84321c7dc6e3c6fc).
Both commits make possible to switch port forwarding method at runtime.
Really worthwhile change; all else equal the easier we can make offering inbound conn capacity the better.
I’ve reviewed and built locally, though my router doesn’t support NAT-PMP out of the box. I’ll see what I can do in the meantime in terms of more comprehensive testing.
hebasto force-pushed
on Oct 22, 2020
hebasto
commented at 6:37 pm on October 22, 2020:
member
DrahtBot added the label
Needs rebase
on Oct 27, 2020
hebasto force-pushed
on Oct 27, 2020
hebasto
commented at 10:27 am on October 27, 2020:
member
Rebased bddfeade1e7740f04002f6d88e6e9840ed985bea -> 5fd127243f452827dab3b4f4f47b6e96816fdfb8 (pr18077.41 -> pr18077.42) due to the conflict with #19124.
DrahtBot removed the label
Needs rebase
on Oct 27, 2020
jamesob approved
jamesob
commented at 6:45 pm on October 27, 2020:
member
Re-reviewed diffs after rebase. Built locally with NAT-PMP enabled. My gateway doesn’t support NAT-PMP, but regular IBD works okay.
DrahtBot added the label
Needs rebase
on Oct 29, 2020
hebasto force-pushed
on Oct 29, 2020
hebasto
commented at 2:58 pm on October 29, 2020:
member
Rebased 5fd127243f452827dab3b4f4f47b6e96816fdfb8 -> 90d9547f135ef0ffc00dd790072c3ae307f053ad (pr18077.42 -> pr18077.43) due to the conflict with #20156.
DrahtBot removed the label
Needs rebase
on Oct 29, 2020
hebasto closed this
on Oct 30, 2020
hebasto reopened this
on Oct 30, 2020
hebasto force-pushed
on Oct 30, 2020
hebasto
commented at 5:38 pm on October 30, 2020:
member
Perhaps I’m reading the code wrong, but it seems like “If both UPnP and NAT-PMP are enabled, a successful allocation from UPnP prevails over one from NAT-PMP” is a more accurate description her
in
src/mapport.cpp:285
in
29fb5708caoutdated
286+ // Enabling another protocol does not cause switching from the currently used one.
287+ return;
288+ }
289+
290+ assert(g_mapport_thread.joinable());
291+ assert(!g_mapport_interrupt);
luke-jr
commented at 10:51 pm on October 30, 2020:
Couldn’t this be true if the user is impossibly fast?
I don’t think so due to the CThreadInterrupt class implementation.
DrahtBot added the label
Needs rebase
on Nov 9, 2020
hebasto force-pushed
on Dec 7, 2020
hebasto
commented at 11:02 am on December 7, 2020:
member
Rebased 29fb5708ca04da9ca0c25c1b801887354eb714bc -> 3c26d53f538442363834178a45bc8b459b5b334d (pr18077.44 -> pr18077.45) due to the conflicts with #20202, #20494 and the recent CI changes.
DrahtBot removed the label
Needs rebase
on Dec 7, 2020
DrahtBot added the label
Needs rebase
on Dec 10, 2020
hebasto force-pushed
on Dec 10, 2020
hebasto
commented at 6:30 pm on December 10, 2020:
member
Rebased 3c26d53f538442363834178a45bc8b459b5b334d -> cc68169e72c5b28fe53466a86eeac9fd214cd0d1 (pr18077.45 -> pr18077.46) due to the conflict with #20527.
DrahtBot removed the label
Needs rebase
on Dec 10, 2020
DrahtBot added the label
Needs rebase
on Dec 15, 2020
hebasto force-pushed
on Dec 15, 2020
hebasto
commented at 6:29 pm on December 15, 2020:
member
DrahtBot removed the label
Needs rebase
on Dec 15, 2020
LarryRuane
commented at 8:44 pm on December 16, 2020:
contributor
In case any of this is helpful… I wanted to try running this, I’m running Ubuntu 18.04 as a Virtualbox guest on a Windows 10 host running at home (Xfinity-Comcast, nothing unusual), I checked out branch pr18077.47, ran
0$ sudo apt install libminiupnpc-dev libnatpmp-dev
1(... successful)
2$ ./autogen.sh && ./configure --disable-wallet --without-miniupnpc --enable-natpmp-default && make
3(...)
4checking whether to build with support for UPnP... no
5checking whether to build with support for NAT-PMP... yes
6checking whether to build with NAT-PMP enabled by default... yes
7(...)
8$ src/bitcoind
Starts up normally, but this prints to debug.log every 5 minutes:
02020-12-16T19:14:17Z natpmp: The gateway does not support NAT-PMP.
and bitcoin-cli -netstat shows that I have no incoming peers. I think this is all as expected, but I’m not testing much. I don’t know how to change my gateway to support NAT-PMP (I’d appreciate any help). I did change my cable modem router’s firewall to allow P2P applications on both IPv4 and IPv6, but that didn’t make any difference.
hebasto
commented at 9:32 am on December 17, 2020:
member
I don’t know how to change my gateway to support NAT-PMP (I’d appreciate any help).
Your gateway s/w manual (if available) could help. My TP-Link Archer C6 does not have NAT-PMP support with stock s/w, so I’ve flashed the OpenWrt on it.
laanwj
commented at 1:10 pm on December 17, 2020:
member
Looked over the overall changes, they look reasonable to me.
Will test.
FWIW, I disagree. I think we should prefer NATPMP and phase out UPnP in the longer run when it has proven to be stable.
(of course, if a lot of issues actually come up it’s different, but I wouldn’t do this based on one comment)
@luke-jr, what do you mean by “maps random ports often”? Some implementation of natpmp has bugs? Can you give an example?
Maybe just remove this comment “// Low priority protocol.” – it is unclear what is meant by it and is missing in other places where #ifdef USE_NATPMP is used.
hebasto
commented at 10:04 pm on December 18, 2020:
The external TCP or UDP port assigned to the client is always randomised rather than giving the first client the port it actually requested and then trying to work out what to do for additional clients that want the same external port.
@hebasto, Thanks for the clarification! IMO the nat-pmp implementation overriding the desired external port is fine as long as we advertise the overriden one instead of the desired one (I guess we do). That should also be expected as it is allowed by the RFC.
I guess something like that happens with UPnP too if the desired port is already used?
hebasto
commented at 9:37 am on December 25, 2020:
IMO the nat-pmp implementation overriding the desired external port is fine as long as we advertise the overriden one instead of the desired one (I guess we do).
75+ } else if (r_read == NATPMP_ERR_NOGATEWAYSUPPORT) {
76+ LogPrintf("natpmp: The gateway does not support NAT-PMP.\n");
77+ } else {
78+ LogPrintf("natpmp: readnatpmpresponseorretry() for public address failed with %d error.\n", r_read);
79+ }
80+
I guess at some point in the future we could replace this thread (which does nothing but waiting and periodically run stuff) with scheduler runnables instead? (not in this PR)
DrahtBot added the label
Needs rebase
on Dec 17, 2020
hebasto force-pushed
on Dec 18, 2020
hebasto
commented at 11:03 pm on December 18, 2020:
member
DrahtBot removed the label
Needs rebase
on Dec 19, 2020
DrahtBot added the label
Needs rebase
on Jan 7, 2021
refactor: Move port mapping code to its own module
This commit does not change behavior.
02ccf69dd6
refactor: Replace magic number with named constant28e2961fd6
net: Keep trying to use UPnP when -upnp=18b50d1b5bb
net: Add flags for port mapping protocols4e91b1e24d
scripted-diff: Rename UPnP stuff
-BEGIN VERIFY SCRIPT-
sed -i 's/g_upnp_interrupt/g_mapport_interrupt/' src/mapport.cpp
sed -i 's/if(g_upnp_thread/if (g_mapport_thread/' src/mapport.cpp
sed -i 's/g_upnp_thread/g_mapport_thread/' src/mapport.cpp
sed -i 's/LOCAL_UPNP/LOCAL_MAPPED/' src/mapport.cpp
sed -i 's/\bupnp\b/mapport/' src/mapport.cpp
sed -i 's/LOCAL_UPNP, /LOCAL_MAPPED,/' src/net.h
-END VERIFY SCRIPT-
cf151cc68c
gui: Apply port mapping changes on dialog exit
This commit does not change behavior. It is a prerequisite for NAT-PMP
support adding.
58e8364dcd
net: Add libnatpmp supporta8d9f275d0
net: Add NAT-PMP to port mapping loop28acffd9d5
net: Add -natpmp command line optiona39f7336a3
gui: Add NAT-PMP network option5a0185b6c9
ci: Add libnatpmp-dev package to some buildse28f9be87a
doc: Add libnatpmp stuffae749d12dd
doc: Add release notesa191e23b8e
hebasto force-pushed
on Jan 7, 2021
hebasto
commented at 4:25 pm on January 7, 2021:
member
Rebased 890e59c64d62fd39778ede620a70fe6bc60d9993 -> a191e23b8e7f0e19fc0359825eb7ca0d47966fa9 (pr18077.48 -> pr18077.49) due to the conflict with #20864.
DrahtBot removed the label
Needs rebase
on Jan 7, 2021
laanwj
commented at 6:39 pm on January 7, 2021:
member
Tested and code review ACKa191e23b8e7f0e19fc0359825eb7ca0d47966fa9
laanwj merged this
on Jan 7, 2021
laanwj closed this
on Jan 7, 2021
hebasto deleted the branch
on Jan 7, 2021
sidhujag referenced this in commit
8d8f45119e
on Jan 7, 2021
random-zebra referenced this in commit
fce12cf6c3
on Jun 24, 2021
apoelstra referenced this in commit
fdfc181255
on Jul 11, 2021
apoelstra referenced this in commit
8964d4c5e1
on Jul 11, 2021
apoelstra referenced this in commit
4f33ba757d
on Jul 11, 2021
kittywhiskers referenced this in commit
687c7d4a5d
on Feb 26, 2022
PastaPastaPasta referenced this in commit
47ad9ab146
on Mar 5, 2022
ryanofsky referenced this in commit
101ea8668c
on Apr 19, 2022
ryanofsky referenced this in commit
236bede111
on Apr 23, 2022
ryanofsky referenced this in commit
d50e50ef67
on May 2, 2022
ryanofsky referenced this in commit
4954e35808
on May 16, 2022
ryanofsky referenced this in commit
7962bbd470
on May 17, 2022
ryanofsky referenced this in commit
dc43c4fc01
on May 19, 2022
ryanofsky referenced this in commit
4848368071
on May 19, 2022
ryanofsky referenced this in commit
29e371de75
on May 19, 2022
ryanofsky referenced this in commit
69ebadd5f3
on May 20, 2022
ryanofsky referenced this in commit
da33f2d8fe
on May 20, 2022
ryanofsky referenced this in commit
fc30d78f10
on May 20, 2022
ryanofsky referenced this in commit
56590dc8f0
on May 20, 2022
ryanofsky referenced this in commit
1821316f8f
on May 23, 2022
ryanofsky referenced this in commit
f299e12104
on May 23, 2022
ryanofsky referenced this in commit
f854ab8ee0
on May 26, 2022
ryanofsky referenced this in commit
b2c8fc344f
on May 26, 2022
ryanofsky referenced this in commit
383aee6ba2
on May 31, 2022
ryanofsky referenced this in commit
13ce751718
on Jun 6, 2022
ryanofsky referenced this in commit
d2ada6e635
on Jun 9, 2022
janus referenced this in commit
4e8d501701
on Aug 4, 2022
This is a metadata mirror of the GitHub repository
bitcoin/bitcoin.
This site is not affiliated with GitHub.
Content is generated from a GitHub metadata backup.
generated: 2024-11-23 09:12 UTC
This site is hosted by @0xB10C More mirrored repositories can be found on mirror.b10c.me