1
0
Fork 0
mirror of https://passt.top/passt synced 2025-06-13 02:55:34 +02:00

tap: Extend tap_send_frames() to allow multi-buffer frames

tap_send_frames() takes a vector of buffers and requires exactly one frame
per buffer.  We have future plans where we want to have multiple buffers
per frame in some circumstances, so extend tap_send_frames() to take the
number of buffers per frame as a parameter.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
[sbrivio: Improve comment to rembufs calculation]
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
David Gibson 2024-03-08 17:53:22 +11:00 committed by Stefano Brivio
parent f67238aa86
commit 2d0e0084b6
4 changed files with 59 additions and 37 deletions

8
tcp.c
View file

@ -1289,10 +1289,10 @@ static void tcp_rst_do(struct ctx *c, struct tcp_tap_conn *conn);
*/
static void tcp_l2_flags_buf_flush(const struct ctx *c)
{
tap_send_frames(c, tcp6_l2_flags_iov, tcp6_l2_flags_buf_used);
tap_send_frames(c, tcp6_l2_flags_iov, 1, tcp6_l2_flags_buf_used);
tcp6_l2_flags_buf_used = 0;
tap_send_frames(c, tcp4_l2_flags_iov, tcp4_l2_flags_buf_used);
tap_send_frames(c, tcp4_l2_flags_iov, 1, tcp4_l2_flags_buf_used);
tcp4_l2_flags_buf_used = 0;
}
@ -1305,12 +1305,12 @@ static void tcp_l2_data_buf_flush(const struct ctx *c)
unsigned i;
size_t m;
m = tap_send_frames(c, tcp6_l2_iov, tcp6_l2_buf_used);
m = tap_send_frames(c, tcp6_l2_iov, 1, tcp6_l2_buf_used);
for (i = 0; i < m; i++)
*tcp6_l2_buf_seq_update[i].seq += tcp6_l2_buf_seq_update[i].len;
tcp6_l2_buf_used = 0;
m = tap_send_frames(c, tcp4_l2_iov, tcp4_l2_buf_used);
m = tap_send_frames(c, tcp4_l2_iov, 1, tcp4_l2_buf_used);
for (i = 0; i < m; i++)
*tcp4_l2_buf_seq_update[i].seq += tcp4_l2_buf_seq_update[i].len;
tcp4_l2_buf_used = 0;