Skip to content

Commit

Permalink
net: Remove IFF_DOWN flag to compatible with Linux/*BSD
Browse files Browse the repository at this point in the history
turn off interface by checking IFF_UP flag isn't set:
apache/nuttx#1838

Signed-off-by: Xiang Xiao <[email protected]>
  • Loading branch information
xiaoxiang781216 authored and GUIDINGLI committed Oct 7, 2024
1 parent 58e5bc7 commit 9b8a027
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lte/alt1250/alt1250_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void alt1250_netdev_unregister(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
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));
Expand Down
7 changes: 1 addition & 6 deletions lte/alt1250/usock_handlers/alt1250_ioctl_ifreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,14 +399,9 @@ int usockreq_ioctl_ifreq(FAR struct alt1250_s *dev,
{
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
{
dbg_alt1250("unexpected ifr_flags:0x%02x\n", if_req->ifr_flags);
*usock_result = -EINVAL;
ret = do_ifdown(dev, req, usock_result, usock_xid, ackinfo);
}

return ret;
Expand Down
2 changes: 1 addition & 1 deletion netutils/netinit/netinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ static int netinit_monitor(void)

ninfo("Taking the link down\n");

ifr.ifr_flags = IFF_DOWN;
ifr.ifr_flags = 0;
ret = ioctl(sd, SIOCSIFFLAGS, (unsigned long)&ifr);
if (ret < 0)
{
Expand Down
2 changes: 0 additions & 2 deletions netutils/netlib/netlib_setifstatus.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ int netlib_ifdown(const char *ifname)

/* Perform the ioctl to ifup flag */

req.ifr_flags |= IFF_DOWN;

ret = ioctl(sockfd, SIOCSIFFLAGS, (unsigned long)&req);
close(sockfd);
}
Expand Down

0 comments on commit 9b8a027

Please sign in to comment.