cluster/zeromq: Hook up and enable IPV6 by default

ZeroMQ's IPv6 support isn't enabled by default, resulting in
"No such device" errors when attempting to listen on an IPv6
address. This change adds a ipv6 option to the ZeroMQ module
and enables it by default. Further, adds a test configuring
everything to listen on IPv6 ::1 as well, and one test to provoke
the original error. This also regularizes some error messages.

The addr_to_uri() calls weren't actually needed, but they apparently do
not hurt and the result is easier on the eyes, so use them :-)
This commit is contained in:
Arne Welzel 2025-06-20 12:32:31 +02:00
parent cf43cf1809
commit 89c0b0faf3
14 changed files with 293 additions and 21 deletions

View file

@ -22,6 +22,9 @@
##! possible to run non-Zeek logger nodes. All a logger node needs to do is
##! open a ZeroMQ PULL socket and interpret the format used by Zeek nodes
##! to send their log writes.
@load base/utils/addrs
module Cluster::Backend::ZeroMQ;
export {
@ -139,6 +142,15 @@ export {
## for more details.
const log_rcvbuf: int = -1 &redef;
## Set ZMQ_IPV6 option.
##
## The ZeroMQ library has IPv6 support in ZeroMQ. For Zeek we enable it
## unconditionally such that listening or connecting with IPv6 just works.
##
## See ZeroMQ's `ZMQ_IPV6 documentation <http://api.zeromq.org/4-2:zmq-setsockopt#toc23>`_
## for more details.
const ipv6 = T &redef;
## Do not silently drop messages if high-water-mark is reached.
##
## Whether to configure ``ZMQ_XPUB_NODROP`` on the XPUB socket
@ -278,7 +290,7 @@ redef Cluster::worker_pool_spec = Cluster::PoolSpec(
@if ( Cluster::local_node_type() == Cluster::LOGGER || (Cluster::manager_is_logger && Cluster::local_node_type() == Cluster::MANAGER) )
const my_node = Cluster::nodes[Cluster::node];
@if ( my_node?$p )
redef listen_log_endpoint = fmt("tcp://%s:%s", my_node$ip, port_to_count(my_node$p));
redef listen_log_endpoint = fmt("tcp://%s:%s", addr_to_uri(my_node$ip), port_to_count(my_node$p));
@endif
@endif
@ -298,7 +310,7 @@ event zeek_init() &priority=100
local endp: string;
if ( node$node_type == Cluster::LOGGER && node?$p )
{
endp = fmt("tcp://%s:%s", node$ip, port_to_count(node$p));
endp = fmt("tcp://%s:%s", addr_to_uri(node$ip), port_to_count(node$p));
connect_log_endpoints += endp;
}