Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/nsd/dist Fix NSD when built with --enable-recvm...



details:   https://anonhg.NetBSD.org/src/rev/158c6c7d6bb8
branches:  trunk
changeset: 446014:158c6c7d6bb8
user:      hannken <hannken%NetBSD.org@localhost>
date:      Tue Nov 20 10:03:39 2018 +0000

description:
Fix NSD when built with --enable-recvmmsg:

When resetting a query with query_reset(queries[i], ...) always restore the
corresponding msgs[i].msg_hdr.msg_namelen from queries[i]->addrlen.

After receiving a message set queries[i]->addrlen to the received msg_namelen.

Reported upstream, will be fixed for 4.1.26

diffstat:

 external/bsd/nsd/dist/server.c |  10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diffs (61 lines):

diff -r c39fed508280 -r 158c6c7d6bb8 external/bsd/nsd/dist/server.c
--- a/external/bsd/nsd/dist/server.c    Tue Nov 20 08:47:55 2018 +0000
+++ b/external/bsd/nsd/dist/server.c    Tue Nov 20 10:03:39 2018 +0000
@@ -2209,6 +2209,7 @@
        for (i = 0; i < recvcount; i++) {
        loopstart:
                received = msgs[i].msg_len;
+               queries[i]->addrlen = msgs[i].msg_hdr.msg_namelen;
                q = queries[i];
                if (received == -1) {
                        log_msg(LOG_ERR, "recvmmsg %d failed %s", i, strerror(
@@ -2217,6 +2218,7 @@
                        /* No zone statup */
                        query_reset(queries[i], UDP_MAX_MESSAGE_LEN, 0);
                        iovecs[i].iov_len = buffer_remaining(q->packet);
+                       msgs[i].msg_hdr.msg_namelen = queries[i]->addrlen;
                        goto swap_drop;
                }
 
@@ -2264,6 +2266,7 @@
                } else {
                        query_reset(queries[i], UDP_MAX_MESSAGE_LEN, 0);
                        iovecs[i].iov_len = buffer_remaining(q->packet);
+                       msgs[i].msg_hdr.msg_namelen = queries[i]->addrlen;
                swap_drop:
                        STATUP(data->nsd, dropped);
                        ZTATUP(data->nsd, q->zone, dropped);
@@ -2304,6 +2307,7 @@
        for(i=0; i<recvcount; i++) {
                query_reset(queries[i], UDP_MAX_MESSAGE_LEN, 0);
                iovecs[i].iov_len = buffer_remaining(queries[i]->packet);
+               msgs[i].msg_hdr.msg_namelen = queries[i]->addrlen;
        }
 }
 
@@ -2344,13 +2348,15 @@
        }
        for (i = 0; i < recvcount; i++) {
                received = msgs[i].msg_len;
-               msgs[i].msg_hdr.msg_namelen = queries[i]->addrlen;
+               queries[i]->addrlen = msgs[i].msg_hdr.msg_namelen;
                if (received == -1) {
                        log_msg(LOG_ERR, "recvmmsg failed");
                        STATUP(data->nsd, rxerr);
                        /* No zone statup */
                        /* the error can be found in msgs[i].msg_hdr.msg_flags */
                        query_reset(queries[i], UDP_MAX_MESSAGE_LEN, 0);
+                       iovecs[i].iov_len = buffer_remaining(queries[i]->packet);
+                       msgs[i].msg_hdr.msg_namelen = queries[i]->addrlen;
                        continue;
                }
                q = queries[i];
@@ -2442,6 +2448,8 @@
 #ifndef NONBLOCKING_IS_BROKEN
 #ifdef HAVE_RECVMMSG
                query_reset(queries[i], UDP_MAX_MESSAGE_LEN, 0);
+               iovecs[i].iov_len = buffer_remaining(queries[i]->packet);
+               msgs[i].msg_hdr.msg_namelen = queries[i]->addrlen;
 #endif
        }
 #endif



Home | Main Index | Thread Index | Old Index