net/tap: fix rx cksum flags on IP options packets
[dpdk.git] / drivers / net / tap / rte_eth_tap.c
index 2f8abb1..e7b185a 100644 (file)
@@ -7,8 +7,8 @@
 #include <rte_byteorder.h>
 #include <rte_common.h>
 #include <rte_mbuf.h>
-#include <rte_ethdev_driver.h>
-#include <rte_ethdev_vdev.h>
+#include <ethdev_driver.h>
+#include <ethdev_vdev.h>
 #include <rte_malloc.h>
 #include <rte_bus_vdev.h>
 #include <rte_kvargs.h>
@@ -303,6 +303,7 @@ tap_verify_csum(struct rte_mbuf *mbuf)
        uint16_t cksum = 0;
        void *l3_hdr;
        void *l4_hdr;
+       struct rte_udp_hdr *udp_hdr;
 
        if (l2 == RTE_PTYPE_L2_ETHER_VLAN)
                l2_len += 4;
@@ -349,10 +350,23 @@ tap_verify_csum(struct rte_mbuf *mbuf)
                /* Don't verify checksum for multi-segment packets. */
                if (mbuf->nb_segs > 1)
                        return;
-               if (l3 == RTE_PTYPE_L3_IPV4)
+               if (l3 == RTE_PTYPE_L3_IPV4 || l3 == RTE_PTYPE_L3_IPV4_EXT) {
+                       if (l4 == RTE_PTYPE_L4_UDP) {
+                               udp_hdr = (struct rte_udp_hdr *)l4_hdr;
+                               if (udp_hdr->dgram_cksum == 0) {
+                                       /*
+                                        * For IPv4, a zero UDP checksum
+                                        * indicates that the sender did not
+                                        * generate one [RFC 768].
+                                        */
+                                       mbuf->ol_flags |= PKT_RX_L4_CKSUM_NONE;
+                                       return;
+                               }
+                       }
                        cksum = ~rte_ipv4_udptcp_cksum(l3_hdr, l4_hdr);
-               else if (l3 == RTE_PTYPE_L3_IPV6)
+               } else { /* l3 == RTE_PTYPE_L3_IPV6, checked above */
                        cksum = ~rte_ipv6_udptcp_cksum(l3_hdr, l4_hdr);
+               }
                mbuf->ol_flags |= cksum ?
                        PKT_RX_L4_CKSUM_BAD :
                        PKT_RX_L4_CKSUM_GOOD;
@@ -1876,7 +1890,7 @@ static const struct eth_dev_ops ops = {
        .stats_reset            = tap_stats_reset,
        .dev_supported_ptypes_get = tap_dev_supported_ptypes_get,
        .rss_hash_update        = tap_rss_hash_update,
-       .filter_ctrl            = tap_dev_filter_ctrl,
+       .flow_ops_get           = tap_dev_flow_ops_get,
 };
 
 static int