__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

[email protected]: ~ $
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __NET_IP_TUNNELS_H
#define __NET_IP_TUNNELS_H 1

#include <linux/if_tunnel.h>
#include <linux/netdevice.h>
#include <linux/skbuff.h>
#include <linux/socket.h>
#include <linux/types.h>
#include <linux/u64_stats_sync.h>
#include <linux/bitops.h>

#include <net/dsfield.h>
#include <net/gro_cells.h>
#include <net/inet_ecn.h>
#include <net/netns/generic.h>
#include <net/rtnetlink.h>
#include <net/lwtunnel.h>
#include <net/dst_cache.h>

#if IS_ENABLED(CONFIG_IPV6)
#include <net/ipv6.h>
#include <net/ip6_fib.h>
#include <net/ip6_route.h>
#endif

/* Keep error state on tunnel for 30 sec */
#define IPTUNNEL_ERR_TIMEO	(30*HZ)

/* Used to memset ip_tunnel padding. */
#define IP_TUNNEL_KEY_SIZE	offsetofend(struct ip_tunnel_key, tp_dst)

/* Used to memset ipv4 address padding. */
#define IP_TUNNEL_KEY_IPV4_PAD	offsetofend(struct ip_tunnel_key, u.ipv4.dst)
#define IP_TUNNEL_KEY_IPV4_PAD_LEN				\
	(sizeof_field(struct ip_tunnel_key, u) -		\
	 sizeof_field(struct ip_tunnel_key, u.ipv4))

#define __ipt_flag_op(op, ...)					\
	op(__VA_ARGS__, __IP_TUNNEL_FLAG_NUM)

#define IP_TUNNEL_DECLARE_FLAGS(...)				\
	__ipt_flag_op(DECLARE_BITMAP, __VA_ARGS__)

#define ip_tunnel_flags_zero(...)	__ipt_flag_op(bitmap_zero, __VA_ARGS__)
#define ip_tunnel_flags_copy(...)	__ipt_flag_op(bitmap_copy, __VA_ARGS__)
#define ip_tunnel_flags_and(...)	__ipt_flag_op(bitmap_and, __VA_ARGS__)
#define ip_tunnel_flags_or(...)		__ipt_flag_op(bitmap_or, __VA_ARGS__)

#define ip_tunnel_flags_empty(...)				\
	__ipt_flag_op(bitmap_empty, __VA_ARGS__)
#define ip_tunnel_flags_intersect(...)				\
	__ipt_flag_op(bitmap_intersects, __VA_ARGS__)
#define ip_tunnel_flags_subset(...)				\
	__ipt_flag_op(bitmap_subset, __VA_ARGS__)

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) + 1)),\
		 struct ip_tunnel_info * : ((void *)((info) + 1))\
	)

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;
};

/* 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;
/* A fan overlay /8 (250.0.0.0/8, for example) maps to exactly one /16
 * underlay (10.88.0.0/16, for example).  Multiple local addresses within
 * the /16 may be used, but a particular overlay may not span
 * multiple underlay subnets.
 *
 * We store one underlay, indexed by the overlay's high order octet.
 */
#define FAN_OVERLAY_CNT		256

struct ip_fan_map {
	__be32			underlay;
	__be32			overlay;
	u16			underlay_prefix;
	u16			overlay_prefix;
	u32			overlay_mask;
	struct list_head	list;
	struct rcu_head		rcu;
};

struct ip_tunnel_fan {
	struct list_head	fan_maps;
};

/* 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;

	struct net_device	*dev;
	netdevice_tracker	dev_tracker;

	struct net		*net;	/* netns for packet i/o */

	unsigned long	err_time;	/* Time when the last ICMP error
					 * arrived */
	int		err_count;	/* Number of arrived ICMP errors */

	/* These four fields used only by GRE */
	u32		i_seqno;	/* The last seen seqno	*/
	atomic_t	o_seqno;	/* The last output seqno */
	int		tun_hlen;	/* Precalculated header length */

	/* These four fields used only by ERSPAN */
	u32		index;		/* ERSPAN type II index */
	u8		erspan_ver;	/* ERSPAN version */
	u8		dir;		/* ERSPAN direction */
	u16		hwid;		/* ERSPAN hardware ID */

	struct dst_cache dst_cache;

	struct ip_tunnel_parm_kern parms;

	int		mlink;
	int		encap_hlen;	/* Encap header length (FOU,GUE) */
	int		hlen;		/* tun_hlen + encap_hlen */
	struct ip_tunnel_encap encap;

	/* for SIT */
