Skip to content

Commit cd50608

Browse files
rluboskartben
authored andcommitted
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 <[email protected]>
1 parent 29a2b5c commit cd50608

File tree

1 file changed

+3
-1
lines changed
  • tests/net/socket/af_packet/src

1 file changed

+3
-1
lines changed

tests/net/socket/af_packet/src/main.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,8 @@ static void test_recvfrom_common(int sock_type, int proto)
894894
offset = sizeof(struct net_eth_hdr);
895895
}
896896

897+
pkt_len -= offset;
898+
897899
ret = zsock_recvfrom(packet_sock_2, rx_buf, sizeof(rx_buf), 0,
898900
(struct sockaddr *)&ll_rx, &addrlen);
899901
zassert_not_equal(ret, -1, "Failed to receive packet (%d)", errno);
@@ -927,7 +929,7 @@ ZTEST(socket_packet, test_dgram_sock_recv_proto_wildcard)
927929

928930
ZTEST(socket_packet, test_dgram_sock_recvfrom_proto_wildcard)
929931
{
930-
test_recvfrom_common(SOCK_RAW, ETH_P_ALL);
932+
test_recvfrom_common(SOCK_DGRAM, ETH_P_ALL);
931933
}
932934

933935
ZTEST(socket_packet, test_raw_dgram_udp_socks_recv)

0 commit comments

Comments
 (0)