mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-10 07:59:42 -04:00
Merge branch 'net-maintain-netif-vs-dev-prefix-semantics'
Stanislav Fomichev says:
====================
net: maintain netif vs dev prefix semantics
Commit cc34acd577 ("docs: net: document new locking reality")
introduced netif_ vs dev_ function semantics: the former expects locked
netdev, the latter takes care of the locking. We don't strictly
follow this semantics on either side, but there are more dev_xxx handlers
now that don't fit. Rename them to netif_xxx where appropriate. We care only
about driver-visible APIs, don't touch stack-internal routines.
The rest seem to be ok:
* dev_xdp_prog_count - mostly called by sw drivers (bonding), should not matter
* dev_get_by_xxx - too many to reasonably cleanup, already have different flavors
* dev_fetch_sw_netstats - don't need instance lock
* dev_get_tstats64 - never called directly, only as an ndo callback
* dev_pick_tx_zero - never called directly, only as an ndo callback
* dev_add_pack / dev_remove_pack - called early enough (in module init) to not matter
* dev_get_iflink - mostly called by sw drivers, should not matter
* dev_fill_forward_path - ditto
* dev_getbyhwaddr_rcu - ditto
* dev_getbyhwaddr - ditto
* dev_getfirstbyhwtype - ditto
* dev_valid_name - ditto
* __dev_forward_skb dev_forward_skb dev_queue_xmit_nit - established helpers, no netif vs dev distinction
====================
Link: https://patch.msgid.link/20250717172333.1288349-1-sdf@fomichev.me
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
@@ -165,7 +165,7 @@ struct sfp_bus* sfp_bus
|
||||
struct lock_class_key* qdisc_tx_busylock
|
||||
bool proto_down
|
||||
unsigned:1 wol_enabled
|
||||
unsigned:1 threaded napi_poll(napi_enable,dev_set_threaded)
|
||||
unsigned:1 threaded napi_poll(napi_enable,netif_set_threaded)
|
||||
unsigned_long:1 see_all_hwtstamp_requests
|
||||
unsigned_long:1 change_proto_down
|
||||
unsigned_long:1 netns_immutable
|
||||
|
||||
@@ -65,7 +65,7 @@ static int rxe_query_port(struct ib_device *ibdev,
|
||||
attr->state = ib_get_curr_port_state(ndev);
|
||||
if (attr->state == IB_PORT_ACTIVE)
|
||||
attr->phys_state = IB_PORT_PHYS_STATE_LINK_UP;
|
||||
else if (dev_get_flags(ndev) & IFF_UP)
|
||||
else if (netif_get_flags(ndev) & IFF_UP)
|
||||
attr->phys_state = IB_PORT_PHYS_STATE_POLLING;
|
||||
else
|
||||
attr->phys_state = IB_PORT_PHYS_STATE_DISABLED;
|
||||
|
||||
@@ -1040,7 +1040,7 @@ static int bond_set_dev_addr(struct net_device *bond_dev,
|
||||
|
||||
slave_dbg(bond_dev, slave_dev, "bond_dev=%p slave_dev=%p slave_dev->addr_len=%d\n",
|
||||
bond_dev, slave_dev, slave_dev->addr_len);
|
||||
err = dev_pre_changeaddr_notify(bond_dev, slave_dev->dev_addr, NULL);
|
||||
err = netif_pre_changeaddr_notify(bond_dev, slave_dev->dev_addr, NULL);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
@@ -2669,7 +2669,7 @@ static int __bond_release_one(struct net_device *bond_dev,
|
||||
|
||||
if (unregister) {
|
||||
netdev_lock_ops(slave_dev);
|
||||
__dev_set_mtu(slave_dev, slave->original_mtu);
|
||||
__netif_set_mtu(slave_dev, slave->original_mtu);
|
||||
netdev_unlock_ops(slave_dev);
|
||||
} else {
|
||||
dev_set_mtu(slave_dev, slave->original_mtu);
|
||||
@@ -6743,3 +6743,4 @@ module_exit(bonding_exit);
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_DESCRIPTION(DRV_DESCRIPTION);
|
||||
MODULE_AUTHOR("Thomas Davis, tadavis@lbl.gov and many others");
|
||||
MODULE_IMPORT_NS("NETDEV_INTERNAL");
|
||||
|
||||
@@ -2688,7 +2688,7 @@ static int atl1c_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
||||
adapter->mii.mdio_write = atl1c_mdio_write;
|
||||
adapter->mii.phy_id_mask = 0x1f;
|
||||
adapter->mii.reg_num_mask = MDIO_CTRL_REG_MASK;
|
||||
dev_set_threaded(netdev, true);
|
||||
netif_set_threaded(netdev, true);
|
||||
for (i = 0; i < adapter->rx_queue_count; ++i)
|
||||
netif_napi_add(netdev, &adapter->rrd_ring[i].napi,
|
||||
atl1c_clean_rx);
|
||||
|
||||
@@ -4967,7 +4967,7 @@ void mtk_eth_set_dma_device(struct mtk_eth *eth, struct device *dma_dev)
|
||||
list_add_tail(&dev->close_list, &dev_list);
|
||||
}
|
||||
|
||||
dev_close_many(&dev_list, false);
|
||||
netif_close_many(&dev_list, false);
|
||||
|
||||
eth->dma_dev = dma_dev;
|
||||
|
||||
@@ -5610,3 +5610,4 @@ module_platform_driver(mtk_driver);
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("John Crispin <blogic@openwrt.org>");
|
||||
MODULE_DESCRIPTION("Ethernet driver for MediaTek SoC");
|
||||
MODULE_IMPORT_NS("NETDEV_INTERNAL");
|
||||
|
||||
@@ -5446,7 +5446,7 @@ int mlx5e_tc_esw_init(struct mlx5_rep_uplink_priv *uplink_priv)
|
||||
goto err_action_counter;
|
||||
}
|
||||
|
||||
err = dev_get_port_parent_id(priv->netdev, &ppid, false);
|
||||
err = netif_get_port_parent_id(priv->netdev, &ppid, false);
|
||||
if (!err) {
|
||||
memcpy(&key, &ppid.id, sizeof(key));
|
||||
mlx5_esw_offloads_devcom_init(esw, key);
|
||||
|
||||
@@ -156,7 +156,7 @@ static int mlxsw_pci_napi_devs_init(struct mlxsw_pci *mlxsw_pci)
|
||||
}
|
||||
strscpy(mlxsw_pci->napi_dev_rx->name, "mlxsw_rx",
|
||||
sizeof(mlxsw_pci->napi_dev_rx->name));
|
||||
dev_set_threaded(mlxsw_pci->napi_dev_rx, true);
|
||||
netif_set_threaded(mlxsw_pci->napi_dev_rx, true);
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -3075,7 +3075,7 @@ static int ravb_probe(struct platform_device *pdev)
|
||||
if (info->coalesce_irqs) {
|
||||
netdev_sw_irq_coalesce_default_on(ndev);
|
||||
if (num_present_cpus() == 1)
|
||||
dev_set_threaded(ndev, true);
|
||||
netif_set_threaded(ndev, true);
|
||||
}
|
||||
|
||||
/* Network device register */
|
||||
|
||||
@@ -784,9 +784,9 @@ static int ipvlan_device_event(struct notifier_block *unused,
|
||||
case NETDEV_PRE_CHANGEADDR:
|
||||
prechaddr_info = ptr;
|
||||
list_for_each_entry(ipvlan, &port->ipvlans, pnode) {
|
||||
err = dev_pre_changeaddr_notify(ipvlan->dev,
|
||||
prechaddr_info->dev_addr,
|
||||
extack);
|
||||
err = netif_pre_changeaddr_notify(ipvlan->dev,
|
||||
prechaddr_info->dev_addr,
|
||||
extack);
|
||||
if (err)
|
||||
return notifier_from_errno(err);
|
||||
}
|
||||
@@ -1094,3 +1094,4 @@ MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("Mahesh Bandewar <maheshb@google.com>");
|
||||
MODULE_DESCRIPTION("Driver for L3 (IPv6/IPv4) based VLANs");
|
||||
MODULE_ALIAS_RTNL_LINK("ipvlan");
|
||||
MODULE_IMPORT_NS("NETDEV_INTERNAL");
|
||||
|
||||
@@ -1000,8 +1000,8 @@ static long tap_ioctl(struct file *file, unsigned int cmd,
|
||||
return -ENOLINK;
|
||||
}
|
||||
ret = 0;
|
||||
dev_get_mac_address((struct sockaddr *)&ss, dev_net(tap->dev),
|
||||
tap->dev->name);
|
||||
netif_get_mac_address((struct sockaddr *)&ss, dev_net(tap->dev),
|
||||
tap->dev->name);
|
||||
if (copy_to_user(&ifr->ifr_name, tap->dev->name, IFNAMSIZ) ||
|
||||
copy_to_user(&ifr->ifr_hwaddr, &ss, sizeof(ifr->ifr_hwaddr)))
|
||||
ret = -EFAULT;
|
||||
@@ -1282,3 +1282,4 @@ MODULE_DESCRIPTION("Common library for drivers implementing the TAP interface");
|
||||
MODULE_AUTHOR("Arnd Bergmann <arnd@arndb.de>");
|
||||
MODULE_AUTHOR("Sainath Grandhi <sainath.grandhi@intel.com>");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_IMPORT_NS("NETDEV_INTERNAL");
|
||||
|
||||
@@ -3223,7 +3223,7 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
|
||||
|
||||
case SIOCGIFHWADDR:
|
||||
/* Get hw address */
|
||||
dev_get_mac_address(&ifr.ifr_hwaddr, net, tun->dev->name);
|
||||
netif_get_mac_address(&ifr.ifr_hwaddr, net, tun->dev->name);
|
||||
if (copy_to_user(argp, &ifr, ifreq_len))
|
||||
ret = -EFAULT;
|
||||
break;
|
||||
@@ -3732,3 +3732,4 @@ MODULE_AUTHOR(DRV_COPYRIGHT);
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_ALIAS_MISCDEV(TUN_MINOR);
|
||||
MODULE_ALIAS("devname:net/tun");
|
||||
MODULE_IMPORT_NS("NETDEV_INTERNAL");
|
||||
|
||||
@@ -366,7 +366,7 @@ static int wg_newlink(struct net_device *dev,
|
||||
if (ret < 0)
|
||||
goto err_free_handshake_queue;
|
||||
|
||||
dev_set_threaded(dev, true);
|
||||
netif_set_threaded(dev, true);
|
||||
ret = register_netdevice(dev);
|
||||
if (ret < 0)
|
||||
goto err_uninit_ratelimiter;
|
||||
|
||||
@@ -936,7 +936,7 @@ static int ath10k_snoc_hif_start(struct ath10k *ar)
|
||||
|
||||
bitmap_clear(ar_snoc->pending_ce_irqs, 0, CE_COUNT_MAX);
|
||||
|
||||
dev_set_threaded(ar->napi_dev, true);
|
||||
netif_set_threaded(ar->napi_dev, true);
|
||||
ath10k_core_napi_enable(ar);
|
||||
/* IRQs are left enabled when we restart due to a firmware crash */
|
||||
if (!test_bit(ATH10K_SNOC_FLAG_RECOVERY, &ar_snoc->flags))
|
||||
|
||||
@@ -7847,7 +7847,7 @@ static int fsctl_query_iface_info_ioctl(struct ksmbd_conn *conn,
|
||||
if (!ksmbd_find_netdev_name_iface_list(netdev->name))
|
||||
continue;
|
||||
|
||||
flags = dev_get_flags(netdev);
|
||||
flags = netif_get_flags(netdev);
|
||||
if (!(flags & IFF_RUNNING))
|
||||
continue;
|
||||
ipv6_retry:
|
||||
|
||||
@@ -589,6 +589,7 @@ static inline bool napi_complete(struct napi_struct *n)
|
||||
return napi_complete_done(n, 0);
|
||||
}
|
||||
|
||||
int netif_set_threaded(struct net_device *dev, bool threaded);
|
||||
int dev_set_threaded(struct net_device *dev, bool threaded);
|
||||
|
||||
void napi_disable(struct napi_struct *n);
|
||||
@@ -3342,7 +3343,7 @@ int netif_open(struct net_device *dev, struct netlink_ext_ack *extack);
|
||||
int dev_open(struct net_device *dev, struct netlink_ext_ack *extack);
|
||||
void netif_close(struct net_device *dev);
|
||||
void dev_close(struct net_device *dev);
|
||||
void dev_close_many(struct list_head *head, bool unlink);
|
||||
void netif_close_many(struct list_head *head, bool unlink);
|
||||
void netif_disable_lro(struct net_device *dev);
|
||||
void dev_disable_lro(struct net_device *dev);
|
||||
int dev_loopback_xmit(struct net *net, struct sock *sk, struct sk_buff *newskb);
|
||||
@@ -4196,7 +4197,7 @@ int generic_hwtstamp_set_lower(struct net_device *dev,
|
||||
struct kernel_hwtstamp_config *kernel_cfg,
|
||||
struct netlink_ext_ack *extack);
|
||||
int dev_ethtool(struct net *net, struct ifreq *ifr, void __user *userdata);
|
||||
unsigned int dev_get_flags(const struct net_device *);
|
||||
unsigned int netif_get_flags(const struct net_device *dev);
|
||||
int __dev_change_flags(struct net_device *dev, unsigned int flags,
|
||||
struct netlink_ext_ack *extack);
|
||||
int netif_change_flags(struct net_device *dev, unsigned int flags,
|
||||
@@ -4211,20 +4212,20 @@ int __dev_change_net_namespace(struct net_device *dev, struct net *net,
|
||||
struct netlink_ext_ack *extack);
|
||||
int dev_change_net_namespace(struct net_device *dev, struct net *net,
|
||||
const char *pat);
|
||||
int __dev_set_mtu(struct net_device *, int);
|
||||
int __netif_set_mtu(struct net_device *dev, int new_mtu);
|
||||
int netif_set_mtu(struct net_device *dev, int new_mtu);
|
||||
int dev_set_mtu(struct net_device *, int);
|
||||
int dev_pre_changeaddr_notify(struct net_device *dev, const char *addr,
|
||||
struct netlink_ext_ack *extack);
|
||||
int netif_pre_changeaddr_notify(struct net_device *dev, const char *addr,
|
||||
struct netlink_ext_ack *extack);
|
||||
int netif_set_mac_address(struct net_device *dev, struct sockaddr_storage *ss,
|
||||
struct netlink_ext_ack *extack);
|
||||
int dev_set_mac_address(struct net_device *dev, struct sockaddr_storage *ss,
|
||||
struct netlink_ext_ack *extack);
|
||||
int dev_set_mac_address_user(struct net_device *dev, struct sockaddr_storage *ss,
|
||||
struct netlink_ext_ack *extack);
|
||||
int dev_get_mac_address(struct sockaddr *sa, struct net *net, char *dev_name);
|
||||
int dev_get_port_parent_id(struct net_device *dev,
|
||||
struct netdev_phys_item_id *ppid, bool recurse);
|
||||
int netif_get_mac_address(struct sockaddr *sa, struct net *net, char *dev_name);
|
||||
int netif_get_port_parent_id(struct net_device *dev,
|
||||
struct netdev_phys_item_id *ppid, bool recurse);
|
||||
bool netdev_port_same_parent_id(struct net_device *a, struct net_device *b);
|
||||
|
||||
struct sk_buff *validate_xmit_skb_list(struct sk_buff *skb, struct net_device *dev, bool *again);
|
||||
|
||||
@@ -470,7 +470,7 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
|
||||
list_add(&vlandev->close_list, &close_list);
|
||||
}
|
||||
|
||||
dev_close_many(&close_list, false);
|
||||
netif_close_many(&close_list, false);
|
||||
|
||||
list_for_each_entry_safe(vlandev, tmp, &close_list, close_list) {
|
||||
vlan_stacked_transfer_operstate(dev, vlandev,
|
||||
@@ -483,7 +483,7 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
|
||||
case NETDEV_UP:
|
||||
/* Put all VLANs for this dev in the up state too. */
|
||||
vlan_group_for_each_dev(grp, i, vlandev) {
|
||||
flgs = dev_get_flags(vlandev);
|
||||
flgs = netif_get_flags(vlandev);
|
||||
if (flgs & IFF_UP)
|
||||
continue;
|
||||
|
||||
@@ -765,3 +765,4 @@ module_exit(vlan_cleanup_module);
|
||||
MODULE_DESCRIPTION("802.1Q/802.1ad VLAN Protocol");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_VERSION(DRV_VERSION);
|
||||
MODULE_IMPORT_NS("NETDEV_INTERNAL");
|
||||
|
||||
@@ -74,9 +74,9 @@ static int br_device_event(struct notifier_block *unused, unsigned long event, v
|
||||
if (br->dev->addr_assign_type == NET_ADDR_SET)
|
||||
break;
|
||||
prechaddr_info = ptr;
|
||||
err = dev_pre_changeaddr_notify(br->dev,
|
||||
prechaddr_info->dev_addr,
|
||||
extack);
|
||||
err = netif_pre_changeaddr_notify(br->dev,
|
||||
prechaddr_info->dev_addr,
|
||||
extack);
|
||||
if (err)
|
||||
return notifier_from_errno(err);
|
||||
break;
|
||||
@@ -484,3 +484,4 @@ MODULE_LICENSE("GPL");
|
||||
MODULE_VERSION(BR_VERSION);
|
||||
MODULE_ALIAS_RTNL_LINK("bridge");
|
||||
MODULE_DESCRIPTION("Ethernet bridge driver");
|
||||
MODULE_IMPORT_NS("NETDEV_INTERNAL");
|
||||
|
||||
@@ -668,7 +668,8 @@ int br_add_if(struct net_bridge *br, struct net_device *dev,
|
||||
/* Ask for permission to use this MAC address now, even if we
|
||||
* don't end up choosing it below.
|
||||
*/
|
||||
err = dev_pre_changeaddr_notify(br->dev, dev->dev_addr, extack);
|
||||
err = netif_pre_changeaddr_notify(br->dev, dev->dev_addr,
|
||||
extack);
|
||||
if (err)
|
||||
goto err6;
|
||||
}
|
||||
|
||||
@@ -479,7 +479,7 @@ static int br_fill_ifinfo(struct sk_buff *skb,
|
||||
hdr->__ifi_pad = 0;
|
||||
hdr->ifi_type = dev->type;
|
||||
hdr->ifi_index = dev->ifindex;
|
||||
hdr->ifi_flags = dev_get_flags(dev);
|
||||
hdr->ifi_flags = netif_get_flags(dev);
|
||||
hdr->ifi_change = 0;
|
||||
|
||||
if (nla_put_string(skb, IFLA_IFNAME, dev->name) ||
|
||||
|
||||
@@ -837,7 +837,7 @@ int br_switchdev_port_offload(struct net_bridge_port *p,
|
||||
struct netdev_phys_item_id ppid;
|
||||
int err;
|
||||
|
||||
err = dev_get_port_parent_id(dev, &ppid, false);
|
||||
err = netif_get_port_parent_id(dev, &ppid, false);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
|
||||
@@ -1768,7 +1768,7 @@ static void __dev_close(struct net_device *dev)
|
||||
list_del(&single);
|
||||
}
|
||||
|
||||
void dev_close_many(struct list_head *head, bool unlink)
|
||||
void netif_close_many(struct list_head *head, bool unlink)
|
||||
{
|
||||
struct net_device *dev, *tmp;
|
||||
|
||||
@@ -1786,7 +1786,7 @@ void dev_close_many(struct list_head *head, bool unlink)
|
||||
list_del_init(&dev->close_list);
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL(dev_close_many);
|
||||
EXPORT_SYMBOL_NS_GPL(netif_close_many, "NETDEV_INTERNAL");
|
||||
|
||||
void netif_close(struct net_device *dev)
|
||||
{
|
||||
@@ -1794,7 +1794,7 @@ void netif_close(struct net_device *dev)
|
||||
LIST_HEAD(single);
|
||||
|
||||
list_add(&dev->close_list, &single);
|
||||
dev_close_many(&single, true);
|
||||
netif_close_many(&single, true);
|
||||
list_del(&single);
|
||||
}
|
||||
}
|
||||
@@ -4798,7 +4798,7 @@ static inline void ____napi_schedule(struct softnet_data *sd,
|
||||
|
||||
if (test_bit(NAPI_STATE_THREADED, &napi->state)) {
|
||||
/* Paired with smp_mb__before_atomic() in
|
||||
* napi_enable()/dev_set_threaded().
|
||||
* napi_enable()/netif_set_threaded().
|
||||
* Use READ_ONCE() to guarantee a complete
|
||||
* read on napi->thread. Only call
|
||||
* wake_up_process() when it's not NULL.
|
||||
@@ -6990,7 +6990,7 @@ int napi_set_threaded(struct napi_struct *napi, bool threaded)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dev_set_threaded(struct net_device *dev, bool threaded)
|
||||
int netif_set_threaded(struct net_device *dev, bool threaded)
|
||||
{
|
||||
struct napi_struct *napi;
|
||||
int err = 0;
|
||||
@@ -7031,7 +7031,7 @@ int dev_set_threaded(struct net_device *dev, bool threaded)
|
||||
|
||||
return err;
|
||||
}
|
||||
EXPORT_SYMBOL(dev_set_threaded);
|
||||
EXPORT_SYMBOL(netif_set_threaded);
|
||||
|
||||
/**
|
||||
* netif_queue_set_napi - Associate queue with the napi
|
||||
@@ -9454,12 +9454,12 @@ void dev_set_rx_mode(struct net_device *dev)
|
||||
}
|
||||
|
||||
/**
|
||||
* dev_get_flags - get flags reported to userspace
|
||||
* @dev: device
|
||||
* netif_get_flags() - get flags reported to userspace
|
||||
* @dev: device
|
||||
*
|
||||
* Get the combination of flag bits exported through APIs to userspace.
|
||||
* Get the combination of flag bits exported through APIs to userspace.
|
||||
*/
|
||||
unsigned int dev_get_flags(const struct net_device *dev)
|
||||
unsigned int netif_get_flags(const struct net_device *dev)
|
||||
{
|
||||
unsigned int flags;
|
||||
|
||||
@@ -9482,7 +9482,7 @@ unsigned int dev_get_flags(const struct net_device *dev)
|
||||
|
||||
return flags;
|
||||
}
|
||||
EXPORT_SYMBOL(dev_get_flags);
|
||||
EXPORT_SYMBOL(netif_get_flags);
|
||||
|
||||
int __dev_change_flags(struct net_device *dev, unsigned int flags,
|
||||
struct netlink_ext_ack *extack)
|
||||
@@ -9594,7 +9594,7 @@ int netif_change_flags(struct net_device *dev, unsigned int flags,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int __dev_set_mtu(struct net_device *dev, int new_mtu)
|
||||
int __netif_set_mtu(struct net_device *dev, int new_mtu)
|
||||
{
|
||||
const struct net_device_ops *ops = dev->netdev_ops;
|
||||
|
||||
@@ -9605,7 +9605,7 @@ int __dev_set_mtu(struct net_device *dev, int new_mtu)
|
||||
WRITE_ONCE(dev->mtu, new_mtu);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(__dev_set_mtu);
|
||||
EXPORT_SYMBOL_NS_GPL(__netif_set_mtu, "NETDEV_INTERNAL");
|
||||
|
||||
int dev_validate_mtu(struct net_device *dev, int new_mtu,
|
||||
struct netlink_ext_ack *extack)
|
||||
@@ -9624,18 +9624,22 @@ int dev_validate_mtu(struct net_device *dev, int new_mtu,
|
||||
}
|
||||
|
||||
/**
|
||||
* netif_set_mtu_ext - Change maximum transfer unit
|
||||
* @dev: device
|
||||
* @new_mtu: new transfer unit
|
||||
* @extack: netlink extended ack
|
||||
* netif_set_mtu_ext() - Change maximum transfer unit
|
||||
* @dev: device
|
||||
* @new_mtu: new transfer unit
|
||||
* @extack: netlink extended ack
|
||||
*
|
||||
* Change the maximum transfer size of the network device.
|
||||
* Change the maximum transfer size of the network device.
|
||||
*
|
||||
* Return: 0 on success, -errno on failure.
|
||||
*/
|
||||
int netif_set_mtu_ext(struct net_device *dev, int new_mtu,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
int err, orig_mtu;
|
||||
|
||||
netdev_ops_assert_locked(dev);
|
||||
|
||||
if (new_mtu == dev->mtu)
|
||||
return 0;
|
||||
|
||||
@@ -9652,7 +9656,7 @@ int netif_set_mtu_ext(struct net_device *dev, int new_mtu,
|
||||
return err;
|
||||
|
||||
orig_mtu = dev->mtu;
|
||||
err = __dev_set_mtu(dev, new_mtu);
|
||||
err = __netif_set_mtu(dev, new_mtu);
|
||||
|
||||
if (!err) {
|
||||
err = call_netdevice_notifiers_mtu(NETDEV_CHANGEMTU, dev,
|
||||
@@ -9662,7 +9666,7 @@ int netif_set_mtu_ext(struct net_device *dev, int new_mtu,
|
||||
/* setting mtu back and notifying everyone again,
|
||||
* so that they have a chance to revert changes.
|
||||
*/
|
||||
__dev_set_mtu(dev, orig_mtu);
|
||||
__netif_set_mtu(dev, orig_mtu);
|
||||
call_netdevice_notifiers_mtu(NETDEV_CHANGEMTU, dev,
|
||||
new_mtu);
|
||||
}
|
||||
@@ -9716,13 +9720,15 @@ void netif_set_group(struct net_device *dev, int new_group)
|
||||
}
|
||||
|
||||
/**
|
||||
* dev_pre_changeaddr_notify - Call NETDEV_PRE_CHANGEADDR.
|
||||
* @dev: device
|
||||
* @addr: new address
|
||||
* @extack: netlink extended ack
|
||||
* netif_pre_changeaddr_notify() - Call NETDEV_PRE_CHANGEADDR.
|
||||
* @dev: device
|
||||
* @addr: new address
|
||||
* @extack: netlink extended ack
|
||||
*
|
||||
* Return: 0 on success, -errno on failure.
|
||||
*/
|
||||
int dev_pre_changeaddr_notify(struct net_device *dev, const char *addr,
|
||||
struct netlink_ext_ack *extack)
|
||||
int netif_pre_changeaddr_notify(struct net_device *dev, const char *addr,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
struct netdev_notifier_pre_changeaddr_info info = {
|
||||
.info.dev = dev,
|
||||
@@ -9734,7 +9740,7 @@ int dev_pre_changeaddr_notify(struct net_device *dev, const char *addr,
|
||||
rc = call_netdevice_notifiers_info(NETDEV_PRE_CHANGEADDR, &info.info);
|
||||
return notifier_to_errno(rc);
|
||||
}
|
||||
EXPORT_SYMBOL(dev_pre_changeaddr_notify);
|
||||
EXPORT_SYMBOL_NS_GPL(netif_pre_changeaddr_notify, "NETDEV_INTERNAL");
|
||||
|
||||
int netif_set_mac_address(struct net_device *dev, struct sockaddr_storage *ss,
|
||||
struct netlink_ext_ack *extack)
|
||||
@@ -9748,7 +9754,7 @@ int netif_set_mac_address(struct net_device *dev, struct sockaddr_storage *ss,
|
||||
return -EINVAL;
|
||||
if (!netif_device_present(dev))
|
||||
return -ENODEV;
|
||||
err = dev_pre_changeaddr_notify(dev, ss->__data, extack);
|
||||
err = netif_pre_changeaddr_notify(dev, ss->__data, extack);
|
||||
if (err)
|
||||
return err;
|
||||
if (memcmp(dev->dev_addr, ss->__data, dev->addr_len)) {
|
||||
@@ -9765,7 +9771,7 @@ int netif_set_mac_address(struct net_device *dev, struct sockaddr_storage *ss,
|
||||
DECLARE_RWSEM(dev_addr_sem);
|
||||
|
||||
/* "sa" is a true struct sockaddr with limited "sa_data" member. */
|
||||
int dev_get_mac_address(struct sockaddr *sa, struct net *net, char *dev_name)
|
||||
int netif_get_mac_address(struct sockaddr *sa, struct net *net, char *dev_name)
|
||||
{
|
||||
size_t size = sizeof(sa->sa_data_min);
|
||||
struct net_device *dev;
|
||||
@@ -9791,7 +9797,7 @@ int dev_get_mac_address(struct sockaddr *sa, struct net *net, char *dev_name)
|
||||
up_read(&dev_addr_sem);
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(dev_get_mac_address);
|
||||
EXPORT_SYMBOL_NS_GPL(netif_get_mac_address, "NETDEV_INTERNAL");
|
||||
|
||||
int netif_change_carrier(struct net_device *dev, bool new_carrier)
|
||||
{
|
||||
@@ -9844,16 +9850,17 @@ int dev_get_phys_port_name(struct net_device *dev,
|
||||
}
|
||||
|
||||
/**
|
||||
* dev_get_port_parent_id - Get the device's port parent identifier
|
||||
* @dev: network device
|
||||
* @ppid: pointer to a storage for the port's parent identifier
|
||||
* @recurse: allow/disallow recursion to lower devices
|
||||
* netif_get_port_parent_id() - Get the device's port parent identifier
|
||||
* @dev: network device
|
||||
* @ppid: pointer to a storage for the port's parent identifier
|
||||
* @recurse: allow/disallow recursion to lower devices
|
||||
*
|
||||
* Get the devices's port parent identifier
|
||||
* Get the devices's port parent identifier.
|
||||
*
|
||||
* Return: 0 on success, -errno on failure.
|
||||
*/
|
||||
int dev_get_port_parent_id(struct net_device *dev,
|
||||
struct netdev_phys_item_id *ppid,
|
||||
bool recurse)
|
||||
int netif_get_port_parent_id(struct net_device *dev,
|
||||
struct netdev_phys_item_id *ppid, bool recurse)
|
||||
{
|
||||
const struct net_device_ops *ops = dev->netdev_ops;
|
||||
struct netdev_phys_item_id first = { };
|
||||
@@ -9872,7 +9879,7 @@ int dev_get_port_parent_id(struct net_device *dev,
|
||||
return err;
|
||||
|
||||
netdev_for_each_lower_dev(dev, lower_dev, iter) {
|
||||
err = dev_get_port_parent_id(lower_dev, ppid, true);
|
||||
err = netif_get_port_parent_id(lower_dev, ppid, true);
|
||||
if (err)
|
||||
break;
|
||||
if (!first.id_len)
|
||||
@@ -9883,7 +9890,7 @@ int dev_get_port_parent_id(struct net_device *dev,
|
||||
|
||||
return err;
|
||||
}
|
||||
EXPORT_SYMBOL(dev_get_port_parent_id);
|
||||
EXPORT_SYMBOL(netif_get_port_parent_id);
|
||||
|
||||
/**
|
||||
* netdev_port_same_parent_id - Indicate if two network devices have
|
||||
@@ -9896,8 +9903,8 @@ bool netdev_port_same_parent_id(struct net_device *a, struct net_device *b)
|
||||
struct netdev_phys_item_id a_id = { };
|
||||
struct netdev_phys_item_id b_id = { };
|
||||
|
||||
if (dev_get_port_parent_id(a, &a_id, true) ||
|
||||
dev_get_port_parent_id(b, &b_id, true))
|
||||
if (netif_get_port_parent_id(a, &a_id, true) ||
|
||||
netif_get_port_parent_id(b, &b_id, true))
|
||||
return false;
|
||||
|
||||
return netdev_phys_item_id_same(&a_id, &b_id);
|
||||
@@ -12092,7 +12099,7 @@ void unregister_netdevice_many_notify(struct list_head *head,
|
||||
netdev_lock(dev);
|
||||
}
|
||||
}
|
||||
dev_close_many(&close_head, true);
|
||||
netif_close_many(&close_head, true);
|
||||
/* ... now unlock them and go over the rest. */
|
||||
list_for_each_entry(dev, head, unreg_list) {
|
||||
if (netdev_need_ops_lock(dev))
|
||||
@@ -12100,7 +12107,7 @@ void unregister_netdevice_many_notify(struct list_head *head,
|
||||
else
|
||||
list_add_tail(&dev->close_list, &close_head);
|
||||
}
|
||||
dev_close_many(&close_head, true);
|
||||
netif_close_many(&close_head, true);
|
||||
|
||||
list_for_each_entry(dev, head, unreg_list) {
|
||||
/* And unlink it from device chain. */
|
||||
|
||||
@@ -603,7 +603,7 @@ int dev_addr_add(struct net_device *dev, const unsigned char *addr,
|
||||
|
||||
ASSERT_RTNL();
|
||||
|
||||
err = dev_pre_changeaddr_notify(dev, addr, NULL);
|
||||
err = netif_pre_changeaddr_notify(dev, addr, NULL);
|
||||
if (err)
|
||||
return err;
|
||||
err = __hw_addr_add(&dev->dev_addrs, addr, dev->addr_len, addr_type);
|
||||
|
||||
@@ -367,3 +367,15 @@ void netdev_state_change(struct net_device *dev)
|
||||
netdev_unlock_ops(dev);
|
||||
}
|
||||
EXPORT_SYMBOL(netdev_state_change);
|
||||
|
||||
int dev_set_threaded(struct net_device *dev, bool threaded)
|
||||
{
|
||||
int ret;
|
||||
|
||||
netdev_lock(dev);
|
||||
ret = netif_set_threaded(dev, threaded);
|
||||
netdev_unlock(dev);
|
||||
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(dev_set_threaded);
|
||||
|
||||
@@ -147,7 +147,7 @@ static int dev_ifsioc_locked(struct net *net, struct ifreq *ifr, unsigned int cm
|
||||
|
||||
switch (cmd) {
|
||||
case SIOCGIFFLAGS: /* Get interface flags */
|
||||
ifr->ifr_flags = (short) dev_get_flags(dev);
|
||||
ifr->ifr_flags = (short)netif_get_flags(dev);
|
||||
return 0;
|
||||
|
||||
case SIOCGIFMETRIC: /* Get the metric on the interface
|
||||
@@ -728,7 +728,8 @@ int dev_ioctl(struct net *net, unsigned int cmd, struct ifreq *ifr,
|
||||
switch (cmd) {
|
||||
case SIOCGIFHWADDR:
|
||||
dev_load(net, ifr->ifr_name);
|
||||
ret = dev_get_mac_address(&ifr->ifr_hwaddr, net, ifr->ifr_name);
|
||||
ret = netif_get_mac_address(&ifr->ifr_hwaddr, net,
|
||||
ifr->ifr_name);
|
||||
if (colon)
|
||||
*colon = ':';
|
||||
return ret;
|
||||
|
||||
@@ -256,7 +256,7 @@ static ssize_t name_assign_type_show(struct device *dev,
|
||||
}
|
||||
static DEVICE_ATTR_RO(name_assign_type);
|
||||
|
||||
/* use same locking rules as GIFHWADDR ioctl's (dev_get_mac_address()) */
|
||||
/* use same locking rules as GIFHWADDR ioctl's (netif_get_mac_address()) */
|
||||
static ssize_t address_show(struct device *dev, struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
@@ -687,7 +687,7 @@ static ssize_t phys_switch_id_show(struct device *dev,
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = dev_get_port_parent_id(netdev, &ppid, false);
|
||||
ret = netif_get_port_parent_id(netdev, &ppid, false);
|
||||
if (!ret)
|
||||
ret = sysfs_emit(buf, "%*phN\n", ppid.id_len, ppid.id);
|
||||
|
||||
@@ -757,7 +757,7 @@ static int modify_napi_threaded(struct net_device *dev, unsigned long val)
|
||||
if (val != 0 && val != 1)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
ret = dev_set_threaded(dev, val);
|
||||
ret = netif_set_threaded(dev, val);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1448,7 +1448,7 @@ static int rtnl_phys_switch_id_fill(struct sk_buff *skb, struct net_device *dev)
|
||||
struct netdev_phys_item_id ppid = { };
|
||||
int err;
|
||||
|
||||
err = dev_get_port_parent_id(dev, &ppid, false);
|
||||
err = netif_get_port_parent_id(dev, &ppid, false);
|
||||
if (err) {
|
||||
if (err == -EOPNOTSUPP)
|
||||
return 0;
|
||||
@@ -2038,7 +2038,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb,
|
||||
ifm->__ifi_pad = 0;
|
||||
ifm->ifi_type = READ_ONCE(dev->type);
|
||||
ifm->ifi_index = READ_ONCE(dev->ifindex);
|
||||
ifm->ifi_flags = dev_get_flags(dev);
|
||||
ifm->ifi_flags = netif_get_flags(dev);
|
||||
ifm->ifi_change = change;
|
||||
|
||||
if (tgt_netnsid >= 0 && nla_put_s32(skb, IFLA_TARGET_NETNSID, tgt_netnsid))
|
||||
@@ -5227,7 +5227,7 @@ int ndo_dflt_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
|
||||
ifm->__ifi_pad = 0;
|
||||
ifm->ifi_type = dev->type;
|
||||
ifm->ifi_index = dev->ifindex;
|
||||
ifm->ifi_flags = dev_get_flags(dev);
|
||||
ifm->ifi_flags = netif_get_flags(dev);
|
||||
ifm->ifi_change = 0;
|
||||
|
||||
|
||||
|
||||
@@ -1621,7 +1621,7 @@ void dsa_switch_shutdown(struct dsa_switch *ds)
|
||||
dsa_switch_for_each_cpu_port(dp, ds)
|
||||
list_add(&dp->conduit->close_list, &close_list);
|
||||
|
||||
dev_close_many(&close_list, true);
|
||||
netif_close_many(&close_list, true);
|
||||
|
||||
dsa_switch_for_each_user_port(dp, ds) {
|
||||
conduit = dsa_port_to_conduit(dp);
|
||||
@@ -1829,3 +1829,4 @@ MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
|
||||
MODULE_DESCRIPTION("Driver for Distributed Switch Architecture switch chips");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_ALIAS("platform:dsa");
|
||||
MODULE_IMPORT_NS("NETDEV_INTERNAL");
|
||||
|
||||
@@ -3604,7 +3604,7 @@ static int dsa_user_netdevice_event(struct notifier_block *nb,
|
||||
list_add(&dp->user->close_list, &close_list);
|
||||
}
|
||||
|
||||
dev_close_many(&close_list, true);
|
||||
netif_close_many(&close_list, true);
|
||||
|
||||
return NOTIFY_OK;
|
||||
}
|
||||
|
||||
@@ -1524,7 +1524,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
|
||||
fib_disable_ip(dev, event, false);
|
||||
break;
|
||||
case NETDEV_CHANGE:
|
||||
flags = dev_get_flags(dev);
|
||||
flags = netif_get_flags(dev);
|
||||
if (flags & (IFF_RUNNING | IFF_LOWER_UP))
|
||||
fib_sync_up(dev, RTNH_F_LINKDOWN);
|
||||
else
|
||||
|
||||
@@ -2087,7 +2087,7 @@ int fib_sync_up(struct net_device *dev, unsigned char nh_flags)
|
||||
return 0;
|
||||
|
||||
if (nh_flags & RTNH_F_DEAD) {
|
||||
unsigned int flags = dev_get_flags(dev);
|
||||
unsigned int flags = netif_get_flags(dev);
|
||||
|
||||
if (flags & (IFF_RUNNING | IFF_LOWER_UP))
|
||||
nh_flags |= RTNH_F_LINKDOWN;
|
||||
|
||||
@@ -901,7 +901,7 @@ static int vif_add(struct net *net, struct mr_table *mrt,
|
||||
vifc->vifc_flags | (!mrtsock ? VIFF_STATIC : 0),
|
||||
(VIFF_TUNNEL | VIFF_REGISTER));
|
||||
|
||||
err = dev_get_port_parent_id(dev, &ppid, true);
|
||||
err = netif_get_port_parent_id(dev, &ppid, true);
|
||||
if (err == 0) {
|
||||
memcpy(v->dev_parent_id.id, ppid.id, ppid.id_len);
|
||||
v->dev_parent_id.id_len = ppid.id_len;
|
||||
|
||||
@@ -3884,7 +3884,7 @@ static int nh_netdev_event(struct notifier_block *this,
|
||||
nexthop_flush_dev(dev, event);
|
||||
break;
|
||||
case NETDEV_CHANGE:
|
||||
if (!(dev_get_flags(dev) & (IFF_RUNNING | IFF_LOWER_UP)))
|
||||
if (!(netif_get_flags(dev) & (IFF_RUNNING | IFF_LOWER_UP)))
|
||||
nexthop_flush_dev(dev, event);
|
||||
break;
|
||||
case NETDEV_CHANGEMTU:
|
||||
|
||||
@@ -6072,7 +6072,7 @@ static int inet6_fill_ifinfo(struct sk_buff *skb, struct inet6_dev *idev,
|
||||
hdr->ifi_type = dev->type;
|
||||
ifindex = READ_ONCE(dev->ifindex);
|
||||
hdr->ifi_index = ifindex;
|
||||
hdr->ifi_flags = dev_get_flags(dev);
|
||||
hdr->ifi_flags = netif_get_flags(dev);
|
||||
hdr->ifi_change = 0;
|
||||
|
||||
iflink = dev_get_iflink(dev);
|
||||
|
||||
@@ -706,7 +706,7 @@ static int mpls_nh_assign_dev(struct net *net, struct mpls_route *rt,
|
||||
} else {
|
||||
unsigned int flags;
|
||||
|
||||
flags = dev_get_flags(dev);
|
||||
flags = netif_get_flags(dev);
|
||||
if (!(flags & (IFF_RUNNING | IFF_LOWER_UP)))
|
||||
nh->nh_flags |= RTNH_F_LINKDOWN;
|
||||
}
|
||||
@@ -1616,14 +1616,14 @@ static int mpls_dev_notify(struct notifier_block *this, unsigned long event,
|
||||
return notifier_from_errno(err);
|
||||
break;
|
||||
case NETDEV_UP:
|
||||
flags = dev_get_flags(dev);
|
||||
flags = netif_get_flags(dev);
|
||||
if (flags & (IFF_RUNNING | IFF_LOWER_UP))
|
||||
mpls_ifup(dev, RTNH_F_DEAD | RTNH_F_LINKDOWN);
|
||||
else
|
||||
mpls_ifup(dev, RTNH_F_DEAD);
|
||||
break;
|
||||
case NETDEV_CHANGE:
|
||||
flags = dev_get_flags(dev);
|
||||
flags = netif_get_flags(dev);
|
||||
if (flags & (IFF_RUNNING | IFF_LOWER_UP)) {
|
||||
mpls_ifup(dev, RTNH_F_DEAD | RTNH_F_LINKDOWN);
|
||||
} else {
|
||||
|
||||
@@ -431,7 +431,7 @@ static struct nlmsghdr *rtnetlink_ifinfo_prep(struct net_device *dev,
|
||||
r->__ifi_pad = 0;
|
||||
r->ifi_type = dev->type;
|
||||
r->ifi_index = dev->ifindex;
|
||||
r->ifi_flags = dev_get_flags(dev);
|
||||
r->ifi_flags = netif_get_flags(dev);
|
||||
r->ifi_change = 0; /* Wireless changes don't affect those flags */
|
||||
|
||||
if (nla_put_string(skb, IFLA_IFNAME, dev->name))
|
||||
|
||||
Reference in New Issue
Block a user