From cd50608f243b544a98b8a333df18a39e00855e23 Mon Sep 17 00:00:00 2001 From: Robert Lubos Date: Fri, 25 Apr 2025 15:53:44 +0200 Subject: [PATCH] tests: net: sockets: af_packet: Fix recvfrom DGRAM test The recvfrom test case for DGRAM packet socket specified wrong socket type, so RAW sockets were tested twice instead. Also, for the DGRAM variant, the offset was not taken into account for the expected packet length. Signed-off-by: Robert Lubos --- tests/net/socket/af_packet/src/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/net/socket/af_packet/src/main.c b/tests/net/socket/af_packet/src/main.c index 68b5c58e79f..04f2683f84f 100644 --- a/tests/net/socket/af_packet/src/main.c +++ b/tests/net/socket/af_packet/src/main.c @@ -894,6 +894,8 @@ static void test_recvfrom_common(int sock_type, int proto) offset = sizeof(struct net_eth_hdr); } + pkt_len -= offset; + ret = zsock_recvfrom(packet_sock_2, rx_buf, sizeof(rx_buf), 0, (struct sockaddr *)&ll_rx, &addrlen); zassert_not_equal(ret, -1, "Failed to receive packet (%d)", errno); @@ -927,7 +929,7 @@ ZTEST(socket_packet, test_dgram_sock_recv_proto_wildcard) ZTEST(socket_packet, test_dgram_sock_recvfrom_proto_wildcard) { - test_recvfrom_common(SOCK_RAW, ETH_P_ALL); + test_recvfrom_common(SOCK_DGRAM, ETH_P_ALL); } ZTEST(socket_packet, test_raw_dgram_udp_socks_recv)