Skip to content

Commit c26f394

Browse files
rluboskartben
authored andcommitted
net: context: Verify if CONFIG_NET_SOCKETS_PACKET_DGRAM is enabled
Verify if CONFIG_NET_SOCKETS_PACKET_DGRAM is enabled when creating a datagram packet socket. Otherwise, it's possible to create non-functional AF_PACKET/SOCK_DGRAM socket w/o an error. Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
1 parent a9405d0 commit c26f394

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

subsys/net/ip/net_context.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,11 @@ static int net_context_check(sa_family_t family, enum net_sock_type type,
482482
NET_DBG("AF_PACKET disabled");
483483
return -EPFNOSUPPORT;
484484
}
485+
if (!IS_ENABLED(CONFIG_NET_SOCKETS_PACKET_DGRAM) &&
486+
type == SOCK_DGRAM) {
487+
NET_DBG("DGRAM socket type disabled.");
488+
return -EPROTOTYPE;
489+
}
485490
if (type != SOCK_RAW && type != SOCK_DGRAM) {
486491
NET_DBG("AF_PACKET only supports RAW and DGRAM socket "
487492
"types.");

0 commit comments

Comments
 (0)