Skip to content

ipc: support per-address max-connections options on -ipcbind - #35037

Merged
sedited merged 4 commits into
bitcoin:masterfrom
enochaz:04-26-ipcbind-max-connections-draft
Oct 8, 2026
Merged

sedited merged 4 commits into
bitcoin:masterfrom
enochaz:04-26-ipcbind-max-connections-draft

Conversation

@enochaz

@enochaz enochaz commented Apr 9, 2026 •

Copy link
Copy Markdown
Contributor

The branch extends -ipcbind to accept ,max-connections=<n> options, for example -ipcbind=unix:,max-connections=8 or -ipcbind=unix:/custom/path,max-connections=8, instead of introducing a separate global -ipcmaxconnections option.

This keeps the connection limit attached to each IPC listener instead of introducing a global -ipcmaxconnections option (#34978). A global option would not allow different limits for different -ipcbind addresses, and the inline option format can be extended in the future with additional options.

@DrahtBot

DrahtBot commented Apr 9, 2026 •

Copy link
Copy Markdown
Contributor

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

External sites

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
ACK ryanofsky, sedited, ViniciusCestarii
Concept ACK kevkevinpal, Sjors
Stale ACK xyzconstant, Eunovo

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #36097 (mining: replace interrupt methods with cancellation arguments by xyzconstant)
  • #31260 (scripted-diff: Type-safe settings retrieval by ryanofsky)
  • #28690 (build: Introduce internal kernel library by sedited)
  • #17783 (common: Disallow calling IsArgSet() on ALLOW_LIST options by ryanofsky)
  • #17581 (refactor: Remove settings merge reverse precedence code by ryanofsky)
  • #17580 (refactor: Add ALLOW_LIST flags and enforce usage in CheckArgFlags by ryanofsky)
  • #17493 (util: Forbid ambiguous multiple assignments in config file by ryanofsky)

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.

LLM Linter (✨ experimental)

Possible places where named args for integral literals may be used (e.g. func(x, /*named_arg=*/0) in C++, and func(x, named_arg=0) in Python):

  • [ParseIntOption(name, value, 1, static_cast<int64_t>(ipc::MAX_CONNECTIONS))] in src/ipc/listen.cpp

2026-09-30 12:42:23

@enochaz enochaz changed the title 04 26 ipcbind max connections draft ipc: support per-address max-connections options on -ipcbind Apr 9, 2026
@enochaz
enochaz force-pushed the 04-26-ipcbind-max-connections-draft branch from 065bfe9 to 788107e Compare April 9, 2026 13:57
@enochaz
enochaz force-pushed the 04-26-ipcbind-max-connections-draft branch from 788107e to 9a30318 Compare April 9, 2026 14:19
@ryanofsky

ryanofsky commented Apr 9, 2026 •

Copy link
Copy Markdown
Contributor

Concept ACK. Looks like suggestions from #35036 (comment) apply here too (sorry, saw that PR first in my inbox).

IMO this is a better alternative to adding a new -ipcmaxconnections option like #34978, and I'd prefer this approach but both approaches seem reasonable. Main reason I prefer this approach is IPC is a pretty generic feature, so it seems useful to be able to set different limits for different purposes (like GUIs vs mining clients).

@enochaz
enochaz force-pushed the 04-26-ipcbind-max-connections-draft branch from 8a2fa52 to 57a0a29 Compare April 9, 2026 14:55
@enochaz

enochaz commented Apr 9, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review @ryanofsky

I pushed updates based on your review here as well

  • the bind-address type is now shared
  • parsing moved behind the interfaces::Ipc boundary
  • the parser handles trailing socket options
  • listenAddress() now takes the bind-address struct directly

Comment thread test/functional/interface_ipc_init.py Resolved
@kevkevinpal

Copy link
Copy Markdown
Contributor

Concept ACK

I agree with Ryanofsky. I think this approach seems more reasonable than #34978, even though both can work and both make sense this seems cleaner. I think it makes sense to go with this approach instead of adding the -ipcmaxconnections option.

@fanquake

Copy link
Copy Markdown
Member

cc @Sjors

@enochaz
enochaz force-pushed the 04-26-ipcbind-max-connections-draft branch 7 times, most recently from 2309ca9 to 50fba48 Compare April 20, 2026 18:31

@Eunovo Eunovo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ACK c88b81d:

LGTM, left some nits.

Comment thread src/ipc/test/ipc_tests.cpp Resolved
Comment thread src/ipc/test/ipc_tests.cpp Resolved
Comment thread src/ipc/test/ipc_tests.cpp Resolved
Comment thread doc/release-notes-35037.md Resolved
Comment thread src/ipc/test/ipc_tests.cpp Resolved
@enochaz

enochaz commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

Addressed nits and suggestions by @Eunovo

@ViniciusCestarii ViniciusCestarii left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-ACK 39b1c5a

@nullfail

Copy link
Copy Markdown
Contributor

re-ACK 39b1c5a

Nice changes

@enochaz

enochaz commented Sep 16, 2026

Copy link
Copy Markdown
Contributor Author

Removed a stale comment 9be61a9#diff-5768699cb2773eff506c411cdb8ca5c1a5fddc6e4cc82a9cfc64b2c0f4f85e52R286 in the ipc_tests

@Eunovo

Eunovo commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

reACK 78a1251

@ryanofsky ryanofsky left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code review ACK 78a1251. Changes since last review were moving some changes to an earlier commit, adding ipc_fds constant, adding assert, updating tests and release notes.

(Previously discussed ideas I think would still be good as followups: making the parse method virtual #35037 (comment) so we are not linking ipc code into the common library, and making parsing code more compact and generic #35037 (comment))

Comment thread src/init.cpp Resolved
Comment thread src/ipc/listen.cpp Outdated
Comment on lines +48 to +87
size_t next{0};
while (next <= options_view.size()) {
const size_t end{options_view.find(',', next)};
const std::string_view option{
options_view.substr(next, end - next)};

if (option.empty()) {
return util::Error{Untranslated("Empty socket option")};
}

const size_t equals{option.find('=')};
const std::string_view name{option.substr(0, equals)};
const std::string_view value{
equals == std::string_view::npos ? std::string_view{} : option.substr(equals + 1)};

if (name != "max-connections") {
return util::Error{Untranslated(strprintf("Unknown socket option '%s'", name))};
}
if (value.empty()) {
return util::Error{Untranslated("Missing value for max-connections option")};
}

int64_t parsed_value{-1};
const auto [last, ec]{std::from_chars(value.data(), value.data() + value.size(), parsed_value)};

if (ec != std::errc{} || last != value.data() + value.size()) {
return util::Error{Untranslated("Invalid max-connections value '" + std::string{value} + "'")};
}
if (parsed_value < 1) {
return util::Error{Untranslated("max-connections must be at least 1")};
}
if (parsed_value > static_cast<int64_t>(ipc::MAX_CONNECTIONS)) {
return util::Error{Untranslated("max-connections must be at most " + util::ToString(ipc::MAX_CONNECTIONS))};
}

listen_address.max_connections = static_cast<size_t>(parsed_value);

if (end == std::string_view::npos) break;
next = end + 1;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would prefer this too.

Comment thread doc/release-notes-35037.md Resolved
@enochaz

enochaz commented Sep 26, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review @sedited . Addressed comments made

  • Simplified the parser to use SplitString and ParseIntOption
  • Simplified the init.cpp arg wording
  • Mentioned that the unix socket paths are now url decoded in the release notes

@ryanofsky ryanofsky left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code review 4ac08a6. Changes since last review: parsing now uses SplitString and ParseIntOption, the release notes mention URL decoding, and the help text is reworded. The parsing changes look good, but the new help text has unformatted %d placeholders (comment below), so I'd re-ACK once that's fixed.

Comment thread src/init.cpp Resolved
Parse optional max-connections socket options from -ipcbind values
through interfaces::Ipc, returning ipc::ListenAddress values that keep
each listener address and connection limit together.

Use comma delimited socket options to avoid ambiguity with paths
containing colons, and validate each configured limit before adding it
to IPC file descriptor reservations.
Add IPC coverage for local listener capacity over unix sockets.

Verify a listener at capacity resumes accepting after a disconnect, check separate
listeners enforce their limits independently, and cover parser and aggregate file
descriptor limit boundaries.

@ryanofsky ryanofsky left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code review ACK 856f9ea. Only change since last review is wrapping the -ipcbind help text in strprintf so the default and maximum values are shown. Thanks for all the updates!

@enochaz

enochaz commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

friendly ping @ViniciusCestarii @xyzconstant

@sedited sedited left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ACK 856f9ea

@ViniciusCestarii ViniciusCestarii left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

re-ACK 856f9ea

@nullfail

nullfail commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Post-merge ACK 856f9ea

@hebasto

hebasto commented Oct 9, 2026

Copy link
Copy Markdown
Member

All interface_ipc*.py tests fail on NetBSD:

AssertionError: Unexpected stderr Warning: Reducing -maxconnections from 76 to 61, because of system limitations. != 

Similar issues were resolved earlier in #36078 and #31537.

@enochaz

enochaz commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

All interface_ipc*.py tests fail on NetBSD:

AssertionError: Unexpected stderr Warning: Reducing -maxconnections from 76 to 61, because of system limitations. != 

Similar issues were resolved earlier in #36078 and #31537.

The framework’s current limit of 76 comes from the NetBSD fd budget before ipc reservations

# num_p2p_max_connections = available_fds - min_required_fds = 256 - 180 = 76;
f.write("maxconnections=76\n")

Which is why I think we have this test failing. Should we include the 17 descriptors for a default ipc listener in that calculation and lower the test default to 59, or would we prefer adjusting only ipc enabled tests? Wondering if lowering It to 59 would cause issues for other tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.