net: reduce log level for PCP/NAT-PMP NOT_AUTHORIZED failures #34117

pull ANAVHEOBA wants to merge 2 commits into bitcoin:master from ANAVHEOBA:master changing 2 files +27 −6
  1. ANAVHEOBA commented at 4:35 PM on December 19, 2025: none

    Users running Bitcoin Core on home networks with routers that don't support PCP (Port Control Protocol) or NAT-PMP port mapping receive frequent warning-level log messages every few minutes:

    "pcp: Mapping failed with result NOT_AUTHORIZED (code 2)"

    This is expected behavior for many consumer routers that have PCP disabled by default, not an actionable error. The repeated warnings create unnecessary log noise.

    This change:

    • Adds explicit constants for NOT_AUTHORIZED result code (value 2) for both NAT-PMP and PCP protocols
    • Downgrades NOT_AUTHORIZED failures from LogWarning to LogDebug since this is an expected condition on many networks
    • Keeps LogWarning for other failure types that may indicate actual configuration or network issues

    The NOT_AUTHORIZED message will still be visible when running with -debug=net for users who need to troubleshoot port mapping issues.

    Fixes #34114

    <!-- *** Please remove the following help text before submitting: *** Pull requests without a rationale and clear improvement may be closed immediately. GUI-related pull requests should be opened against https://github.com/bitcoin-core/gui first. See CONTRIBUTING.md -->

    <!-- Please provide clear motivation for your patch and explain how it improves Bitcoin Core user experience or Bitcoin Core developer experience significantly: * Any test improvements or new tests that improve coverage are always welcome. * All other changes should have accompanying unit tests (see `src/test/`) or functional tests (see `test/`). Contributors should note which tests cover modified code. If no tests exist for a region of modified code, new tests should accompany the change. * Bug fixes are most welcome when they come with steps to reproduce or an explanation of the potential issue as well as reasoning for the way the bug was fixed. * Features are welcome, but might be rejected due to design or scope issues. If a feature is based on a lot of dependencies, contributors should first consider building the system outside of Bitcoin Core, if possible. * Refactoring changes are only accepted if they are required for a feature or bug fix or otherwise improve developer experience significantly. For example, most "code style" refactoring changes require a thorough explanation why they are useful, what downsides they have and why they *significantly* improve developer experience or avoid serious programming bugs. Note that code style is often a subjective matter. Unless they are explicitly mentioned to be preferred in the [developer notes](/doc/developer-notes.md), stylistic code changes are usually rejected. -->

    <!-- Bitcoin Core has a thorough review process and even the most trivial change needs to pass a lot of eyes and requires non-zero or even substantial time effort to review. There is a huge lack of active reviewers on the project, so patches often sit for a long time. -->

  2. net: reduce log level for PCP/NAT-PMP NOT_AUTHORIZED failures
    Users running Bitcoin Core on home networks with routers that don't
    support PCP (Port Control Protocol) or NAT-PMP port mapping receive
    frequent warning-level log messages every few minutes:
    
      "pcp: Mapping failed with result NOT_AUTHORIZED (code 2)"
    
    This is expected behavior for many consumer routers that have PCP
    disabled by default, not an actionable error. The repeated warnings
    create unnecessary log noise.
    
    This change:
    - Adds explicit constants for NOT_AUTHORIZED result code (value 2)
      for both NAT-PMP and PCP protocols
    - Downgrades NOT_AUTHORIZED failures from LogWarning to LogDebug
      since this is an expected condition on many networks
    - Keeps LogWarning for other failure types that may indicate
      actual configuration or network issues
    
    The NOT_AUTHORIZED message will still be visible when running with
    -debug=net for users who need to troubleshoot port mapping issues.
    
    Fixes #34114
    78e7259081
  3. DrahtBot added the label P2P on Dec 19, 2025
  4. DrahtBot commented at 4:35 PM on December 19, 2025: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/34117.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  5. net: fix CJDNS address discovery when -externalip is set
    When -externalip is specified, Bitcoin Core disables automatic address
    discovery by setting fDiscover to false. This is intended to prevent
    discovery of IPv4/IPv6 addresses when the user already knows their
    public IP.
    
    However, this also incorrectly prevented CJDNS addresses from being
    discovered and added to the local address list. CJDNS is a separate
    overlay network, and specifying an IPv4/IPv6 external IP should not
    affect CJDNS address advertising.
    
    This fix modifies:
    1. Discover() - Continue processing CJDNS addresses even when fDiscover
       is false, skipping only non-CJDNS addresses
    2. AddLocal() - Allow CJDNS addresses to be added even when discovery
       is disabled, since they should still be advertised
    
    Now users running with -externalip and -cjdnsreachable will have their
    CJDNS address properly appear in local addresses and be logged via
    AddLocal(), matching the behavior when -externalip is not specified.
    
    Fixes #33471
    af5c2fcf14
  6. janb84 commented at 5:35 PM on December 19, 2025: contributor

    you have created a PR with 2 commits, one is unrelated to this PR it seems

  7. ANAVHEOBA commented at 6:05 PM on December 19, 2025: none

    Both commit were on the issues list

  8. janb84 commented at 9:06 AM on December 22, 2025: contributor

    Both commit were on the issues list

    Not how this works, one PR one topic. Currently the PR description describes the commit for fixing #34114, I suggest that you keep that commit and create a new PR for the other commit, that has code for fixing #33471.

  9. bensig commented at 3:10 AM on January 5, 2026: contributor

    This PR mixes two unrelated changes:

    1. Log level reduction for PCP/NAT-PMP NOT_AUTHORIZED (pcp.cpp) - fixes #34114
    2. CJDNS address discovery fix when -externalip is set (net.cpp) - fixes #33471

    These should be separate PRs. Each change looks reasonable on its own, but combining unrelated fixes makes review harder and complicates git history/bisecting.

    Would you please split this into two PRs and resubmit?

  10. maflcko commented at 10:13 AM on January 5, 2026: member

    @ANAVHEOBA are you still working on this?

  11. ANAVHEOBA commented at 4:56 PM on January 5, 2026: none

    Yes, I push today

  12. ANAVHEOBA commented at 4:57 PM on January 5, 2026: none

    I am interested in working with bitcoin what is it going to take

  13. maflcko commented at 7:14 AM on January 6, 2026: member

    I'll go ahead and close this for now. This clearly needs separate pull requests, so this one will need to be closed either way.

  14. maflcko closed this on Jan 6, 2026

  15. willcl-ark commented at 3:11 PM on January 14, 2026: member

    @ANAVHEOBA do you intend to open a new PR with the first commit only as a fix to #34114?

    If you don't want to then I'd be happy to cherry-pick your commit and open a pr with it in, as the fix looks good to me.

  16. luke-jr referenced this in commit 00354e1161 on Jan 22, 2026
  17. princeOmri84 commented at 12:11 AM on February 11, 2026: none

    $10000

  18. bitcoin locked this on Feb 11, 2026

github-metadata-mirror

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: 2026-04-22 18:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me