net/nfc/llcp_core.c
Source file repositories/reference/linux-study-clean/net/nfc/llcp_core.c
File Facts
- System
- Linux kernel
- Corpus path
net/nfc/llcp_core.c- Extension
.c- Size
- 36661 bytes
- Lines
- 1713
- 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.
- 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/init.hlinux/kernel.hlinux/list.hlinux/nfc.hnfc.hllcp.h
Detected Declarations
function nfc_llcp_sock_linkfunction nfc_llcp_sock_unlinkfunction nfc_llcp_socket_remote_param_initfunction nfc_llcp_socket_purgefunction nfc_llcp_socket_releasefunction sk_for_each_safefunction list_for_each_entry_safefunction sk_for_each_safefunction local_cleanupfunction local_releasefunction nfc_llcp_local_putfunction sk_for_eachfunction nfc_llcp_sock_putfunction nfc_llcp_timeout_workfunction nfc_llcp_symm_timerfunction nfc_llcp_sdreq_timeout_workfunction hlist_for_each_entry_safefunction nfc_llcp_sdreq_timerfunction nfc_llcp_wks_sapfunction sk_for_eachfunction nfc_llcp_get_sdp_ssapfunction nfc_llcp_get_local_ssapfunction nfc_llcp_put_ssapfunction nfc_llcp_reserve_sdp_ssapfunction nfc_llcp_build_gbfunction nfc_llcp_set_remote_gbfunction nfc_llcp_dsapfunction nfc_llcp_ptypefunction nfc_llcp_ssapfunction nfc_llcp_nsfunction nfc_llcp_nrfunction nfc_llcp_set_nrnsfunction nfc_llcp_send_to_raw_sockfunction sk_for_eachfunction nfc_llcp_tx_workfunction sk_for_eachfunction nfc_llcp_recv_uifunction nfc_llcp_recv_connectfunction nfc_llcp_queue_i_framesfunction skb_queue_lenfunction nfc_llcp_recv_hdlcfunction skb_queue_walk_safefunction skb_queue_reverse_walk_safefunction nfc_llcp_recv_discfunction nfc_llcp_recv_ccfunction nfc_llcp_recv_dmfunction nfc_llcp_recv_snlfunction hlist_for_each_entry
Annotated Snippet
if (sk->sk_state == LLCP_LISTEN) {
struct nfc_llcp_sock *lsk, *n;
struct sock *accept_sk;
list_for_each_entry_safe(lsk, n,
&llcp_sock->accept_queue,
accept_queue) {
accept_sk = &lsk->sk;
bh_lock_sock(accept_sk);
nfc_llcp_accept_unlink(accept_sk);
if (err)
accept_sk->sk_err = err;
accept_sk->sk_state = LLCP_CLOSED;
accept_sk->sk_state_change(sk);
bh_unlock_sock(accept_sk);
}
}
if (err)
sk->sk_err = err;
sk->sk_state = LLCP_CLOSED;
sk->sk_state_change(sk);
bh_unlock_sock(sk);
sk_del_node_init(sk);
}
write_unlock(&local->sockets.lock);
/* If we still have a device, we keep the RAW sockets alive */
if (device == true)
return;
write_lock(&local->raw_sockets.lock);
sk_for_each_safe(sk, tmp, &local->raw_sockets.head) {
llcp_sock = nfc_llcp_sock(sk);
bh_lock_sock(sk);
nfc_llcp_socket_purge(llcp_sock);
if (err)
sk->sk_err = err;
sk->sk_state = LLCP_CLOSED;
sk->sk_state_change(sk);
bh_unlock_sock(sk);
sk_del_node_init(sk);
}
write_unlock(&local->raw_sockets.lock);
}
static struct nfc_llcp_local *nfc_llcp_local_get(struct nfc_llcp_local *local)
{
/* Since using nfc_llcp_local may result in usage of nfc_dev, whenever
* we hold a reference to local, we also need to hold a reference to
* the device to avoid UAF.
*/
if (!nfc_get_device(local->dev->idx))
return NULL;
kref_get(&local->ref);
return local;
}
static void local_cleanup(struct nfc_llcp_local *local)
{
nfc_llcp_socket_release(local, false, ENXIO);
timer_delete_sync(&local->link_timer);
skb_queue_purge(&local->tx_queue);
cancel_work_sync(&local->tx_work);
cancel_work_sync(&local->rx_work);
cancel_work_sync(&local->timeout_work);
kfree_skb(local->rx_pending);
local->rx_pending = NULL;
timer_delete_sync(&local->sdreq_timer);
cancel_work_sync(&local->sdreq_timeout_work);
nfc_llcp_free_sdp_tlv_list(&local->pending_sdreqs);
}
static void local_release(struct kref *ref)
{
Annotation
- Immediate include surface: `linux/init.h`, `linux/kernel.h`, `linux/list.h`, `linux/nfc.h`, `nfc.h`, `llcp.h`.
- Detected declarations: `function nfc_llcp_sock_link`, `function nfc_llcp_sock_unlink`, `function nfc_llcp_socket_remote_param_init`, `function nfc_llcp_socket_purge`, `function nfc_llcp_socket_release`, `function sk_for_each_safe`, `function list_for_each_entry_safe`, `function sk_for_each_safe`, `function local_cleanup`, `function local_release`.
- 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.