Blame SOURCES/kvm-nbd-server-Ignore-write-errors-when-replying-to-NBD_.patch

7711c0
From d706e465682307df95a723e1a74b32c0db93e259 Mon Sep 17 00:00:00 2001
7711c0
From: John Snow <jsnow@redhat.com>
7711c0
Date: Fri, 22 Mar 2019 03:22:30 +0100
7711c0
Subject: [PATCH 063/163] nbd/server: Ignore write errors when replying to
7711c0
 NBD_OPT_ABORT
7711c0
MIME-Version: 1.0
7711c0
Content-Type: text/plain; charset=UTF-8
7711c0
Content-Transfer-Encoding: 8bit
7711c0
7711c0
RH-Author: John Snow <jsnow@redhat.com>
7711c0
Message-id: <20190322032241.8111-18-jsnow@redhat.com>
7711c0
Patchwork-id: 85105
7711c0
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 17/28] nbd/server: Ignore write errors when replying to NBD_OPT_ABORT
7711c0
Bugzilla: 1691563
7711c0
RH-Acked-by: Max Reitz <mreitz@redhat.com>
7711c0
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
7711c0
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
7711c0
From: Eric Blake <eblake@redhat.com>
7711c0
7711c0
Commit 37ec36f6 intentionally ignores errors when trying to reply
7711c0
to an NBD_OPT_ABORT request for plaintext clients, but did not make
7711c0
the same change for a TLS server.  Since NBD_OPT_ABORT is
7711c0
documented as being a potential for an EPIPE when the client hangs
7711c0
up without waiting for our reply, we don't need to pollute the
7711c0
server's output with that failure.
7711c0
7711c0
Signed-off-by: Eric Blake <eblake@redhat.com>
7711c0
Message-Id: <20181117223221.2198751-1-eblake@redhat.com>
7711c0
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
7711c0
(cherry picked from commit 3e99ebb9d3df15ce0ecf1b435816c9c46ee9a1ad)
7711c0
Signed-off-by: John Snow <jsnow@redhat.com>
7711c0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
---
7711c0
 nbd/server.c | 12 ++++++++----
7711c0
 1 file changed, 8 insertions(+), 4 deletions(-)
7711c0
7711c0
diff --git a/nbd/server.c b/nbd/server.c
7711c0
index 418b1d4..e8fd6b4 100644
7711c0
--- a/nbd/server.c
7711c0
+++ b/nbd/server.c
7711c0
@@ -1134,12 +1134,16 @@ static int nbd_negotiate_options(NBDClient *client, uint16_t myflags,
7711c0
                 return -EINVAL;
7711c0
 
7711c0
             default:
7711c0
-                ret = nbd_opt_drop(client, NBD_REP_ERR_TLS_REQD, errp,
7711c0
+                /* Let the client keep trying, unless they asked to
7711c0
+                 * quit. Always try to give an error back to the
7711c0
+                 * client; but when replying to OPT_ABORT, be aware
7711c0
+                 * that the client may hang up before receiving the
7711c0
+                 * error, in which case we are fine ignoring the
7711c0
+                 * resulting EPIPE. */
7711c0
+                ret = nbd_opt_drop(client, NBD_REP_ERR_TLS_REQD,
7711c0
+                                   option == NBD_OPT_ABORT ? NULL : errp,
7711c0
                                    "Option 0x%" PRIx32
7711c0
                                    " not permitted before TLS", option);
7711c0
-                /* Let the client keep trying, unless they asked to
7711c0
-                 * quit. In this mode, we've already sent an error, so
7711c0
-                 * we can't ack the abort.  */
7711c0
                 if (option == NBD_OPT_ABORT) {
7711c0
                     return 1;
7711c0
                 }
7711c0
-- 
7711c0
1.8.3.1
7711c0