[dpdk-dev] [PATCH v3] net/tap: perform proto field update for tun only
Varghese, Vipin
vipin.varghese at intel.com
Wed May 23 06:33:12 CEST 2018
HI Keith,
Thanks for pointing out, please find my answer and update below
<Snipped>
> > + /*
> > + * 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
> > + * then compares whether its v4 or v6. If first byte
> > + * is 4 or 6, then protocol field is updated.
> > + */
> > + char *buff_data = rte_pktmbuf_mtod(seg, void *);
> > + j = (*buff_data & 0xf0);
> > + pi.proto = (j == 0x40) ? 0x0008 :
> > (j == 0x60) ? 0xdd86 : 0x00;
>
> Warning Will Robinson: Magic numbers :-)
>
> Can we use the correct values here ETHERTYPE_IPV6 and ETHERTYPE_IP and
> then use htons() on the values please.
Earlier I refrained from doing this assuming htnos comparison is done for each packet leading to extra cycles. So updated the comments with explanation for logic explanation and readability.
But I am ok to in co-operate the idea of using MACRO with htnos. I have used ETHER_TYPE_IPv4 and ETHER_TYPE_IPv6 which does not require extra include. The changes are available in v4 version.
>
> > + }
<Snipped>
More information about the dev
mailing list