summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFrode Nordahl <frode.nordahl@canonical.com>2023-02-09 08:48:24 +0100
committerIlya Maximets <i.maximets@ovn.org>2023-02-10 20:09:29 +0100
commit5f219af8b3c723d7117c075941ab80fe6a6c768f (patch)
tree734a7b0cb0c45d78e2c988d239f7dab2aa4d7243 /lib
parent7bb0c33d78a2731b568c97209e0ec08baecbce3d (diff)
downloadopenvswitch-5f219af8b3c723d7117c075941ab80fe6a6c768f.tar.gz
ovsdb-server: Fix handling of DNS name for listener configuration.
Commit 08e9e5337383 fixed proper initialization of the dns-resolve module, and made DNS resolution asynchronous. A side effect of that change revealed a long standing logic bug which broke ovsdb-server listener configuration using DNS names. Previously this worked because the DNS resolution would block, now that DNS resolution is asynchronous the code before this change would assume the error from jsonrpc_pstream_open meant the remote was a specification for an active outgoing connection, even when that was not the case. To fix this a couple of changes was made to socket-util: 1) Pass optional result of dns resolution from inet_parse_passive. When (re-)configuring listeners that use DNS names, we may need to know whether the provided connection string is invalid or if the provided DNS name has finished resolving. 2) Check dns resolution status in inet_open_passive. If the connection string is valid, and contains a DNS name, inet_open_passive will now return -EAGAIN if dns resolution failed. DNS resolution failure may either mean the asynchronous resolver has not completed yet, or that the name does not resolve. Reported-at: https://bugs.launchpad.net/bugs/1998781 Fixes: 08e9e5337383 ("ovsdb: raft: Fix inability to read the database with DNS host names.") Fixes: 771680d96fb6 ("DNS: Add basic support for asynchronous DNS resolving") Signed-off-by: Frode Nordahl <frode.nordahl@canonical.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/socket-util.c13
-rw-r--r--lib/socket-util.h3
2 files changed, 12 insertions, 4 deletions
diff --git a/lib/socket-util.c b/lib/socket-util.c
index 38705cc51..3eb3a3816 100644
--- a/lib/socket-util.c
+++ b/lib/socket-util.c
@@ -660,7 +660,8 @@ exit:
* zeros '*ss' and returns false. */
bool
inet_parse_passive(const char *target_, int default_port,
- struct sockaddr_storage *ss)
+ struct sockaddr_storage *ss,
+ bool resolve_host, bool *dns_failure)
{
char *target = xstrdup(target_);
char *port, *host;
@@ -672,7 +673,7 @@ inet_parse_passive(const char *target_, int default_port,
ok = false;
} else {
ok = parse_sockaddr_components(ss, host, port, default_port,
- target_, true, NULL);
+ target_, resolve_host, dns_failure);
}
if (!ok) {
memset(ss, 0, sizeof *ss);
@@ -710,8 +711,14 @@ inet_open_passive(int style, const char *target, int default_port,
struct sockaddr_storage ss;
int fd = 0, error;
unsigned int yes = 1;
+ bool dns_failure;
- if (!inet_parse_passive(target, default_port, &ss)) {
+ if (!inet_parse_passive(target, default_port, &ss, true, &dns_failure)) {
+ if (dns_failure) {
+ /* DNS failure means asynchronous DNS resolution is in progress,
+ * or that the name does currently not resolve. */
+ return -EAGAIN;
+ }
return -EAFNOSUPPORT;
}
kernel_chooses_port = ss_get_port(&ss) == 0;
diff --git a/lib/socket-util.h b/lib/socket-util.h
index bf66393df..4eec627e3 100644
--- a/lib/socket-util.h
+++ b/lib/socket-util.h
@@ -55,7 +55,8 @@ int inet_open_active(int style, const char *target, int default_port,
struct sockaddr_storage *ssp, int *fdp, uint8_t dscp);
bool inet_parse_passive(const char *target, int default_port,
- struct sockaddr_storage *ssp);
+ struct sockaddr_storage *ssp,
+ bool resolve_host, bool *dns_failure);
int inet_open_passive(int style, const char *target, int default_port,
struct sockaddr_storage *ssp, uint8_t dscp,
bool kernel_print_port);