drivers/net/tun_vnet.h
Source file repositories/reference/linux-study-clean/drivers/net/tun_vnet.h
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/tun_vnet.h- Extension
.h- Size
- 6666 bytes
- Lines
- 270
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
function tun_vnet_legacy_is_little_endianfunction tun_get_vnet_befunction tun_set_vnet_befunction tun_vnet_is_little_endianfunction tun_vnet16_to_cpufunction cpu_to_tun_vnet16function tun_vnet_ioctlfunction tun_vnet_parse_sizefunction __tun_vnet_hdr_getfunction tun_vnet_hdr_getfunction __tun_vnet_hdr_putfunction tun_vnet_hdr_putfunction tun_vnet_hdr_to_skbfunction tun_vnet_hdr_guest_featuresfunction tun_vnet_hdr_tnl_to_skbfunction tun_vnet_hdr_from_skbfunction tun_vnet_hdr_tnl_from_skb
Annotated Snippet
if (net_ratelimit()) {
netdev_err(dev, "unexpected GSO type: 0x%x, gso_size %d, hdr_len %d\n",
sinfo->gso_type, tun_vnet16_to_cpu(flags, hdr->gso_size),
tun_vnet16_to_cpu(flags, hdr->hdr_len));
print_hex_dump(KERN_ERR, "tun: ",
DUMP_PREFIX_NONE,
16, 1, skb->head,
min(tun_vnet16_to_cpu(flags, hdr->hdr_len), 64), true);
}
WARN_ON_ONCE(1);
return -EINVAL;
}
return 0;
}
static inline int
tun_vnet_hdr_tnl_from_skb(unsigned int flags,
const struct net_device *dev,
const struct sk_buff *skb,
struct virtio_net_hdr_v1_hash_tunnel *tnl_hdr)
{
bool has_tnl_offload = !!(dev->features & NETIF_F_GSO_UDP_TUNNEL);
int vlan_hlen = skb_vlan_tag_present(skb) ? VLAN_HLEN : 0;
if (virtio_net_hdr_tnl_from_skb(skb, tnl_hdr, has_tnl_offload,
tun_vnet_is_little_endian(flags),
vlan_hlen, true, false)) {
struct virtio_net_hdr_v1 *hdr = &tnl_hdr->hash_hdr.hdr;
struct skb_shared_info *sinfo = skb_shinfo(skb);
if (net_ratelimit()) {
int hdr_len = tun_vnet16_to_cpu(flags, hdr->hdr_len);
netdev_err(dev, "unexpected GSO type: 0x%x, gso_size %d, hdr_len %d\n",
sinfo->gso_type,
tun_vnet16_to_cpu(flags, hdr->gso_size),
tun_vnet16_to_cpu(flags, hdr->hdr_len));
print_hex_dump(KERN_ERR, "tun: ", DUMP_PREFIX_NONE,
16, 1, skb->head, min(hdr_len, 64),
true);
}
WARN_ON_ONCE(1);
return -EINVAL;
}
return 0;
}
#endif /* TUN_VNET_H */
Annotation
- Detected declarations: `function tun_vnet_legacy_is_little_endian`, `function tun_get_vnet_be`, `function tun_set_vnet_be`, `function tun_vnet_is_little_endian`, `function tun_vnet16_to_cpu`, `function cpu_to_tun_vnet16`, `function tun_vnet_ioctl`, `function tun_vnet_parse_size`, `function __tun_vnet_hdr_get`, `function tun_vnet_hdr_get`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.