Skip to contentSkip to conversation

Make nbd-tester-client use FIXED_NEWSTYLE negotiation

PATCH In review Alex Bligh 1 participant 2 messages Apr 11, 2016

lore
Share & tools
lore

Alex Bligh

author
#0 lore raw

PATCH 1/1 Make nbd-tester-client use FIXED_NEWSTYLE negotiation

---
 tests/run/nbd-tester-client.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
tests/run/nbd-tester-client.c +8 -4
index 06396a7..1b99fa8 100644
@@ -342,6 +342,8 @@ int setup_connection_common(int sock, char* name, CONNECTION_TYPE ctype, int* se
 	u64 tmp64;
 	uint64_t mymagic = (name ? opts_magic : cliserv_magic);
 	uint32_t tmp32 = 0;
+	uint16_t handshakeflags = 0;
+	uint32_t negotiationflags = 0;
 
 	if(ctype<CONNECTION_TYPE_INIT_PASSWD)
 		goto end;
@@ -370,10 +372,12 @@ int setup_connection_common(int sock, char* name, CONNECTION_TYPE ctype, int* se
 		READ_ALL_ERRCHK(sock, buf, 128, err, "Could not read data: %s", strerror(errno));
 		goto end;
 	}
-	/* flags */
-	READ_ALL_ERRCHK(sock, buf, sizeof(uint16_t), err, "Could not read reserved field: %s", strerror(errno));
-	/* reserved field */
-	WRITE_ALL_ERRCHK(sock, &tmp32, sizeof(tmp32), err, "Could not write reserved field: %s", strerror(errno));
+	/* handshake flags */
+	READ_ALL_ERRCHK(sock, &handshakeflags, sizeof(handshakeflags), err, "Could not read reserved field: %s", strerror(errno));
+	/* negotiation flags */
+	if (handshakeflags & NBD_FLAG_FIXED_NEWSTYLE)
+		negotiationflags |= NBD_FLAG_C_FIXED_NEWSTYLE;
+	WRITE_ALL_ERRCHK(sock, &negotiationflags, sizeof(negotiationflags), err, "Could not write reserved field: %s", strerror(errno));
 	/* magic */
 	tmp64 = htonll(opts_magic);
 	WRITE_ALL_ERRCHK(sock, &tmp64, sizeof(tmp64), err, "Could not write magic: %s", strerror(errno));
Signature · 1 line
1.9.1
author
#1 lore raw

Apologies - wrong list. The perils of relying on history.

Alex

Quoted 39 lines · Alex Bligh

---
tests/run/nbd-tester-client.c | 12 ++++++++----

1 file changed, 8 insertions(+), 4 deletions(-)
tests/run/nbd-tester-client.c +8 -4
index 06396a7..1b99fa8 100644
@@ -342,6 +342,8 @@ int setup_connection_common(int sock, char* name, CONNECTION_TYPE ctype, int* se
 	u64 tmp64;
 	uint64_t mymagic = (name ? opts_magic : cliserv_magic);
 	uint32_t tmp32 = 0;
+	uint16_t handshakeflags = 0;
+	uint32_t negotiationflags = 0;
 
 	if(ctype<CONNECTION_TYPE_INIT_PASSWD)
 		goto end;
@@ -370,10 +372,12 @@ int setup_connection_common(int sock, char* name, CONNECTION_TYPE ctype, int* se
 		READ_ALL_ERRCHK(sock, buf, 128, err, "Could not read data: %s", strerror(errno));
 		goto end;
 	}
-	/* flags */
-	READ_ALL_ERRCHK(sock, buf, sizeof(uint16_t), err, "Could not read reserved field: %s", strerror(errno));
-	/* reserved field */
-	WRITE_ALL_ERRCHK(sock, &tmp32, sizeof(tmp32), err, "Could not write reserved field: %s", strerror(errno));
+	/* handshake flags */
+	READ_ALL_ERRCHK(sock, &handshakeflags, sizeof(handshakeflags), err, "Could not read reserved field: %s", strerror(errno));
+	/* negotiation flags */
+	if (handshakeflags & NBD_FLAG_FIXED_NEWSTYLE)
+		negotiationflags |= NBD_FLAG_C_FIXED_NEWSTYLE;
+	WRITE_ALL_ERRCHK(sock, &negotiationflags, sizeof(negotiationflags), err, "Could not write reserved field: %s", strerror(errno));
 	/* magic */
 	tmp64 = htonll(opts_magic);
 	WRITE_ALL_ERRCHK(sock, &tmp64, sizeof(tmp64), err, "Could not write magic: %s", strerror(errno));
Signature · 1 line
1.9.1
Signature · 1 line
Alex Bligh