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.

Dependency Surface

Detected Declarations

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

Implementation Notes