net/core/dev_api.c
Source file repositories/reference/linux-study-clean/net/core/dev_api.c
File Facts
- System
- Linux kernel
- Corpus path
net/core/dev_api.c- Extension
.c- Size
- 8979 bytes
- Lines
- 386
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/netdevice.hnet/netdev_lock.hdev.h
Detected Declarations
function dev_change_namefunction dev_set_aliasfunction dev_change_flagsfunction dev_set_groupfunction dev_set_mac_address_userfunction dev_change_net_namespacefunction dev_change_carrierfunction dev_change_tx_queue_lenfunction dev_change_proto_downfunction dev_openfunction dev_closefunction dev_eth_ioctlfunction dev_set_mtufunction dev_disable_lrofunction dev_set_promiscuityfunction dev_set_allmultifunction dev_set_mac_addressfunction dev_xdp_propagatefunction netdev_state_changefunction dev_set_threadedexport dev_set_aliasexport dev_change_flagsexport dev_set_mac_address_userexport dev_change_net_namespaceexport dev_openexport dev_closeexport dev_eth_ioctlexport dev_set_mtuexport dev_disable_lroexport dev_set_promiscuityexport dev_set_allmultiexport dev_set_mac_addressexport dev_xdp_propagateexport netdev_state_changeexport dev_set_threaded
Annotated Snippet
const struct net_device_ops *ops = dev->netdev_ops;
int ret = -ENODEV;
if (!ops->ndo_eth_ioctl)
return -EOPNOTSUPP;
netdev_lock_ops(dev);
if (netif_device_present(dev))
ret = ops->ndo_eth_ioctl(dev, ifr, cmd);
netdev_unlock_ops(dev);
return ret;
}
EXPORT_SYMBOL(dev_eth_ioctl);
int dev_set_mtu(struct net_device *dev, int new_mtu)
{
int ret;
netdev_lock_ops(dev);
ret = netif_set_mtu(dev, new_mtu);
netdev_unlock_ops(dev);
return ret;
}
EXPORT_SYMBOL(dev_set_mtu);
/**
* dev_disable_lro() - disable Large Receive Offload on a device
* @dev: device
*
* Disable Large Receive Offload (LRO) on a net device. Must be
* called under RTNL. This is needed if received packets may be
* forwarded to another interface.
*/
void dev_disable_lro(struct net_device *dev)
{
netdev_lock_ops(dev);
netif_disable_lro(dev);
netdev_unlock_ops(dev);
}
EXPORT_SYMBOL(dev_disable_lro);
/**
* dev_set_promiscuity() - update promiscuity count on a device
* @dev: device
* @inc: modifier
*
* Add or remove promiscuity from a device. While the count in the device
* remains above zero the interface remains promiscuous. Once it hits zero
* the device reverts back to normal filtering operation. A negative inc
* value is used to drop promiscuity on the device.
* Return 0 if successful or a negative errno code on error.
*/
int dev_set_promiscuity(struct net_device *dev, int inc)
{
int ret;
netdev_lock_ops(dev);
ret = netif_set_promiscuity(dev, inc);
netif_rx_mode_sync(dev);
netdev_unlock_ops(dev);
return ret;
}
EXPORT_SYMBOL(dev_set_promiscuity);
/**
* dev_set_allmulti() - update allmulti count on a device
* @dev: device
* @inc: modifier
*
* Add or remove reception of all multicast frames to a device. While the
* count in the device remains above zero the interface remains listening
* to all interfaces. Once it hits zero the device reverts back to normal
* filtering operation. A negative @inc value is used to drop the counter
* when releasing a resource needing all multicasts.
*
* Return: 0 on success, -errno on failure.
*/
int dev_set_allmulti(struct net_device *dev, int inc)
{
int ret;
netdev_lock_ops(dev);
ret = netif_set_allmulti(dev, inc, true);
netif_rx_mode_sync(dev);
netdev_unlock_ops(dev);
Annotation
- Immediate include surface: `linux/netdevice.h`, `net/netdev_lock.h`, `dev.h`.
- Detected declarations: `function dev_change_name`, `function dev_set_alias`, `function dev_change_flags`, `function dev_set_group`, `function dev_set_mac_address_user`, `function dev_change_net_namespace`, `function dev_change_carrier`, `function dev_change_tx_queue_len`, `function dev_change_proto_down`, `function dev_open`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: pattern implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.