diff options
author | Barry Spinney <spinney@mellanox.com> | 2016-04-28 22:35:39 -0500 |
---|---|---|
committer | Maxim Uvarov <maxim.uvarov@linaro.org> | 2016-04-29 11:47:42 +0300 |
commit | 1d70bc57f818794ae3db4a7279b45fa483aadc4f (patch) | |
tree | ad82ba77ccbc7dbe7cb4b53cdabf52d563919e00 /test | |
parent | 5ae6f0af33ce8b0dde9dab15df564fce2765dbb8 (diff) |
linux-generic: packet: fix number of parsing bugs, some vlan_hdr_t related
This patch fixes a bug in parse_ipv6 caused because the IPv6 payload
length does not include the IPv6 header and a bug in parse_udp where
l4_offset was subtracted from l3_offset instead of the other way around.
Also fixed some bugs related to incorrect vlan_hdr_t. The corrected
vlan header then required some fixes to odp_classification.c and the
classifier validation test code. Also added ODPH_IPV6ADDR_LEN.
Finally made a number of cosmetic changes to satisfy checkpatch.
Signed-off-by: Barry Spinney <spinney@mellanox.com>
Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/validation/classification/odp_classification_common.c | 20 | ||||
-rw-r--r-- | test/validation/classification/odp_classification_tests.c | 7 |
2 files changed, 12 insertions, 15 deletions
diff --git a/test/validation/classification/odp_classification_common.c b/test/validation/classification/odp_classification_common.c index c1afd00d4..7a42ac745 100644 --- a/test/validation/classification/odp_classification_common.c +++ b/test/validation/classification/odp_classification_common.c @@ -92,7 +92,7 @@ int cls_pkt_set_seq(odp_packet_t pkt) ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL); offset = odp_packet_l4_offset(pkt); - CU_ASSERT_FATAL(offset != 0); + CU_ASSERT_FATAL(offset != ODP_PACKET_OFFSET_INVALID); if (ip->proto == ODPH_IPPROTO_UDP) status = odp_packet_copy_from_mem(pkt, offset + ODPH_UDPHDR_LEN, @@ -116,7 +116,7 @@ uint32_t cls_pkt_get_seq(odp_packet_t pkt) ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL); offset = odp_packet_l4_offset(pkt); - if (!offset && !ip) + if (offset == ODP_PACKET_OFFSET_INVALID || ip == NULL) return TEST_SEQ_INVALID; if (ip->proto == ODPH_IPPROTO_UDP) @@ -269,19 +269,15 @@ odp_packet_t create_packet_len(odp_pool_t pool, bool vlan, offset += sizeof(odph_ethhdr_t); if (vlan) { /* Default vlan header */ - uint8_t *parseptr; - odph_vlanhdr_t *vlan; + odph_vlanhdr_t *vlan_hdr; - vlan = (odph_vlanhdr_t *)(ðhdr->type); - parseptr = (uint8_t *)vlan; - vlan->tci = odp_cpu_to_be_16(0); - vlan->tpid = odp_cpu_to_be_16(ODPH_ETHTYPE_VLAN); + ethhdr->type = odp_cpu_to_be_16(ODPH_ETHTYPE_VLAN); + vlan_hdr = (odph_vlanhdr_t *)(ethhdr + 1); + vlan_hdr->tci = odp_cpu_to_be_16(0); + vlan_hdr->type = odp_cpu_to_be_16(ODPH_ETHTYPE_IPV4); offset += sizeof(odph_vlanhdr_t); - parseptr += sizeof(odph_vlanhdr_t); - odp_u16be_t *type = (odp_u16be_t *)(void *)parseptr; - *type = odp_cpu_to_be_16(ODPH_ETHTYPE_IPV4); } else { - ethhdr->type = odp_cpu_to_be_16(ODPH_ETHTYPE_IPV4); + ethhdr->type = odp_cpu_to_be_16(ODPH_ETHTYPE_IPV4); } odp_packet_l3_offset_set(pkt, offset); diff --git a/test/validation/classification/odp_classification_tests.c b/test/validation/classification/odp_classification_tests.c index 12360569d..ed45518be 100644 --- a/test/validation/classification/odp_classification_tests.c +++ b/test/validation/classification/odp_classification_tests.c @@ -165,7 +165,6 @@ void configure_cls_pmr_chain(void) cos_list[CLS_PMR_CHAIN_SRC] = odp_cls_cos_create(cosname, &cls_param); CU_ASSERT_FATAL(cos_list[CLS_PMR_CHAIN_SRC] != ODP_COS_INVALID); - odp_queue_param_init(&qparam); qparam.type = ODP_QUEUE_TYPE_SCHED; qparam.sched.prio = ODP_SCHED_PRIO_NORMAL; @@ -389,6 +388,7 @@ void classification_test_pktio_set_skip(void) { int retval; size_t offset = 5; + retval = odp_pktio_skip_set(pktio_loop, offset); CU_ASSERT(retval == 0); @@ -406,6 +406,7 @@ void classification_test_pktio_set_headroom(void) { size_t headroom; int retval; + headroom = 5; retval = odp_pktio_headroom_set(pktio_loop, headroom); CU_ASSERT(retval == 0); @@ -475,15 +476,15 @@ void test_cos_with_l2_priority(void) odp_queue_t queue; odp_pool_t pool; uint32_t seqno = 0; - uint8_t i; + for (i = 0; i < CLS_L2_QOS_MAX; i++) { pkt = create_packet(pool_default, true, &seq, true); CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); seqno = cls_pkt_get_seq(pkt); CU_ASSERT(seqno != TEST_SEQ_INVALID); ethhdr = (odph_ethhdr_t *)odp_packet_l2_ptr(pkt, NULL); - vlan = (odph_vlanhdr_t *)(ðhdr->type); + vlan = (odph_vlanhdr_t *)(ethhdr + 1); vlan->tci = odp_cpu_to_be_16(i << 13); enqueue_pktio_interface(pkt, pktio_loop); pkt = receive_packet(&queue, ODP_TIME_SEC_IN_NS); |