net/mpls/internal.h

Source file repositories/reference/linux-study-clean/net/mpls/internal.h

File Facts

System
Linux kernel
Corpus path
net/mpls/internal.h
Extension
.h
Size
5826 bytes
Lines
216
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 mpls_entry_decoded {
	u32 label;
	u8 ttl;
	u8 tc;
	u8 bos;
};

struct mpls_pcpu_stats {
	struct mpls_link_stats	stats;
	struct u64_stats_sync	syncp;
};

struct mpls_dev {
	int				input_enabled;
	struct net_device		*dev;
	struct mpls_pcpu_stats __percpu	*stats;

	struct ctl_table_header		*sysctl;
	struct rcu_head			rcu;
};

#if BITS_PER_LONG == 32

#define MPLS_INC_STATS_LEN(mdev, len, pkts_field, bytes_field)		\
	do {								\
		TYPEOF_UNQUAL(*(mdev)->stats) *ptr =			\
			raw_cpu_ptr((mdev)->stats);			\
		local_bh_disable();					\
		u64_stats_update_begin(&ptr->syncp);			\
		ptr->stats.pkts_field++;				\
		ptr->stats.bytes_field += (len);			\
		u64_stats_update_end(&ptr->syncp);			\
		local_bh_enable();					\
	} while (0)

#define MPLS_INC_STATS(mdev, field)					\
	do {								\
		TYPEOF_UNQUAL(*(mdev)->stats) *ptr =			\
			raw_cpu_ptr((mdev)->stats);			\
		local_bh_disable();					\
		u64_stats_update_begin(&ptr->syncp);			\
		ptr->stats.field++;					\
		u64_stats_update_end(&ptr->syncp);			\
		local_bh_enable();					\
	} while (0)

#else

#define MPLS_INC_STATS_LEN(mdev, len, pkts_field, bytes_field)		\
	do {								\
		this_cpu_inc((mdev)->stats->stats.pkts_field);		\
		this_cpu_add((mdev)->stats->stats.bytes_field, (len));	\
	} while (0)

#define MPLS_INC_STATS(mdev, field)			\
	this_cpu_inc((mdev)->stats->stats.field)

#endif

struct sk_buff;

#define LABEL_NOT_SPECIFIED (1 << 20)

/* This maximum ha length copied from the definition of struct neighbour */
#define VIA_ALEN_ALIGN sizeof(unsigned long)
#define MAX_VIA_ALEN (ALIGN(MAX_ADDR_LEN, VIA_ALEN_ALIGN))

enum mpls_payload_type {
	MPT_UNSPEC, /* IPv4 or IPv6 */
	MPT_IPV4 = 4,
	MPT_IPV6 = 6,

	/* Other types not implemented:
	 *  - Pseudo-wire with or without control word (RFC4385)
	 *  - GAL (RFC5586)
	 */
};

struct mpls_nh { /* next hop label forwarding entry */
	struct net_device	*nh_dev;
	netdevice_tracker	nh_dev_tracker;

	/* nh_flags is accessed under RCU in the packet path; it is
	 * modified handling netdev events with rtnl lock held
	 */
	unsigned int		nh_flags;
	u8			nh_labels;
	u8			nh_via_alen;
	u8			nh_via_table;
	u8			nh_reserved1;

Annotation

Implementation Notes