net/nfc/netlink.c
Source file repositories/reference/linux-study-clean/net/nfc/netlink.c
File Facts
- System
- Linux kernel
- Corpus path
net/nfc/netlink.c- Extension
.c- Size
- 41268 bytes
- Lines
- 1932
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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
net/genetlink.hlinux/nfc.hlinux/slab.hnfc.hllcp.h
Detected Declarations
struct se_io_ctxstruct urelease_workfunction nfc_genl_send_targetfunction nfc_genl_dump_targetsfunction nfc_genl_dump_targets_donefunction nfc_genl_targets_foundfunction nfc_genl_target_lostfunction nfc_genl_tm_activatedfunction nfc_genl_tm_deactivatedfunction nfc_genl_setup_device_addedfunction nfc_genl_device_addedfunction nfc_genl_device_removedfunction nfc_genl_llc_send_sdresfunction nfc_genl_se_addedfunction nfc_genl_se_removedfunction nfc_genl_se_transactionfunction nfc_genl_se_connectivityfunction nfc_genl_send_devicefunction nfc_genl_dump_devicesfunction nfc_genl_dump_devices_donefunction nfc_genl_dep_link_up_eventfunction nfc_genl_dep_link_down_eventfunction nfc_genl_get_devicefunction nfc_genl_dev_upfunction nfc_genl_dev_downfunction nfc_genl_start_pollfunction nfc_genl_stop_pollfunction nfc_genl_activate_targetfunction nfc_genl_deactivate_targetfunction nfc_genl_dep_link_upfunction nfc_genl_dep_link_downfunction nfc_genl_send_paramsfunction nfc_genl_llc_get_paramsfunction nfc_genl_llc_set_paramsfunction nfc_genl_llc_sdreqfunction nla_for_each_nestedfunction nfc_genl_fw_downloadfunction nfc_genl_fw_download_donefunction nfc_genl_enable_sefunction nfc_genl_disable_sefunction nfc_genl_send_sefunction list_for_each_entry_safefunction nfc_genl_dump_sesfunction nfc_genl_dump_ses_donefunction nfc_se_iofunction se_io_cbfunction nfc_genl_se_iofunction nfc_genl_vendor_cmd
Annotated Snippet
struct se_io_ctx {
u32 dev_idx;
u32 se_idx;
};
static void se_io_cb(void *context, u8 *apdu, size_t apdu_len, int err)
{
struct se_io_ctx *ctx = context;
struct sk_buff *msg;
void *hdr;
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg) {
kfree(ctx);
return;
}
hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0,
NFC_CMD_SE_IO);
if (!hdr)
goto free_msg;
if (nla_put_u32(msg, NFC_ATTR_DEVICE_INDEX, ctx->dev_idx) ||
nla_put_u32(msg, NFC_ATTR_SE_INDEX, ctx->se_idx) ||
nla_put(msg, NFC_ATTR_SE_APDU, apdu_len, apdu))
goto nla_put_failure;
genlmsg_end(msg, hdr);
genlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_KERNEL);
kfree(ctx);
return;
nla_put_failure:
free_msg:
nlmsg_free(msg);
kfree(ctx);
return;
}
static int nfc_genl_se_io(struct sk_buff *skb, struct genl_info *info)
{
struct nfc_dev *dev;
struct se_io_ctx *ctx;
u32 dev_idx, se_idx;
u8 *apdu;
size_t apdu_len;
int rc;
if (!info->attrs[NFC_ATTR_DEVICE_INDEX] ||
!info->attrs[NFC_ATTR_SE_INDEX] ||
!info->attrs[NFC_ATTR_SE_APDU])
return -EINVAL;
dev_idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
se_idx = nla_get_u32(info->attrs[NFC_ATTR_SE_INDEX]);
dev = nfc_get_device(dev_idx);
if (!dev)
return -ENODEV;
if (!dev->ops || !dev->ops->se_io) {
rc = -EOPNOTSUPP;
goto put_dev;
}
apdu_len = nla_len(info->attrs[NFC_ATTR_SE_APDU]);
if (apdu_len == 0) {
rc = -EINVAL;
goto put_dev;
}
apdu = nla_data(info->attrs[NFC_ATTR_SE_APDU]);
ctx = kzalloc_obj(struct se_io_ctx);
if (!ctx) {
rc = -ENOMEM;
goto put_dev;
}
ctx->dev_idx = dev_idx;
ctx->se_idx = se_idx;
rc = nfc_se_io(dev, se_idx, apdu, apdu_len, se_io_cb, ctx);
put_dev:
nfc_put_device(dev);
Annotation
- Immediate include surface: `net/genetlink.h`, `linux/nfc.h`, `linux/slab.h`, `nfc.h`, `llcp.h`.
- Detected declarations: `struct se_io_ctx`, `struct urelease_work`, `function nfc_genl_send_target`, `function nfc_genl_dump_targets`, `function nfc_genl_dump_targets_done`, `function nfc_genl_targets_found`, `function nfc_genl_target_lost`, `function nfc_genl_tm_activated`, `function nfc_genl_tm_deactivated`, `function nfc_genl_setup_device_added`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration 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.