net/ipv6/addrlabel.c
Source file repositories/reference/linux-study-clean/net/ipv6/addrlabel.c
File Facts
- System
- Linux kernel
- Corpus path
net/ipv6/addrlabel.c- Extension
.c- Size
- 16009 bytes
- Lines
- 641
- 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.
- 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/list.hlinux/rcupdate.hlinux/in6.hlinux/slab.hnet/addrconf.hlinux/if_addrlabel.hlinux/netlink.hlinux/rtnetlink.h
Detected Declarations
struct ip6addrlbl_entryfunction __ip6addrlbl_matchfunction hlist_for_each_entry_rcufunction ipv6_addr_labelfunction __ip6addrlbl_addfunction hlist_for_each_entry_safefunction ip6addrlbl_addfunction __ip6addrlbl_delfunction hlist_for_each_entry_safefunction ip6addrlbl_delfunction ip6addrlbl_net_initfunction ip6addrlbl_net_exitfunction ipv6_addr_label_initfunction ipv6_addr_label_cleanupfunction addrlbl_ifindex_existsfunction ip6addrlbl_newdelfunction ip6addrlbl_putmsgfunction ip6addrlbl_fillfunction ip6addrlbl_valid_dump_reqfunction ip6addrlbl_dumpfunction ip6addrlbl_msgsizefunction ip6addrlbl_valid_get_reqfunction ip6addrlbl_getfunction ipv6_addr_label_rtnl_register
Annotated Snippet
struct ip6addrlbl_entry {
struct in6_addr prefix;
int prefixlen;
int ifindex;
int addrtype;
u32 label;
struct hlist_node list;
struct rcu_head rcu;
};
/*
* Default policy table (RFC6724 + extensions)
*
* prefix addr_type label
* -------------------------------------------------------------------------
* ::1/128 LOOPBACK 0
* ::/0 N/A 1
* 2002::/16 N/A 2
* ::/96 COMPATv4 3
* ::ffff:0:0/96 V4MAPPED 4
* fc00::/7 N/A 5 ULA (RFC 4193)
* 2001::/32 N/A 6 Teredo (RFC 4380)
* 2001:10::/28 N/A 7 ORCHID (RFC 4843)
* fec0::/10 N/A 11 Site-local
* (deprecated by RFC3879)
* 3ffe::/16 N/A 12 6bone
*
* Note: 0xffffffff is used if we do not have any policies.
* Note: Labels for ULA and 6to4 are different from labels listed in RFC6724.
*/
#define IPV6_ADDR_LABEL_DEFAULT 0xffffffffUL
static const __net_initconst struct ip6addrlbl_init_table
{
const struct in6_addr *prefix;
int prefixlen;
u32 label;
} ip6addrlbl_init_table[] = {
{ /* ::/0 */
.prefix = &in6addr_any,
.label = 1,
}, { /* fc00::/7 */
.prefix = &(struct in6_addr){ { { 0xfc } } } ,
.prefixlen = 7,
.label = 5,
}, { /* fec0::/10 */
.prefix = &(struct in6_addr){ { { 0xfe, 0xc0 } } },
.prefixlen = 10,
.label = 11,
}, { /* 2002::/16 */
.prefix = &(struct in6_addr){ { { 0x20, 0x02 } } },
.prefixlen = 16,
.label = 2,
}, { /* 3ffe::/16 */
.prefix = &(struct in6_addr){ { { 0x3f, 0xfe } } },
.prefixlen = 16,
.label = 12,
}, { /* 2001::/32 */
.prefix = &(struct in6_addr){ { { 0x20, 0x01 } } },
.prefixlen = 32,
.label = 6,
}, { /* 2001:10::/28 */
.prefix = &(struct in6_addr){ { { 0x20, 0x01, 0x00, 0x10 } } },
.prefixlen = 28,
.label = 7,
}, { /* ::ffff:0:0 */
.prefix = &(struct in6_addr){ { { [10] = 0xff, [11] = 0xff } } },
.prefixlen = 96,
.label = 4,
}, { /* ::/96 */
.prefix = &in6addr_any,
.prefixlen = 96,
.label = 3,
}, { /* ::1/128 */
.prefix = &in6addr_loopback,
.prefixlen = 128,
.label = 0,
}
};
/* Find label */
static bool __ip6addrlbl_match(const struct ip6addrlbl_entry *p,
const struct in6_addr *addr,
int addrtype, int ifindex)
{
if (p->ifindex && p->ifindex != ifindex)
return false;
if (p->addrtype && p->addrtype != addrtype)
return false;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/list.h`, `linux/rcupdate.h`, `linux/in6.h`, `linux/slab.h`, `net/addrconf.h`, `linux/if_addrlabel.h`, `linux/netlink.h`.
- Detected declarations: `struct ip6addrlbl_entry`, `function __ip6addrlbl_match`, `function hlist_for_each_entry_rcu`, `function ipv6_addr_label`, `function __ip6addrlbl_add`, `function hlist_for_each_entry_safe`, `function ip6addrlbl_add`, `function __ip6addrlbl_del`, `function hlist_for_each_entry_safe`, `function ip6addrlbl_del`.
- 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.