User Tools

Site Tools


ip_up_down

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
ip_up_down [2018/10/04 10:57]
rpjday [dev_ioctl()]
ip_up_down [2018/10/04 11:09]
rpjday [__dev_change_flags()]
Line 484: Line 484:
  case SIOCSIFFLAGS:​ /​* Set interface flags */  case SIOCSIFFLAGS:​ /​* Set interface flags */
  return dev_change_flags(dev,​ ifr->​ifr_flags);​  return dev_change_flags(dev,​ ifr->​ifr_flags);​
 +</​code>​
 +
 +===== net/​core/​dev.c =====
 +
 +==== dev_change_flags() ====
 +
 +<​code>​
 +int dev_change_flags(struct net_device *dev, unsigned int flags)
 +{
 + int ret;
 + unsigned int changes, old_flags = dev->​flags,​ old_gflags = dev->​gflags;​
 +
 + ret = __dev_change_flags(dev,​ flags);
 + if (ret < 0)
 + return ret;
 +
 + changes = (old_flags ^ dev->​flags) | (old_gflags ^ dev->​gflags);​
 + __dev_notify_flags(dev,​ old_flags, changes);
 + return ret;
 +}
 +</​code>​
 +
 +==== __dev_change_flags() ====
 +
 +<​code>​
 +int __dev_change_flags(struct net_device *dev, unsigned int flags)
 +{
 + unsigned int old_flags = dev->​flags;​
 + int ret;
 +
 + ASSERT_RTNL();​
 +
 + /*
 + * Set the flags on our device.
 + */
 +
 + dev->​flags = (flags & (IFF_DEBUG | IFF_NOTRAILERS | IFF_NOARP |
 +        ​IFF_DYNAMIC | IFF_MULTICAST | IFF_PORTSEL |
 +        ​IFF_AUTOMEDIA)) |
 +      ​(dev->​flags & (IFF_UP | IFF_VOLATILE | IFF_PROMISC |
 +     IFF_ALLMULTI));​
 +
 +... snip ...
 +
 + ret = 0;
 + if ((old_flags ^ flags) & IFF_UP) {
 + if (old_flags & IFF_UP)
 + __dev_close(dev);​
 + else
 + ret = __dev_open(dev);​
 + }
 </​code>​ </​code>​
ip_up_down.txt ยท Last modified: 2018/10/04 11:09 by rpjday