From 998bb35c60b855eeb65598d46134b971df9da3ae Mon Sep 17 00:00:00 2001 From: LekKit <50500857+LekKit@users.noreply.github.com> Date: Sun, 3 Mar 2024 12:19:23 +0200 Subject: [PATCH] tap_user: Spawn net thread on tap_attach() --- src/devices/tap_user.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/devices/tap_user.c b/src/devices/tap_user.c index 5ad53b8d4..3d8b47228 100644 --- a/src/devices/tap_user.c +++ b/src/devices/tap_user.c @@ -150,7 +150,6 @@ struct tap_dev { static inline bool eth_send(tap_dev_t* tap, const void* buffer, size_t size) { - if (!tap->net.feed_rx) return false; return tap->net.feed_rx(tap->net.net_dev, buffer, size); } @@ -1081,16 +1080,15 @@ tap_dev_t* tap_open() tap_portfwd(tap, "tcp/[::1]:2022=22"); tap_portfwd(tap, "tcp/127.0.0.1:2022=22"); - tap->thread = thread_create(tap_thread, tap); - return tap; } void tap_attach(tap_dev_t* tap, const tap_net_dev_t* net_dev) { - spin_lock(&tap->lock); - tap->net = *net_dev; - spin_unlock(&tap->lock); + if (tap->net.feed_rx == NULL) { + tap->net = *net_dev; + tap->thread = thread_create(tap_thread, tap); + } } bool tap_portfwd(tap_dev_t* tap, const char* fwd)