From 7e131e920c04054b9d005dac718ac54e5169fa71 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Fri, 22 Nov 2024 17:43:36 +0100 Subject: tcp: Move tcp_l2_buf_fill_headers() to tcp_buf.c This function only has callers in tcp_buf.c. More importantly, it's inherently tied to the "buf" path, because it uses internal knowledge of how we lay out the various headers across our locally allocated buffers. Therefore, move it to tcp_buf.c. Slightly reformat the prototypes while we're at it. Signed-off-by: David Gibson Signed-off-by: Laurent Vivier Signed-off-by: Stefano Brivio --- tcp_vu.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'tcp_vu.c') diff --git a/tcp_vu.c b/tcp_vu.c index 1bebb31..f27e175 100644 --- a/tcp_vu.c +++ b/tcp_vu.c @@ -98,7 +98,7 @@ int tcp_vu_send_flag(const struct ctx *c, struct tcp_tap_conn *conn, int flags) struct vu_dev *vdev = c->vdev; struct vu_virtq *vq = &vdev->vq[VHOST_USER_RX_QUEUE]; const struct flowside *tapside = TAPFLOW(conn); - size_t l2len, l4len, optlen, hdrlen; + size_t optlen, hdrlen; struct vu_virtq_element flags_elem[2]; struct tcp_payload_t *payload; struct ipv6hdr *ip6h = NULL; @@ -157,19 +157,15 @@ int tcp_vu_send_flag(const struct ctx *c, struct tcp_tap_conn *conn, int flags) return ret; } + flags_elem[0].in_sg[0].iov_len = hdrlen + optlen; + if (CONN_V4(conn)) { - l4len = tcp_fill_headers4(conn, NULL, iph, payload, optlen, - NULL, seq, true); - l2len = sizeof(*iph); + tcp_fill_headers4(conn, NULL, iph, payload, optlen, NULL, seq, + true); } else { - l4len = tcp_fill_headers6(conn, NULL, ip6h, payload, optlen, - seq, true); - l2len = sizeof(*ip6h); + tcp_fill_headers6(conn, NULL, ip6h, payload, optlen, seq, true); } - l2len += l4len + sizeof(struct ethhdr); - flags_elem[0].in_sg[0].iov_len = l2len + - sizeof(struct virtio_net_hdr_mrg_rxbuf); if (*c->pcap) { tcp_vu_update_check(tapside, &flags_elem[0].in_sg[0], 1); pcap_iov(&flags_elem[0].in_sg[0], 1, -- cgit v1.2.3