net/ipv6/seg6.c
Source file repositories/reference/linux-study-clean/net/ipv6/seg6.c
File Facts
- System
- Linux kernel
- Corpus path
net/ipv6/seg6.c- Extension
.c- Size
- 11373 bytes
- Lines
- 545
- 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/errno.hlinux/types.hlinux/socket.hlinux/net.hlinux/in6.hlinux/slab.hlinux/rhashtable.hnet/ipv6.hnet/protocol.hnet/seg6.hnet/genetlink.hlinux/seg6.hlinux/seg6_genl.hnet/seg6_hmac.h
Detected Declarations
function seg6_validate_srhfunction seg6_icmp_srhfunction seg6_genl_sethmacfunction seg6_genl_sethmacfunction seg6_genl_set_tunsrcfunction seg6_genl_get_tunsrcfunction __seg6_hmac_fill_infofunction __seg6_genl_dumphmac_elementfunction seg6_genl_dumphmac_startfunction seg6_genl_dumphmac_donefunction seg6_genl_dumphmacfunction seg6_genl_dumphmac_startfunction seg6_genl_dumphmac_donefunction seg6_genl_dumphmacfunction seg6_net_initfunction seg6_net_exitfunction seg6_initfunction seg6_exit
Annotated Snippet
if (IS_ERR(hinfo)) {
if (PTR_ERR(hinfo) == -EAGAIN)
continue;
ret = PTR_ERR(hinfo);
goto done;
} else if (!hinfo) {
break;
}
ret = __seg6_genl_dumphmac_element(hinfo,
NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq,
NLM_F_MULTI,
skb, SEG6_CMD_DUMPHMAC);
if (ret)
goto done;
}
ret = skb->len;
done:
rhashtable_walk_stop(iter);
return ret;
}
#else
static int seg6_genl_dumphmac_start(struct netlink_callback *cb)
{
return 0;
}
static int seg6_genl_dumphmac_done(struct netlink_callback *cb)
{
return 0;
}
static int seg6_genl_dumphmac(struct sk_buff *skb, struct netlink_callback *cb)
{
return -ENOTSUPP;
}
#endif
static int __net_init seg6_net_init(struct net *net)
{
struct seg6_pernet_data *sdata;
sdata = kzalloc_obj(*sdata);
if (!sdata)
return -ENOMEM;
mutex_init(&sdata->lock);
sdata->tun_src = kzalloc_obj(*sdata->tun_src);
if (!sdata->tun_src) {
kfree(sdata);
return -ENOMEM;
}
net->ipv6.seg6_data = sdata;
if (seg6_hmac_net_init(net)) {
kfree(rcu_dereference_raw(sdata->tun_src));
kfree(sdata);
return -ENOMEM;
}
return 0;
}
static void __net_exit seg6_net_exit(struct net *net)
{
struct seg6_pernet_data *sdata = seg6_pernet(net);
seg6_hmac_net_exit(net);
kfree(rcu_dereference_raw(sdata->tun_src));
kfree(sdata);
}
static struct pernet_operations ip6_segments_ops = {
.init = seg6_net_init,
.exit = seg6_net_exit,
};
static const struct genl_ops seg6_genl_ops[] = {
{
.cmd = SEG6_CMD_SETHMAC,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
Annotation
- Immediate include surface: `linux/errno.h`, `linux/types.h`, `linux/socket.h`, `linux/net.h`, `linux/in6.h`, `linux/slab.h`, `linux/rhashtable.h`, `net/ipv6.h`.
- Detected declarations: `function seg6_validate_srh`, `function seg6_icmp_srh`, `function seg6_genl_sethmac`, `function seg6_genl_sethmac`, `function seg6_genl_set_tunsrc`, `function seg6_genl_get_tunsrc`, `function __seg6_hmac_fill_info`, `function __seg6_genl_dumphmac_element`, `function seg6_genl_dumphmac_start`, `function seg6_genl_dumphmac_done`.
- 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.