#ifdef CONFIG_IPV6_SIT_6RD
	struct ip_tunnel_6rd_parm ip6rd;
#endif
	struct ip_tunnel_prl_entry __rcu *prl;	/* potential router list */
	unsigned int		prl_count;	/* # of entries in PRL */
	struct ip_tunnel_fan	fan;
	unsigned int		ip_tnl_net_id;
	struct gro_cells	gro_cells;
	__u32			fwmark;
	bool			collect_md;
	bool			ignore_df;
};

static inline int fan_has_map(const struct ip_tunnel_fan *fan)
{
	return !list_empty(&fan->fan_maps);
}

struct tnl_ptk_info {
	IP_TUNNEL_DECLARE_FLAGS(flags);
	__be16 proto;
	__be32 key;
	__be32 seq;
	int hdr_len;
};

#define PACKET_RCVD	0
#define PACKET_REJECT	1
#define PACKET_NEXT	2

#define IP_TNL_HASH_BITS   7
#define IP_TNL_HASH_SIZE   (1 << IP_TNL_HASH_BITS)

struct ip_tunnel_net {
	struct net_device *fb_tunnel_dev;
	struct rtnl_link_ops *rtnl_link_ops;
	struct hlist_head tunnels[IP_TNL_HASH_SIZE];
	struct ip_tunnel __rcu *collect_md_tun;
	int type;
};

static inline void ip_tunnel_set_options_present(unsigned long *flags)
{
	IP_TUNNEL_DECLARE_FLAGS(present) = { };

	__set_bit(IP_TUNNEL_GENEVE_OPT_BIT, present);
	__set_bit(IP_TUNNEL_VXLAN_OPT_BIT, present);
	__set_bit(IP_TUNNEL_ERSPAN_OPT_BIT, present);
	__set_bit(IP_TUNNEL_GTP_OPT_BIT, present);
	__set_bit(IP_TUNNEL_PFCP_OPT_BIT, present);

	ip_tunnel_flags_or(flags, flags, present);
}

static inline void ip_tunnel_clear_options_present(unsigned long *flags)
{
	IP_TUNNEL_DECLARE_FLAGS(present) = { };

	__set_bit(IP_TUNNEL_GENEVE_OPT_BIT, present);
	__set_bit(IP_TUNNEL_VXLAN_OPT_BIT, present);
	__set_bit(IP_TUNNEL_ERSPAN_OPT_BIT, present);
	__set_bit(IP_TUNNEL_GTP_OPT_BIT, present);
	__set_bit(IP_TUNNEL_PFCP_OPT_BIT, present);

	__ipt_flag_op(bitmap_andnot, flags, flags, present);
}

static inline bool ip_tunnel_is_options_present(const unsigned long *flags)
{
	IP_TUNNEL_DECLARE_FLAGS(present) = { };

	__set_bit(IP_TUNNEL_GENEVE_OPT_BIT, present);
	__set_bit(IP_TUNNEL_VXLAN_OPT_BIT, present);
	__set_bit(IP_TUNNEL_ERSPAN_OPT_BIT, present);
	__set_bit(IP_TUNNEL_GTP_OPT_BIT, present);
	__set_bit(IP_TUNNEL_PFCP_OPT_BIT, present);

	return ip_tunnel_flags_intersect(flags, present);
}

static inline bool ip_tunnel_flags_is_be16_compat(const unsigned long *flags)
{
	IP_TUNNEL_DECLARE_FLAGS(supp) = { };

	bitmap_set(supp, 0, BITS_PER_TYPE(__be16));
	__set_bit(IP_TUNNEL_VTI_BIT, supp);

	return ip_tunnel_flags_subset(flags, supp);
}

static inline void ip_tunnel_flags_from_be16(unsigned long *dst, __be16 flags)
{
	ip_tunnel_flags_zero(dst);

	bitmap_write(dst, be16_to_cpu(flags), 0, BITS_PER_TYPE(__be16));
	__assign_bit(IP_TUNNEL_VTI_BIT, dst, flags & VTI_ISVTI);
}

