From 2e11cc00e9e825a21ead67f4f0d21dad183adcbd Mon Sep 17 00:00:00 2001 From: Epagris Date: Wed, 1 May 2024 18:28:24 +0200 Subject: [PATCH] - EthIntf: automatically discard packets if link is down --- eth_interface.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/eth_interface.c b/eth_interface.c index 2883aeb..178c995 100644 --- a/eth_interface.c +++ b/eth_interface.c @@ -138,7 +138,14 @@ void ethinf_receive(EthInterface *intf, const RawPckt *rawPckt) { } void ethinf_transmit(EthInterface *intf, const RawPckt *rawPckt) { - if (mq_push(intf->txQ, rawPckt)) { // push packet onto the message queue + // if link is down, discard packets + if (!ethinf_get_link_state(intf)) { + dynmem_free(rawPckt->payload); + return; + } + + // push packet onto the message queue + if (mq_push(intf->txQ, rawPckt)) { ethinf_push_notification(intf, ETH_IIE_TRANSMIT_NOTIFY, 0); // notify processing thread of the peding transmit } else { ERROR("Interface TRANSMIT queue full, packet dropped!\n");