[dpdk-dev] [PATCH 1/2] net/tap: add tun support

Ophir Munk ophirmu at mellanox.com
Thu Apr 12 13:49:08 CEST 2018


Hi Vipin,
This patch (adding TUN to TAP) has been Acked and accepted in next-net branch.
I have some questions regarding the implementation (please find below).

> -----Original Message-----
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Vipin Varghese
> Sent: Tuesday, April 03, 2018 12:38 AM
> To: dev at dpdk.org; pascal.mazon at 6wind.com; ferruh.yigit at intel.com
> Cc: Vipin Varghese <vipin.varghese at intel.com>
> Subject: [dpdk-dev] [PATCH 1/2] net/tap: add tun support
> 
> The change adds functional TUN PMD logic to the existing TAP PMD.
> TUN PMD can be initialized with 'net_tunX' where 'X' represents unique id.
> PMD supports argument interface, while MAC address and remote are not
> supported.
> 

[...]

> 
> +		/*
> +		 * TUN and TAP are created with IFF_NO_PI disabled.
> +		 * For TUN PMD this mandatory as fields are used by
> +		 * Kernel tun.c to determine whether its IP or non IP
> +		 * packets.
> +		 *
> +		 * The logic fetches the first byte of data from mbuf.
> +		 * compares whether its v4 or v6. If none matches default
> +		 * value 0x00 is taken for protocol field.
> +		 */
> +		char *buff_data = rte_pktmbuf_mtod(seg, void *);
> +		j = (*buff_data & 0xf0);
> +		if (j & (0x40 | 0x60))
> +			pi.proto = (j == 0x40) ? 0x0008 : 0xdd86;
> +

1. Accessing the first byte here assumes it is the first IP header byte (layer 3) which is correct for TUN.
For TAP however the first byte belongs to Ethernet destination address (layer 2). 
Please explain how this logic will work for TAP.

2. If the first TUN byte contains 0x2X (which is neither IPv4 nor IPv6) it will end up by setting ip.proto as 0xdd86. 
Please explain how this logic will work for non-IP packets in TUN



More information about the dev mailing list