From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id D3AD35B20 for ; Sat, 21 Apr 2018 17:09:58 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Apr 2018 08:09:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,307,1520924400"; d="scan'208";a="222265466" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga006.fm.intel.com with ESMTP; 21 Apr 2018 08:09:57 -0700 Received: from FMSMSX110.amr.corp.intel.com (10.18.116.10) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sat, 21 Apr 2018 08:09:56 -0700 Received: from bgsmsx151.gar.corp.intel.com (10.224.48.42) by fmsmsx110.amr.corp.intel.com (10.18.116.10) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sat, 21 Apr 2018 08:09:56 -0700 Received: from bgsmsx101.gar.corp.intel.com ([169.254.1.242]) by BGSMSX151.gar.corp.intel.com ([169.254.3.7]) with mapi id 14.03.0319.002; Sat, 21 Apr 2018 20:39:53 +0530 From: "Varghese, Vipin" To: Ophir Munk , "dev@dpdk.org" , "pascal.mazon@6wind.com" , "Yigit, Ferruh" , Thomas Monjalon , Olga Shern , Shahaf Shuler Thread-Topic: [dpdk-dev] [PATCH 1/2] net/tap: add tun support Thread-Index: AQHTypsdhempI7P0FUC67o3nf5WGVaP8tx0AgAFX1FCAC+KLgIAAAneAgAF1StA= Date: Sat, 21 Apr 2018 15:09:53 +0000 Message-ID: <4C9E0AB70F954A408CC4ADDBF0F8FA7D4D1DFD5A@BGSMSX101.gar.corp.intel.com> References: <1519625719-10443-1-git-send-email-vipin.varghese@intel.com> <1522705068-18198-1-git-send-email-vipin.varghese@intel.com> <4C9E0AB70F954A408CC4ADDBF0F8FA7D4D1C8BAB@BGSMSX101.gar.corp.intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZDMyNDgyNjctMjRmNi00OTFkLWE1YTktNWE5MzM1ZGJhYTE4IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJ1RG94bWgwQTVJOVUwd1lUWEM0Ylk1YzY2Z3poK3NWdklUMzJYbTNOYTdxWWhMOE1Td2JlNHFwVTZsdjFHZkVoIn0= dlp-product: dlpe-windows dlp-version: 11.0.200.100 dlp-reaction: no-action x-originating-ip: [10.223.10.10] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH 1/2] net/tap: add tun support X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Apr 2018 15:10:00 -0000 Hi Ophir, > Hi Vipin, > I missed your point: > You claim that TAP should work regardless of any pi.proto values. > Can you confirm that for ALL kernels versions (past and future)? I have tested with 3.13.0 , 4.4.0 with patch fix. >=20 > > -----Original Message----- > > From: Ophir Munk > > Sent: Saturday, April 21, 2018 12:49 AM > > To: Varghese, Vipin ; dev@dpdk.org; > > pascal.mazon@6wind.com; Yigit, Ferruh ; Thomas > > Monjalon ; Olga Shern ; > > Shahaf Shuler > > Subject: RE: [dpdk-dev] [PATCH 1/2] net/tap: add tun support > > > > Hi Vipin, > > > > Please find comments inline. > > > > > -----Original Message----- > > > From: Varghese, Vipin [mailto:vipin.varghese@intel.com] > > > Sent: Friday, April 13, 2018 6:18 AM > > > To: Ophir Munk ; dev@dpdk.org; > > > pascal.mazon@6wind.com; Yigit, Ferruh ; > > > Thomas Monjalon ; Olga Shern > > > ; Shahaf Shuler > > > Subject: RE: [dpdk-dev] [PATCH 1/2] net/tap: add tun support > > > > > > > 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. > > > > > > Based on linux code base '/driver/net/tap.c' and '/driver/net/tun.c' > > > from 3.13. to 4.16, > > > > > > Please find my observation below > > > 1. File: tun.c, function: tun_get_user, check for 'tun->flags & > > > TUN_TYPE_MASK' is done and if non ip is taken counter 'rx_dropped' > > > is updated. > > > 2. File: tap.c, there are no checks for 'tap->flags' for IFF_NO_PI > > > in rx data path. Counter 'rx_dropped' is updated in 'tap_handle_frame= '. > > > > > > > I understand that in kernel implementation there is no check for > > tap->flags in file tap.c, however I think there is a bug in dpdk rte_et= h_tap.c > file. > > Please find below an example which demonstrates this claim. > > > > > Please find my reasoning below > > > 1. First approach was to have separate function for tap and tun TX an= d RX. > > > But this will introduce code duplication, hence reworked the code as > > above. > > > > I agree. Avoiding code duplication is a good approach. > > > > > 2. During my internal testing assigning dummy value for protocol > > > field in TAP packets, did not show a difference in behaviour. May be > > > there are some specific cases this failing. > > > > > > If there difference in behaviour, can please share the same? > > > > > > > Please consider the following example: > > I am running testpmd with a TAP device, --forward-mode=3Dcsum. > > I am injecting a TCP packet, which is forwarded back (mac addresses > > swapped) to the sender. > > Using gdb I set a breakpoint at pmd_tx_burst() in file rte_eth_tap.c > > > > Looking at the following code inside pmd_tx_burst(): > > > > 527 char *buff_data =3D rte_pktmbuf_mtod(seg, void *); > > 528 j =3D (*buff_data & 0xf0); > > 529 pi.proto =3D (j =3D=3D 0x40) ? 0x0008 : > > 530 (j =3D=3D 0x60) ? 0xdd86 : 0x00; > > > > I am printing the first 20 bytes of buff_data in line 527: > > > > (gdb) p/x *(unsigned char *)buff_data@20 > > $3 =3D {0x0, 0x25, 0x88, 0x10, 0x66, 0x2, 0xf4, 0x52, 0x14, 0x7a, 0x59, > > 0x81, 0x8, 0x0, 0x45, 0x0, 0x4, 0xdf, 0x0, 0x1} > > > > The gdb printout refers to: > > 6 bytes of destination MAC address: 0x0, 0x25, 0x88, 0x10, 0x66, 0x2 > > 6 bytes of source MAC address: 0xf4, 0x52, 0x14, 0x7a, 0x59, 0x81 > > 2 bytes of Ethernet type: 0x8, 0x0 - (IPv4) IP header starting with 0x4= 5, ... > > which is the byte (0x45) that "j" should have looked at > > > > In the case of TAP - buff_data starts with the destination MAC address > > of the sender (0x0, ...). > > The code in line 528 expects that buff_data would start with an IP > > header protocol (e.g. 0x45), but it is not the case for TAP. > > In my case j=3D0x0 (line 528) which is harmless (as it ends up with > > setting pi.proto=3D0x00, which is correct for TAP). > > However, if the sender had an Intel NIC - the destination MAC address > > could have started with: > > $3 =3D {0x40, 0x25, 0xC2, ... > > Or- > > $3 =3D {0x64, 0xD4, 0xDA, ... > > > > as 4025C2 and 64D4DA are reserved prefixes for Intel Ethernet MAC > > addresses, see: http://www.coffer.com/mac_find/?string=3Dintel > > > > In this case pi.proto could end up with 0x0008 or 0xdd86 instead of > > 0x0 as expected for TAP. > > > > I hope that this example clarifies the bug I am referring to. > > Thanks for sharing detailed example overview. But as you mentioned this wil= l break ' 4025C2' and ' 64D4DA',=20 This will not solve for the correction patch ' https://dpdk.org/dev/patchw= ork/patch/37986/'.=20 Only choice left is separate tx_burst for TAP and TUN PMD, as we do not wan= t to check PMD type on each call.=20 Questions: 1) Is this ok to split tx_burst and have redundant code? 2) Does applications transparently send packets coming from Physical NIC to= TAP interface? Does not the application Modifies the DEST MAC addr to TAP interface? > > > > > > > > 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 > > > > > > I see your point. You are correct about this. Thanks for pointing > > > out, may I send correction for this as > > > > > > """ > > > - if (j & (0x40 | 0x60)) > > > - pi.proto =3D (j =3D=3D 0x40) ? 0x0008 : 0xdd86; > > > + pi.proto =3D (j =3D=3D 0x40) ? 0x0008 : > > > + (j =3D=3D 0x60) ? 0xdd86 : > > > + 0x00; > > > """