include/net/nsh.h
Source file repositories/reference/linux-study-clean/include/net/nsh.h
File Facts
- System
- Linux kernel
- Corpus path
include/net/nsh.h- Extension
.h- Size
- 12667 bytes
- Lines
- 311
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/skbuff.h
Detected Declarations
struct nsh_md1_ctxstruct nsh_md2_tlvstruct nshhdrfunction nsh_hdr_lenfunction nsh_get_verfunction nsh_get_flagsfunction nsh_get_ttlfunction __nsh_set_xflagfunction nsh_set_flags_and_ttlfunction nsh_set_flags_ttl_len
Annotated Snippet
struct nsh_md1_ctx {
__be32 context[4];
};
struct nsh_md2_tlv {
__be16 md_class;
u8 type;
u8 length;
u8 md_value[];
};
struct nshhdr {
__be16 ver_flags_ttl_len;
u8 mdtype;
u8 np;
__be32 path_hdr;
union {
struct nsh_md1_ctx md1;
struct nsh_md2_tlv md2;
};
};
/* Masking NSH header fields. */
#define NSH_VER_MASK 0xc000
#define NSH_VER_SHIFT 14
#define NSH_FLAGS_MASK 0x3000
#define NSH_FLAGS_SHIFT 12
#define NSH_TTL_MASK 0x0fc0
#define NSH_TTL_SHIFT 6
#define NSH_LEN_MASK 0x003f
#define NSH_LEN_SHIFT 0
#define NSH_MDTYPE_MASK 0x0f
#define NSH_MDTYPE_SHIFT 0
#define NSH_SPI_MASK 0xffffff00
#define NSH_SPI_SHIFT 8
#define NSH_SI_MASK 0x000000ff
#define NSH_SI_SHIFT 0
/* MD Type Registry. */
#define NSH_M_TYPE1 0x01
#define NSH_M_TYPE2 0x02
#define NSH_M_EXP1 0xFE
#define NSH_M_EXP2 0xFF
/* NSH Base Header Length */
#define NSH_BASE_HDR_LEN 8
/* NSH MD Type 1 header Length. */
#define NSH_M_TYPE1_LEN 24
/* NSH header maximum Length. */
#define NSH_HDR_MAX_LEN ((NSH_LEN_MASK >> NSH_LEN_SHIFT) * 4)
/* NSH context headers maximum Length. */
#define NSH_CTX_HDRS_MAX_LEN (NSH_HDR_MAX_LEN - NSH_BASE_HDR_LEN)
static inline struct nshhdr *nsh_hdr(struct sk_buff *skb)
{
return (struct nshhdr *)skb_network_header(skb);
}
static inline u16 nsh_hdr_len(const struct nshhdr *nsh)
{
return ((ntohs(nsh->ver_flags_ttl_len) & NSH_LEN_MASK)
>> NSH_LEN_SHIFT) << 2;
}
static inline u8 nsh_get_ver(const struct nshhdr *nsh)
{
return (ntohs(nsh->ver_flags_ttl_len) & NSH_VER_MASK)
>> NSH_VER_SHIFT;
}
static inline u8 nsh_get_flags(const struct nshhdr *nsh)
{
return (ntohs(nsh->ver_flags_ttl_len) & NSH_FLAGS_MASK)
>> NSH_FLAGS_SHIFT;
}
static inline u8 nsh_get_ttl(const struct nshhdr *nsh)
{
return (ntohs(nsh->ver_flags_ttl_len) & NSH_TTL_MASK)
>> NSH_TTL_SHIFT;
}
static inline void __nsh_set_xflag(struct nshhdr *nsh, u16 xflag, u16 xmask)
{
nsh->ver_flags_ttl_len
Annotation
- Immediate include surface: `linux/skbuff.h`.
- Detected declarations: `struct nsh_md1_ctx`, `struct nsh_md2_tlv`, `struct nshhdr`, `function nsh_hdr_len`, `function nsh_get_ver`, `function nsh_get_flags`, `function nsh_get_ttl`, `function __nsh_set_xflag`, `function nsh_set_flags_and_ttl`, `function nsh_set_flags_ttl_len`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
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.