From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id CD6399AB8 for ; Tue, 7 Jun 2016 18:10:06 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP; 07 Jun 2016 09:10:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,434,1459839600"; d="scan'208";a="970720996" Received: from irsmsx152.ger.corp.intel.com ([163.33.192.66]) by orsmga001.jf.intel.com with ESMTP; 07 Jun 2016 09:10:04 -0700 Received: from irsmsx108.ger.corp.intel.com ([169.254.11.183]) by IRSMSX152.ger.corp.intel.com ([169.254.6.247]) with mapi id 14.03.0248.002; Tue, 7 Jun 2016 17:10:04 +0100 From: "De Lara Guarch, Pablo" To: "Gonzalez Monroy, Sergio" , "dev@dpdk.org" CC: "Mcnamara, John" Thread-Topic: [dpdk-dev] [PATCH v2 7/9] examples/ipsec-secgw: ipv6 support Thread-Index: AQHRsQLx8z4eZUlYh0Kq+t8+AGl8VJ/eSdCw Date: Tue, 7 Jun 2016 16:10:03 +0000 Message-ID: References: <1462552302-5852-1-git-send-email-sergio.gonzalez.monroy@intel.com> <1463575330-8467-1-git-send-email-sergio.gonzalez.monroy@intel.com> <1463575330-8467-8-git-send-email-sergio.gonzalez.monroy@intel.com> In-Reply-To: <1463575330-8467-8-git-send-email-sergio.gonzalez.monroy@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiODNmODIwZTUtODY2NS00MzIzLTgzMGUtZGI4ZTA1YzNlYjVlIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6InE3XC9IZWRTekV4eU9DU2d3T3dQajBuVUltWUM5XC9RZDQrQnp2TWg5Q0I1cz0ifQ== x-ctpclassification: CTP_IC x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2 7/9] examples/ipsec-secgw: ipv6 support X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Jun 2016 16:10:07 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Sergio Gonzalez > Monroy > Sent: Wednesday, May 18, 2016 1:42 PM > To: dev@dpdk.org > Cc: Mcnamara, John > Subject: [dpdk-dev] [PATCH v2 7/9] examples/ipsec-secgw: ipv6 support >=20 > Support IPSec IPv6 allowing IPv4/IPv6 traffic in IPv4 or IPv6 tunnel. >=20 > We need separate Routing (LPM) and SP (ACL) tables for IPv4 and IPv6, > but a common SA table. >=20 > Signed-off-by: Sergio Gonzalez Monroy ... > +static inline void > +ip4_ecn_setup(struct ip *ip4) > +{ > + if (ip4->ip_tos & IPTOS_ECN_MASK) > + ip4->ip_tos |=3D IPTOS_ECN_CE; > +} > + > +static inline void > +ip6_ecn_setup(struct ip6_hdr *ip6) > +{ > + if ((ntohl(ip6->ip6_flow) >> 20) & IPTOS_ECN_MASK) > + ip6->ip6_flow =3D htonl(ntohl(ip6->ip6_flow) | > + (IPTOS_ECN_CE << 20)); > } >=20 > static inline int > -ip4ip_inbound(struct rte_mbuf *m, uint32_t offset) > +ipip_inbound(struct rte_mbuf *m, uint32_t offset) This function should return void, since it is returning 0 always. > { > - struct ip *inip; > - struct ip *outip; > + struct ip *inip4, *outip4; > + struct ip6_hdr *inip6, *outip6; > + uint32_t ip_len, set_ecn; >=20 > - outip =3D rte_pktmbuf_mtod(m, struct ip*); > + outip4 =3D rte_pktmbuf_mtod(m, struct ip*); >=20 > - RTE_ASSERT(outip->ip_v =3D=3D IPVERSION); > + RTE_ASSERT(outip4->ip_v =3D=3D IPVERSION || outip4->ip_v =3D=3D > IP6_VERSION); >=20 > - offset +=3D sizeof(struct ip); > - inip =3D (struct ip *)rte_pktmbuf_adj(m, offset); > - RTE_ASSERT(inip->ip_v =3D=3D IPVERSION || inip->ip_v =3D=3D > IPV6_VERSION); > + if (outip4->ip_v =3D=3D IPVERSION) { > + ip_len =3D sizeof(struct ip); > + set_ecn =3D ((outip4->ip_tos & IPTOS_ECN_CE) =3D=3D > IPTOS_ECN_CE); > + } else { > + outip6 =3D (struct ip6_hdr *)outip4; > + ip_len =3D sizeof(struct ip6_hdr); > + set_ecn =3D ntohl(outip6->ip6_flow) >> 20; > + set_ecn =3D ((set_ecn & IPTOS_ECN_CE) =3D=3D IPTOS_ECN_CE); > + } > + > + inip4 =3D (struct ip *)rte_pktmbuf_adj(m, offset + ip_len); > + RTE_ASSERT(inip4->ip_v =3D=3D IPVERSION || inip4->ip_v =3D=3D > IP6_VERSION); >=20 > /* Check packet is still bigger than IP header (inner) */ > - RTE_ASSERT(rte_pktmbuf_pkt_len(m) > sizeof(struct ip)); > + RTE_ASSERT(rte_pktmbuf_pkt_len(m) > ip_len); >=20 > /* RFC4301 5.1.2.1 Note 6 */ > - if ((inip->ip_tos & htons(IPTOS_ECN_ECT0 | IPTOS_ECN_ECT1)) && > - ((outip->ip_tos & htons(IPTOS_ECN_CE)) =3D=3D > IPTOS_ECN_CE)) > - inip->ip_tos |=3D htons(IPTOS_ECN_CE); > + if (inip4->ip_v =3D=3D IPVERSION) { > + if (set_ecn) > + ip4_ecn_setup(inip4); > + /* XXX This should be done by the forwarding engine instead > */ > + inip4->ip_ttl -=3D 1; > + } else { > + inip6 =3D (struct ip6_hdr *)inip4; > + if (set_ecn) > + ip6_ecn_setup(inip6); > + /* XXX This should be done by the forwarding engine instead > */ > + inip6->ip6_hops -=3D 1; > + } >=20 > return 0; > }