include/net/lwtunnel.h
Source file repositories/reference/linux-study-clean/include/net/lwtunnel.h
File Facts
- System
- Linux kernel
- Corpus path
include/net/lwtunnel.h- Extension
.h- Size
- 6851 bytes
- Lines
- 271
- 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/lwtunnel.hlinux/netdevice.hlinux/skbuff.hlinux/types.hnet/route.h
Detected Declarations
struct lwtunnel_statestruct lwtunnel_encap_opsfunction lwtstate_getfunction lwtstate_putfunction lwtunnel_output_redirectfunction lwtunnel_input_redirectfunction lwtunnel_xmit_redirectfunction lwtunnel_headroomfunction lwtunnel_set_redirectfunction lwtstate_freefunction lwtstate_putfunction lwtunnel_input_redirectfunction lwtunnel_xmit_redirectfunction lwtunnel_set_redirectfunction lwtunnel_encap_add_opsfunction lwtunnel_encap_del_opsfunction lwtunnel_valid_encap_typefunction lwtunnel_valid_encap_type_attrfunction lwtunnel_build_statefunction lwtunnel_fill_encapfunction lwtunnel_get_encap_sizefunction lwtunnel_cmp_encapfunction lwtunnel_outputfunction lwtunnel_inputfunction lwtunnel_xmit
Annotated Snippet
struct lwtunnel_state {
__u16 type;
__u16 flags;
__u16 headroom;
atomic_t refcnt;
int (*orig_output)(struct net *net, struct sock *sk, struct sk_buff *skb);
int (*orig_input)(struct sk_buff *);
struct rcu_head rcu;
__u8 data[];
};
struct lwtunnel_encap_ops {
int (*build_state)(struct net *net, struct nlattr *encap,
unsigned int family, const void *cfg,
struct lwtunnel_state **ts,
struct netlink_ext_ack *extack);
void (*destroy_state)(struct lwtunnel_state *lws);
int (*output)(struct net *net, struct sock *sk, struct sk_buff *skb);
int (*input)(struct sk_buff *skb);
int (*fill_encap)(struct sk_buff *skb,
struct lwtunnel_state *lwtstate);
int (*get_encap_size)(struct lwtunnel_state *lwtstate);
int (*cmp_encap)(struct lwtunnel_state *a, struct lwtunnel_state *b);
int (*xmit)(struct sk_buff *skb);
struct module *owner;
};
#ifdef CONFIG_LWTUNNEL
DECLARE_STATIC_KEY_FALSE(nf_hooks_lwtunnel_enabled);
void lwtstate_free(struct lwtunnel_state *lws);
static inline struct lwtunnel_state *
lwtstate_get(struct lwtunnel_state *lws)
{
if (lws)
atomic_inc(&lws->refcnt);
return lws;
}
static inline void lwtstate_put(struct lwtunnel_state *lws)
{
if (!lws)
return;
if (atomic_dec_and_test(&lws->refcnt))
lwtstate_free(lws);
}
static inline bool lwtunnel_output_redirect(struct lwtunnel_state *lwtstate)
{
if (lwtstate && (lwtstate->flags & LWTUNNEL_STATE_OUTPUT_REDIRECT))
return true;
return false;
}
static inline bool lwtunnel_input_redirect(struct lwtunnel_state *lwtstate)
{
if (lwtstate && (lwtstate->flags & LWTUNNEL_STATE_INPUT_REDIRECT))
return true;
return false;
}
static inline bool lwtunnel_xmit_redirect(struct lwtunnel_state *lwtstate)
{
if (lwtstate && (lwtstate->flags & LWTUNNEL_STATE_XMIT_REDIRECT))
return true;
return false;
}
static inline unsigned int lwtunnel_headroom(struct lwtunnel_state *lwtstate,
unsigned int mtu)
{
if ((lwtunnel_xmit_redirect(lwtstate) ||
lwtunnel_output_redirect(lwtstate)) && lwtstate->headroom < mtu)
return lwtstate->headroom;
return 0;
}
int lwtunnel_encap_add_ops(const struct lwtunnel_encap_ops *op,
unsigned int num);
int lwtunnel_encap_del_ops(const struct lwtunnel_encap_ops *op,
unsigned int num);
Annotation
- Immediate include surface: `linux/lwtunnel.h`, `linux/netdevice.h`, `linux/skbuff.h`, `linux/types.h`, `net/route.h`.
- Detected declarations: `struct lwtunnel_state`, `struct lwtunnel_encap_ops`, `function lwtstate_get`, `function lwtstate_put`, `function lwtunnel_output_redirect`, `function lwtunnel_input_redirect`, `function lwtunnel_xmit_redirect`, `function lwtunnel_headroom`, `function lwtunnel_set_redirect`, `function lwtstate_free`.
- 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.