Fix bug #50064: Zero-copy RX: ARP reply fails with PBUF_REF

Kept the optimized version intact, see discussion in savannah bug tracker
This commit is contained in:
Dirk Ziegelmeier 2017-01-18 10:15:02 +01:00
parent b198c877db
commit 199c38de29

View File

@ -128,7 +128,11 @@ static u8_t etharp_cached_entry;
static err_t etharp_request_dst(struct netif *netif, const ip4_addr_t *ipaddr, const struct eth_addr* hw_dst_addr); static err_t etharp_request_dst(struct netif *netif, const ip4_addr_t *ipaddr, const struct eth_addr* hw_dst_addr);
static err_t etharp_raw(struct netif *netif,
const struct eth_addr *ethsrc_addr, const struct eth_addr *ethdst_addr,
const struct eth_addr *hwsrc_addr, const ip4_addr_t *ipsrc_addr,
const struct eth_addr *hwdst_addr, const ip4_addr_t *ipdst_addr,
const u16_t opcode);
#if ARP_QUEUEING #if ARP_QUEUEING
/** /**
@ -695,7 +699,16 @@ etharp_input(struct pbuf *p, struct netif *netif)
LWIP_DEBUGF (ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_input: incoming ARP request\n")); LWIP_DEBUGF (ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_input: incoming ARP request\n"));
/* ARP request for our address? */ /* ARP request for our address? */
if (for_us) { if (for_us) {
if (p->type == PBUF_REF) {
ip4_addr_t sipaddr;
IPADDR2_COPY(&sipaddr.addr, &hdr->sipaddr);
etharp_raw(netif,
(struct eth_addr *)netif->hwaddr, &hdr->dhwaddr,
(struct eth_addr *)netif->hwaddr, netif_ip4_addr(netif),
&hdr->shwaddr, &sipaddr,
ARP_REPLY);
} else {
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_input: replying to ARP request for our IP address\n")); LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_input: replying to ARP request for our IP address\n"));
/* Re-use pbuf to send ARP reply. /* Re-use pbuf to send ARP reply.
Since we are re-using an existing pbuf, we can't call etharp_raw since Since we are re-using an existing pbuf, we can't call etharp_raw since
@ -726,7 +739,7 @@ etharp_input(struct pbuf *p, struct netif *netif)
{ {
ethernet_output(netif, p, &hdr->shwaddr, &hdr->dhwaddr, ETHTYPE_ARP); ethernet_output(netif, p, &hdr->shwaddr, &hdr->dhwaddr, ETHTYPE_ARP);
} }
}
/* we are not configured? */ /* we are not configured? */
} else if (ip4_addr_isany_val(*netif_ip4_addr(netif))) { } else if (ip4_addr_isany_val(*netif_ip4_addr(netif))) {
/* { for_us == 0 and netif->ip_addr.addr == 0 } */ /* { for_us == 0 and netif->ip_addr.addr == 0 } */