net/core/rtnetlink.c
Source file repositories/reference/linux-study-clean/net/core/rtnetlink.c
File Facts
- System
- Linux kernel
- Corpus path
net/core/rtnetlink.c- Extension
.c- Size
- 179084 bytes
- Lines
- 7217
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitops.hlinux/errno.hlinux/module.hlinux/types.hlinux/socket.hlinux/kernel.hlinux/timer.hlinux/string.hlinux/sockios.hlinux/net.hlinux/fcntl.hlinux/mm.hlinux/slab.hlinux/interrupt.hlinux/capability.hlinux/skbuff.hlinux/init.hlinux/security.hlinux/mutex.hlinux/if_addr.hlinux/if_bridge.hlinux/if_vlan.hlinux/pci.hlinux/etherdevice.hlinux/bpf.hlinux/uaccess.hlinux/inet.hlinux/netdevice.hnet/ip.hnet/protocol.hnet/arp.hnet/route.h
Detected Declarations
struct rtnl_linkstruct rtnl_netsstruct rtnl_newlink_tbsstruct rtnl_offload_xstats_request_usedstruct rtnl_stats_dump_filtersstruct rtnl_mdb_dump_ctxfunction rtnl_lockfunction rtnl_lock_interruptiblefunction rtnl_lock_killablefunction rtnl_kfree_skbsfunction __rtnl_unlockfunction rtnl_unlockfunction rtnl_trylockfunction rtnl_is_lockedfunction refcount_dec_and_rtnl_lockfunction lockdep_rtnl_is_heldfunction __rtnl_net_lockfunction __rtnl_net_unlockfunction rtnl_net_lockfunction rtnl_net_unlockfunction rtnl_net_trylockfunction rtnl_net_lock_killablefunction rtnl_net_cmp_locksfunction rtnl_net_lock_cmp_fnfunction rtnl_net_is_lockedfunction lockdep_rtnl_net_is_heldfunction rtnl_net_cmp_locksfunction rtnl_nets_initfunction rtnl_nets_destroyfunction rtnl_nets_destroyfunction rtnl_nets_lockfunction rtnl_nets_unlockfunction rtm_msgindexfunction rtnl_register_internalfunction rtnl_unregisterfunction rtnl_unregisterfunction pointersfunction __rtnl_unregister_manyfunction list_for_each_entry_rcufunction rtnl_link_ops_putfunction rtnl_link_registerfunction list_for_each_entryfunction __rtnl_kill_linksfunction for_each_netdevfunction rtnl_lock_unregistering_allfunction rtnl_link_unregisterfunction rtnl_link_get_slave_info_data_sizefunction rtnl_link_get_size
Annotated Snippet
const struct net_device_ops *ops = dev->netdev_ops;
if (!ops->ndo_set_vf_rate)
return -EOPNOTSUPP;
if (max_tx_rate && max_tx_rate < min_tx_rate)
return -EINVAL;
return ops->ndo_set_vf_rate(dev, vf, min_tx_rate, max_tx_rate);
}
static int validate_linkmsg(struct net_device *dev, struct nlattr *tb[],
struct netlink_ext_ack *extack)
{
if (tb[IFLA_ADDRESS] &&
nla_len(tb[IFLA_ADDRESS]) < dev->addr_len)
return -EINVAL;
if (tb[IFLA_BROADCAST] &&
nla_len(tb[IFLA_BROADCAST]) < dev->addr_len)
return -EINVAL;
if (tb[IFLA_GSO_MAX_SIZE] &&
nla_get_u32(tb[IFLA_GSO_MAX_SIZE]) > dev->tso_max_size) {
NL_SET_ERR_MSG(extack, "too big gso_max_size");
return -EINVAL;
}
if (tb[IFLA_GSO_MAX_SEGS] &&
(nla_get_u32(tb[IFLA_GSO_MAX_SEGS]) > GSO_MAX_SEGS ||
nla_get_u32(tb[IFLA_GSO_MAX_SEGS]) > dev->tso_max_segs)) {
NL_SET_ERR_MSG(extack, "too big gso_max_segs");
return -EINVAL;
}
if (tb[IFLA_GRO_MAX_SIZE] &&
nla_get_u32(tb[IFLA_GRO_MAX_SIZE]) > GRO_MAX_SIZE) {
NL_SET_ERR_MSG(extack, "too big gro_max_size");
return -EINVAL;
}
if (tb[IFLA_GSO_IPV4_MAX_SIZE] &&
nla_get_u32(tb[IFLA_GSO_IPV4_MAX_SIZE]) > dev->tso_max_size) {
NL_SET_ERR_MSG(extack, "too big gso_ipv4_max_size");
return -EINVAL;
}
if (tb[IFLA_GRO_IPV4_MAX_SIZE] &&
nla_get_u32(tb[IFLA_GRO_IPV4_MAX_SIZE]) > GRO_MAX_SIZE) {
NL_SET_ERR_MSG(extack, "too big gro_ipv4_max_size");
return -EINVAL;
}
if (tb[IFLA_AF_SPEC]) {
struct nlattr *af;
int rem, err;
nla_for_each_nested(af, tb[IFLA_AF_SPEC], rem) {
struct rtnl_af_ops *af_ops;
int af_ops_srcu_index;
af_ops = rtnl_af_lookup(nla_type(af), &af_ops_srcu_index);
if (!af_ops)
return -EAFNOSUPPORT;
if (!af_ops->set_link_af)
err = -EOPNOTSUPP;
else if (af_ops->validate_link_af)
err = af_ops->validate_link_af(dev, af, extack);
else
err = 0;
rtnl_af_put(af_ops, af_ops_srcu_index);
if (err < 0)
return err;
}
}
return 0;
}
static int handle_infiniband_guid(struct net_device *dev, struct ifla_vf_guid *ivt,
int guid_type)
{
const struct net_device_ops *ops = dev->netdev_ops;
return ops->ndo_set_vf_guid(dev, ivt->vf, ivt->guid, guid_type);
}
static int handle_vf_guid(struct net_device *dev, struct ifla_vf_guid *ivt, int guid_type)
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/errno.h`, `linux/module.h`, `linux/types.h`, `linux/socket.h`, `linux/kernel.h`, `linux/timer.h`, `linux/string.h`.
- Detected declarations: `struct rtnl_link`, `struct rtnl_nets`, `struct rtnl_newlink_tbs`, `struct rtnl_offload_xstats_request_used`, `struct rtnl_stats_dump_filters`, `struct rtnl_mdb_dump_ctx`, `function rtnl_lock`, `function rtnl_lock_interruptible`, `function rtnl_lock_killable`, `function rtnl_kfree_skbs`.
- 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.