67 lines
3.0 KiB
Diff
67 lines
3.0 KiB
Diff
From 0bdea17c0aa37c4cdf586c072a7b35f8d0598cc3 Mon Sep 17 00:00:00 2001
|
|
From: "Dmitry V. Levin" <ldv@strace.io>
|
|
Date: Fri, 7 Jul 2023 08:00:00 +0000
|
|
Subject: [PATCH] resolved: fix use of ERRNO_IS_DISCONNECT()
|
|
|
|
Given that ERRNO_IS_DISCONNECT() also matches positive values,
|
|
make sure this macro is not called with arguments that do not have
|
|
errno semantics.
|
|
|
|
In this case the argument passed to ERRNO_IS_DISCONNECT() is the value
|
|
returned by manager_recv() which can legitimately return 1 without errno
|
|
semantics, so fix this by moving ERRNO_IS_DISCONNECT() invocation to the
|
|
branch where the return value is known to be negative.
|
|
|
|
Conflict:NA
|
|
Reference:https://github.com/systemd/systemd-stable/commit/0bdea17c0aa37c4cdf586c072a7b35f8d0598cc3
|
|
|
|
---
|
|
src/resolve/resolved-dns-transaction.c | 27 ++++++++++++--------------
|
|
1 file changed, 12 insertions(+), 15 deletions(-)
|
|
|
|
diff --git a/src/resolve/resolved-dns-transaction.c b/src/resolve/resolved-dns-transaction.c
|
|
index a5293357c0..323786896b 100644
|
|
--- a/src/resolve/resolved-dns-transaction.c
|
|
+++ b/src/resolve/resolved-dns-transaction.c
|
|
@@ -1367,25 +1367,22 @@ static int on_dns_packet(sd_event_source *s, int fd, uint32_t revents, void *use
|
|
assert(t->scope);
|
|
|
|
r = manager_recv(t->scope->manager, fd, DNS_PROTOCOL_DNS, &p);
|
|
- if (ERRNO_IS_DISCONNECT(r)) {
|
|
- usec_t usec;
|
|
-
|
|
- /* UDP connection failures get reported via ICMP and then are possibly delivered to us on the
|
|
- * next recvmsg(). Treat this like a lost packet. */
|
|
+ if (r < 0) {
|
|
+ if (ERRNO_IS_DISCONNECT(r)) {
|
|
+ usec_t usec;
|
|
|
|
- log_debug_errno(r, "Connection failure for DNS UDP packet: %m");
|
|
- assert_se(sd_event_now(t->scope->manager->event, CLOCK_BOOTTIME, &usec) >= 0);
|
|
- dns_server_packet_lost(t->server, IPPROTO_UDP, t->current_feature_level);
|
|
+ /* UDP connection failures get reported via ICMP and then are possibly delivered to us on the
|
|
+ * next recvmsg(). Treat this like a lost packet. */
|
|
|
|
- dns_transaction_close_connection(t, /* use_graveyard = */ false);
|
|
+ log_debug_errno(r, "Connection failure for DNS UDP packet: %m");
|
|
+ assert_se(sd_event_now(t->scope->manager->event, CLOCK_BOOTTIME, &usec) >= 0);
|
|
+ dns_server_packet_lost(t->server, IPPROTO_UDP, t->current_feature_level);
|
|
|
|
- if (dns_transaction_limited_retry(t)) /* Try a different server */
|
|
- return 0;
|
|
+ dns_transaction_close_connection(t, /* use_graveyard = */ false);
|
|
|
|
- dns_transaction_complete_errno(t, r);
|
|
- return 0;
|
|
- }
|
|
- if (r < 0) {
|
|
+ if (dns_transaction_limited_retry(t)) /* Try a different server */
|
|
+ return 0;
|
|
+ }
|
|
dns_transaction_complete_errno(t, r);
|
|
return 0;
|
|
}
|
|
--
|
|
2.39.1
|
|
|