net/l2tp/l2tp_core.h

Source file repositories/reference/linux-study-clean/net/l2tp/l2tp_core.h

File Facts

System
Linux kernel
Corpus path
net/l2tp/l2tp_core.h
Extension
.h
Size
11121 bytes
Lines
341
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 l2tp_stats {
	atomic_long_t		tx_packets;
	atomic_long_t		tx_bytes;
	atomic_long_t		tx_errors;
	atomic_long_t		rx_packets;
	atomic_long_t		rx_bytes;
	atomic_long_t		rx_seq_discards;
	atomic_long_t		rx_oos_packets;
	atomic_long_t		rx_errors;
	atomic_long_t		rx_cookie_discards;
	atomic_long_t		rx_invalid;
};

struct l2tp_tunnel;

/* L2TP session configuration */
struct l2tp_session_cfg {
	enum l2tp_pwtype	pw_type;
	unsigned int		recv_seq:1;	/* expect receive packets with sequence numbers? */
	unsigned int		send_seq:1;	/* send packets with sequence numbers? */
	unsigned int		lns_mode:1;	/* behave as LNS?
						 * LAC enables sequence numbers under LNS control.
						 */
	u16			l2specific_type; /* Layer 2 specific type */
	u8			cookie[8];	/* optional cookie */
	int			cookie_len;	/* 0, 4 or 8 bytes */
	u8			peer_cookie[8];	/* peer's cookie */
	int			peer_cookie_len; /* 0, 4 or 8 bytes */
	int			reorder_timeout; /* configured reorder timeout (in jiffies) */
	char			*ifname;
};

struct l2tp_session_coll_list {
	spinlock_t lock;	/* for access to list */
	struct list_head list;
	refcount_t ref_count;
};

/* Represents a session (pseudowire) instance.
 * Tracks runtime state including cookies, dataplane packet sequencing, and IO statistics.
 * Is linked into a per-tunnel session list and a per-net ("global") IDR tree.
 */
#define L2TP_SESSION_NAME_MAX 32
struct l2tp_session {
	int			magic;		/* should be L2TP_SESSION_MAGIC */
	long			dead;
	struct rcu_head		rcu;

	struct l2tp_tunnel	*tunnel;	/* back pointer to tunnel context */
	u32			session_id;
	u32			peer_session_id;
	u8			cookie[8];
	int			cookie_len;
	u8			peer_cookie[8];
	int			peer_cookie_len;
	u16			l2specific_type;
	u16			hdr_len;
	u32			nr;		/* session NR state (receive) */
	u32			ns;		/* session NR state (send) */
	struct sk_buff_head	reorder_q;	/* receive reorder queue */
	u32			nr_max;		/* max NR. Depends on tunnel */
	u32			nr_window_size;	/* NR window size */
	u32			nr_oos;		/* NR of last OOS packet */
	int			nr_oos_count;	/* for OOS recovery */
	int			nr_oos_count_max;
	struct list_head	list;		/* per-tunnel list node */
	refcount_t		ref_count;
	struct hlist_node	hlist;		/* per-net session hlist */
	unsigned long		hlist_key;	/* key for session hlist */
	struct l2tp_session_coll_list *coll_list; /* session collision list */
	struct list_head	clist;		/* for coll_list */

	char			name[L2TP_SESSION_NAME_MAX]; /* for logging */
	char			ifname[IFNAMSIZ];
	unsigned int		recv_seq:1;	/* expect receive packets with sequence numbers? */
	unsigned int		send_seq:1;	/* send packets with sequence numbers? */
	unsigned int		lns_mode:1;	/* behave as LNS?
						 * LAC enables sequence numbers under LNS control.
						 */
	int			reorder_timeout; /* configured reorder timeout (in jiffies) */
	int			reorder_skip;	/* set if skip to next nr */
	enum l2tp_pwtype	pwtype;
	struct l2tp_stats	stats;
	struct work_struct	del_work;

	/* Session receive handler for data packets.
	 * Each pseudowire implementation should implement this callback in order to
	 * handle incoming packets.  Packets are passed to the pseudowire handler after
	 * reordering, if data sequence numbers are enabled for the session.
	 */

Annotation

Implementation Notes