static inline __be16 ip_tunnel_flags_to_be16(const unsigned long *flags)
{
	__be16 ret;

	ret = cpu_to_be16(bitmap_read(flags, 0, BITS_PER_TYPE(__be16)));
	if (test_bit(IP_TUNNEL_VTI_BIT, flags))
		ret |= VTI_ISVTI;

	return ret;
}

static inline void ip_tunnel_key_init(struct ip_tunnel_key *key,
				      __be32 saddr, __be32 daddr,
				      u8 tos, u8 ttl, __be32 label,
				      __be16 tp_src, __be16 tp_dst,
				      __be64 tun_id,
				      const unsigned long *tun_flags)
{
	key->tun_id = tun_id;
	key->u.ipv4.src = saddr;
	key->u.ipv4.dst = daddr;
	memset((unsigned char *)key + IP_TUNNEL_KEY_IPV4_PAD,
	       0, IP_TUNNEL_KEY_IPV4_PAD_LEN);
	key->tos = tos;
	key->ttl = ttl;
	key->label = label;
	ip_tunnel_flags_copy(key->tun_flags, tun_flags);

	/* For the tunnel types on the top of IPsec, the tp_src and tp_dst of
	 * the upper tunnel are used.
	 * E.g: GRE over IPSEC, the tp_src and tp_port are zero.
	 */
	key->tp_src = tp_src;
	key->tp_dst = tp_dst;

	/* Clear struct padding. */
	if (sizeof(*key) != IP_TUNNEL_KEY_SIZE)
		memset((unsigned char *)key + IP_TUNNEL_KEY_SIZE,
		       0, sizeof(*key) - IP_TUNNEL_KEY_SIZE);
}

static inline bool
ip_tunnel_dst_cache_usable(const struct sk_buff *skb,
			   const struct ip_tunnel_info *info)
{
	if (skb->mark)
		return false;

	return !info || !test_bit(IP_TUNNEL_NOCACHE_BIT, info->key.tun_flags);
}

static inline unsigned short ip_tunnel_info_af(const struct ip_tunnel_info
					       *tun_info)
{
	return tun_info->mode & IP_TUNNEL_INFO_IPV6 ? AF_INET6 : AF_INET;
}

static inline __be64 key32_to_tunnel_id(__be32 key)
{
#ifdef __BIG_ENDIAN
	return (__force __be64)key;
#else
	return (__force __be64)((__force u64)key << 32);
#endif
}

/* Returns the least-significant 32 bits of a __be64. */
static inline __be32 tunnel_id_to_key32(__be64 tun_id)
{
#ifdef __BIG_ENDIAN
	return (__force __be32)tun_id;
#else
	return (__force __be32)((__force u64)tun_id >> 32);
#endif
}

#ifdef CONFIG_INET

static inline void ip_tunnel_init_flow(struct flowi4 *fl4,
				       int proto,
				       __be32 daddr, __be32 saddr,
				       __be32 key, __u8 tos,
				       struct net *net, int oif,
				       __u32 mark, __u32 tun_inner_hash,
				       __u8 flow_flags)
{
	memset(fl4, 0, sizeof(*fl4));

	if (oif) {
		fl4->flowi4_l3mdev = l3mdev_master_upper_ifindex_by_index(net, oif);
		/* Legacy VRF/l3mdev use case */
		fl4->flowi4_oif = fl4->flowi4_l3mdev ? 0 : oif;
	}

	fl4->daddr = daddr;
	fl4->saddr = saddr;
	fl4->flowi4_tos = tos;
	fl4->flowi4_proto = proto;
	fl4->fl4_gre_key = key;
	fl4->flowi4_mark = mark;
	fl4->flowi4_multipath_hash = tun_inner_hash;
	fl4->flowi4_flags = flow_flags;
}

int ip_tunnel_init(struct net_device *dev);
void ip_tunnel_uninit(struct net_device *dev);
void  ip_tunnel_dellink(struct net_device *dev, struct list_head *head);
struct net *ip_tunnel_get_link_net(const struct net_device *dev);
int ip_tunnel_get_iflink(const struct net_device *dev);
int ip_tunnel_init_net(struct net *net, unsigned int ip_tnl_net_id,
		       struct rtnl_link_ops *ops, char *devname);

void ip_tunnel_delete_nets(struct list_head *list_net, unsigned int id,
			   struct rtnl_link_ops *ops,
			   struct list_head *dev_to_kill);

void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
		    const struct iphdr *tnl_params, const u8 protocol);
void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
		       const u8 proto, int tunnel_hlen);
