net/ipv6/seg6_local.c
Source file repositories/reference/linux-study-clean/net/ipv6/seg6_local.c
File Facts
- System
- Linux kernel
- Corpus path
net/ipv6/seg6_local.c- Extension
.c- Size
- 70201 bytes
- Lines
- 2721
- 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/filter.hlinux/types.hlinux/skbuff.hlinux/net.hlinux/module.hnet/ip.hnet/lwtunnel.hnet/netevent.hnet/netns/generic.hnet/ip6_fib.hnet/route.hnet/seg6.hlinux/seg6.hlinux/seg6_local.hnet/addrconf.hnet/ip6_route.hnet/dst_cache.hnet/ip_tunnels.hnet/seg6_hmac.hnet/seg6_local.hlinux/etherdevice.hlinux/bpf.hlinux/netfilter.h
Detected Declarations
struct seg6_local_lwtstruct seg6_local_lwtunnel_opsstruct seg6_action_descstruct bpf_lwt_progstruct seg6_flavors_infostruct seg6_end_dt_infostruct pcpu_seg6_local_countersstruct seg6_local_countersstruct seg6_local_lwtstruct seg6_action_paramenum seg6_end_dt_modeenum seg6_local_pktinfoenum seg6_local_flv_actionfunction decap_and_validatefunction advance_nextsegfunction seg6_lookup_any_nexthopfunction seg6_lookup_nexthopfunction seg6_flv_lcblock_octectsfunction seg6_flv_lcnode_func_octectsfunction seg6_next_csid_is_arg_zerofunction seg6_next_csid_advance_argfunction input_action_end_finishfunction input_action_end_corefunction end_next_csid_corefunction input_action_end_x_finishfunction input_action_end_x_corefunction end_x_next_csid_corefunction seg6_next_csid_enabledfunction seg6_flv_supp_ops_by_actionfunction seg6_get_srh_pktinfofunction seg6_local_flv8986_act_lookupfunction seg6_pop_srhfunction end_flv8986_corefunction input_action_endfunction input_action_end_xfunction input_action_end_tfunction input_action_end_dx2function input_action_end_dx6_finishfunction input_action_end_dx6function input_action_end_dx4_finishfunction input_action_end_dx4function __seg6_end_dt_vrf_buildfunction input_action_end_dt4function seg6_end_dt4_buildfunction seg6_end_dt6_parse_modefunction seg6_end_dt6_get_modefunction seg6_end_dt6_buildfunction input_action_end_dt6
Annotated Snippet
struct seg6_local_lwtunnel_ops {
int (*build_state)(struct seg6_local_lwt *slwt, const void *cfg,
struct netlink_ext_ack *extack);
void (*destroy_state)(struct seg6_local_lwt *slwt);
};
struct seg6_action_desc {
int action;
unsigned long attrs;
/* The optattrs field is used for specifying all the optional
* attributes supported by a specific behavior.
* It means that if one of these attributes is not provided in the
* netlink message during the behavior creation, no errors will be
* returned to the userspace.
*
* Each attribute can be only of two types (mutually exclusive):
* 1) required or 2) optional.
* Every user MUST obey to this rule! If you set an attribute as
* required the same attribute CANNOT be set as optional and vice
* versa.
*/
unsigned long optattrs;
int (*input)(struct sk_buff *skb, struct seg6_local_lwt *slwt);
int static_headroom;
struct seg6_local_lwtunnel_ops slwt_ops;
};
struct bpf_lwt_prog {
struct bpf_prog *prog;
char *name;
};
/* default length values (expressed in bits) for both Locator-Block and
* Locator-Node Function.
*
* Both SEG6_LOCAL_LCBLOCK_DBITS and SEG6_LOCAL_LCNODE_FN_DBITS *must* be:
* i) greater than 0;
* ii) evenly divisible by 8. In other terms, the lengths of the
* Locator-Block and Locator-Node Function must be byte-aligned (we can
* relax this constraint in the future if really needed).
*
* Moreover, a third condition must hold:
* iii) SEG6_LOCAL_LCBLOCK_DBITS + SEG6_LOCAL_LCNODE_FN_DBITS <= 128.
*
* The correctness of SEG6_LOCAL_LCBLOCK_DBITS and SEG6_LOCAL_LCNODE_FN_DBITS
* values are checked during the kernel compilation. If the compilation stops,
* check the value of these parameters to see if they meet conditions (i), (ii)
* and (iii).
*/
#define SEG6_LOCAL_LCBLOCK_DBITS 32
#define SEG6_LOCAL_LCNODE_FN_DBITS 16
/* The following next_csid_chk_{cntr,lcblock,lcblock_fn}_bits macros can be
* used directly to check whether the lengths (in bits) of Locator-Block and
* Locator-Node Function are valid according to (i), (ii), (iii).
*/
#define next_csid_chk_cntr_bits(blen, flen) \
((blen) + (flen) > 128)
#define next_csid_chk_lcblock_bits(blen) \
({ \
typeof(blen) __tmp = blen; \
(!__tmp || __tmp > 120 || (__tmp & 0x07)); \
})
#define next_csid_chk_lcnode_fn_bits(flen) \
next_csid_chk_lcblock_bits(flen)
/* flag indicating that flavors are set up for a given End* behavior */
#define SEG6_F_LOCAL_FLAVORS SEG6_F_ATTR(SEG6_LOCAL_FLAVORS)
#define SEG6_F_LOCAL_FLV_OP(flvname) BIT(SEG6_LOCAL_FLV_OP_##flvname)
#define SEG6_F_LOCAL_FLV_NEXT_CSID SEG6_F_LOCAL_FLV_OP(NEXT_CSID)
#define SEG6_F_LOCAL_FLV_PSP SEG6_F_LOCAL_FLV_OP(PSP)
/* Supported RFC8986 Flavor operations are reported in this bitmask */
#define SEG6_LOCAL_FLV8986_SUPP_OPS SEG6_F_LOCAL_FLV_PSP
#define SEG6_LOCAL_END_FLV_SUPP_OPS (SEG6_F_LOCAL_FLV_NEXT_CSID | \
SEG6_LOCAL_FLV8986_SUPP_OPS)
#define SEG6_LOCAL_END_X_FLV_SUPP_OPS SEG6_F_LOCAL_FLV_NEXT_CSID
struct seg6_flavors_info {
/* Flavor operations */
__u32 flv_ops;
/* Locator-Block length, expressed in bits */
Annotation
- Immediate include surface: `linux/filter.h`, `linux/types.h`, `linux/skbuff.h`, `linux/net.h`, `linux/module.h`, `net/ip.h`, `net/lwtunnel.h`, `net/netevent.h`.
- Detected declarations: `struct seg6_local_lwt`, `struct seg6_local_lwtunnel_ops`, `struct seg6_action_desc`, `struct bpf_lwt_prog`, `struct seg6_flavors_info`, `struct seg6_end_dt_info`, `struct pcpu_seg6_local_counters`, `struct seg6_local_counters`, `struct seg6_local_lwt`, `struct seg6_action_param`.
- 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.