> -----Original Message----- > From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Sergio Gonzalez > Monroy > Sent: Wednesday, May 18, 2016 1:42 PM > To: dev at dpdk.org > Cc: Mcnamara, John > Subject: [dpdk-dev] [PATCH v2 7/9] examples/ipsec-secgw: ipv6 support > > Support IPSec IPv6 allowing IPv4/IPv6 traffic in IPv4 or IPv6 tunnel. > > We need separate Routing (LPM) and SP (ACL) tables for IPv4 and IPv6, > but a common SA table. > > Signed-off-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy at intel.com>
... > +static inline void > +ip4_ecn_setup(struct ip *ip4) > +{ > + if (ip4->ip_tos & IPTOS_ECN_MASK) > + ip4->ip_tos |= 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 = htonl(ntohl(ip6->ip6_flow) | > + (IPTOS_ECN_CE << 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; > > - outip = rte_pktmbuf_mtod(m, struct ip*); > + outip4 = rte_pktmbuf_mtod(m, struct ip*); > > - RTE_ASSERT(outip->ip_v == IPVERSION); > + RTE_ASSERT(outip4->ip_v == IPVERSION || outip4->ip_v == > IP6_VERSION); > > - offset += sizeof(struct ip); > - inip = (struct ip *)rte_pktmbuf_adj(m, offset); > - RTE_ASSERT(inip->ip_v == IPVERSION || inip->ip_v == > IPV6_VERSION); > + if (outip4->ip_v == IPVERSION) { > + ip_len = sizeof(struct ip); > + set_ecn = ((outip4->ip_tos & IPTOS_ECN_CE) == > IPTOS_ECN_CE); > + } else { > + outip6 = (struct ip6_hdr *)outip4; > + ip_len = sizeof(struct ip6_hdr); > + set_ecn = ntohl(outip6->ip6_flow) >> 20; > + set_ecn = ((set_ecn & IPTOS_ECN_CE) == IPTOS_ECN_CE); > + } > + > + inip4 = (struct ip *)rte_pktmbuf_adj(m, offset + ip_len); > + RTE_ASSERT(inip4->ip_v == IPVERSION || inip4->ip_v == > IP6_VERSION); > > /* 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); > > /* 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)) == > IPTOS_ECN_CE)) > - inip->ip_tos |= htons(IPTOS_ECN_CE); > + if (inip4->ip_v == IPVERSION) { > + if (set_ecn) > + ip4_ecn_setup(inip4); > + /* XXX This should be done by the forwarding engine instead > */ > + inip4->ip_ttl -= 1; > + } else { > + inip6 = (struct ip6_hdr *)inip4; > + if (set_ecn) > + ip6_ecn_setup(inip6); > + /* XXX This should be done by the forwarding engine instead > */ > + inip6->ip6_hops -= 1; > + } > > return 0; > }