include/net/ip_tunnels.h
Source file repositories/reference/linux-study-clean/include/net/ip_tunnels.h
File Facts
- System
- Linux kernel
- Corpus path
include/net/ip_tunnels.h- Extension
.h- Size
- 20762 bytes
- Lines
- 768
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/if_tunnel.hlinux/netdevice.hlinux/skbuff.hlinux/socket.hlinux/types.hlinux/u64_stats_sync.hlinux/bitops.hnet/dsfield.hnet/flow.hnet/gro_cells.hnet/inet_dscp.hnet/inet_ecn.hnet/netns/generic.hnet/rtnetlink.hnet/lwtunnel.hnet/dst_cache.hnet/netdev_lock.hnet/ipv6.hnet/ip6_fib.hnet/ip6_route.h
Detected Declarations
struct ip_tunnel_keystruct ip_tunnel_encapstruct ip_tunnel_infostruct ip_tunnel_6rd_parmstruct ip_tunnel_prl_entrystruct metadata_dststruct ip_tunnel_parm_kernstruct ip_tunnelstruct tnl_ptk_infostruct ip_tunnel_netstruct ip_tunnel_encap_opsfunction ip_tunnel_set_options_presentfunction ip_tunnel_clear_options_presentfunction ip_tunnel_is_options_presentfunction ip_tunnel_flags_is_be16_compatfunction ip_tunnel_flags_from_be16function ip_tunnel_flags_to_be16function ip_tunnel_key_initfunction ip_tunnel_dst_cache_usablefunction ip_tunnel_info_affunction key32_to_tunnel_idfunction tunnel_id_to_key32function ip_tunnel_init_flowfunction pskb_inet_may_pull_reasonfunction pskb_inet_may_pullfunction skb_vlan_inet_preparefunction ip_encap_hlenfunction ip_tunnel_encapfunction ip_tunnel_get_dsfieldfunction ip_tunnel_get_flowlabelfunction ip_tunnel_get_ttlfunction ip_tunnel_ecn_encapfunction iptunnel_pull_headerfunction ip_tunnel_adj_headroomfunction iptunnel_pull_offloadsfunction iptunnel_xmit_statsfunction ip_tunnel_info_opts_getfunction ip_tunnel_info_opts_setfunction ip_tunnel_collect_metadatafunction ip_tunnel_need_metadata
Annotated Snippet
struct ip_tunnel_key {
__be64 tun_id;
union {
struct {
__be32 src;
__be32 dst;
} ipv4;
struct {
struct in6_addr src;
struct in6_addr dst;
} ipv6;
} u;
IP_TUNNEL_DECLARE_FLAGS(tun_flags);
__be32 label; /* Flow Label for IPv6 */
u32 nhid;
u8 tos; /* TOS for IPv4, TC for IPv6 */
u8 ttl; /* TTL for IPv4, HL for IPv6 */
__be16 tp_src;
__be16 tp_dst;
__u8 flow_flags;
};
struct ip_tunnel_encap {
u16 type;
u16 flags;
__be16 sport;
__be16 dport;
};
/* Flags for ip_tunnel_info mode. */
#define IP_TUNNEL_INFO_TX 0x01 /* represents tx tunnel parameters */
#define IP_TUNNEL_INFO_IPV6 0x02 /* key contains IPv6 addresses */
#define IP_TUNNEL_INFO_BRIDGE 0x04 /* represents a bridged tunnel id */
/* Maximum tunnel options length. */
#define IP_TUNNEL_OPTS_MAX \
GENMASK((sizeof_field(struct ip_tunnel_info, \
options_len) * BITS_PER_BYTE) - 1, 0)
#define ip_tunnel_info_opts(info) \
_Generic(info, \
const struct ip_tunnel_info * : ((const void *)(info)->options),\
struct ip_tunnel_info * : ((void *)(info)->options)\
)
struct ip_tunnel_info {
struct ip_tunnel_key key;
struct ip_tunnel_encap encap;
#ifdef CONFIG_DST_CACHE
struct dst_cache dst_cache;
#endif
u8 options_len;
u8 mode;
u8 options[] __aligned_largest __counted_by(options_len);
};
/* 6rd prefix/relay information */
#ifdef CONFIG_IPV6_SIT_6RD
struct ip_tunnel_6rd_parm {
struct in6_addr prefix;
__be32 relay_prefix;
u16 prefixlen;
u16 relay_prefixlen;
};
#endif
struct ip_tunnel_prl_entry {
struct ip_tunnel_prl_entry __rcu *next;
__be32 addr;
u16 flags;
struct rcu_head rcu_head;
};
struct metadata_dst;
/* Kernel-side variant of ip_tunnel_parm */
struct ip_tunnel_parm_kern {
char name[IFNAMSIZ];
IP_TUNNEL_DECLARE_FLAGS(i_flags);
IP_TUNNEL_DECLARE_FLAGS(o_flags);
__be32 i_key;
__be32 o_key;
int link;
struct iphdr iph;
};
struct ip_tunnel {
struct ip_tunnel __rcu *next;
struct hlist_node hash_node;
Annotation
- Immediate include surface: `linux/if_tunnel.h`, `linux/netdevice.h`, `linux/skbuff.h`, `linux/socket.h`, `linux/types.h`, `linux/u64_stats_sync.h`, `linux/bitops.h`, `net/dsfield.h`.
- Detected declarations: `struct ip_tunnel_key`, `struct ip_tunnel_encap`, `struct ip_tunnel_info`, `struct ip_tunnel_6rd_parm`, `struct ip_tunnel_prl_entry`, `struct metadata_dst`, `struct ip_tunnel_parm_kern`, `struct ip_tunnel`, `struct tnl_ptk_info`, `struct ip_tunnel_net`.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.