net: Tighten ETHERTYPE decode.
The uip stack processes received packets by calling net_recv() but does not discard packets marked with an ethertype other than IPv4 or IPv6 resulting in confusion further up the stack. Discard non IPv4/v6 packets from further processing by the IP stack. Change-Id: Ic62f8d12b02da197b1abc774a581bff30330080c Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
This commit is contained in:
parent
9c3ebee4a1
commit
710e82faca
1 changed files with 10 additions and 4 deletions
|
@ -98,9 +98,9 @@ static int net_driver_ethernet_send(struct net_buf *buf)
|
|||
|
||||
void net_driver_ethernet_recv(struct net_buf *buf)
|
||||
{
|
||||
#ifdef CONFIG_NETWORKING_WITH_IPV4
|
||||
struct uip_eth_hdr *eth_hdr = (struct uip_eth_hdr *)uip_buf(buf);
|
||||
|
||||
#ifdef CONFIG_NETWORKING_WITH_IPV4
|
||||
if (eth_hdr->type == uip_htons(UIP_ETHTYPE_ARP)) {
|
||||
uip_arp_arpin(buf);
|
||||
|
||||
|
@ -127,9 +127,15 @@ void net_driver_ethernet_recv(struct net_buf *buf)
|
|||
ip_buf_unref(buf);
|
||||
} else
|
||||
#endif
|
||||
|
||||
if (net_recv(buf) != 0) {
|
||||
NET_ERR("Unexpected return value from net_recv.\n");
|
||||
if (eth_hdr->type == uip_htons(UIP_ETHTYPE_IP) ||
|
||||
eth_hdr->type == uip_htons(UIP_ETHTYPE_IPV6)) {
|
||||
if (net_recv(buf) != 0) {
|
||||
NET_ERR("Unexpected return value from net_recv.\n");
|
||||
ip_buf_unref(buf);
|
||||
}
|
||||
} else {
|
||||
NET_DBG("Dropping unknown ethertype %x\n",
|
||||
uip_ntohs(eth_hdr->type));
|
||||
ip_buf_unref(buf);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue