mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-12-26 03:16:18 +00:00
ip4: fix swapped src/dst params with ip4_route_src
This fixes a couple of occurrences where the src and dst parameters to ip4_route_src() were swapped. This was most likely due to confusion between ip_route(src, dst) and ip4_route_src(dst, src) This was found in a system where LWIP_IPV4_SRC_ROUTING is 0 The UDP case was an application socket bound to INADDR_ANY with IP_MULTICAST_IF set. Transmits would result in calling ip4_route(dst) where dst was pcb->local_addr (which was INADDR_ANY) instead of pcb->mcast_ip4. This resulted in a routing failure The ICMP issue was found through code analysis only
This commit is contained in:
parent
006bb84368
commit
2b2ea50cb1
@ -380,7 +380,7 @@ icmp_send_response(struct pbuf *p, u8_t type, u8_t code)
|
|||||||
{
|
{
|
||||||
ip4_addr_t iphdr_dst;
|
ip4_addr_t iphdr_dst;
|
||||||
ip4_addr_copy(iphdr_dst, iphdr->dest);
|
ip4_addr_copy(iphdr_dst, iphdr->dest);
|
||||||
netif = ip4_route_src(&iphdr_src, &iphdr_dst);
|
netif = ip4_route_src(&iphdr_dst, &iphdr_src);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
netif = ip4_route(&iphdr_src);
|
netif = ip4_route(&iphdr_src);
|
||||||
|
@ -539,7 +539,7 @@ udp_sendto_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *dst_ip,
|
|||||||
fails, we try regular routing as though no override was set. */
|
fails, we try regular routing as though no override was set. */
|
||||||
if (!ip4_addr_isany_val(pcb->mcast_ip4) &&
|
if (!ip4_addr_isany_val(pcb->mcast_ip4) &&
|
||||||
!ip4_addr_cmp(&pcb->mcast_ip4, IP4_ADDR_BROADCAST)) {
|
!ip4_addr_cmp(&pcb->mcast_ip4, IP4_ADDR_BROADCAST)) {
|
||||||
netif = ip4_route_src(ip_2_ip4(&pcb->local_ip), &pcb->mcast_ip4);
|
netif = ip4_route_src(&pcb->mcast_ip4, ip_2_ip4(&pcb->local_ip));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* LWIP_IPV4 */
|
#endif /* LWIP_IPV4 */
|
||||||
|
Loading…
Reference in New Issue
Block a user