include/net/l3mdev.h
Source file repositories/reference/linux-study-clean/include/net/l3mdev.h
File Facts
- System
- Linux kernel
- Corpus path
include/net/l3mdev.h- Extension
.h- Size
- 7765 bytes
- Lines
- 365
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
net/dst.hnet/fib_rules.h
Detected Declarations
struct l3mdev_opsenum l3mdev_typefunction l3mdev_fib_rule_iif_matchfunction l3mdev_fib_rule_oif_matchfunction l3mdev_master_ifindexfunction l3mdev_master_ifindex_by_indexfunction l3mdev_master_upper_ifindex_by_indexfunction l3mdev_fib_tablefunction netif_index_is_l3_masterfunction l3mdev_master_ifindex_rcufunction l3mdev_master_ifindexfunction l3mdev_master_ifindex_by_indexfunction l3mdev_master_upper_ifindex_by_index_rcufunction l3mdev_master_upper_ifindex_by_indexfunction l3mdev_fib_table_rcufunction l3mdev_fib_tablefunction l3mdev_fib_table_by_indexfunction netif_index_is_l3_masterfunction l3mdev_table_lookup_registerfunction l3mdev_table_lookup_unregisterfunction l3mdev_fib_rule_matchfunction l3mdev_fib_rule_iif_matchfunction l3mdev_fib_rule_oif_matchfunction l3mdev_update_flow
Annotated Snippet
struct l3mdev_ops {
u32 (*l3mdev_fib_table)(const struct net_device *dev);
struct sk_buff * (*l3mdev_l3_rcv)(struct net_device *dev,
struct sk_buff *skb, u16 proto);
struct sk_buff * (*l3mdev_l3_out)(struct net_device *dev,
struct sock *sk, struct sk_buff *skb,
u16 proto);
/* IPv6 ops */
struct dst_entry * (*l3mdev_link_scope_lookup)(const struct net_device *dev,
struct flowi6 *fl6);
};
#ifdef CONFIG_NET_L3_MASTER_DEV
int l3mdev_table_lookup_register(enum l3mdev_type l3type,
lookup_by_table_id_t fn);
void l3mdev_table_lookup_unregister(enum l3mdev_type l3type,
lookup_by_table_id_t fn);
int l3mdev_ifindex_lookup_by_table_id(enum l3mdev_type l3type, struct net *net,
u32 table_id);
int l3mdev_fib_rule_match(struct net *net, struct flowi *fl,
struct fib_lookup_arg *arg);
static inline
bool l3mdev_fib_rule_iif_match(const struct flowi *fl, int iifindex)
{
return !(fl->flowi_flags & FLOWI_FLAG_L3MDEV_OIF) &&
fl->flowi_l3mdev == iifindex;
}
static inline
bool l3mdev_fib_rule_oif_match(const struct flowi *fl, int oifindex)
{
return fl->flowi_flags & FLOWI_FLAG_L3MDEV_OIF &&
fl->flowi_l3mdev == oifindex;
}
void l3mdev_update_flow(struct net *net, struct flowi *fl);
int l3mdev_master_ifindex_rcu(const struct net_device *dev);
static inline int l3mdev_master_ifindex(struct net_device *dev)
{
int ifindex;
rcu_read_lock();
ifindex = l3mdev_master_ifindex_rcu(dev);
rcu_read_unlock();
return ifindex;
}
static inline int l3mdev_master_ifindex_by_index(struct net *net, int ifindex)
{
struct net_device *dev;
int rc = 0;
if (ifindex) {
rcu_read_lock();
dev = dev_get_by_index_rcu(net, ifindex);
if (dev)
rc = l3mdev_master_ifindex_rcu(dev);
rcu_read_unlock();
}
return rc;
}
static inline
struct net_device *l3mdev_master_dev_rcu(const struct net_device *_dev)
{
/* netdev_master_upper_dev_get_rcu calls
* list_first_or_null_rcu to walk the upper dev list.
* list_first_or_null_rcu does not handle a const arg. We aren't
* making changes, just want the master device from that list so
* typecast to remove the const
*/
struct net_device *dev = (struct net_device *)_dev;
struct net_device *master;
if (!dev)
return NULL;
if (netif_is_l3_master(dev))
master = dev;
Annotation
- Immediate include surface: `net/dst.h`, `net/fib_rules.h`.
- Detected declarations: `struct l3mdev_ops`, `enum l3mdev_type`, `function l3mdev_fib_rule_iif_match`, `function l3mdev_fib_rule_oif_match`, `function l3mdev_master_ifindex`, `function l3mdev_master_ifindex_by_index`, `function l3mdev_master_upper_ifindex_by_index`, `function l3mdev_fib_table`, `function netif_index_is_l3_master`, `function l3mdev_master_ifindex_rcu`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.