* [PATCH trivial 0/3] tcp_vu: Remove redundant header field assignments
@ 2026-03-20 13:51 Laurent Vivier
2026-03-20 13:51 ` [PATCH trivial 1/3] tcp_vu: Remove redundant eh->h_proto assignments Laurent Vivier
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Laurent Vivier @ 2026-03-20 13:51 UTC (permalink / raw)
To: passt-dev; +Cc: Laurent Vivier
tcp_vu_send_flag() and tcp_vu_prepare() set several header fields
that are unconditionally overwritten by tcp_fill_headers() or
tcp_prepare_flags() shortly after.
This series removes:
1. eh->h_proto assignments in both tcp_vu_send_flag() and
tcp_vu_prepare(), overwritten by tcp_fill_headers()
2. eh->h_source memcpy in tcp_vu_send_flag(), overwritten by
eth_update_mac() called from tcp_fill_headers()
3. th->doff and th->ack assignments in tcp_vu_send_flag(),
overwritten by tcp_prepare_flags()
Laurent Vivier (3):
tcp_vu: Remove redundant eh->h_proto assignments
tcp_vu: Remove redundant eh->h_source assignment in tcp_vu_send_flag()
tcp_vu: Remove redundant th->doff and th->ack in tcp_vu_send_flag()
tcp_vu.c | 11 -----------
1 file changed, 11 deletions(-)
--
2.53.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH trivial 1/3] tcp_vu: Remove redundant eh->h_proto assignments
2026-03-20 13:51 [PATCH trivial 0/3] tcp_vu: Remove redundant header field assignments Laurent Vivier
@ 2026-03-20 13:51 ` Laurent Vivier
2026-03-23 23:08 ` David Gibson
2026-03-20 13:51 ` [PATCH trivial 2/3] tcp_vu: Remove redundant eh->h_source assignment in tcp_vu_send_flag() Laurent Vivier
2026-03-20 13:51 ` [PATCH trivial 3/3] tcp_vu: Remove redundant th->doff and th->ack " Laurent Vivier
2 siblings, 1 reply; 7+ messages in thread
From: Laurent Vivier @ 2026-03-20 13:51 UTC (permalink / raw)
To: passt-dev; +Cc: Laurent Vivier
tcp_fill_headers() unconditionally sets eh->h_proto based on whether
ip4h or ip6h is non-NULL. The assignments in tcp_vu_send_flag() and
tcp_vu_prepare() are therefore redundant and can be removed.
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
tcp_vu.c | 8 --------
1 file changed, 8 deletions(-)
diff --git a/tcp_vu.c b/tcp_vu.c
index fd734e857b3b..c616b1fec2bf 100644
--- a/tcp_vu.c
+++ b/tcp_vu.c
@@ -105,15 +105,11 @@ int tcp_vu_send_flag(const struct ctx *c, struct tcp_tap_conn *conn, int flags)
memcpy(eh->h_source, c->our_tap_mac, sizeof(eh->h_source));
if (CONN_V4(conn)) {
- eh->h_proto = htons(ETH_P_IP);
-
ip4h = vu_ip(flags_elem[0].in_sg[0].iov_base);
*ip4h = (struct iphdr)L2_BUF_IP4_INIT(IPPROTO_TCP);
th = vu_payloadv4(flags_elem[0].in_sg[0].iov_base);
} else {
- eh->h_proto = htons(ETH_P_IPV6);
-
ip6h = vu_ip(flags_elem[0].in_sg[0].iov_base);
*ip6h = (struct ipv6hdr)L2_BUF_IP6_INIT(IPPROTO_TCP);
th = vu_payloadv6(flags_elem[0].in_sg[0].iov_base);
@@ -307,14 +303,10 @@ static void tcp_vu_prepare(const struct ctx *c, struct tcp_tap_conn *conn,
/* initialize header */
if (!v6) {
- eh->h_proto = htons(ETH_P_IP);
-
ip4h = vu_ip(base);
*ip4h = (struct iphdr)L2_BUF_IP4_INIT(IPPROTO_TCP);
th = vu_payloadv4(base);
} else {
- eh->h_proto = htons(ETH_P_IPV6);
-
ip6h = vu_ip(base);
*ip6h = (struct ipv6hdr)L2_BUF_IP6_INIT(IPPROTO_TCP);
--
2.53.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH trivial 2/3] tcp_vu: Remove redundant eh->h_source assignment in tcp_vu_send_flag()
2026-03-20 13:51 [PATCH trivial 0/3] tcp_vu: Remove redundant header field assignments Laurent Vivier
2026-03-20 13:51 ` [PATCH trivial 1/3] tcp_vu: Remove redundant eh->h_proto assignments Laurent Vivier
@ 2026-03-20 13:51 ` Laurent Vivier
2026-03-23 23:10 ` David Gibson
2026-03-20 13:51 ` [PATCH trivial 3/3] tcp_vu: Remove redundant th->doff and th->ack " Laurent Vivier
2 siblings, 1 reply; 7+ messages in thread
From: Laurent Vivier @ 2026-03-20 13:51 UTC (permalink / raw)
To: passt-dev; +Cc: Laurent Vivier
tcp_fill_headers() calls eth_update_mac(eh, NULL, omac) which
unconditionally overwrites eh->h_source. The prior memcpy() setting
it to c->our_tap_mac is therefore redundant.
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
tcp_vu.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/tcp_vu.c b/tcp_vu.c
index c616b1fec2bf..9c4e916b1b8d 100644
--- a/tcp_vu.c
+++ b/tcp_vu.c
@@ -102,7 +102,6 @@ int tcp_vu_send_flag(const struct ctx *c, struct tcp_tap_conn *conn, int flags)
eh = vu_eth(flags_elem[0].in_sg[0].iov_base);
memcpy(eh->h_dest, c->guest_mac, sizeof(eh->h_dest));
- memcpy(eh->h_source, c->our_tap_mac, sizeof(eh->h_source));
if (CONN_V4(conn)) {
ip4h = vu_ip(flags_elem[0].in_sg[0].iov_base);
--
2.53.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH trivial 3/3] tcp_vu: Remove redundant th->doff and th->ack in tcp_vu_send_flag()
2026-03-20 13:51 [PATCH trivial 0/3] tcp_vu: Remove redundant header field assignments Laurent Vivier
2026-03-20 13:51 ` [PATCH trivial 1/3] tcp_vu: Remove redundant eh->h_proto assignments Laurent Vivier
2026-03-20 13:51 ` [PATCH trivial 2/3] tcp_vu: Remove redundant eh->h_source assignment in tcp_vu_send_flag() Laurent Vivier
@ 2026-03-20 13:51 ` Laurent Vivier
2026-03-23 23:11 ` David Gibson
2 siblings, 1 reply; 7+ messages in thread
From: Laurent Vivier @ 2026-03-20 13:51 UTC (permalink / raw)
To: passt-dev; +Cc: Laurent Vivier
tcp_prepare_flags() unconditionally sets th->doff and th->ack, so
setting them right after the memset() is redundant.
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
tcp_vu.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/tcp_vu.c b/tcp_vu.c
index 9c4e916b1b8d..7a348eb01248 100644
--- a/tcp_vu.c
+++ b/tcp_vu.c
@@ -115,8 +115,6 @@ int tcp_vu_send_flag(const struct ctx *c, struct tcp_tap_conn *conn, int flags)
}
memset(th, 0, sizeof(*th));
- th->doff = sizeof(*th) / 4;
- th->ack = 1;
seq = conn->seq_to_tap;
opts = (struct tcp_syn_opts *)(th + 1);
--
2.53.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH trivial 1/3] tcp_vu: Remove redundant eh->h_proto assignments
2026-03-20 13:51 ` [PATCH trivial 1/3] tcp_vu: Remove redundant eh->h_proto assignments Laurent Vivier
@ 2026-03-23 23:08 ` David Gibson
0 siblings, 0 replies; 7+ messages in thread
From: David Gibson @ 2026-03-23 23:08 UTC (permalink / raw)
To: Laurent Vivier; +Cc: passt-dev
[-- Attachment #1: Type: text/plain, Size: 1900 bytes --]
On Fri, Mar 20, 2026 at 02:51:14PM +0100, Laurent Vivier wrote:
> tcp_fill_headers() unconditionally sets eh->h_proto based on whether
> ip4h or ip6h is non-NULL. The assignments in tcp_vu_send_flag() and
> tcp_vu_prepare() are therefore redundant and can be removed.
>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> tcp_vu.c | 8 --------
> 1 file changed, 8 deletions(-)
>
> diff --git a/tcp_vu.c b/tcp_vu.c
> index fd734e857b3b..c616b1fec2bf 100644
> --- a/tcp_vu.c
> +++ b/tcp_vu.c
> @@ -105,15 +105,11 @@ int tcp_vu_send_flag(const struct ctx *c, struct tcp_tap_conn *conn, int flags)
> memcpy(eh->h_source, c->our_tap_mac, sizeof(eh->h_source));
>
> if (CONN_V4(conn)) {
> - eh->h_proto = htons(ETH_P_IP);
> -
> ip4h = vu_ip(flags_elem[0].in_sg[0].iov_base);
> *ip4h = (struct iphdr)L2_BUF_IP4_INIT(IPPROTO_TCP);
>
> th = vu_payloadv4(flags_elem[0].in_sg[0].iov_base);
> } else {
> - eh->h_proto = htons(ETH_P_IPV6);
> -
> ip6h = vu_ip(flags_elem[0].in_sg[0].iov_base);
> *ip6h = (struct ipv6hdr)L2_BUF_IP6_INIT(IPPROTO_TCP);
> th = vu_payloadv6(flags_elem[0].in_sg[0].iov_base);
> @@ -307,14 +303,10 @@ static void tcp_vu_prepare(const struct ctx *c, struct tcp_tap_conn *conn,
> /* initialize header */
>
> if (!v6) {
> - eh->h_proto = htons(ETH_P_IP);
> -
> ip4h = vu_ip(base);
> *ip4h = (struct iphdr)L2_BUF_IP4_INIT(IPPROTO_TCP);
> th = vu_payloadv4(base);
> } else {
> - eh->h_proto = htons(ETH_P_IPV6);
> -
> ip6h = vu_ip(base);
> *ip6h = (struct ipv6hdr)L2_BUF_IP6_INIT(IPPROTO_TCP);
>
> --
> 2.53.0
>
--
David Gibson (he or they) | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you, not the other way
| around.
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH trivial 2/3] tcp_vu: Remove redundant eh->h_source assignment in tcp_vu_send_flag()
2026-03-20 13:51 ` [PATCH trivial 2/3] tcp_vu: Remove redundant eh->h_source assignment in tcp_vu_send_flag() Laurent Vivier
@ 2026-03-23 23:10 ` David Gibson
0 siblings, 0 replies; 7+ messages in thread
From: David Gibson @ 2026-03-23 23:10 UTC (permalink / raw)
To: Laurent Vivier; +Cc: passt-dev
[-- Attachment #1: Type: text/plain, Size: 1134 bytes --]
On Fri, Mar 20, 2026 at 02:51:15PM +0100, Laurent Vivier wrote:
> tcp_fill_headers() calls eth_update_mac(eh, NULL, omac) which
> unconditionally overwrites eh->h_source. The prior memcpy() setting
> it to c->our_tap_mac is therefore redundant.
>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> tcp_vu.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/tcp_vu.c b/tcp_vu.c
> index c616b1fec2bf..9c4e916b1b8d 100644
> --- a/tcp_vu.c
> +++ b/tcp_vu.c
> @@ -102,7 +102,6 @@ int tcp_vu_send_flag(const struct ctx *c, struct tcp_tap_conn *conn, int flags)
> eh = vu_eth(flags_elem[0].in_sg[0].iov_base);
>
> memcpy(eh->h_dest, c->guest_mac, sizeof(eh->h_dest));
> - memcpy(eh->h_source, c->our_tap_mac, sizeof(eh->h_source));
>
> if (CONN_V4(conn)) {
> ip4h = vu_ip(flags_elem[0].in_sg[0].iov_base);
> --
> 2.53.0
>
--
David Gibson (he or they) | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you, not the other way
| around.
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH trivial 3/3] tcp_vu: Remove redundant th->doff and th->ack in tcp_vu_send_flag()
2026-03-20 13:51 ` [PATCH trivial 3/3] tcp_vu: Remove redundant th->doff and th->ack " Laurent Vivier
@ 2026-03-23 23:11 ` David Gibson
0 siblings, 0 replies; 7+ messages in thread
From: David Gibson @ 2026-03-23 23:11 UTC (permalink / raw)
To: Laurent Vivier; +Cc: passt-dev
[-- Attachment #1: Type: text/plain, Size: 986 bytes --]
On Fri, Mar 20, 2026 at 02:51:16PM +0100, Laurent Vivier wrote:
> tcp_prepare_flags() unconditionally sets th->doff and th->ack, so
> setting them right after the memset() is redundant.
>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> tcp_vu.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/tcp_vu.c b/tcp_vu.c
> index 9c4e916b1b8d..7a348eb01248 100644
> --- a/tcp_vu.c
> +++ b/tcp_vu.c
> @@ -115,8 +115,6 @@ int tcp_vu_send_flag(const struct ctx *c, struct tcp_tap_conn *conn, int flags)
> }
>
> memset(th, 0, sizeof(*th));
> - th->doff = sizeof(*th) / 4;
> - th->ack = 1;
>
> seq = conn->seq_to_tap;
> opts = (struct tcp_syn_opts *)(th + 1);
> --
> 2.53.0
>
--
David Gibson (he or they) | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you, not the other way
| around.
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-03-23 23:11 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-20 13:51 [PATCH trivial 0/3] tcp_vu: Remove redundant header field assignments Laurent Vivier
2026-03-20 13:51 ` [PATCH trivial 1/3] tcp_vu: Remove redundant eh->h_proto assignments Laurent Vivier
2026-03-23 23:08 ` David Gibson
2026-03-20 13:51 ` [PATCH trivial 2/3] tcp_vu: Remove redundant eh->h_source assignment in tcp_vu_send_flag() Laurent Vivier
2026-03-23 23:10 ` David Gibson
2026-03-20 13:51 ` [PATCH trivial 3/3] tcp_vu: Remove redundant th->doff and th->ack " Laurent Vivier
2026-03-23 23:11 ` David Gibson
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).