net: core: Pass the actual LL proto for DGRAM packet sockets

After L2 processing, the LL protocol type is already known and should be
set accordingly on the packet. Therefore it can be passed to the
net_packet_socket_input() function to allow proper socket filtering
based on protocol.

Additionally, as LL protocol type is 16 bit value, fix the proto
parameter type in net_packet_socket_input().

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
Robert Lubos 2025-04-16 13:00:04 +02:00 committed by Benjamin Cabé
commit edba291799
3 changed files with 4 additions and 4 deletions

View file

@ -117,7 +117,7 @@ static inline enum net_verdict process_data(struct net_pkt *pkt,
/* Consecutive call will forward packets to SOCK_DGRAM packet sockets
* (after L2 removed header).
*/
ret = net_packet_socket_input(pkt, ETH_P_ALL);
ret = net_packet_socket_input(pkt, net_pkt_ll_proto_type(pkt));
if (ret != NET_CONTINUE) {
return ret;
}

View file

@ -20,7 +20,7 @@ LOG_MODULE_REGISTER(net_sockets_raw, CONFIG_NET_SOCKETS_LOG_LEVEL);
#include "connection.h"
#include "packet_socket.h"
enum net_verdict net_packet_socket_input(struct net_pkt *pkt, uint8_t proto)
enum net_verdict net_packet_socket_input(struct net_pkt *pkt, uint16_t proto)
{
sa_family_t orig_family;
enum net_verdict net_verdict;

View file

@ -26,10 +26,10 @@
* disabled, the function will always return NET_DROP.
*/
#if defined(CONFIG_NET_SOCKETS_PACKET)
enum net_verdict net_packet_socket_input(struct net_pkt *pkt, uint8_t proto);
enum net_verdict net_packet_socket_input(struct net_pkt *pkt, uint16_t proto);
#else
static inline enum net_verdict net_packet_socket_input(struct net_pkt *pkt,
uint8_t proto)
uint16_t proto)
{
return NET_CONTINUE;
}