aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2023-03-27 14:56:33 +1100
committerStefano Brivio <sbrivio@redhat.com>2023-03-29 13:46:58 +0200
commit085672f77cce3e91a116ac39cff581bca64ba50a (patch)
tree84e996dc845f193f57fd54857137081f35c56d84
parent1ee2f7cada9e6f739a00d39bb9821f1ce3493d92 (diff)
downloadpasst-085672f77cce3e91a116ac39cff581bca64ba50a.tar
passt-085672f77cce3e91a116ac39cff581bca64ba50a.tar.gz
passt-085672f77cce3e91a116ac39cff581bca64ba50a.tar.bz2
passt-085672f77cce3e91a116ac39cff581bca64ba50a.tar.lz
passt-085672f77cce3e91a116ac39cff581bca64ba50a.tar.xz
passt-085672f77cce3e91a116ac39cff581bca64ba50a.tar.zst
passt-085672f77cce3e91a116ac39cff581bca64ba50a.zip
tcp: Clarify allowed state for tcp_data_from_tap()
Comments suggest that this should only be called for an ESTABLISHED connection. However, it's non-trivial to ascertain that from the actual control flow in the caller. Add an ASSERT() to make it very clear that this is only called in ESTABLISHED state. In fact, there were some circumstances where it could be called on a CLOSED connection. In a sense that is "established", but with that assert this does require specific (trivial) handling to avoid a spurious abort(). Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r--tcp.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/tcp.c b/tcp.c
index f156287..d82c62e 100644
--- a/tcp.c
+++ b/tcp.c
@@ -2337,6 +2337,11 @@ static void tcp_data_from_tap(struct ctx *c, struct tcp_tap_conn *conn,
size_t len;
ssize_t n;
+ if (conn->events == CLOSED)
+ return;
+
+ ASSERT(conn->events & ESTABLISHED);
+
for (i = 0, iov_i = 0; i < (int)p->count; i++) {
uint32_t seq, seq_offset, ack_seq;
struct tcphdr *th;