addrman: don't overwrite addr_info when resetting I2P ports #22468

pull vasild wants to merge 2 commits into bitcoin:master from vasild:reset_i2p_ports_no_overwrite_pos changing 1 files +7 −13
  1. vasild commented at 10:40 AM on July 16, 2021: member

    In CAddrMan::ResetI2PPorts() we copy addr_info to addr_info_newport, change the port in the latter and eventually, if necessary, we overwrite addr_info with addr_info_newport.

    The problem is that after creating the copy, addr_info.nRandomPos may be changed by ClearNew() -> Delete() -> SwapRandom(). Later, overwriting the entire addr_info with the stale addr_info_newport would restore the previous/stale nRandomPos.

    To fix that change just the port in addr_info.

    Fixes https://github.com/bitcoin/bitcoin/issues/22467

  2. addrman: don't overwrite addr_info when resetting I2P ports
    In `CAddrMan::ResetI2PPorts()` we copy `addr_info` to
    `addr_info_newport`, change the `port` in the latter and eventually, if
    necessary, we overwrite `addr_info` with `addr_info_newport`.
    
    The problem is that after creating the copy, `addr_info.nRandomPos` may
    be changed by `ClearNew() -> Delete() -> SwapRandom()`. Later,
    overwriting the entire `addr_info` with the stale `addr_info_newport`
    would restore the previous/stale `nRandomPos`.
    
    To fix that change just the port in `addr_info`.
    
    Fixes https://github.com/bitcoin/bitcoin/issues/22467
    8c8cd36329
  3. addrman: simplify ResetI2PPorts() by removing addr_info_newport
    It is not necessary to have a separate variable `addr_info_newport`, we
    can directly change the port in `addr_info`.
    84b624ec83
  4. fanquake added the label P2P on Jul 16, 2021
  5. MarcoFalke added this to the milestone 22.0 on Jul 16, 2021
  6. jonatack commented at 10:33 AM on July 17, 2021: member

    ACK 84b624ec83c3d6528ce82fe37bdc4cdc5ecb9e47

    Running fuzzer and ran units with 24cad6353921e81f370 cherry picked on this branch.

  7. jonatack commented at 9:44 AM on July 19, 2021: member

    Still fuzzing with your last three pulls cherry-picked together + running on mainnet with DEBUG_ADDRMAN.

  8. DrahtBot commented at 7:29 PM on July 19, 2021: member

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    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.

  9. fanquake commented at 1:03 AM on July 20, 2021: member

    Closing now that #22497 has been merged.

  10. fanquake closed this on Jul 20, 2021

  11. vasild deleted the branch on Jul 20, 2021
  12. DrahtBot locked this on Aug 16, 2022

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-17 09:14 UTC

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