summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorWayne <[email protected]>2023-05-17 09:54:47 +0800
committerGitHub <[email protected]>2023-05-17 09:54:47 +0800
commita2b7a4407027d92b2e1bbf31989c20ad5893bd8c (patch)
treebab954606af20cdc11fa5306c059354b93054be0 /components
parent3b913914c2362637ab0cc70aef30eeb0f33baf7a (diff)
[components][net][lwip][port] Fix next-hop finding in lwip_ip4_route_src. (#7504)
Co-authored-by: Wayne Lin <[email protected]>
Diffstat (limited to 'components')
-rw-r--r--components/net/lwip/port/sys_arch.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/components/net/lwip/port/sys_arch.c b/components/net/lwip/port/sys_arch.c
index 066a75e92a..8eb46e7a76 100644
--- a/components/net/lwip/port/sys_arch.c
+++ b/components/net/lwip/port/sys_arch.c
@@ -675,24 +675,24 @@ struct netif *lwip_ip4_route_src(const ip4_addr_t *dest, const ip4_addr_t *src)
{
struct netif *netif;
+ if (src == NULL)
+ return NULL;
+
/* 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? */
if (netif_is_up(netif) && netif_is_link_up(netif) && !ip4_addr_isany_val(*netif_ip4_addr(netif)))
{
- /* gateway matches on a non broadcast interface? (i.e. peer in a point to point interface) */
- if (src != NULL)
+ /* source ip address equals netif's ip address? */
+ if (ip4_addr_cmp(src, netif_ip4_addr(netif)))
{
- if (ip4_addr_cmp(src, netif_ip4_addr(netif)))
- {
- return netif;
- }
+ return netif;
}
}
}
- netif = netif_default;
- return netif;
+
+ return NULL;
}
#endif /* LWIP_HOOK_IP4_ROUTE_SRC */
#endif /*LWIP_VERSION_MAJOR >= 2 */