public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: passt-dev@passt.top, Stefano Brivio <sbrivio@redhat.com>
Cc: David Gibson <david@gibson.dropbear.id.au>
Subject: [PATCH 1/2] tap, pasta: Handle incomplete tap sends for pasta too
Date: Wed,  8 Nov 2023 14:17:53 +1100	[thread overview]
Message-ID: <20231108031754.2670078-2-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20231108031754.2670078-1-david@gibson.dropbear.id.au>

Since a469fc39 ("tcp, tap: Don't increase tap-side sequence counter for
dropped frames") we've handled more gracefully the case where we get data
from the socket side, but are temporarily unable to send it all to the tap
side (e.g. due to full buffers).

That code relies on tap_send_frames() returning the number of frames it
successfully sent, which in turn gets it from tap_send_frames_passt() or
tap_send_frames_pasta().

While tap_send_frames_passt() has returned that information since b62ed9ca
("tap: Don't pcap frames that didn't get sent"), tap_send_frames_pasta()
always returns as though it succesfully sent every frame.  However there
certainly are cases where it will return early without sending all frames.
Update it report that properly, so that the calling functions can handle it
properly.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 tap.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/tap.c b/tap.c
index 3a938f3..00622e7 100644
--- a/tap.c
+++ b/tap.c
@@ -330,8 +330,6 @@ static size_t tap_send_frames_pasta(const struct ctx *c,
 			case EWOULDBLOCK:
 #endif
 			case EINTR:
-				i--;
-				break;
 			case ENOBUFS:
 			case ENOSPC:
 				break;
@@ -341,7 +339,7 @@ static size_t tap_send_frames_pasta(const struct ctx *c,
 		}
 	}
 
-	return n;
+	return i;
 }
 
 /**
-- 
@@ -330,8 +330,6 @@ static size_t tap_send_frames_pasta(const struct ctx *c,
 			case EWOULDBLOCK:
 #endif
 			case EINTR:
-				i--;
-				break;
 			case ENOBUFS:
 			case ENOSPC:
 				break;
@@ -341,7 +339,7 @@ static size_t tap_send_frames_pasta(const struct ctx *c,
 		}
 	}
 
-	return n;
+	return i;
 }
 
 /**
-- 
2.41.0


  reply	other threads:[~2023-11-08  3:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-08  3:17 [PATCH 0/2] Handle incomplete tap writes for pasta David Gibson
2023-11-08  3:17 ` David Gibson [this message]
2023-11-08  3:17 ` [PATCH 2/2] tap, pasta: Handle short writes to /dev/tap David Gibson
2023-11-10 13:51 ` [PATCH 0/2] Handle incomplete tap writes for pasta Stefano Brivio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231108031754.2670078-2-david@gibson.dropbear.id.au \
    --to=david@gibson.dropbear.id.au \
    --cc=passt-dev@passt.top \
    --cc=sbrivio@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).