int ip_tunnel_ctl(struct net_device *dev, struct ip_tunnel_parm_kern *p,
		  int cmd);
bool ip_tunnel_parm_from_user(struct ip_tunnel_parm_kern *kp,
			      const void __user *data);
bool ip_tunnel_parm_to_user(void __user *data, struct ip_tunnel_parm_kern *kp);
int ip_tunnel_siocdevprivate(struct net_device *dev, struct ifreq *ifr,
			     void __user *data, int cmd);
int __ip_tunnel_change_mtu(struct net_device *dev, int new_mtu, bool strict);
int ip_tunnel_change_mtu(struct net_device *dev, int new_mtu);

struct ip_tunnel *ip_tunnel_lookup(struct ip_tunnel_net *itn,
				   int link, const unsigned long *flags,
				   __be32 remote, __be32 local,
				   __be32 key);

void ip_tunnel_md_udp_encap(struct sk_buff *skb, struct ip_tunnel_info *info);
int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,
		  const struct tnl_ptk_info *tpi, struct metadata_dst *tun_dst,
		  bool log_ecn_error);
int ip_tunnel_changelink(struct net_device *dev, struct nlattr *tb[],
			 struct ip_tunnel_parm_kern *p, __u32 fwmark);
int ip_tunnel_newlink(struct net_device *dev, struct nlattr *tb[],
		      struct ip_tunnel_parm_kern *p, __u32 fwmark);
void ip_tunnel_setup(struct net_device *dev, unsigned int net_id);

bool ip_tunnel_netlink_encap_parms(struct nlattr *data[],
				   struct ip_tunnel_encap *encap);

void ip_tunnel_netlink_parms(struct nlattr *data[],
			     struct ip_tunnel_parm_kern *parms);

extern const struct header_ops ip_tunnel_header_ops;
__be16 ip_tunnel_parse_protocol(const struct sk_buff *skb);

struct ip_tunnel_encap_ops {
	size_t (*encap_hlen)(struct ip_tunnel_encap *e);
	int (*build_header)(struct sk_buff *skb, struct ip_tunnel_encap *e,
			    u8 *protocol, struct flowi4 *fl4);
	int (*err_handler)(struct sk_buff *skb, u32 info);
};

#define MAX_IPTUN_ENCAP_OPS 8

extern const struct ip_tunnel_encap_ops __rcu *
		iptun_encaps[MAX_IPTUN_ENCAP_OPS];

int ip_tunnel_encap_add_ops(const struct ip_tunnel_encap_ops *op,
			    unsigned int num);
int ip_tunnel_encap_del_ops(const struct ip_tunnel_encap_ops *op,
			    unsigned int num);

int ip_tunnel_encap_setup(struct ip_tunnel *t,
			  struct ip_tunnel_encap *ipencap);

static inline enum skb_drop_reason
pskb_inet_may_pull_reason(struct sk_buff *skb)
{
	int nhlen;

	switch (skb->protocol) {
#if IS_ENABLED(CONFIG_IPV6)
	case htons(ETH_P_IPV6):
		nhlen = sizeof(struct ipv6hdr);
		break;
#endif
	case htons(ETH_P_IP):
		nhlen = sizeof(struct iphdr);
		break;
	default:
		nhlen = 0;
	}

	return pskb_network_may_pull_reason(skb, nhlen);
}

static inline bool pskb_inet_may_pull(struct sk_buff *skb)
{
	return pskb_inet_may_pull_reason(skb) == SKB_NOT_DROPPED_YET;
}

/* Variant of pskb_inet_may_pull().
 */
static inline enum skb_drop_reason
skb_vlan_inet_prepare(struct sk_buff *skb, bool inner_proto_inherit)
{
	int nhlen = 0, maclen = inner_proto_inherit ? 0 : ETH_HLEN;
	__be16 type = skb->protocol;
	enum skb_drop_reason reason;

	/* Essentially this is skb_protocol(skb, true)
	 * And we get MAC len.
	 */
	if (eth_type_vlan(type))
		type = __vlan_get_protocol(skb, type, &maclen);

	switch (type) {
#if IS_ENABLED(CONFIG_IPV6)
	case htons(ETH_P_IPV6):
		nhlen = sizeof(struct ipv6hdr);
		break;
#endif
	case htons(ETH_P_IP):
		nhlen = sizeof(struct iphdr);
		break;
	}
	/* For ETH_P_IPV6/ETH_P_IP we make sure to pull
	 * a base network header in skb->head.
	 */
	reason = pskb_may_pull_reason(skb, maclen + nhlen);
	if (reason)
		return reason;

	skb_set_network_header(skb, maclen);

	return SKB_NOT_DROPPED_YET;
}

