From 2a581e3fab1de44fe14caec972ce6f27b73f5419 Mon Sep 17 00:00:00 2001 From: Liu Zhi Fu Date: Thu, 12 Jul 2018 16:49:22 +0800 Subject: [PATCH] lwip: add source ip based route for unicast packet Add source IP based route for unicast packets forwarding. --- components/lwip/core/ipv4/ip4.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/lwip/core/ipv4/ip4.c b/components/lwip/core/ipv4/ip4.c index d2b9195a4..376a8cf96 100644 --- a/components/lwip/core/ipv4/ip4.c +++ b/components/lwip/core/ipv4/ip4.c @@ -142,7 +142,7 @@ ip4_route_src_hook(const ip4_addr_t *dest, const ip4_addr_t *src) struct netif *netif = NULL; /* destination IP is broadcast IP? */ - if ((src != NULL) && (dest->addr == IPADDR_BROADCAST)) { + if ((src != NULL) && (!ip4_addr_isany(src) || (dest->addr == IPADDR_BROADCAST))) { /* iterate through netifs */ for (netif = netif_list; netif != NULL; netif = netif->next) { /* is the netif up, does it have a link and a valid address? */