net/can/j1939/transport.c
Source file repositories/reference/linux-study-clean/net/can/j1939/transport.c
File Facts
- System
- Linux kernel
- Corpus path
net/can/j1939/transport.c- Extension
.c- Size
- 57562 bytes
- Lines
- 2252
- 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/can/skb.hnet/can.hj1939-priv.h
Detected Declarations
enum j1939_xtp_abortfunction j1939_xtp_abort_to_errnofunction j1939_session_list_lockfunction j1939_session_list_unlockfunction j1939_session_getfunction __j1939_session_dropfunction j1939_session_destroyfunction __j1939_session_releasefunction j1939_session_putfunction j1939_session_txtimer_cancelfunction j1939_session_rxtimer_cancelfunction j1939_session_timers_cancelfunction j1939_cb_is_broadcastfunction j1939_session_skb_drop_oldfunction j1939_session_skb_queuefunction j1939_tp_im_receiverfunction j1939_tp_im_transmitterfunction j1939_tp_im_involvedfunction j1939_tp_im_involved_anydirfunction j1939_xtp_ctl_to_pgnfunction j1939_tp_ctl_to_sizefunction j1939_etp_ctl_to_packetfunction j1939_etp_ctl_to_sizefunction broadcastsfunction list_for_each_entryfunction list_for_each_entryfunction j1939_skbcb_swapfunction j1939_tp_tx_datfunction j1939_xtp_do_tx_ctlfunction j1939_tp_tx_ctlfunction j1939_xtp_tx_abortfunction j1939_tp_schedule_txtimerfunction j1939_tp_set_rxtimeoutfunction j1939_session_tx_rtsfunction j1939_session_tx_dpofunction j1939_session_tx_datfunction j1939_xtp_txnext_transmiterfunction j1939_session_tx_ctsfunction j1939_session_tx_eomafunction j1939_xtp_txnext_receiverfunction j1939_simple_txnextfunction can_put_echo_skbfunction j1939_session_deactivate_lockedfunction j1939_session_deactivatefunction j1939_session_deactivate_activate_nextfunction __j1939_session_cancelfunction j1939_session_cancelfunction j1939_tp_txtimer
Annotated Snippet
if (se_addr->src_name) {
if (se_addr->src_name != sk_addr->dst_name)
return false;
} else if (se_addr->sa != sk_addr->da) {
return false;
}
if (se_addr->dst_name) {
if (se_addr->dst_name != sk_addr->src_name)
return false;
} else if (se_addr->da != sk_addr->sa) {
return false;
}
} else {
if (se_addr->src_name) {
if (se_addr->src_name != sk_addr->src_name)
return false;
} else if (se_addr->sa != sk_addr->sa) {
return false;
}
if (se_addr->dst_name) {
if (se_addr->dst_name != sk_addr->dst_name)
return false;
} else if (se_addr->da != sk_addr->da) {
return false;
}
}
return true;
}
static struct
j1939_session *j1939_session_get_by_addr_locked(struct j1939_priv *priv,
struct list_head *root,
struct j1939_addr *addr,
bool reverse, bool transmitter)
{
struct j1939_session *session;
lockdep_assert_held(&priv->active_session_list_lock);
list_for_each_entry(session, root, active_session_list_entry) {
j1939_session_get(session);
if (j1939_session_match(&session->skcb.addr, addr, reverse) &&
session->transmission == transmitter)
return session;
j1939_session_put(session);
}
return NULL;
}
static struct
j1939_session *j1939_session_get_simple(struct j1939_priv *priv,
struct sk_buff *skb)
{
struct j1939_sk_buff_cb *skcb = j1939_skb_to_cb(skb);
struct j1939_session *session;
lockdep_assert_held(&priv->active_session_list_lock);
list_for_each_entry(session, &priv->active_session_list,
active_session_list_entry) {
j1939_session_get(session);
if (session->skcb.addr.type == J1939_SIMPLE &&
session->tskey == skcb->tskey && session->sk == skb->sk)
return session;
j1939_session_put(session);
}
return NULL;
}
static struct
j1939_session *j1939_session_get_by_addr(struct j1939_priv *priv,
struct j1939_addr *addr,
bool reverse, bool transmitter)
{
struct j1939_session *session;
j1939_session_list_lock(priv);
session = j1939_session_get_by_addr_locked(priv,
&priv->active_session_list,
addr, reverse, transmitter);
j1939_session_list_unlock(priv);
return session;
}
Annotation
- Immediate include surface: `linux/can/skb.h`, `net/can.h`, `j1939-priv.h`.
- Detected declarations: `enum j1939_xtp_abort`, `function j1939_xtp_abort_to_errno`, `function j1939_session_list_lock`, `function j1939_session_list_unlock`, `function j1939_session_get`, `function __j1939_session_drop`, `function j1939_session_destroy`, `function __j1939_session_release`, `function j1939_session_put`, `function j1939_session_txtimer_cancel`.
- 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.