Skip to content

Conversation

@vasild
Copy link
Contributor

@vasild vasild commented May 30, 2024

Allow the callers of CreateSock() to pass all 3 arguments to the socket(2) syscall. This makes it possible to create sockets of any domain/type/protocol. In addition to extending arguments, some extra safety checks were put in place.

The need for this came up during the discussion in #30043 (comment)

@DrahtBot
Copy link
Contributor

DrahtBot commented May 30, 2024

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

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK tdb3, theStack, achow101
Stale ACK laanwj

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #29876 (build: add -Wundef by fanquake)
  • #29641 (scripted-diff: Use LogInfo/LogDebug over LogPrintf/LogPrint by maflcko)
  • #29625 (Several randomness improvements by sipa)

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
Copy link
Member

laanwj commented May 30, 2024

Concept and code review (but untested, will use this to make a testing harness for #30043) ACK 77e34ded543e19ba27cab8d0cfc464af27f04bbf

Copy link
Contributor

@tdb3 tdb3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK for 77e34ded543e19ba27cab8d0cfc464af27f04bbf

Thanks. Seems like a reasonable change.

Sanity checks performed:

  • Synced the last 1.5 day's worth of blocks on signet. Binding and sync seemed to work fine.
  • Ran all unit and functional tests (passed).

Left some minor notes (just thinking out loud, so no need to answer/comment unless you feel it's necessary).

Copy link
Contributor

@theStack theStack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept and code-review ACK 77e34ded543e19ba27cab8d0cfc464af27f04bbf

@vasild vasild force-pushed the extend_CreateSock branch from 77e34de to 5f549c3 Compare June 12, 2024 06:49
@vasild
Copy link
Contributor Author

vasild commented Jun 12, 2024

77e34ded54...5f549c35d9: fix typo in the comment: s/socke/socket/

Copy link
Contributor

@theStack theStack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-ACK 5f549c35d9a75c7019fe8a96963b988df5498eed 🧦

@DrahtBot DrahtBot requested review from laanwj and tdb3 June 12, 2024 07:09
Copy link
Contributor

@tdb3 tdb3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-ACK 5f549c35d9a75c7019fe8a96963b988df5498eed

@achow101
Copy link
Member

ACK 5f549c35d9a75c7019fe8a96963b988df5498eed

@achow101
Copy link
Member

Silent merge conflict

../../../src/test/fuzz/i2p.cpp:30:16: error: no viable overloaded '='
   30 |     CreateSock = [&fuzzed_data_provider](const sa_family_t&) {
      |     ~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   31 |         return std::make_unique<FuzzedSock>(fuzzed_data_provider);
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   32 |     };
      |     ~
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/std_function.h:469:7: note: candidate function not viable: no known conversion from '(lambda at ../../../src/test/fuzz/i2p.cpp:30:18)' to 'const function<unique_ptr<Sock> (int, int, int)>' for 1st argument
  469 |       operator=(const function& __x)
      |       ^         ~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/std_function.h:487:7: note: candidate function not viable: no known conversion from '(lambda at ../../../src/test/fuzz/i2p.cpp:30:18)' to 'function<unique_ptr<Sock> (int, int, int)>' for 1st argument
  487 |       operator=(function&& __x) noexcept
      |       ^         ~~~~~~~~~~~~~~
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/std_function.h:501:7: note: candidate function not viable: no known conversion from '(lambda at ../../../src/test/fuzz/i2p.cpp:30:18)' to 'nullptr_t' (aka 'std::nullptr_t') for 1st argument
  501 |       operator=(nullptr_t) noexcept
      |       ^         ~~~~~~~~~
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/std_function.h:531:2: note: candidate template ignored: requirement '_Callable<(lambda at ../../../src/test/fuzz/i2p.cpp:30:18), (lambda at ../../../src/test/fuzz/i2p.cpp:30:18), std::__invoke_result<(lambda at ../../../src/test/fuzz/i2p.cpp:30:18) &, int, int, int>>::value' was not satisfied [with _Functor = (lambda at ../../../src/test/fuzz/i2p.cpp:30:18)]
  531 |         operator=(_Functor&& __f)
      |         ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/std_function.h:541:2: note: candidate template ignored: could not match 'reference_wrapper<_Functor>' against '(lambda at ../../../src/test/fuzz/i2p.cpp:30:18)'
  541 |         operator=(reference_wrapper<_Functor> __f) noexcept
      |         ^
1 error generated.
make[2]: *** [Makefile:17184: test/fuzz/fuzz-i2p.o] Error 1

@DrahtBot
Copy link
Contributor

🚧 At least one of the CI tasks failed. Make sure to run all tests locally, according to the
documentation.

Possibly this is due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.

Leave a comment here, if you need help tracking down a confusing failure.

Debug: https://github.com/bitcoin/bitcoin/runs/26113679661

Allow the callers of `CreateSock()` to pass all 3 arguments to the
`socket(2)` syscall. This makes it possible to create sockets of
any domain/type/protocol.
@vasild vasild force-pushed the extend_CreateSock branch from 5f549c3 to 1245d13 Compare June 14, 2024 12:24
@vasild
Copy link
Contributor Author

vasild commented Jun 14, 2024

5f549c35d9...1245d1388b: rebase due to (silent) merge conflict

@DrahtBot DrahtBot requested review from achow101 and theStack June 14, 2024 14:03
Copy link
Contributor

@tdb3 tdb3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re ACK 1245d13

Copy link
Contributor

@theStack theStack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-ACK 1245d13

@DrahtBot DrahtBot mentioned this pull request Jun 19, 2024
@achow101
Copy link
Member

ACK 1245d13

@achow101 achow101 merged commit a961ad1 into bitcoin:master Jun 20, 2024
@vasild vasild deleted the extend_CreateSock branch June 21, 2024 03:28
@Sjors Sjors mentioned this pull request Jun 21, 2024
24 tasks
@bitcoin bitcoin locked and limited conversation to collaborators Jun 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants