include/linux/if_tun.h

Source file repositories/reference/linux-study-clean/include/linux/if_tun.h

File Facts

System
Linux kernel
Corpus path
include/linux/if_tun.h
Extension
.h
Size
1635 bytes
Lines
81
Domain
Core OS
Bucket
Core Kernel Interface
Inferred role
Core OS: implementation source
Status
source implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

struct tun_msg_ctl {
	unsigned short type;
	unsigned short num;
	void *ptr;
};

#if defined(CONFIG_TUN) || defined(CONFIG_TUN_MODULE)
struct socket *tun_get_socket(struct file *);
struct ptr_ring *tun_get_tx_ring(struct file *file);
void tun_wake_queue(struct file *file, int consumed);

static inline bool tun_is_xdp_frame(void *ptr)
{
	return (unsigned long)ptr & TUN_XDP_FLAG;
}

static inline void *tun_xdp_to_ptr(struct xdp_frame *xdp)
{
	return (void *)((unsigned long)xdp | TUN_XDP_FLAG);
}

static inline struct xdp_frame *tun_ptr_to_xdp(void *ptr)
{
	return (void *)((unsigned long)ptr & ~TUN_XDP_FLAG);
}

void tun_ptr_free(void *ptr);
#else
#include <linux/err.h>
#include <linux/errno.h>
struct file;
struct socket;

static inline struct socket *tun_get_socket(struct file *f)
{
	return ERR_PTR(-EINVAL);
}

static inline struct ptr_ring *tun_get_tx_ring(struct file *f)
{
	return ERR_PTR(-EINVAL);
}

static inline void tun_wake_queue(struct file *f, int consumed) {}

static inline bool tun_is_xdp_frame(void *ptr)
{
	return false;
}

static inline void *tun_xdp_to_ptr(struct xdp_frame *xdp)
{
	return NULL;
}

static inline struct xdp_frame *tun_ptr_to_xdp(void *ptr)
{
	return NULL;
}

static inline void tun_ptr_free(void *ptr)
{
}
#endif /* CONFIG_TUN */
#endif /* __IF_TUN_H */

Annotation

Implementation Notes