include/net/netdev_lock.h
Source file repositories/reference/linux-study-clean/include/net/netdev_lock.h
File Facts
- System
- Linux kernel
- Corpus path
include/net/netdev_lock.h- Extension
.h- Size
- 3885 bytes
- Lines
- 156
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source 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 or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/lockdep.hlinux/netdevice.hlinux/rtnetlink.h
Detected Declarations
function netdev_trylockfunction netdev_assert_lockedfunction netdev_assert_locked_or_invisiblefunction netdev_need_ops_lockfunction netdev_lock_opsfunction netdev_unlock_opsfunction netdev_lock_ops_to_fullfunction netdev_unlock_full_to_opsfunction netdev_assert_locked_ops_compatfunction netdev_assert_locked_ops_compat_or_invisiblefunction netdev_assert_locked_opsfunction netdev_lock_ops_compatfunction netdev_unlock_ops_compatfunction netdev_is_locked_ops_compatfunction netdev_lock_cmp_fn
Annotated Snippet
#ifndef _NET_NETDEV_LOCK_H
#define _NET_NETDEV_LOCK_H
#include <linux/lockdep.h>
#include <linux/netdevice.h>
#include <linux/rtnetlink.h>
static inline bool netdev_trylock(struct net_device *dev)
{
return mutex_trylock(&dev->lock);
}
static inline void netdev_assert_locked(const struct net_device *dev)
{
lockdep_assert_held(&dev->lock);
}
static inline void
netdev_assert_locked_or_invisible(const struct net_device *dev)
{
if (dev->reg_state == NETREG_REGISTERED ||
dev->reg_state == NETREG_UNREGISTERING)
netdev_assert_locked(dev);
}
static inline bool netdev_need_ops_lock(const struct net_device *dev)
{
bool ret = dev->request_ops_lock || !!dev->queue_mgmt_ops;
#if IS_ENABLED(CONFIG_NET_SHAPER)
ret |= !!dev->netdev_ops->net_shaper_ops;
#endif
return ret;
}
static inline void netdev_lock_ops(struct net_device *dev)
{
if (netdev_need_ops_lock(dev))
netdev_lock(dev);
}
static inline void netdev_unlock_ops(struct net_device *dev)
{
if (netdev_need_ops_lock(dev))
netdev_unlock(dev);
}
static inline void netdev_lock_ops_to_full(struct net_device *dev)
{
if (netdev_need_ops_lock(dev))
netdev_assert_locked(dev);
else
netdev_lock(dev);
}
static inline void netdev_unlock_full_to_ops(struct net_device *dev)
{
if (netdev_need_ops_lock(dev))
netdev_assert_locked(dev);
else
netdev_unlock(dev);
}
static inline void netdev_assert_locked_ops_compat(const struct net_device *dev)
{
if (netdev_need_ops_lock(dev))
lockdep_assert_held(&dev->lock);
else
ASSERT_RTNL();
}
static inline void
netdev_assert_locked_ops_compat_or_invisible(const struct net_device *dev)
{
if (dev->reg_state == NETREG_REGISTERED ||
dev->reg_state == NETREG_UNREGISTERING)
netdev_assert_locked_ops_compat(dev);
}
static inline void netdev_assert_locked_ops(const struct net_device *dev)
{
if (netdev_need_ops_lock(dev))
netdev_assert_locked(dev);
}
static inline void netdev_lock_ops_compat(struct net_device *dev)
{
if (netdev_need_ops_lock(dev))
netdev_lock(dev);
Annotation
- Immediate include surface: `linux/lockdep.h`, `linux/netdevice.h`, `linux/rtnetlink.h`.
- Detected declarations: `function netdev_trylock`, `function netdev_assert_locked`, `function netdev_assert_locked_or_invisible`, `function netdev_need_ops_lock`, `function netdev_lock_ops`, `function netdev_unlock_ops`, `function netdev_lock_ops_to_full`, `function netdev_unlock_full_to_ops`, `function netdev_assert_locked_ops_compat`, `function netdev_assert_locked_ops_compat_or_invisible`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
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.