static inline int ip_encap_hlen(struct ip_tunnel_encap *e)
{
	const struct ip_tunnel_encap_ops *ops;
	int hlen = -EINVAL;

	if (e->type == TUNNEL_ENCAP_NONE)
		return 0;

	if (e->type >= MAX_IPTUN_ENCAP_OPS)
		return -EINVAL;

	rcu_read_lock();
	ops = rcu_dereference(iptun_encaps[e->type]);
	if (likely(ops && ops->encap_hlen))
		hlen = ops->encap_hlen(e);
	rcu_read_unlock();

	return hlen;
}

static inline int ip_tunnel_encap(struct sk_buff *skb,
				  struct ip_tunnel_encap *e,
				  u8 *protocol, struct flowi4 *fl4)
{
	const struct ip_tunnel_encap_ops *ops;
	int ret = -EINVAL;

	if (e->type == TUNNEL_ENCAP_NONE)
		return 0;

	if (e->type >= MAX_IPTUN_ENCAP_OPS)
		return -EINVAL;

	rcu_read_lock();
	ops = rcu_dereference(iptun_encaps[e->type]);
	if (likely(ops && ops->build_header))
		ret = ops->build_header(skb, e, protocol, fl4);
	rcu_read_unlock();

	return ret;
}

/* Extract dsfield from inner protocol */
static inline u8 ip_tunnel_get_dsfield(const struct iphdr *iph,
				       const struct sk_buff *skb)
{
	__be16 payload_protocol = skb_protocol(skb, true);

	if (payload_protocol == htons(ETH_P_IP))
		return iph->tos;
	else if (payload_protocol == htons(ETH_P_IPV6))
		return ipv6_get_dsfield((const struct ipv6hdr *)iph);
	else
		return 0;
}

static inline __be32 ip_tunnel_get_flowlabel(const struct iphdr *iph,
					     const struct sk_buff *skb)
{
	__be16 payload_protocol = skb_protocol(skb, true);

	if (payload_protocol == htons(ETH_P_IPV6))
		return ip6_flowlabel((const struct ipv6hdr *)iph);
	else
		return 0;
}

static inline u8 ip_tunnel_get_ttl(const struct iphdr *iph,
				       const struct sk_buff *skb)
{
	__be16 payload_protocol = skb_protocol(skb, true);

	if (payload_protocol == htons(ETH_P_IP))
		return iph->ttl;
	else if (payload_protocol == htons(ETH_P_IPV6))
		return ((const struct ipv6hdr *)iph)->hop_limit;
	else
		return 0;
}

/* Propagate ECN bits out */
static inline u8 ip_tunnel_ecn_encap(u8 tos, const struct iphdr *iph,
				     const struct sk_buff *skb)
{
	u8 inner = ip_tunnel_get_dsfield(iph, skb);

	return INET_ECN_encapsulate(tos, inner);
}

int __iptunnel_pull_header(struct sk_buff *skb, int hdr_len,
			   __be16 inner_proto, bool raw_proto, bool xnet);

static inline int iptunnel_pull_header(struct sk_buff *skb, int hdr_len,
				       __be16 inner_proto, bool xnet)
{
	return __iptunnel_pull_header(skb, hdr_len, inner_proto, false, xnet);
}

void iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb,
		   __be32 src, __be32 dst, u8 proto,
		   u8 tos, u8 ttl, __be16 df, bool xnet);
struct metadata_dst *iptunnel_metadata_reply(struct metadata_dst *md,
					     gfp_t flags);
int skb_tunnel_check_pmtu(struct sk_buff *skb, struct dst_entry *encap_dst,
			  int headroom, bool reply);

int iptunnel_handle_offloads(struct sk_buff *skb, int gso_type_mask);

static inline int iptunnel_pull_offloads(struct sk_buff *skb)
{
	if (skb_is_gso(skb)) {
		int err;

		err = skb_unclone(skb, GFP_ATOMIC);
		if (unlikely(err))
			return err;
		skb_shinfo(skb)->gso_type &= ~(NETIF_F_GSO_ENCAP_ALL >>
					       NETIF_F_GSO_SHIFT);
	}

	skb->encapsulation = 0;
	return 0;
}

