dev.c (fbcb21705930f2930f506149d0b8d36dfbe45107) | dev.c (a54acb3a6f853e8394c4cb7b6a4d93c88f13eefd) |
---|---|
1/* 2 * NET3 Protocol independent device support routines. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 7 * 2 of the License, or (at your option) any later version. 8 * --- 646 unchanged lines hidden (view full) --- 655 656/******************************************************************************* 657 658 Device Interface Subroutines 659 660*******************************************************************************/ 661 662/** | 1/* 2 * NET3 Protocol independent device support routines. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 7 * 2 of the License, or (at your option) any later version. 8 * --- 646 unchanged lines hidden (view full) --- 655 656/******************************************************************************* 657 658 Device Interface Subroutines 659 660*******************************************************************************/ 661 662/** |
663 * dev_get_iflink - get 'iflink' value of a interface 664 * @dev: targeted interface 665 * 666 * Indicates the ifindex the interface is linked to. 667 * Physical interfaces have the same 'ifindex' and 'iflink' values. 668 */ 669 670int dev_get_iflink(const struct net_device *dev) 671{ 672 if (dev->netdev_ops && dev->netdev_ops->ndo_get_iflink) 673 return dev->netdev_ops->ndo_get_iflink(dev); 674 675 return dev->iflink; 676} 677EXPORT_SYMBOL(dev_get_iflink); 678 679/** |
|
663 * __dev_get_by_name - find a device by its name 664 * @net: the applicable net namespace 665 * @name: name to find 666 * 667 * Find an interface by name. Must be called under RTNL semaphore 668 * or @dev_base_lock. If the name is found a pointer to the device 669 * is returned. If the name is not found then %NULL is returned. The 670 * reference counters are not incremented so the caller must be --- 5669 unchanged lines hidden (view full) --- 6340 } 6341 6342 ret = -EBUSY; 6343 if (!dev->ifindex) 6344 dev->ifindex = dev_new_index(net); 6345 else if (__dev_get_by_index(net, dev->ifindex)) 6346 goto err_uninit; 6347 | 680 * __dev_get_by_name - find a device by its name 681 * @net: the applicable net namespace 682 * @name: name to find 683 * 684 * Find an interface by name. Must be called under RTNL semaphore 685 * or @dev_base_lock. If the name is found a pointer to the device 686 * is returned. If the name is not found then %NULL is returned. The 687 * reference counters are not incremented so the caller must be --- 5669 unchanged lines hidden (view full) --- 6357 } 6358 6359 ret = -EBUSY; 6360 if (!dev->ifindex) 6361 dev->ifindex = dev_new_index(net); 6362 else if (__dev_get_by_index(net, dev->ifindex)) 6363 goto err_uninit; 6364 |
6348 if (dev->iflink == -1) | 6365 if (dev_get_iflink(dev) == -1) |
6349 dev->iflink = dev->ifindex; 6350 6351 /* Transfer changeable features to wanted_features and enable 6352 * software offloads (GSO and GRO). 6353 */ 6354 dev->hw_features |= NETIF_F_SOFT_FEATURES; 6355 dev->features |= NETIF_F_SOFT_FEATURES; 6356 dev->wanted_features = dev->features & dev->hw_features; --- 699 unchanged lines hidden (view full) --- 7056 kobject_uevent(&dev->dev.kobj, KOBJ_REMOVE); 7057 netdev_adjacent_del_links(dev); 7058 7059 /* Actually switch the network namespace */ 7060 dev_net_set(dev, net); 7061 7062 /* If there is an ifindex conflict assign a new one */ 7063 if (__dev_get_by_index(net, dev->ifindex)) { | 6366 dev->iflink = dev->ifindex; 6367 6368 /* Transfer changeable features to wanted_features and enable 6369 * software offloads (GSO and GRO). 6370 */ 6371 dev->hw_features |= NETIF_F_SOFT_FEATURES; 6372 dev->features |= NETIF_F_SOFT_FEATURES; 6373 dev->wanted_features = dev->features & dev->hw_features; --- 699 unchanged lines hidden (view full) --- 7073 kobject_uevent(&dev->dev.kobj, KOBJ_REMOVE); 7074 netdev_adjacent_del_links(dev); 7075 7076 /* Actually switch the network namespace */ 7077 dev_net_set(dev, net); 7078 7079 /* If there is an ifindex conflict assign a new one */ 7080 if (__dev_get_by_index(net, dev->ifindex)) { |
7064 int iflink = (dev->iflink == dev->ifindex); | 7081 int iflink = (dev_get_iflink(dev) == dev->ifindex); |
7065 dev->ifindex = dev_new_index(net); 7066 if (iflink) 7067 dev->iflink = dev->ifindex; 7068 } 7069 7070 /* Send a netdev-add uevent to the new namespace */ 7071 kobject_uevent(&dev->dev.kobj, KOBJ_ADD); 7072 netdev_adjacent_add_links(dev); --- 427 unchanged lines hidden --- | 7082 dev->ifindex = dev_new_index(net); 7083 if (iflink) 7084 dev->iflink = dev->ifindex; 7085 } 7086 7087 /* Send a netdev-add uevent to the new namespace */ 7088 kobject_uevent(&dev->dev.kobj, KOBJ_ADD); 7089 netdev_adjacent_add_links(dev); --- 427 unchanged lines hidden --- |