Repository navigation
zmq: Add support to listen on IPv6 addresses - #22079
Conversation
|
Concept ACK. |
|
Concept ACK, it's kind of fascinating this went without IPv6 support for so long. |
9e493c0 to
fe8d37c
Compare
|
Concept ACK |
|
@n-thumann: Would you mind rebasing this PR on master? Then #22103 is included, which fixed the IPv6 detection for *BSDs and macOS systems. |
fe8d37c to
f9079ce
Compare
Done ✌🏻 |
Thanks! On my system (OpenBSD 6.9), the functional test |
I was able to confirm this behavior on OpenBSD, but not on any other OS (Debian, Ubuntu, macOS, FreeBSD). |
Very interesting, thanks for investigating deeper! I can confirm that the test succeeds with your latest changes. |
Good point! I've ran some more tests and indeed DragonFly BSD is also affected. I also confirmed that only setting Raw test results
|
There was a problem hiding this comment.
This is pretty ugly. Can we just ignore errors setting ZMQ_IPV6 if the subsequent bind succeeds?
There was a problem hiding this comment.
I cleaned up a little bit, but I'm not sure, if ignoring an error while setting ZMQ_IPV6 is a good idea: If it fails, the binding of an IPv6 address will also fail and and prior error could help narrowing down the issue. And if we set the option on e.g. OpenBSD without checking, the bind will always fail for IPv4.
Did I got you right? You want to always set ZMQ_IPV6 and see if the binding succeeds. If it does, all fine. If it didn't, what then?
e1820a5 to
7bbf6d8
Compare
There was a problem hiding this comment.
7bbf6d8c92b still works here (OpenBSD 6.9) and the code looks cleaner than the previous version, with the pre-processor dependency gone. I tend to agree with @luke-jr that having to analyze the address string first in order to set (or not set) a socket option is "ugly", but on the other hand I don't see another solution.
Some suggestions:
- Would add a short comment on why we only set ZMQ_IPV6 on IPv6 endpoints (like you had already in one of your earlier commits; you could simply take that and replace "OpenBSD" with "On some systems (like e.g. OpenBSD)...")
- Could introduce a helper function like
IsZMQAddressIPV6that contains the IPv6 determination logic from the ZMQ address string; then you could simply writeconst int enable_ipv6 { IsZMQAddressIPV6(address) ? 1 : 0 };
Absolutely! I'd be nice to have the plain address to bind, but the string entered by the user is the only thing to work with :/
Applied! |
|
@n-thumann: looks good to me. Could you squash at least the last two commits (or probably better even the last three, in order to avoid an "in-between" state where the "only set zmq_ipv6 if needed" fix has only been applied on one side), in order to ease review? |
dab5b86 to
0cc296e
Compare
|
Squashed :) |
There was a problem hiding this comment.
Some feedback regarding coding style and structure (that I unfortunately missed before), regarding the first commit:
- variables should be named in
snake_caserather than (lower)camelCase(e.g. s/tcpIndex/tcp_index/) - "If an if only has a single-statement then-clause, it can appear on the same line as the if, without braces. In every other case, braces are required, and the then and else clauses must appear correctly indented on a new line."
- Since the
IsZMQAddressIPV6helper doesn't use any instance specific data, I'd suggest to move it out of the class and simply put it in a static function on top of the file
0cc296e to
e699883
Compare
|
Done! Btw, I really do appreciate your feedback! |
theStack
left a comment
There was a problem hiding this comment.
Tested ACK e699883 🌱
(reviewed code, built PR branch and ran included test on both OpenBSD 6.9 and Debian bullseye/sid, works as expected)
Done! Btw, I really do appreciate your feedback!
You're welcome. Looking forward to see more contributions from you in the future :-)
|
Code review ACK e699883 |
|
This went into 23.0, but I'm not sure it actually got a release note. Removing the label. |
This PR adds support for listening on IPv6 addresses with bitcoinds ZMQ interface, just like the RPC server.
Currently, it is not possible to specify an IPv6 address, as the
ZMQ_IPV6socket option is not set and therefore the ZMQ initialization fails, if one does so. The absence of this option has also been noted here.With this PR one can e.g. set
-zmqpubhashblock=tcp://[::1]:28333to listen on the IPv6 loopback address.