Skip to content

Commit

Permalink
tap_user: Spawn net thread on tap_attach()
Browse files Browse the repository at this point in the history
  • Loading branch information
LekKit authored Mar 3, 2024
1 parent 089eb01 commit 998bb35
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/devices/tap_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 998bb35

Please sign in to comment.