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.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
uapi/linux/if_tun.huapi/linux/virtio_net.hlinux/err.hlinux/errno.h
Detected Declarations
struct tun_msg_ctlstruct filestruct socketfunction tun_is_xdp_framefunction tun_wake_queuefunction tun_ptr_free
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
- Immediate include surface: `uapi/linux/if_tun.h`, `uapi/linux/virtio_net.h`, `linux/err.h`, `linux/errno.h`.
- Detected declarations: `struct tun_msg_ctl`, `struct file`, `struct socket`, `function tun_is_xdp_frame`, `function tun_wake_queue`, `function tun_ptr_free`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.