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.

Dependency Surface

Detected Declarations

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

Implementation Notes