From bb7c77b900397ce415e74f3480cc4b6175ca5d13 Mon Sep 17 00:00:00 2001 From: Denis Lazarev Date: Sat, 5 Oct 2024 20:01:57 +0300 Subject: [PATCH] HAL: linux: Set socket protocol only for receive sockets When creating raw sockets the protocol must be set to 0. In case for receive sockets this means we will receive no packets until we "bind" the socket with a non-zero protocol. In case for only transmit sockets this avoids an expensive call packet receiving function in kernel thats overflow internal receive socket buffer. --- hal/ethernet/linux/ethernet_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hal/ethernet/linux/ethernet_linux.c b/hal/ethernet/linux/ethernet_linux.c index bb989600..81c4aac0 100644 --- a/hal/ethernet/linux/ethernet_linux.c +++ b/hal/ethernet/linux/ethernet_linux.c @@ -174,7 +174,7 @@ Ethernet_createSocket(const char* interfaceId, uint8_t* destAddress) if (self) { - self->rawSocket = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); + self->rawSocket = socket(AF_PACKET, SOCK_RAW, 0); if (self->rawSocket == -1) {