lw_AFTR: IP Checksum required on generated packet. 67/46267/4
authorDanielMartinBuckley <daniel.m.buckley@intel.com>
Thu, 26 Oct 2017 17:48:47 +0000 (18:48 +0100)
committerDanielMartinBuckley <daniel.m.buckley@intel.com>
Wed, 1 Nov 2017 15:23:56 +0000 (15:23 +0000)
In lwAFTR (ipv6 de-encapsulate) the generated ipv4 packet requires an IP
checksum, otherwise this packet is dropped in Openstack. (Openstack is
much stricter than baremetal) Some fields in the header need to be
initialized.

Add flag in Makefile which when enabled will build to include the generate
the IP checksum in the build. FLAG = GEN_DECAP_IPV6_TO_IPV4_CKSUM=y
Not include in default build.

Change-Id: If94e7cff64b03c66362021f05e48fb9265fc8210
Signed-off-by: Daniel Martin Buckley <daniel.m.buckley@intel.com>
VNFs/DPPD-PROX/Makefile
VNFs/DPPD-PROX/handle_ipv6_tunnel.c

index e9a4211..3151f04 100644 (file)
@@ -105,6 +105,11 @@ else
 CFLAGS += -DPROX_MAX_LOG_LVL=$(log)
 endif
 
+# When ipv4 packet is de-encalpusled from ipv6 packet, genaerate IP checksum.
+ifeq ($(GEN_DECAP_IPV6_TO_IPV4_CKSUM),y)
+CFLAGS += -DGEN_DECAP_IPV6_TO_IPV4_CKSUM
+endif
+
 # override any use-case/enviroment specific choices regarding crc and
 # always use the sw implementation
 ifeq ($(crc),soft)
index a92f9cd..3361a6a 100644 (file)
@@ -377,6 +377,8 @@ static int handle_ipv6_encap_bulk(struct task_base* tbase, struct rte_mbuf** mbu
 static inline uint8_t handle_ipv6_decap(struct task_ipv6_decap* ptask, struct rte_mbuf* rx_mbuf, __attribute__((unused)) struct ipv6_tun_dest* tun_dest)
 {
        struct ether_hdr* peth = rte_pktmbuf_mtod(rx_mbuf, struct ether_hdr *);
+       struct task_ipv6_tun_base* tun_base = (struct task_ipv6_tun_base*)ptask;
+       struct ipv4_hdr* pip4 = NULL;
 
        if (unlikely(peth->ether_type != ETYPE_IPv6)) {
                plog_warn("Received non IPv6 packet on ipv6 tunnel port\n");
@@ -400,12 +402,20 @@ static inline uint8_t handle_ipv6_decap(struct task_ipv6_decap* ptask, struct rt
         // Discard IPv6 encapsulation
         rte_pktmbuf_adj(rx_mbuf, ipv6_hdr_len);
         peth = rte_pktmbuf_mtod(rx_mbuf, struct ether_hdr *);
+       pip4 = (struct ipv4_hdr *)(peth + 1);
 
         // Restore Ethernet header
         ether_addr_copy(&ptask->base.src_mac, &peth->s_addr);
         ether_addr_copy(&ptask->dst_mac, &peth->d_addr);
         peth->ether_type = ETYPE_IPv4;
 
+#ifdef GEN_DECAP_IPV6_TO_IPV4_CKSUM
+        // generate an IP checksum for ipv4 packet
+        if (tun_base->runtime_flags & TASK_TX_CRC) {
+                prox_ip_cksum(rx_mbuf, pip4, sizeof(struct ether_hdr), sizeof(struct ipv4_hdr), ptask->base.offload_crc);
+        }
+#endif
+
        return 0;
 }