net/x25/x25_link.c
Source file repositories/reference/linux-study-clean/net/x25/x25_link.c
File Facts
- System
- Linux kernel
- Corpus path
net/x25/x25_link.c- Extension
.c- Size
- 9241 bytes
- Lines
- 422
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/kernel.hlinux/jiffies.hlinux/timer.hlinux/slab.hlinux/netdevice.hlinux/skbuff.hlinux/uaccess.hlinux/init.hnet/x25.h
Detected Declarations
function x25_start_t20timerfunction x25_t20timer_expiryfunction x25_stop_t20timerfunction x25_link_controlfunction x25_transmit_restart_requestfunction x25_transmit_restart_confirmationfunction x25_transmit_clear_requestfunction x25_transmit_linkfunction x25_link_establishedfunction x25_link_terminatedfunction x25_link_device_upfunction __x25_remove_neighfunction x25_link_device_downfunction list_for_each_safefunction x25_subscr_ioctlfunction x25_link_freefunction list_for_each_safe
Annotated Snippet
switch (nb->state) {
case X25_LINK_STATE_0:
/* This can happen when the x25 module just gets loaded
* and doesn't know layer 2 has already connected
*/
nb->state = X25_LINK_STATE_3;
x25_transmit_restart_confirmation(nb);
break;
case X25_LINK_STATE_2:
x25_stop_t20timer(nb);
nb->state = X25_LINK_STATE_3;
break;
case X25_LINK_STATE_3:
/* clear existing virtual calls */
x25_kill_by_neigh(nb);
x25_transmit_restart_confirmation(nb);
break;
}
break;
case X25_RESTART_CONFIRMATION:
switch (nb->state) {
case X25_LINK_STATE_2:
x25_stop_t20timer(nb);
nb->state = X25_LINK_STATE_3;
break;
case X25_LINK_STATE_3:
/* clear existing virtual calls */
x25_kill_by_neigh(nb);
x25_transmit_restart_request(nb);
nb->state = X25_LINK_STATE_2;
x25_start_t20timer(nb);
break;
}
break;
case X25_DIAGNOSTIC:
if (!pskb_may_pull(skb, X25_STD_MIN_LEN + 4))
break;
pr_warn("diagnostic #%d - %02X %02X %02X\n",
skb->data[3], skb->data[4],
skb->data[5], skb->data[6]);
break;
default:
pr_warn("received unknown %02X with LCI 000\n",
frametype);
break;
}
if (nb->state == X25_LINK_STATE_3)
while ((skbn = skb_dequeue(&nb->queue)) != NULL)
x25_send_frame(skbn, nb);
}
/*
* This routine is called when a Restart Request is needed
*/
static void x25_transmit_restart_request(struct x25_neigh *nb)
{
unsigned char *dptr;
int len = X25_MAX_L2_LEN + X25_STD_MIN_LEN + 2;
struct sk_buff *skb = alloc_skb(len, GFP_ATOMIC);
if (!skb)
return;
skb_reserve(skb, X25_MAX_L2_LEN);
dptr = skb_put(skb, X25_STD_MIN_LEN + 2);
*dptr++ = nb->extended ? X25_GFI_EXTSEQ : X25_GFI_STDSEQ;
*dptr++ = 0x00;
*dptr++ = X25_RESTART_REQUEST;
*dptr++ = 0x00;
*dptr++ = 0;
skb->sk = NULL;
x25_send_frame(skb, nb);
}
/*
* This routine is called when a Restart Confirmation is needed
*/
static void x25_transmit_restart_confirmation(struct x25_neigh *nb)
{
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/jiffies.h`, `linux/timer.h`, `linux/slab.h`, `linux/netdevice.h`, `linux/skbuff.h`, `linux/uaccess.h`, `linux/init.h`.
- Detected declarations: `function x25_start_t20timer`, `function x25_t20timer_expiry`, `function x25_stop_t20timer`, `function x25_link_control`, `function x25_transmit_restart_request`, `function x25_transmit_restart_confirmation`, `function x25_transmit_clear_request`, `function x25_transmit_link`, `function x25_link_established`, `function x25_link_terminated`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.