net/l2tp/l2tp_eth.c
Source file repositories/reference/linux-study-clean/net/l2tp/l2tp_eth.c
File Facts
- System
- Linux kernel
- Corpus path
net/l2tp/l2tp_eth.c- Extension
.c- Size
- 7810 bytes
- Lines
- 353
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/module.hlinux/skbuff.hlinux/socket.hlinux/hash.hlinux/l2tp.hlinux/in.hlinux/etherdevice.hlinux/spinlock.hlinux/string.hnet/sock.hnet/ip.hnet/icmp.hnet/udp.hnet/inet_common.hnet/inet_hashtables.hnet/tcp_states.hnet/protocol.hnet/xfrm.hnet/net_namespace.hnet/netns/generic.hnet/netdev_lock.hlinux/ip.hlinux/ipv6.hlinux/udp.hl2tp_core.h
Detected Declarations
struct l2tp_ethstruct l2tp_eth_sessfunction l2tp_eth_dev_initfunction l2tp_eth_dev_uninitfunction l2tp_eth_dev_xmitfunction l2tp_eth_dev_setupfunction l2tp_eth_dev_recvfunction l2tp_eth_deletefunction l2tp_eth_showfunction l2tp_eth_adjust_mtufunction l2tp_eth_createfunction l2tp_eth_initfunction l2tp_eth_exitmodule init l2tp_eth_init
Annotated Snippet
static const struct net_device_ops l2tp_eth_netdev_ops = {
.ndo_init = l2tp_eth_dev_init,
.ndo_uninit = l2tp_eth_dev_uninit,
.ndo_start_xmit = l2tp_eth_dev_xmit,
.ndo_set_mac_address = eth_mac_addr,
};
static const struct device_type l2tpeth_type = {
.name = "l2tpeth",
};
static void l2tp_eth_dev_setup(struct net_device *dev)
{
SET_NETDEV_DEVTYPE(dev, &l2tpeth_type);
ether_setup(dev);
dev->priv_flags &= ~IFF_TX_SKB_SHARING;
dev->lltx = true;
dev->netdev_ops = &l2tp_eth_netdev_ops;
dev->needs_free_netdev = true;
dev->pcpu_stat_type = NETDEV_PCPU_STAT_DSTATS;
}
static void l2tp_eth_dev_recv(struct l2tp_session *session, struct sk_buff *skb, int data_len)
{
struct l2tp_eth_sess *spriv = l2tp_session_priv(session);
struct net_device *dev;
if (!pskb_may_pull(skb, ETH_HLEN))
goto error;
secpath_reset(skb);
/* checksums verified by L2TP */
skb->ip_summed = CHECKSUM_NONE;
/* drop outer flow-hash */
skb_clear_hash(skb);
skb_dst_drop(skb);
nf_reset_ct(skb);
rcu_read_lock();
dev = rcu_dereference(spriv->dev);
if (!dev)
goto error_rcu;
if (dev_forward_skb(dev, skb) == NET_RX_SUCCESS)
dev_dstats_rx_add(dev, data_len);
else
DEV_STATS_INC(dev, rx_errors);
rcu_read_unlock();
return;
error_rcu:
rcu_read_unlock();
error:
kfree_skb(skb);
}
static void l2tp_eth_delete(struct l2tp_session *session)
{
struct l2tp_eth_sess *spriv;
struct net_device *dev;
if (session) {
spriv = l2tp_session_priv(session);
rtnl_lock();
dev = rtnl_dereference(spriv->dev);
if (dev) {
unregister_netdevice(dev);
rtnl_unlock();
module_put(THIS_MODULE);
} else {
rtnl_unlock();
}
}
}
static void l2tp_eth_show(struct seq_file *m, void *arg)
{
struct l2tp_session *session = arg;
struct l2tp_eth_sess *spriv = l2tp_session_priv(session);
struct net_device *dev;
rcu_read_lock();
dev = rcu_dereference(spriv->dev);
if (!dev) {
Annotation
- Immediate include surface: `linux/module.h`, `linux/skbuff.h`, `linux/socket.h`, `linux/hash.h`, `linux/l2tp.h`, `linux/in.h`, `linux/etherdevice.h`, `linux/spinlock.h`.
- Detected declarations: `struct l2tp_eth`, `struct l2tp_eth_sess`, `function l2tp_eth_dev_init`, `function l2tp_eth_dev_uninit`, `function l2tp_eth_dev_xmit`, `function l2tp_eth_dev_setup`, `function l2tp_eth_dev_recv`, `function l2tp_eth_delete`, `function l2tp_eth_show`, `function l2tp_eth_adjust_mtu`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.