From: Matthijs Mekking Date: Tue, 20 Oct 2020 08:57:16 +0000 (+0200) Subject: Don't increment network error stats on UV_EOF X-Git-Tag: v9.17.7~54^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6c5ff9421875a1fcdfb8f03ac01afe292075d8d2;p=thirdparty%2Fbind9.git Don't increment network error stats on UV_EOF When networking statistics was added to the netmgr (in commit 5234a8e00a6ae1df738020f27544594ccb8d5215), two lines were added that increment the 'STATID_RECVFAIL' statistic: One if 'uv_read_start' fails and one at the end of the 'read_cb'. The latter happens if 'nread < 0'. According to the libuv documentation, I/O read callbacks (such as for files and sockets) are passed a parameter 'nread'. If 'nread' is less than 0, there was an error and 'UV_EOF' is the end of file error, which you may want to handle differently. In other words, we should not treat EOF as a RECVFAIL error. --- diff --git a/CHANGES b/CHANGES index 4c53f998527..7de204397ac 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +5517. [bug] Handle 'UV_EOF' differently and don't contribute it to + the RECVFAIL statistic count. [GL #2208] + 5516. [func] The default EDNS buffer size has been changed from 4096 to 1232, the EDNS buffer size probing has been removed and ``named`` now sets the DON'T FRAGMENT flag on diff --git a/bin/tests/system/statistics/tests.sh b/bin/tests/system/statistics/tests.sh index 14101deb39f..055bd88d4a4 100644 --- a/bin/tests/system/statistics/tests.sh +++ b/bin/tests/system/statistics/tests.sh @@ -161,6 +161,8 @@ if $FEATURETEST --have-libxml2 && [ -x "${CURL}" ] && [ -x "${XSLTPROC}" ] ; th ${CURL} http://10.53.0.3:${EXTRAPORT1}/xml/v3 > curl.out.${n}.xml 2>/dev/null || ret=1 ${CURL} http://10.53.0.3:${EXTRAPORT1}/bind9.xsl > curl.out.${n}.xsl 2>/dev/null || ret=1 ${XSLTPROC} curl.out.${n}.xsl - < curl.out.${n}.xml > xsltproc.out.${n} 2>/dev/null || ret=1 + cp curl.out.${n}.xml stats.xml.out || ret=1 + # # grep for expected sections. # @@ -205,6 +207,30 @@ if [ $ret != 0 ]; then echo_i "failed"; fi status=`expr $status + $ret` n=`expr $n + 1` +ret=0 +echo_i "checking bind9.xml socket statistics ($n)" +if $FEATURETEST --have-libxml2 && [ -x "${CURL}" ] && [ -x "${XSLTPROC}" ] ; then + # Socket statistics (expect no errors) + grep "0" stats.xml.out >/dev/null || ret=1 + grep "0" stats.xml.out >/dev/null || ret=1 + grep "0" stats.xml.out >/dev/null || ret=1 + grep "0" stats.xml.out >/dev/null || ret=1 + grep "0" stats.xml.out >/dev/null || ret=1 + grep "0" stats.xml.out >/dev/null || ret=1 + + grep "0" stats.xml.out >/dev/null || ret=1 + grep "0" stats.xml.out >/dev/null || ret=1 + grep "0" stats.xml.out >/dev/null || ret=1 + grep "0" stats.xml.out >/dev/null || ret=1 + grep "0" stats.xml.out >/dev/null || ret=1 + grep "0" stats.xml.out >/dev/null || ret=1 +else + echo_i "skipping test as libxml2 and/or curl and/or xsltproc was not found" +fi +if [ $ret != 0 ]; then echo_i "failed"; fi +status=`expr $status + $ret` +n=`expr $n + 1` + ret=0 echo_i "checking priming queries are counted ($n)" grep "1 priming queries" ns3/named.stats diff --git a/doc/notes/notes-current.rst b/doc/notes/notes-current.rst index aa3f0b3a461..0b4e9eb5658 100644 --- a/doc/notes/notes-current.rst +++ b/doc/notes/notes-current.rst @@ -69,3 +69,6 @@ Bug Fixes - `named` would start continous rollovers for policies that algorithms Ed25519 or Ed448 due to a mismatch in created key size and expected key size. [GL #2171] + +- Handle `UV_EOF` differently such that it is not treated as a `TCP4RecvErr` or + `TCP6RecvErr`. [GL #2208] diff --git a/lib/isc/netmgr/tcp.c b/lib/isc/netmgr/tcp.c index 208e703d07a..483bd6d12f7 100644 --- a/lib/isc/netmgr/tcp.c +++ b/lib/isc/netmgr/tcp.c @@ -803,8 +803,10 @@ read_cb(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf) { * This might happen if the inner socket is closing. It means that * it's detached, so the socket will be closed. */ - if (cb != NULL) { + if (nread != UV_EOF) { isc__nm_incstats(sock->mgr, sock->statsindex[STATID_RECVFAIL]); + } + if (cb != NULL) { isc__nmsocket_clearcb(sock); cb(sock->statichandle, ISC_R_EOF, NULL, cbarg); }