net: sockets: packet: Allow proto 0 for RAW sockets
According to AF_PACKET man pages protocol number 0 is allowed, however in such case the socket is only capable of transmitting packets then: "If protocol is set to zero, no packets are received." Therefore, allow to create sockets with such protocol, and at the connection.c level filter out such sockets from data reception. Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
parent
6869668cc9
commit
332843be33
2 changed files with 3 additions and 2 deletions
|
@ -793,7 +793,7 @@ enum net_verdict net_conn_input(struct net_pkt *pkt,
|
|||
* case.
|
||||
*/
|
||||
if (IS_ENABLED(CONFIG_NET_SOCKETS_PACKET) && pkt_family == AF_PACKET) {
|
||||
if (proto != ETH_P_ALL) {
|
||||
if (conn->proto == 0 || proto != ETH_P_ALL) {
|
||||
continue; /* wrong protocol */
|
||||
}
|
||||
} else if (IS_ENABLED(CONFIG_NET_SOCKETS_INET_RAW) && raw_ip_pkt) {
|
||||
|
|
|
@ -486,7 +486,8 @@ static bool packet_is_supported(int family, int type, int proto)
|
|||
switch (type) {
|
||||
case SOCK_RAW:
|
||||
proto = ntohs(proto);
|
||||
return proto == ETH_P_ALL
|
||||
return proto == 0
|
||||
|| proto == ETH_P_ALL
|
||||
|| proto == ETH_P_ECAT
|
||||
|| proto == ETH_P_IEEE802154;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue