net/ipv6/exthdrs.c
Source file repositories/reference/linux-study-clean/net/ipv6/exthdrs.c
File Facts
- System
- Linux kernel
- Corpus path
net/ipv6/exthdrs.c- Extension
.c- Size
- 33766 bytes
- Lines
- 1405
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/errno.hlinux/types.hlinux/socket.hlinux/sockios.hlinux/net.hlinux/netdevice.hlinux/in6.hlinux/icmpv6.hlinux/slab.hlinux/export.hnet/dst.hnet/sock.hnet/snmp.hnet/ipv6.hnet/protocol.hnet/transp_v6.hnet/rawv6.hnet/ndisc.hnet/ip6_route.hnet/addrconf.hnet/calipso.hnet/xfrm.hlinux/seg6.hnet/seg6.hnet/seg6_hmac.hnet/rpl.hlinux/ioam6.hlinux/ioam6_genl.hnet/ioam6.hnet/dst_metadata.hlinux/uaccess.h
Detected Declarations
function ip6_tlvopt_unknownfunction ip6_parse_tlvfunction ipv6_dest_haofunction ipv6_destopt_rcvfunction seg6_update_csumfunction ipv6_srh_rcvfunction ipv6_rpl_srh_rcvfunction skb_headroomfunction ipv6_rthdr_rcvfunction ipv6_exthdrs_initfunction ipv6_exthdrs_exitfunction ipv6_hop_rafunction ipv6_hop_ioamfunction ipv6_hop_jumbofunction ipv6_hop_calipsofunction ipv6_parse_hopoptsfunction skb_network_headerfunction READ_ONCEfunction ipv6_push_rthdr0function ipv6_push_rthdr4function ipv6_push_rthdrfunction ipv6_push_exthdrfunction ipv6_push_nfrag_optsfunction ipv6_push_frag_optsfunction ipv6_dup_optionsfunction ipv6_renew_optionfunction ipv6_renew_optionsexport ipv6_push_frag_optsexport ipv6_dup_optionsexport __ipv6_fixup_optionsexport __fl6_update_dst
Annotated Snippet
if (nh[off] == IPV6_TLV_PAD1) {
padlen++;
if (padlen > 7)
goto bad;
off++;
len--;
continue;
}
if (len < 2)
goto bad;
optlen = nh[off + 1] + 2;
if (optlen > len)
goto bad;
if (nh[off] == IPV6_TLV_PADN) {
/* RFC 2460 states that the purpose of PadN is
* to align the containing header to multiples
* of 8. 7 is therefore the highest valid value.
* See also RFC 4942, Section 2.1.9.5.
*/
padlen += optlen;
if (padlen > 7)
goto bad;
/* RFC 4942 recommends receiving hosts to
* actively check PadN payload to contain
* only zeroes.
*/
for (i = 2; i < optlen; i++) {
if (nh[off + i] != 0)
goto bad;
}
} else {
tlv_count++;
if (tlv_count > max_count)
goto bad;
if (hopbyhop) {
switch (nh[off]) {
case IPV6_TLV_ROUTERALERT:
if (!ipv6_hop_ra(skb, off))
return false;
break;
case IPV6_TLV_IOAM:
if (!ipv6_hop_ioam(skb, off))
return false;
break;
case IPV6_TLV_JUMBO:
if (!ipv6_hop_jumbo(skb, off))
return false;
break;
case IPV6_TLV_CALIPSO:
if (!ipv6_hop_calipso(skb, off))
return false;
break;
default:
if (!ip6_tlvopt_unknown(skb, off,
disallow_unknowns))
return false;
break;
}
} else {
switch (nh[off]) {
#if IS_ENABLED(CONFIG_IPV6_MIP6)
case IPV6_TLV_HAO:
if (!ipv6_dest_hao(skb, off))
return false;
break;
#endif
default:
if (!ip6_tlvopt_unknown(skb, off,
disallow_unknowns))
return false;
break;
}
}
padlen = 0;
/* recompute the network header pointer in case it has changed */
nh = skb_network_header(skb);
}
off += optlen;
len -= optlen;
}
if (len == 0)
return true;
bad:
kfree_skb_reason(skb, SKB_DROP_REASON_IP_INHDR);
return false;
}
Annotation
- Immediate include surface: `linux/errno.h`, `linux/types.h`, `linux/socket.h`, `linux/sockios.h`, `linux/net.h`, `linux/netdevice.h`, `linux/in6.h`, `linux/icmpv6.h`.
- Detected declarations: `function ip6_tlvopt_unknown`, `function ip6_parse_tlv`, `function ipv6_dest_hao`, `function ipv6_destopt_rcv`, `function seg6_update_csum`, `function ipv6_srh_rcv`, `function ipv6_rpl_srh_rcv`, `function skb_headroom`, `function ipv6_rthdr_rcv`, `function ipv6_exthdrs_init`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration 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.