Skip to content

Commit edba291

Browse files
rluboskartben
authored andcommitted
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>
1 parent b985b94 commit edba291

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

subsys/net/ip/net_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ static inline enum net_verdict process_data(struct net_pkt *pkt,
117117
/* Consecutive call will forward packets to SOCK_DGRAM packet sockets
118118
* (after L2 removed header).
119119
*/
120-
ret = net_packet_socket_input(pkt, ETH_P_ALL);
120+
ret = net_packet_socket_input(pkt, net_pkt_ll_proto_type(pkt));
121121
if (ret != NET_CONTINUE) {
122122
return ret;
123123
}

subsys/net/ip/packet_socket.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ LOG_MODULE_REGISTER(net_sockets_raw, CONFIG_NET_SOCKETS_LOG_LEVEL);
2020
#include "connection.h"
2121
#include "packet_socket.h"
2222

23-
enum net_verdict net_packet_socket_input(struct net_pkt *pkt, uint8_t proto)
23+
enum net_verdict net_packet_socket_input(struct net_pkt *pkt, uint16_t proto)
2424
{
2525
sa_family_t orig_family;
2626
enum net_verdict net_verdict;

subsys/net/ip/packet_socket.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
* disabled, the function will always return NET_DROP.
2727
*/
2828
#if defined(CONFIG_NET_SOCKETS_PACKET)
29-
enum net_verdict net_packet_socket_input(struct net_pkt *pkt, uint8_t proto);
29+
enum net_verdict net_packet_socket_input(struct net_pkt *pkt, uint16_t proto);
3030
#else
3131
static inline enum net_verdict net_packet_socket_input(struct net_pkt *pkt,
32-
uint8_t proto)
32+
uint16_t proto)
3333
{
3434
return NET_CONTINUE;
3535
}

0 commit comments

Comments
 (0)