Skip to content

Commit a2b7a44

Browse files
wosayttnttnwosay
andauthored
[components][net][lwip][port] Fix next-hop finding in lwip_ip4_route_src. (#7504)
Co-authored-by: Wayne Lin <[email protected]>
1 parent 3b91391 commit a2b7a44

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

components/net/lwip/port/sys_arch.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -675,24 +675,24 @@ struct netif *lwip_ip4_route_src(const ip4_addr_t *dest, const ip4_addr_t *src)
675675
{
676676
struct netif *netif;
677677

678+
if (src == NULL)
679+
return NULL;
680+
678681
/* iterate through netifs */
679682
for (netif = netif_list; netif != NULL; netif = netif->next)
680683
{
681684
/* is the netif up, does it have a link and a valid address? */
682685
if (netif_is_up(netif) && netif_is_link_up(netif) && !ip4_addr_isany_val(*netif_ip4_addr(netif)))
683686
{
684-
/* gateway matches on a non broadcast interface? (i.e. peer in a point to point interface) */
685-
if (src != NULL)
687+
/* source ip address equals netif's ip address? */
688+
if (ip4_addr_cmp(src, netif_ip4_addr(netif)))
686689
{
687-
if (ip4_addr_cmp(src, netif_ip4_addr(netif)))
688-
{
689-
return netif;
690-
}
690+
return netif;
691691
}
692692
}
693693
}
694-
netif = netif_default;
695-
return netif;
694+
695+
return NULL;
696696
}
697697
#endif /* LWIP_HOOK_IP4_ROUTE_SRC */
698698
#endif /*LWIP_VERSION_MAJOR >= 2 */

0 commit comments

Comments
 (0)