Skip to contentSkip to conversation

libvchan: Make raw_get_{data_ready, buffer_space} match

PATCH In review Jason Andryuk 4 participants 4 messages May 16, 2014 – May 21, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libvchan: Make raw_get_{data_ready, buffer_space} match

For writing into a vchan, raw_get_buffer_space used >, allowing the full ring size to be written. On the read side, raw_get_data_ready compared the ring size with >=. This mismatch means a completely filled buffer cannot be read. Fix this by making the size checks identical.

---
 tools/libvchan/io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libvchan/io.c +1 -1
index 804c63c..6e6e239 100644
@@ -118,7 +118,7 @@ static inline int send_notify(struct libxenvchan *ctrl, uint8_t bit)
 static inline int raw_get_data_ready(struct libxenvchan *ctrl)
 {
 	uint32_t ready = rd_prod(ctrl) - rd_cons(ctrl);
-	if (ready >= rd_ring_size(ctrl))
+	if (ready > rd_ring_size(ctrl))
 		/* We have no way to return errors.  Locking up the ring is
 		 * better than the alternatives. */
 		return 0;
Signature · 1 line
1.8.3.1
#1 lore raw

Jason Andryuk writes ("[PATCH] libvchan: Make raw_get_{data_ready,buffer_space} match"):

Quoted 4 lines

For writing into a vchan, raw_get_buffer_space used >, allowing the full ring size to be written. On the read side, raw_get_data_ready compared the ring size with >=. This mismatch means a completely filled buffer cannot be read. Fix this by making the size checks identical.

This seems right to me, but I have CC'd the authors of this area of code to give them a chance to comment.

Thanks,
Ian.

Quoted 21 lines
---
 tools/libvchan/io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libvchan/io.c +1 -1
index 804c63c..6e6e239 100644
@@ -118,7 +118,7 @@ static inline int send_notify(struct libxenvchan *ctrl, uint8_t bit)
 static inline int raw_get_data_ready(struct libxenvchan *ctrl)
 {
 	uint32_t ready = rd_prod(ctrl) - rd_cons(ctrl);
-	if (ready >= rd_ring_size(ctrl))
+	if (ready > rd_ring_size(ctrl))
 		/* We have no way to return errors.  Locking up the ring is
 		 * better than the alternatives. */
 		return 0;
Signature · 1 line
1.8.3.1
#2 lore raw
Quoted 11 lines · Ian Jackson

Jason Andryuk writes ("[PATCH] libvchan: Make raw_get_{data_ready,buffer_space} match"):

Quoted 4 lines

For writing into a vchan, raw_get_buffer_space used >, allowing the full ring size to be written. On the read side, raw_get_data_ready compared the ring size with >=. This mismatch means a completely filled buffer cannot be read. Fix this by making the size checks identical.

This seems right to me, but I have CC'd the authors of this area of code to give them a chance to comment.

Thanks,
Ian.

This also looks correct to me.

Quoted 23 lines
Quoted 21 lines
---
  tools/libvchan/io.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tools/libvchan/io.c +1 -2
index 804c63c..6e6e239 100644
@@ -118,7 +118,7 @@ static inline int send_notify(struct libxenvchan *ctrl, uint8_t bit)
  static inline int raw_get_data_ready(struct libxenvchan *ctrl)
  {
  	uint32_t ready = rd_prod(ctrl) - rd_cons(ctrl);
-	if (ready >= rd_ring_size(ctrl))
+	if (ready > rd_ring_size(ctrl))
  		/* We have no way to return errors.  Locking up the ring is
  		 * better than the alternatives. */
  		return 0;
--

1.8.3.1

Signature · 2 lines
Daniel De Graaf
National Security Agency
Acked-by
#3 lore raw
Quoted 7 lines · Daniel De Graaf
Quoted 6 lines · Ian Jackson

Jason Andryuk writes ("[PATCH] libvchan: Make raw_get_{data_ready,buffer_space} match"):

Quoted 4 lines

For writing into a vchan, raw_get_buffer_space used >, allowing the full ring size to be written. On the read side, raw_get_data_ready compared the ring size with >=. This mismatch means a completely filled buffer cannot be read. Fix this by making the size checks identical.

Quoted 7 lines
Quoted 5 lines

This seems right to me, but I have CC'd the authors of this area of code to give them a chance to comment.

Thanks,
Ian.

This also looks correct to me.

Can I take that as an Acked-by frm the both of you?

Ian.