From: Tomas Krizek Date: Wed, 26 Aug 2020 11:13:51 +0000 (+0200) Subject: daemon/io: don't notify worker on udp_recv() errors X-Git-Tag: v5.2.0~32^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=82e74cf697204ee082dcf96e9fab1208d5bfcc0e;p=thirdparty%2Fknot-resolver.git daemon/io: don't notify worker on udp_recv() errors The action doesn't increase any counter or do any error handling. It would simply SEGFAULT. Even if it didn't worker_submit() would just return an error code. --- diff --git a/daemon/io.c b/daemon/io.c index 48d264078..1c879188d 100644 --- a/daemon/io.c +++ b/daemon/io.c @@ -61,18 +61,9 @@ void udp_recv(uv_udp_t *handle, ssize_t nread, const uv_buf_t *buf, const struct sockaddr *addr, unsigned flags) { struct session *s = handle->data; - if (session_flags(s)->closing) { - return; - } - if (nread <= 0) { - if (nread < 0) { /* Error response, notify resolver */ - worker_submit(s, NULL, NULL); - } /* nread == 0 is for freeing buffers, we don't need to do this */ + if (session_flags(s)->closing || nread <= 0 || addr->sa_family == AF_UNSPEC) return; - } - if (addr->sa_family == AF_UNSPEC) { - return; - } + if (session_flags(s)->outgoing) { const struct sockaddr *peer = session_get_peer(s); assert(peer->sa_family != AF_UNSPEC); diff --git a/daemon/worker.c b/daemon/worker.c index 41c803760..45ab8133d 100644 --- a/daemon/worker.c +++ b/daemon/worker.c @@ -1583,14 +1583,12 @@ int worker_submit(struct session *session, const struct sockaddr *peer, knot_pkt return kr_error(EINVAL); } - /* Parse packet */ int ret = parse_packet(query); const bool is_query = (knot_wire_get_qr(query->wire) == 0); const bool is_outgoing = session_flags(session)->outgoing; /* Ignore badly formed queries. */ - if (!query || - (ret != kr_ok() && ret != kr_error(EMSGSIZE)) || + if ((ret != kr_ok() && ret != kr_error(EMSGSIZE)) || (is_query == is_outgoing)) { if (query && !is_outgoing) the_worker->stats.dropped += 1; return kr_error(EILSEQ);