net/ieee802154/6lowpan/reassembly.c
Source file repositories/reference/linux-study-clean/net/ieee802154/6lowpan/reassembly.c
File Facts
- System
- Linux kernel
- Corpus path
net/ieee802154/6lowpan/reassembly.c- Extension
.c- Size
- 13406 bytes
- Lines
- 559
- 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
linux/net.hlinux/list.hlinux/netdevice.hlinux/random.hlinux/jhash.hlinux/skbuff.hlinux/slab.hlinux/export.hnet/ieee802154_netdev.hnet/6lowpan.hnet/ipv6_frag.hnet/inet_frag.hnet/ip.h6lowpan_i.h
Detected Declarations
function lowpan_frag_initfunction lowpan_frag_expirefunction fq_findfunction lowpan_frag_queuefunction lowpan_frag_reasmfunction lowpan_frag_rx_handlers_resultfunction lowpan_frag_rx_h_iphcfunction lowpan_invoke_frag_rx_handlersfunction lowpan_get_cbfunction lowpan_frag_rcvfunction lowpan_frags_ns_sysctl_registerfunction lowpan_frags_ns_sysctl_unregisterfunction lowpan_frags_sysctl_registerfunction lowpan_frags_sysctl_unregisterfunction lowpan_frags_ns_sysctl_registerfunction lowpan_frags_ns_sysctl_unregisterfunction lowpan_frags_sysctl_unregisterfunction lowpan_frags_pre_exit_netfunction lowpan_frags_exit_netfunction lowpan_key_hashfnfunction lowpan_obj_hashfnfunction lowpan_obj_cmpfnfunction lowpan_net_frag_initfunction lowpan_net_frag_exit
Annotated Snippet
if (end > fq->q.len) {
/* Some bits beyond end -> corruption. */
if (fq->q.flags & INET_FRAG_LAST_IN)
goto err;
fq->q.len = end;
}
}
ldev = skb->dev;
if (ldev)
skb->dev = NULL;
barrier();
prev_tail = fq->q.fragments_tail;
err = inet_frag_queue_insert(&fq->q, skb, offset, end);
if (err)
goto err;
fq->q.stamp = skb->tstamp;
fq->q.tstamp_type = skb->tstamp_type;
if (frag_type == LOWPAN_DISPATCH_FRAG1)
fq->q.flags |= INET_FRAG_FIRST_IN;
fq->q.meat += skb->len;
add_frag_mem_limit(fq->q.fqdir, skb->truesize);
if (fq->q.flags == (INET_FRAG_FIRST_IN | INET_FRAG_LAST_IN) &&
fq->q.meat == fq->q.len) {
int res;
unsigned long orefdst = skb->_skb_refdst;
skb->_skb_refdst = 0UL;
res = lowpan_frag_reasm(fq, skb, prev_tail, ldev, refs);
skb->_skb_refdst = orefdst;
return res;
}
skb_dst_drop(skb);
return -1;
err:
kfree_skb(skb);
return -1;
}
/* Check if this packet is complete.
*
* It is called with locked fq, and caller must check that
* queue is eligible for reassembly i.e. it is not COMPLETE,
* the last and the first frames arrived and all the bits are here.
*/
static int lowpan_frag_reasm(struct lowpan_frag_queue *fq, struct sk_buff *skb,
struct sk_buff *prev_tail, struct net_device *ldev,
int *refs)
{
void *reasm_data;
inet_frag_kill(&fq->q, refs);
reasm_data = inet_frag_reasm_prepare(&fq->q, skb, prev_tail);
if (!reasm_data)
goto out_oom;
inet_frag_reasm_finish(&fq->q, skb, reasm_data, false);
skb->dev = ldev;
skb->tstamp = fq->q.stamp;
fq->q.rb_fragments = RB_ROOT;
fq->q.fragments_tail = NULL;
fq->q.last_run_head = NULL;
return 1;
out_oom:
net_dbg_ratelimited("lowpan_frag_reasm: no memory for reassembly\n");
return -1;
}
static int lowpan_frag_rx_handlers_result(struct sk_buff *skb,
lowpan_rx_result res)
{
switch (res) {
case RX_QUEUED:
return NET_RX_SUCCESS;
case RX_CONTINUE:
/* nobody cared about this packet */
net_warn_ratelimited("%s: received unknown dispatch\n",
__func__);
fallthrough;
default:
/* all others failure */
return NET_RX_DROP;
Annotation
- Immediate include surface: `linux/net.h`, `linux/list.h`, `linux/netdevice.h`, `linux/random.h`, `linux/jhash.h`, `linux/skbuff.h`, `linux/slab.h`, `linux/export.h`.
- Detected declarations: `function lowpan_frag_init`, `function lowpan_frag_expire`, `function fq_find`, `function lowpan_frag_queue`, `function lowpan_frag_reasm`, `function lowpan_frag_rx_handlers_result`, `function lowpan_frag_rx_h_iphc`, `function lowpan_invoke_frag_rx_handlers`, `function lowpan_get_cb`, `function lowpan_frag_rcv`.
- 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.