static inline void iptunnel_xmit_stats(struct net_device *dev, int pkt_len)
{
	if (pkt_len > 0) {
		struct pcpu_sw_netstats *tstats = get_cpu_ptr(dev->tstats);

		u64_stats_update_begin(&tstats->syncp);
		u64_stats_add(&tstats->tx_bytes, pkt_len);
		u64_stats_inc(&tstats->tx_packets);
		u64_stats_update_end(&tstats->syncp);
		put_cpu_ptr(tstats);
		return;
	}

	if (pkt_len < 0) {
		DEV_STATS_INC(dev, tx_errors);
		DEV_STATS_INC(dev, tx_aborted_errors);
	} else {
		DEV_STATS_INC(dev, tx_dropped);
	}
}

static inline void ip_tunnel_info_opts_get(void *to,
					   const struct ip_tunnel_info *info)
{
	memcpy(to, info + 1, info->options_len);
}

static inline void ip_tunnel_info_opts_set(struct ip_tunnel_info *info,
					   const void *from, int len,
					   const unsigned long *flags)
{
	info->options_len = len;
	if (len > 0) {
		memcpy(ip_tunnel_info_opts(info), from, len);
		ip_tunnel_flags_or(info->key.tun_flags, info->key.tun_flags,
				   flags);
	}
}

static inline struct ip_tunnel_info *lwt_tun_info(struct lwtunnel_state *lwtstate)
{
	return (struct ip_tunnel_info *)lwtstate->data;
}

DECLARE_STATIC_KEY_FALSE(ip_tunnel_metadata_cnt);

/* Returns > 0 if metadata should be collected */
static inline int ip_tunnel_collect_metadata(void)
{
	return static_branch_unlikely(&ip_tunnel_metadata_cnt);
}

void __init ip_tunnel_core_init(void);

void ip_tunnel_need_metadata(void);
void ip_tunnel_unneed_metadata(void);

#else /* CONFIG_INET */

static inline struct ip_tunnel_info *lwt_tun_info(struct lwtunnel_state *lwtstate)
{
	return NULL;
}

static inline void ip_tunnel_need_metadata(void)
{
}

static inline void ip_tunnel_unneed_metadata(void)
{
}

static inline void ip_tunnel_info_opts_get(void *to,
					   const struct ip_tunnel_info *info)
{
}

static inline void ip_tunnel_info_opts_set(struct ip_tunnel_info *info,
					   const void *from, int len,
					   const unsigned long *flags)
{
	info->options_len = 0;
}

#endif /* CONFIG_INET */

#endif /* __NET_IP_TUNNELS_H */

Filemanager

