Skip to content

Commit

Permalink
[components][net][lwip][port] Fix next-hop finding in lwip_ip4_route_…
Browse files Browse the repository at this point in the history
…src. (#7504)

Co-authored-by: Wayne Lin <wclin@nuvoton.com>
  • Loading branch information
wosayttn and ttnwosay authored May 17, 2023
1 parent 3b91391 commit a2b7a44
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions components/net/lwip/port/sys_arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit a2b7a44

Please sign in to comment.