redpanda
redpanda copied to clipboard
net: Improve IPv6 support
Note
This seems to break metrics_reporter:
TRACE 2022-09-28 21:36:26,461 [shard 0] dns_resolver - Release socket 1 -> 2
| test_cluster_rpunit: /v/build/v_deps_build/seastar-prefix/src/seastar/include/seastar/core/future.hh:648: void seastar::future_state<seastar::internal::monostate>::set(A &&...) [T = seastar::internal::monostate, A = <>]: Assertion `_u.st == state::future' failed.
Cover letter
Instead of insisting that IP addresses are IPv4 by default, let the implementation figure it out.
This allows to bind addresses to :: or ::1, for example:
pandaproxy:
pandaproxy_api:
- # curl https://[::1]:18082/topics
address: "::1"
port: 18082
name: ipv6_listener
Notes for Reviewer
I'd like to have included tests, but not all systems have IPv6 enabled. I ran this locally:
#include "net/dns.h"
#include "net/unresolved_address.h"
#include <seastar/testing/thread_test_case.hh>
#include <boost/test/tools/old/interface.hpp>
SEASTAR_THREAD_TEST_CASE(dns_resolve) {
net::unresolved_address ipv4_addr("127.0.0.1", 19092);
auto ipv4 = net::resolve_dns(ipv4_addr).get();
BOOST_REQUIRE_EQUAL(ipv4.port(), ipv4_addr.port());
BOOST_REQUIRE_EQUAL(
ipv4.family(), static_cast<short>(ss::net::inet_address::family::INET));
BOOST_REQUIRE(ipv4.addr().is_ipv4());
BOOST_REQUIRE_EQUAL(ipv4.addr().hostname().get(), "localhost");
net::unresolved_address ipv6_addr("::1", 19093);
auto ipv6 = net::resolve_dns(ipv6_addr).get();
BOOST_REQUIRE_EQUAL(ipv6.port(), ipv6_addr.port());
BOOST_REQUIRE_EQUAL(
ipv6.family(), static_cast<short>(ss::net::inet_address::family::INET6));
BOOST_REQUIRE(ipv6.addr().is_ipv6());
BOOST_REQUIRE_EQUAL(ipv6.addr().hostname().get(), "ip6-localhost");
net::unresolved_address ipv6_addr2("ip6-localhost", 19094);
ipv6 = net::resolve_dns(ipv6_addr2).get();
BOOST_REQUIRE_EQUAL(ipv6.port(), ipv6_addr2.port());
BOOST_REQUIRE_EQUAL(
ipv6.family(), static_cast<short>(ss::net::inet_address::family::INET6));
BOOST_REQUIRE(ipv6.addr().is_ipv6());
BOOST_REQUIRE_EQUAL(ipv6.addr().hostname().get(), "ip6-localhost");
}
Signed-off-by: Ben Pope [email protected]
Fixes #ISSUE-NUMBER, Fixes #ISSUE-NUMBER, ...
Backport Required
- [ ] not a bug fix
- [ ] issue does not exist in previous branches
- [ ] papercut/not impactful enough to backport
- [x] v22.3.x
- [x] v22.2.x
- [x] v22.1.x
- [x] v21.11.x
UX changes
- none
Release notes
- Improve support for IPv6.