[sheepdog] [PATCH] lib/net: fix CMD_FILTER branch never reached

Ruoyu liangry at ucweb.com
Tue Jul 29 03:47:52 CEST 2014


In the previous patch, SD_FLAG_CMD_FILTER is introduced. It should operate
both writing and reading, and what the client read is the subset of what
it write. Therefore, for least modification, SD_FLAG_CMD_FILTER is set to 0x11
(SD_FLAG_CMD_WRITE is 0x01).

The problem is, the previous patch does not handle it correctly. CMD_FILTER
should be checked first.

Signed-off-by: Ruoyu <liangry at ucweb.com>
---
 lib/net.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/lib/net.c b/lib/net.c
index 552e945..5a86107 100644
--- a/lib/net.c
+++ b/lib/net.c
@@ -331,12 +331,13 @@ int exec_req(int sockfd, struct sd_req *hdr, void *data,
 	struct sd_rsp *rsp = (struct sd_rsp *)hdr;
 	unsigned int wlen, rlen;
 
-	if (hdr->flags & SD_FLAG_CMD_WRITE) {
-		wlen = hdr->data_length;
-		rlen = 0;
-	} else if (hdr->flags & SD_FLAG_CMD_FILTER) {
+	/* filter(0x11) contains write(0x01), must check it first */
+	if (hdr->flags & SD_FLAG_CMD_FILTER) {
 		wlen = hdr->data_length;
 		rlen = hdr->data_length;
+	} else if (hdr->flags & SD_FLAG_CMD_WRITE) {
+		wlen = hdr->data_length;
+		rlen = 0;
 	} else {
 		wlen = 0;
 		rlen = hdr->data_length;
-- 
1.8.3.2





More information about the sheepdog mailing list