From 4db947d17c8c7dac3b344c8ce0a266f7be159200 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Fri, 8 Mar 2024 17:53:24 +1100 Subject: tap: Implement tap_send() "slow path" in terms of fast path Most times we send frames to the guest it goes via tap_send_frames(). However "slow path" protocols - ARP, ICMP, ICMPv6, DHCP and DHCPv6 - go via tap_send(). As well as being a semantic duplication, tap_send() contains at least one serious problem: it doesn't properly handle short sends, which can be fatal on the qemu socket connection, since frame boundaries will get out of sync. Rewrite tap_send() to call tap_send_frames(). While we're there, rename it tap_send_single() for clarity. Signed-off-by: David Gibson Signed-off-by: Stefano Brivio --- arp.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'arp.c') diff --git a/arp.c b/arp.c index a35c1b6..113cda2 100644 --- a/arp.c +++ b/arp.c @@ -44,7 +44,6 @@ int arp(const struct ctx *c, const struct pool *p) struct arphdr *ah; struct arpmsg *am; size_t len; - int ret; eh = packet_get(p, 0, 0, sizeof(*eh), NULL); ah = packet_get(p, 0, sizeof(*eh), sizeof(*ah), NULL); @@ -83,8 +82,7 @@ int arp(const struct ctx *c, const struct pool *p) memcpy(eh->h_dest, eh->h_source, sizeof(eh->h_dest)); memcpy(eh->h_source, c->mac, sizeof(eh->h_source)); - if ((ret = tap_send(c, eh, len)) < 0) - warn("ARP: send: %s", strerror(ret)); + tap_send_single(c, eh, len); return 1; } -- cgit v1.2.3