net/ipv6/reassembly.c
Source file repositories/reference/linux-study-clean/net/ipv6/reassembly.c
File Facts
- System
- Linux kernel
- Corpus path
net/ipv6/reassembly.c- Extension
.c- Size
- 15563 bytes
- Lines
- 620
- 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/errno.hlinux/types.hlinux/string.hlinux/socket.hlinux/sockios.hlinux/jiffies.hlinux/net.hlinux/list.hlinux/netdevice.hlinux/in6.hlinux/ipv6.hlinux/icmpv6.hlinux/random.hlinux/jhash.hlinux/skbuff.hlinux/slab.hlinux/export.hlinux/tcp.hlinux/udp.hnet/sock.hnet/snmp.hnet/ipv6.hnet/ip6_route.hnet/protocol.hnet/transp_v6.hnet/rawv6.hnet/ndisc.hnet/addrconf.hnet/ipv6_frag.hnet/inet_ecn.h
Detected Declarations
function ip6_frag_ecnfunction ip6_frag_expirefunction fq_findfunction ip6_frag_queuefunction ip6_frag_reasmfunction ipv6_frag_rcvfunction ip6_frags_ns_sysctl_registerfunction ip6_frags_ns_sysctl_unregisterfunction ip6_frags_sysctl_registerfunction ip6_frags_sysctl_unregisterfunction ip6_frags_ns_sysctl_registerfunction ip6_frags_ns_sysctl_unregisterfunction ip6_frags_sysctl_unregisterfunction ipv6_frags_pre_exit_netfunction ipv6_frags_exit_netfunction ipv6_frag_initfunction ipv6_frag_exit
Annotated Snippet
if (end & 0x7) {
/* RFC2460 says always send parameter problem in
* this case. -DaveM
*/
*prob_offset = offsetof(struct ipv6hdr, payload_len);
inet_frag_kill(&fq->q, refs);
__IP6_INC_STATS(net, idev, IPSTATS_MIB_REASMFAILS);
return -1;
}
if (end > fq->q.len) {
/* Some bits beyond end -> corruption. */
if (fq->q.flags & INET_FRAG_LAST_IN)
goto discard_fq;
fq->q.len = end;
}
}
if (end == offset)
goto discard_fq;
err = -ENOMEM;
/* Point into the IP datagram 'data' part. */
if (!pskb_pull(skb, (u8 *) (fhdr + 1) - skb->data))
goto discard_fq;
err = pskb_trim_rcsum(skb, end - offset);
if (err)
goto discard_fq;
/* Note : skb->rbnode and skb->dev share the same location. */
dev = skb->dev;
/* Makes sure compiler wont do silly aliasing games */
barrier();
prev_tail = fq->q.fragments_tail;
err = inet_frag_queue_insert(&fq->q, skb, offset, end);
if (err)
goto insert_error;
if (dev)
fq->iif = dev->ifindex;
fq->q.stamp = skb->tstamp;
fq->q.tstamp_type = skb->tstamp_type;
fq->q.meat += skb->len;
fq->ecn |= ecn;
add_frag_mem_limit(fq->q.fqdir, skb->truesize);
fragsize = -skb_network_offset(skb) + skb->len;
if (fragsize > fq->q.max_size)
fq->q.max_size = fragsize;
/* The first fragment.
* nhoffset is obtained from the first fragment, of course.
*/
if (offset == 0) {
fq->nhoffset = nhoff;
fq->q.flags |= INET_FRAG_FIRST_IN;
}
if (fq->q.flags == (INET_FRAG_FIRST_IN | INET_FRAG_LAST_IN) &&
fq->q.meat == fq->q.len) {
unsigned long orefdst = skb->_skb_refdst;
skb->_skb_refdst = 0UL;
err = ip6_frag_reasm(fq, skb, prev_tail, dev, idev, refs);
skb->_skb_refdst = orefdst;
return err;
}
skb_dst_drop(skb);
return -EINPROGRESS;
insert_error:
if (err == IPFRAG_DUP) {
SKB_DR_SET(reason, DUP_FRAG);
err = -EINVAL;
goto err;
}
err = -EINVAL;
__IP6_INC_STATS(net, idev, IPSTATS_MIB_REASM_OVERLAPS);
discard_fq:
inet_frag_kill(&fq->q, refs);
__IP6_INC_STATS(net, idev, IPSTATS_MIB_REASMFAILS);
err:
kfree_skb_reason(skb, reason);
return err;
}
/*
Annotation
- Immediate include surface: `linux/errno.h`, `linux/types.h`, `linux/string.h`, `linux/socket.h`, `linux/sockios.h`, `linux/jiffies.h`, `linux/net.h`, `linux/list.h`.
- Detected declarations: `function ip6_frag_ecn`, `function ip6_frag_expire`, `function fq_find`, `function ip6_frag_queue`, `function ip6_frag_reasm`, `function ipv6_frag_rcv`, `function ip6_frags_ns_sysctl_register`, `function ip6_frags_ns_sysctl_unregister`, `function ip6_frags_sysctl_register`, `function ip6_frags_sysctl_unregister`.
- 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.