net: Remove IFF_DOWN flag to compatible with Linux/*BSD

turn off interface by checking IFF_UP flag isn't set:
https://github.com/apache/nuttx/issues/1838

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2024-10-06 15:22:19 +08:00 committed by Xiang Xiao
parent ac11e3cba9
commit f86baa76fc
4 changed files with 3 additions and 10 deletions

View File

@ -60,7 +60,7 @@ void alt1250_netdev_unregister(FAR struct alt1250_s *dev)
void alt1250_netdev_ifdown(FAR struct alt1250_s *dev) void alt1250_netdev_ifdown(FAR struct alt1250_s *dev)
{ {
dev->net_dev.d_flags = IFF_DOWN; dev->net_dev.d_flags = ~IFF_UP;
#ifdef CONFIG_NET_IPv4 #ifdef CONFIG_NET_IPv4
memset(&dev->net_dev.d_ipaddr, 0, sizeof(dev->net_dev.d_ipaddr)); memset(&dev->net_dev.d_ipaddr, 0, sizeof(dev->net_dev.d_ipaddr));
memset(&dev->net_dev.d_draddr, 0, sizeof(dev->net_dev.d_draddr)); memset(&dev->net_dev.d_draddr, 0, sizeof(dev->net_dev.d_draddr));

View File

@ -399,14 +399,9 @@ int usockreq_ioctl_ifreq(FAR struct alt1250_s *dev,
{ {
ret = do_ifup(dev, req, usock_result, usock_xid, ackinfo); ret = do_ifup(dev, req, usock_result, usock_xid, ackinfo);
} }
else if (if_req->ifr_flags & IFF_DOWN)
{
ret = do_ifdown(dev, req, usock_result, usock_xid, ackinfo);
}
else else
{ {
dbg_alt1250("unexpected ifr_flags:0x%02x\n", if_req->ifr_flags); ret = do_ifdown(dev, req, usock_result, usock_xid, ackinfo);
*usock_result = -EINVAL;
} }
return ret; return ret;

View File

@ -904,7 +904,7 @@ static int netinit_monitor(void)
ninfo("Taking the link down\n"); ninfo("Taking the link down\n");
ifr.ifr_flags = IFF_DOWN; ifr.ifr_flags = 0;
ret = ioctl(sd, SIOCSIFFLAGS, (unsigned long)&ifr); ret = ioctl(sd, SIOCSIFFLAGS, (unsigned long)&ifr);
if (ret < 0) if (ret < 0)
{ {

View File

@ -118,8 +118,6 @@ int netlib_ifdown(const char *ifname)
/* Perform the ioctl to ifup flag */ /* Perform the ioctl to ifup flag */
req.ifr_flags |= IFF_DOWN;
ret = ioctl(sockfd, SIOCSIFFLAGS, (unsigned long)&req); ret = ioctl(sockfd, SIOCSIFFLAGS, (unsigned long)&req);
close(sockfd); close(sockfd);
} }