[PATCH] Don't send back unknown program errors for async messages

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

 



From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

If we send back an unknown program error for async messages,
we will confuse the client because they only expect replies
for method calls. Just log & drop any invalid async messages

* src/rpc/virnetserver.c: Don't send error for async messages
---
 src/rpc/virnetserver.c        |   23 +++++++++++++++++++----
 src/rpc/virnetserverprogram.c |   13 ++++++++++++-
 2 files changed, 31 insertions(+), 5 deletions(-)

diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index 9588077..f739743 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -134,10 +134,25 @@ static void virNetServerHandleJob(void *jobOpaque, void *opaque)
               srv, job->client, job->msg, job->prog);
 
     if (!job->prog) {
-        if (virNetServerProgramUnknownError(job->client,
-                                            job->msg,
-                                            &job->msg->header) < 0)
-            goto error;
+        /* Only send back an error for type == CALL. Other
+         * message types are not expecting replies, so we
+         * must just log it & drop them
+         */
+        if (job->msg->header.type == VIR_NET_CALL) {
+            if (virNetServerProgramUnknownError(job->client,
+                                                job->msg,
+                                                &job->msg->header) < 0)
+                goto error;
+        } else {
+            VIR_INFO("Dropping client mesage, unknown program %d version %d type %d proc %d",
+                     job->msg->header.prog, job->msg->header.vers,
+                     job->msg->header.type, job->msg->header.proc);
+            /* Send a dummy reply to free up 'msg' & unblock client rx */
+            virNetMessageClear(job->msg);
+            job->msg->header.type = VIR_NET_REPLY;
+            if (virNetServerClientSendMessage(job->client, job->msg) < 0)
+                goto error;
+        }
         goto cleanup;
     }
 
diff --git a/src/rpc/virnetserverprogram.c b/src/rpc/virnetserverprogram.c
index 334a0bf..47b7ded 100644
--- a/src/rpc/virnetserverprogram.c
+++ b/src/rpc/virnetserverprogram.c
@@ -314,7 +314,18 @@ int virNetServerProgramDispatch(virNetServerProgramPtr prog,
     return ret;
 
 error:
-    ret = virNetServerProgramSendReplyError(prog, client, msg, &rerr, &msg->header);
+    if (msg->header.type == VIR_NET_CALL) {
+        ret = virNetServerProgramSendReplyError(prog, client, msg, &rerr, &msg->header);
+    } else {
+        /* Send a dummy reply to free up 'msg' & unblock client rx */
+        virNetMessageClear(msg);
+        msg->header.type = VIR_NET_REPLY;
+        if (virNetServerClientSendMessage(client, msg) < 0) {
+            ret = -1;
+            goto cleanup;
+        }
+        ret = 0;
+    }
 
 cleanup:
     return ret;
-- 
1.7.6.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]