Name Type Size Permission Actions
9p Folder 0755
bluetooth Folder 0755
caif Folder 0755
iucv Folder 0755
libeth Folder 0755
mana Folder 0755
netfilter Folder 0755
netns Folder 0755
nfc Folder 0755
page_pool Folder 0755
phonet Folder 0755
sctp Folder 0755
tc_act Folder 0755
6lowpan.h File 10.03 KB 0644
Space.h File 455 B 0644
act_api.h File 9.31 KB 0644
addrconf.h File 15.1 KB 0644
af_ieee802154.h File 1.19 KB 0644
af_rxrpc.h File 3.3 KB 0644
af_unix.h File 3.25 KB 0644
af_vsock.h File 8.48 KB 0644
ah.h File 382 B 0644
amt.h File 8.35 KB 0644
arp.h File 1.95 KB 0644
atmclip.h File 1.48 KB 0644
ax25.h File 14.93 KB 0644
ax88796.h File 1.43 KB 0644
bareudp.h File 333 B 0644
bond_3ad.h File 9.45 KB 0644
bond_alb.h File 6.11 KB 0644
bond_options.h File 4.83 KB 0644
bonding.h File 21.34 KB 0644
bpf_sk_storage.h File 1.74 KB 0644
busy_poll.h File 4.33 KB 0644
calipso.h File 1.55 KB 0644
cfg80211-wext.h File 1.86 KB 0644
cfg80211.h File 345.53 KB 0644
cfg802154.h File 16.68 KB 0644
checksum.h File 5.11 KB 0644
cipso_ipv4.h File 7.42 KB 0644
cls_cgroup.h File 2.04 KB 0644
codel.h File 5.86 KB 0644
codel_impl.h File 8.3 KB 0644
codel_qdisc.h File 2.95 KB 0644
compat.h File 2.48 KB 0644
datalink.h File 590 B 0644
dcbevent.h File 766 B 0644
dcbnl.h File 4.98 KB 0644
devlink.h File 72.01 KB 0644
dropreason-core.h File 18.44 KB 0644
dropreason.h File 1.18 KB 0644
dsa.h File 40.96 KB 0644
dsa_stubs.h File 1.28 KB 0644
dscp.h File 3.18 KB 0644
dsfield.h File 1.12 KB 0644
dst.h File 14.76 KB 0644
dst_cache.h File 2.97 KB 0644
dst_metadata.h File 6.56 KB 0644
dst_ops.h File 2.07 KB 0644
eee.h File 832 B 0644
erspan.h File 9.03 KB 0644
esp.h File 1.18 KB 0644
espintcp.h File 972 B 0644
ethoc.h File 439 B 0644
failover.h File 1.18 KB 0644
fib_notifier.h File 1.36 KB 0644
fib_rules.h File 5.39 KB 0644
firewire.h File 599 B 0644
flow.h File 4.96 KB 0644
flow_dissector.h File 12.65 KB 0644
flow_offload.h File 20.18 KB 0644
fou.h File 578 B 0644
fq.h File 2.41 KB 0644
fq_impl.h File 7.96 KB 0644
garp.h File 2.67 KB 0644
gen_stats.h File 2.99 KB 0644
genetlink.h File 20.23 KB 0644
geneve.h File 1.84 KB 0644
gre.h File 3.79 KB 0644
gro.h File 15.56 KB 0644
gro_cells.h File 443 B 0644
gso.h File 3.2 KB 0644
gtp.h File 1.51 KB 0644
gue.h File 3.29 KB 0644
handshake.h File 1.39 KB 0644
hotdata.h File 1.62 KB 0644
hwbm.h File 997 B 0644
icmp.h File 1.87 KB 0644
ieee80211_radiotap.h File 23.25 KB 0644
ieee802154_netdev.h File 13.02 KB 0644
ieee8021q.h File 1.42 KB 0644
if_inet6.h File 6.62 KB 0644
ife.h File 1.03 KB 0644
inet6_connection_sock.h File 794 B 0644
inet6_hashtables.h File 5.57 KB 0644
inet_common.h File 2.83 KB 0644
inet_connection_sock.h File 11.77 KB 0644
inet_dscp.h File 1.55 KB 0644
inet_ecn.h File 7.83 KB 0644
inet_frag.h File 5.25 KB 0644
inet_hashtables.h File 16.6 KB 0644
inet_sock.h File 11.77 KB 0644
inet_timewait_sock.h File 3.79 KB 0644
inetpeer.h File 3.23 KB 0644
ioam6.h File 1.33 KB 0644
ip.h File 23.37 KB 0644
ip6_checksum.h File 2.3 KB 0644
ip6_fib.h File 17.08 KB 0644
ip6_route.h File 10.21 KB 0644
ip6_tunnel.h File 5.04 KB 0644
ip_fib.h File 17.36 KB 0644
ip_tunnels.h File 19.36 KB 0644
ip_vs.h File 53.83 KB 0644
ipcomp.h File 737 B 0644
ipconfig.h File 837 B 0644
ipv6.h File 37.89 KB 0644
ipv6_frag.h File 3.38 KB 0644
ipv6_stubs.h File 3.92 KB 0644
iw_handler.h File 18.97 KB 0644
kcm.h File 4.84 KB 0644
l3mdev.h File 7.03 KB 0644
lag.h File 409 B 0644
lapb.h File 4.82 KB 0644
llc.h File 4.41 KB 0644
llc_c_ac.h File 9.32 KB 0644
llc_c_ev.h File 10.61 KB 0644
llc_c_st.h File 1.78 KB 0644
llc_conn.h File 4.11 KB 0644
llc_if.h File 2.17 KB 0644
llc_pdu.h File 14.46 KB 0644
llc_s_ac.h File 1.59 KB 0644
llc_s_ev.h File 2.22 KB 0644
llc_s_st.h File 1.03 KB 0644
llc_sap.h File 1.08 KB 0644
lwtunnel.h File 6.69 KB 0644
mac80211.h File 303.91 KB 0644
mac802154.h File 14.88 KB 0644
macsec.h File 10.53 KB 0644
mctp.h File 8.67 KB 0644
mctpdevice.h File 1.33 KB 0644
mip6.h File 1016 B 0644
mld.h File 2.85 KB 0644
mpls.h File 943 B 0644
mpls_iptunnel.h File 481 B 0644
mptcp.h File 7.65 KB 0644
mrp.h File 3.13 KB 0644
ncsi.h File 1.94 KB 0644
ndisc.h File 14.14 KB 0644
neighbour.h File 16.64 KB 0644
neighbour_tables.h File 253 B 0644
net_debug.h File 5.23 KB 0644
net_failover.h File 1023 B 0644
net_namespace.h File 14.51 KB 0644
net_ratelimit.h File 220 B 0644
net_shaper.h File 3.49 KB 0644
net_trackers.h File 424 B 0644
netdev_queues.h File 10.38 KB 0644
netdev_rx_queue.h File 1.44 KB 0644
netevent.h File 1.04 KB 0644
netkit.h File 1.16 KB 0644
netlabel.h File 20.57 KB 0644
netlink.h File 72.67 KB 0644
netmem.h File 6.69 KB 0644
netprio_cgroup.h File 1.02 KB 0644
netrom.h File 7.73 KB 0644
nexthop.h File 12.68 KB 0644
nl802154.h File 16.04 KB 0644
nsh.h File 12.3 KB 0644
p8022.h File 403 B 0644
pfcp.h File 1.91 KB 0644
pie.h File 3.6 KB 0644
ping.h File 2.66 KB 0644
pkt_cls.h File 25.99 KB 0644
pkt_sched.h File 7.4 KB 0644
pptp.h File 604 B 0644
proto_memory.h File 1.9 KB 0644
protocol.h File 3.85 KB 0644
psample.h File 1.15 KB 0644
psnap.h File 430 B 0644
raw.h File 2.46 KB 0644
rawv6.h File 862 B 0644
red.h File 11.39 KB 0644
regulatory.h File 9.88 KB 0644
request_sock.h File 7.25 KB 0644
rose.h File 7.71 KB 0644
route.h File 11.89 KB 0644
rpl.h File 749 B 0644
rps.h File 3.91 KB 0644
rsi_91x.h File 1.67 KB 0644
rstreason.h File 7.22 KB 0644
rtnetlink.h File 8.06 KB 0644
rtnh.h File 859 B 0644
sch_generic.h File 34.42 KB 0644
scm.h File 5.36 KB 0644
secure_seq.h File 868 B 0644
seg6.h File 2.43 KB 0644
seg6_hmac.h File 1.7 KB 0644
seg6_local.h File 667 B 0644
selftests.h File 582 B 0644
slhc_vj.h File 6.67 KB 0644
smc.h File 2.41 KB 0644
snmp.h File 5.14 KB 0644
sock.h File 84.05 KB 0644
sock_reuseport.h File 1.82 KB 0644
stp.h File 412 B 0644
strparser.h File 4.34 KB 0644
switchdev.h File 15.1 KB 0644
tc_wrapper.h File 6.29 KB 0644
tcp.h File 84.45 KB 0644
tcp_ao.h File 11.15 KB 0644
tcp_states.h File 1.3 KB 0644
tcx.h File 4.39 KB 0644
timewait_sock.h File 641 B 0644
tipc.h File 2.35 KB 0644
tls.h File 13.37 KB 0644
tls_prot.h File 1.84 KB 0644
tls_toe.h File 2.94 KB 0644
transp_v6.h File 1.88 KB 0644
tso.h File 721 B 0644
tun_proto.h File 1015 B 0644
udp.h File 18.83 KB 0644
udp_tunnel.h File 12.49 KB 0644
udplite.h File 2.3 KB 0644
vsock_addr.h File 662 B 0644
vxlan.h File 15.86 KB 0644
wext.h File 1.47 KB 0644
x25.h File 9.46 KB 0644
x25device.h File 387 B 0644
xdp.h File 19.73 KB 0644
xdp_priv.h File 427 B 0644
xdp_sock.h File 6.64 KB 0644
xdp_sock_drv.h File 9.28 KB 0644
xfrm.h File 62.99 KB 0644
xsk_buff_pool.h File 7.04 KB 0644
Filemanager