[PATCH rtems-lwip] rtemslwip/ifaddrs: Set loopback flag
Kinsey Moore
kinsey.moore at oarcorp.com
Thu Mar 23 19:01:12 UTC 2023
Some consumers of getifaddrs() depend on the loopback flag being set
appropriately to filter interfaces. Make sure that requirement is
satisfied.
---
rtemslwip/bsd_compat/ifaddrs.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/rtemslwip/bsd_compat/ifaddrs.c b/rtemslwip/bsd_compat/ifaddrs.c
index dc6b7f2..9b97d4e 100644
--- a/rtemslwip/bsd_compat/ifaddrs.c
+++ b/rtemslwip/bsd_compat/ifaddrs.c
@@ -65,6 +65,12 @@ static struct ifaddrs *create_ifaddr_from_netif(struct netif *netif)
inet_addr_from_ip4addr(&((struct sockaddr_in *)ifaddr->ifa_addr)->sin_addr, &netif->ip_addr.u_addr.ip4);
inet_addr_from_ip4addr(&((struct sockaddr_in *)ifaddr->ifa_netmask)->sin_addr, &netif->netmask.u_addr.ip4);
((struct sockaddr_in *)ifaddr->ifa_netmask)->sin_addr.s_addr = netif->ip_addr.u_addr.ip4.addr & netif->netmask.u_addr.ip4.addr;
+
+ /* Set IFF_LOOPBACK flag if appropriate */
+ if (127 != (ip4_addr_get_u32(&netif->ip_addr.u_addr.ip4) >> 24)) {
+ ifaddr->ifa_flags |= IFF_LOOPBACK;
+ }
+
return ifaddr;
}
--
2.30.2
More information about the devel
mailing list