net/llc/llc_sap.c
Source file repositories/reference/linux-study-clean/net/llc/llc_sap.c
File Facts
- System
- Linux kernel
- Corpus path
net/llc/llc_sap.c- Extension
.c- Size
- 11470 bytes
- Lines
- 438
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
net/llc.hnet/llc_if.hnet/llc_conn.hnet/llc_pdu.hnet/llc_sap.hnet/llc_s_ac.hnet/llc_s_ev.hnet/llc_s_st.hnet/sock.hnet/tcp_states.hlinux/llc.hlinux/slab.h
Detected Declarations
function Copyrightfunction llc_save_primitivefunction llc_sap_rtn_pdufunction llc_exec_sap_trans_actionsfunction llc_sap_next_statefunction neededfunction llc_build_and_send_test_pktfunction llc_build_and_send_xid_pktfunction llc_sap_rcvfunction llc_dgram_matchfunction llc_mcast_matchfunction llc_do_mcastfunction llc_sap_mcastfunction llc_sap_handler
Annotated Snippet
if (!next_trans[i]->ev(sap, skb)) {
rc = next_trans[i]; /* got event match; return it */
break;
}
return rc;
}
/**
* llc_exec_sap_trans_actions - execute actions related to event
* @sap: pointer to SAP
* @trans: pointer to transition that it's actions must be performed
* @skb: happened event.
*
* This function executes actions that is related to happened event.
* Returns 0 for success and 1 for failure of at least one action.
*/
static int llc_exec_sap_trans_actions(struct llc_sap *sap,
const struct llc_sap_state_trans *trans,
struct sk_buff *skb)
{
int rc = 0;
const llc_sap_action_t *next_action = trans->ev_actions;
for (; next_action && *next_action; next_action++)
if ((*next_action)(sap, skb))
rc = 1;
return rc;
}
/**
* llc_sap_next_state - finds transition, execs actions & change SAP state
* @sap: pointer to SAP
* @skb: happened event
*
* This function finds transition that matches with happened event, then
* executes related actions and finally changes state of SAP. It returns
* 0 on success and 1 for failure.
*/
static int llc_sap_next_state(struct llc_sap *sap, struct sk_buff *skb)
{
const struct llc_sap_state_trans *trans;
int rc = 1;
if (sap->state > LLC_NR_SAP_STATES)
goto out;
trans = llc_find_sap_trans(sap, skb);
if (!trans)
goto out;
/*
* Got the state to which we next transition; perform the actions
* associated with this transition before actually transitioning to the
* next state
*/
rc = llc_exec_sap_trans_actions(sap, trans, skb);
if (rc)
goto out;
/*
* Transition SAP to next state if all actions execute successfully
*/
sap->state = trans->next_state;
out:
return rc;
}
/**
* llc_sap_state_process - sends event to SAP state machine
* @sap: sap to use
* @skb: pointer to occurred event
*
* After executing actions of the event, upper layer will be indicated
* if needed(on receiving an UI frame). sk can be null for the
* datalink_proto case.
*
* This function always consumes a reference to the skb.
*/
static void llc_sap_state_process(struct llc_sap *sap, struct sk_buff *skb)
{
struct llc_sap_state_ev *ev = llc_sap_ev(skb);
ev->ind_cfm_flag = 0;
llc_sap_next_state(sap, skb);
if (ev->ind_cfm_flag == LLC_IND && skb->sk->sk_state != TCP_LISTEN) {
llc_save_primitive(skb->sk, skb, ev->prim);
/* queue skb to the user. */
if (sock_queue_rcv_skb(skb->sk, skb) == 0)
return;
}
kfree_skb(skb);
Annotation
- Immediate include surface: `net/llc.h`, `net/llc_if.h`, `net/llc_conn.h`, `net/llc_pdu.h`, `net/llc_sap.h`, `net/llc_s_ac.h`, `net/llc_s_ev.h`, `net/llc_s_st.h`.
- Detected declarations: `function Copyright`, `function llc_save_primitive`, `function llc_sap_rtn_pdu`, `function llc_exec_sap_trans_actions`, `function llc_sap_next_state`, `function needed`, `function llc_build_and_send_test_pkt`, `function llc_build_and_send_xid_pkt`, `function llc_sap_rcv`, `function llc_dgram_match`.
- 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.