net/ipv6/ip6_flowlabel.c
Source file repositories/reference/linux-study-clean/net/ipv6/ip6_flowlabel.c
File Facts
- System
- Linux kernel
- Corpus path
net/ipv6/ip6_flowlabel.c- Extension
.c- Size
- 21102 bytes
- Lines
- 922
- 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/capability.hlinux/errno.hlinux/types.hlinux/socket.hlinux/net.hlinux/netdevice.hlinux/in6.hlinux/proc_fs.hlinux/seq_file.hlinux/slab.hlinux/export.hlinux/pid_namespace.hlinux/jump_label_ratelimit.hnet/net_namespace.hnet/sock.hnet/ipv6.hnet/rawv6.hnet/transp_v6.hlinux/uaccess.h
Detected Declarations
struct ip6fl_iter_statefunction for_each_fl_rcufunction fl_shared_exclusivefunction fl_free_rcufunction fl_freefunction fl_releasefunction ip6_fl_gcfunction ip6_fl_purgefunction fl6_free_socklistfunction lockdep_is_heldfunction check_lingerfunction fl6_renewfunction fl_createfunction mem_checkfunction fl_linkfunction ipv6_flowlabel_opt_getfunction for_each_sk_fl_rcufunction ipv6_flowlabel_putfunction ipv6_flowlabel_renewfunction ipv6_flowlabel_getfunction for_each_sk_fl_rcufunction ipv6_flowlabel_optfunction for_each_fl_rcufunction for_each_fl_continue_rcufunction for_each_fl_rcufunction ip6fl_seq_stopfunction ip6fl_seq_showfunction ip6_flowlabel_proc_initfunction ip6_flowlabel_proc_finifunction ip6_flowlabel_proc_initfunction ip6_flowlabel_proc_finifunction ip6_flowlabel_initfunction ip6_flowlabel_cleanupexport ipv6_flowlabel_exclusiveexport __fl6_sock_lookupexport fl6_merge_options
Annotated Snippet
struct ip6fl_iter_state {
struct seq_net_private p;
struct pid_namespace *pid_ns;
int bucket;
};
#define ip6fl_seq_private(seq) ((struct ip6fl_iter_state *)(seq)->private)
static struct ip6_flowlabel *ip6fl_get_first(struct seq_file *seq)
{
struct ip6_flowlabel *fl = NULL;
struct ip6fl_iter_state *state = ip6fl_seq_private(seq);
struct net *net = seq_file_net(seq);
for (state->bucket = 0; state->bucket <= FL_HASH_MASK; ++state->bucket) {
for_each_fl_rcu(state->bucket, fl) {
if (net_eq(fl->fl_net, net))
goto out;
}
}
fl = NULL;
out:
return fl;
}
static struct ip6_flowlabel *ip6fl_get_next(struct seq_file *seq, struct ip6_flowlabel *fl)
{
struct ip6fl_iter_state *state = ip6fl_seq_private(seq);
struct net *net = seq_file_net(seq);
for_each_fl_continue_rcu(fl) {
if (net_eq(fl->fl_net, net))
goto out;
}
try_again:
if (++state->bucket <= FL_HASH_MASK) {
for_each_fl_rcu(state->bucket, fl) {
if (net_eq(fl->fl_net, net))
goto out;
}
goto try_again;
}
fl = NULL;
out:
return fl;
}
static struct ip6_flowlabel *ip6fl_get_idx(struct seq_file *seq, loff_t pos)
{
struct ip6_flowlabel *fl = ip6fl_get_first(seq);
if (fl)
while (pos && (fl = ip6fl_get_next(seq, fl)) != NULL)
--pos;
return pos ? NULL : fl;
}
static void *ip6fl_seq_start(struct seq_file *seq, loff_t *pos)
__acquires(RCU)
{
struct ip6fl_iter_state *state = ip6fl_seq_private(seq);
state->pid_ns = proc_pid_ns(file_inode(seq->file)->i_sb);
rcu_read_lock();
return *pos ? ip6fl_get_idx(seq, *pos - 1) : SEQ_START_TOKEN;
}
static void *ip6fl_seq_next(struct seq_file *seq, void *v, loff_t *pos)
{
struct ip6_flowlabel *fl;
if (v == SEQ_START_TOKEN)
fl = ip6fl_get_first(seq);
else
fl = ip6fl_get_next(seq, v);
++*pos;
return fl;
}
static void ip6fl_seq_stop(struct seq_file *seq, void *v)
__releases(RCU)
{
rcu_read_unlock();
}
static int ip6fl_seq_show(struct seq_file *seq, void *v)
{
struct ip6fl_iter_state *state = ip6fl_seq_private(seq);
Annotation
- Immediate include surface: `linux/capability.h`, `linux/errno.h`, `linux/types.h`, `linux/socket.h`, `linux/net.h`, `linux/netdevice.h`, `linux/in6.h`, `linux/proc_fs.h`.
- Detected declarations: `struct ip6fl_iter_state`, `function for_each_fl_rcu`, `function fl_shared_exclusive`, `function fl_free_rcu`, `function fl_free`, `function fl_release`, `function ip6_fl_gc`, `function ip6_fl_purge`, `function fl6_free_socklist`, `function lockdep_is_held`.
- 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.