drivers/net/nlmon.c
Source file repositories/reference/linux-study-clean/drivers/net/nlmon.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/nlmon.c- Extension
.c- Size
- 2631 bytes
- Lines
- 117
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/ethtool.hlinux/module.hlinux/kernel.hlinux/netdevice.hlinux/netlink.hnet/net_namespace.hlinux/if_arp.hnet/rtnetlink.h
Detected Declarations
struct nlmonfunction nlmon_xmitfunction nlmon_openfunction nlmon_closefunction nlmon_get_stats64function always_onfunction nlmon_setupfunction nlmon_validatefunction nlmon_registerfunction nlmon_unregistermodule init nlmon_register
Annotated Snippet
static const struct net_device_ops nlmon_ops = {
.ndo_open = nlmon_open,
.ndo_stop = nlmon_close,
.ndo_start_xmit = nlmon_xmit,
.ndo_get_stats64 = nlmon_get_stats64,
};
static void nlmon_setup(struct net_device *dev)
{
dev->type = ARPHRD_NETLINK;
dev->priv_flags |= IFF_NO_QUEUE;
dev->lltx = true;
dev->netdev_ops = &nlmon_ops;
dev->ethtool_ops = &nlmon_ethtool_ops;
dev->needs_free_netdev = true;
dev->features = NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_HIGHDMA;
dev->flags = IFF_NOARP;
dev->pcpu_stat_type = NETDEV_PCPU_STAT_LSTATS;
/* That's rather a softlimit here, which, of course,
* can be altered. Not a real MTU, but what is to be
* expected in most cases.
*/
dev->mtu = NLMSG_GOODSIZE;
dev->min_mtu = sizeof(struct nlmsghdr);
}
static int nlmon_validate(struct nlattr *tb[], struct nlattr *data[],
struct netlink_ext_ack *extack)
{
if (tb[IFLA_ADDRESS])
return -EINVAL;
return 0;
}
static struct rtnl_link_ops nlmon_link_ops __read_mostly = {
.kind = "nlmon",
.priv_size = sizeof(struct nlmon),
.setup = nlmon_setup,
.validate = nlmon_validate,
};
static __init int nlmon_register(void)
{
return rtnl_link_register(&nlmon_link_ops);
}
static __exit void nlmon_unregister(void)
{
rtnl_link_unregister(&nlmon_link_ops);
}
module_init(nlmon_register);
module_exit(nlmon_unregister);
MODULE_LICENSE("GPL v2");
MODULE_AUTHOR("Daniel Borkmann <dborkman@redhat.com>");
MODULE_AUTHOR("Mathieu Geli <geli@enseirb.fr>");
MODULE_DESCRIPTION("Netlink monitoring device");
MODULE_ALIAS_RTNL_LINK("nlmon");
Annotation
- Immediate include surface: `linux/ethtool.h`, `linux/module.h`, `linux/kernel.h`, `linux/netdevice.h`, `linux/netlink.h`, `net/net_namespace.h`, `linux/if_arp.h`, `net/rtnetlink.h`.
- Detected declarations: `struct nlmon`, `function nlmon_xmit`, `function nlmon_open`, `function nlmon_close`, `function nlmon_get_stats64`, `function always_on`, `function nlmon_setup`, `function nlmon_validate`, `function nlmon_register`, `function nlmon_unregister`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern 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.