1
0
Fork 0
mirror of https://github.com/hermitcore/libhermit.git synced 2025-03-09 00:00:03 +01:00

forward packet to the IP thread

=> don't consume the packet within the interrupt handler
This commit is contained in:
Stefan Lankes 2017-09-20 20:03:56 +02:00
parent b4c5262ac8
commit a2b88521bc

View file

@ -176,14 +176,21 @@ static err_t uhyve_netif_output(struct netif* netif, struct pbuf* p)
return ERR_OK;
}
static void consume_packet(void* ctx)
{
struct pbuf *p = (struct pbuf*) ctx;
mynetif->input(p, mynetif);
}
//------------------------------- POLLING ----------------------------------------
static void uhyve_netif_poll(struct netif* netif)
static void uhyve_netif_poll(void)
{
if (!uhyve_net_init_ok)
return;
uhyve_netif_t* uhyve_netif = netif->state;
uhyve_netif_t* uhyve_netif = mynetif->state;
int len = RX_BUF_LEN;
struct pbuf *p = NULL;
struct pbuf *q;
@ -206,9 +213,13 @@ static void uhyve_netif_poll(struct netif* netif)
#if ETH_PAD_SIZE
pbuf_header(p, ETH_PAD_SIZE); /*reclaim the padding word */
#endif
LINK_STATS_INC(link.recv);
//forward packet to LwIP
netif->input(p, mynetif);
if (tcpip_callback_with_block(consume_packet, p, 0) == ERR_OK)
LINK_STATS_INC(link.recv);
else
LINK_STATS_INC(link.drop);
} else {
LOG_ERROR("uhyve_netif_poll: not enough memory!\n");
LINK_STATS_INC(link.memerr);
@ -219,7 +230,7 @@ static void uhyve_netif_poll(struct netif* netif)
static void uhyve_irqhandler(struct state* s)
{
uhyve_netif_poll(mynetif);
uhyve_netif_poll();
}
//--------------------------------- INIT -----------------------------------------