This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "".
The branch, master has been updated via c0da87688187c81039cf81790fed3d6ed00a956e (commit) via c2a1c48f5fc17cf4dd870057d17059ad668d29ad (commit) via c67dcec1c034a0c75c093b49e2a172bbd3d50def (commit) via 80b9a1e4d6a297ac916cbaf360e7b2114ef86a7a (commit) via 7135eda6854ba60d6379ca5799b4b58959e998b5 (commit) via 017969502cd0247c9b25e80e002ac563860f5a5d (commit) via 3a4f369fb2019761af5d4d7ad09d48f1e5d44f82 (commit) from 962600ecdbe44d386f95a57ac5a91365af0b6c39 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- commit c0da87688187c81039cf81790fed3d6ed00a956e Author: Petri Savolainen petri.savolainen@linaro.org Date: Tue Mar 6 13:38:30 2018 +0200
linux-gen: queue: improve debug print
Print max number of queues and max queue size in global init.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Reviewed-by: Balasubramanian Manoharan bala.manoharan@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/odp_queue_basic.c b/platform/linux-generic/odp_queue_basic.c index e4f6fd82..f87c2876 100644 --- a/platform/linux-generic/odp_queue_basic.c +++ b/platform/linux-generic/odp_queue_basic.c @@ -68,14 +68,37 @@ static inline queue_entry_t *handle_to_qentry(odp_queue_t handle) return get_qentry(queue_id); }
+static int queue_capa(odp_queue_capability_t *capa, int sched) +{ + memset(capa, 0, sizeof(odp_queue_capability_t)); + + /* Reserve some queues for internal use */ + capa->max_queues = ODP_CONFIG_QUEUES - NUM_INTERNAL_QUEUES; + capa->plain.max_num = capa->max_queues; + capa->plain.max_size = CONFIG_QUEUE_SIZE; + capa->plain.lockfree.max_num = queue_glb->queue_lf_num; + capa->plain.lockfree.max_size = queue_glb->queue_lf_size; + capa->sched.max_num = capa->max_queues; + capa->sched.max_size = CONFIG_QUEUE_SIZE; + + if (sched) { + capa->max_ordered_locks = sched_fn->max_ordered_locks(); + capa->max_sched_groups = sched_fn->num_grps(); + capa->sched_prios = odp_schedule_num_prio(); + } + + return 0; +} + static int queue_init_global(void) { uint32_t i; odp_shm_t shm; uint32_t lf_size = 0; queue_lf_func_t *lf_func; + odp_queue_capability_t capa;
- ODP_DBG("Queue init ... "); + ODP_DBG("Starts...\n");
shm = odp_shm_reserve("odp_queues", sizeof(queue_global_t), @@ -100,13 +123,14 @@ static int queue_init_global(void) queue_glb->queue_lf_num = queue_lf_init_global(&lf_size, lf_func); queue_glb->queue_lf_size = lf_size;
- ODP_DBG("done\n"); - ODP_DBG("Queue init global\n"); - ODP_DBG(" struct queue_entry_s size %zu\n", - sizeof(struct queue_entry_s)); - ODP_DBG(" queue_entry_t size %zu\n", - sizeof(queue_entry_t)); - ODP_DBG("\n"); + queue_capa(&capa, 0); + + ODP_DBG("... done.\n"); + ODP_DBG(" queue_entry_t size %u\n", sizeof(queue_entry_t)); + ODP_DBG(" max num queues %u\n", capa.max_queues); + ODP_DBG(" max queue size %u\n", capa.plain.max_size); + ODP_DBG(" max num lockfree %u\n", capa.plain.lockfree.max_num); + ODP_DBG(" max lockfree size %u\n\n", capa.plain.lockfree.max_size);
return 0; } @@ -151,21 +175,7 @@ static int queue_term_global(void)
static int queue_capability(odp_queue_capability_t *capa) { - memset(capa, 0, sizeof(odp_queue_capability_t)); - - /* Reserve some queues for internal use */ - capa->max_queues = ODP_CONFIG_QUEUES - NUM_INTERNAL_QUEUES; - capa->max_ordered_locks = sched_fn->max_ordered_locks(); - capa->max_sched_groups = sched_fn->num_grps(); - capa->sched_prios = odp_schedule_num_prio(); - capa->plain.max_num = capa->max_queues; - capa->plain.max_size = CONFIG_QUEUE_SIZE; - capa->plain.lockfree.max_num = queue_glb->queue_lf_num; - capa->plain.lockfree.max_size = queue_glb->queue_lf_size; - capa->sched.max_num = capa->max_queues; - capa->sched.max_size = CONFIG_QUEUE_SIZE; - - return 0; + return queue_capa(capa, 1); }
static odp_queue_type_t queue_type(odp_queue_t handle)
commit c2a1c48f5fc17cf4dd870057d17059ad668d29ad Author: Petri Savolainen petri.savolainen@linaro.org Date: Tue Mar 6 12:46:33 2018 +0200
linux-gen: pktio: add debug prints
Print interface name on open, start, stop and close calls. Also print driver name and number of queues to ease check of correct configuration.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Reviewed-by: Balasubramanian Manoharan bala.manoharan@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index ae8e390b..f8792b66 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -237,8 +237,6 @@ static odp_pktio_t setup_pktio_entry(const char *name, odp_pool_t pool, pktio_entry->s.ops = pktio_if_ops[pktio_if]; unlock_entry(pktio_entry);
- ODP_DBG("%s uses %s\n", name, pktio_if_ops[pktio_if]->name); - return hdl; }
@@ -255,6 +253,18 @@ static int pool_type_is_packet(odp_pool_t pool) return pool_info.params.type == ODP_POOL_PACKET; }
+static const char *driver_name(odp_pktio_t hdl) +{ + pktio_entry_t *entry; + + if (hdl != ODP_PKTIO_INVALID) { + entry = get_pktio_entry(hdl); + return entry->s.ops->name; + } + + return "bad handle"; +} + odp_pktio_t odp_pktio_open(const char *name, odp_pool_t pool, const odp_pktio_param_t *param) { @@ -279,6 +289,8 @@ odp_pktio_t odp_pktio_open(const char *name, odp_pool_t pool, hdl = setup_pktio_entry(name, pool, param); odp_spinlock_unlock(&pktio_tbl->lock);
+ ODP_DBG("interface: %s, driver: %s\n", name, driver_name(hdl)); + return hdl; }
@@ -391,6 +403,8 @@ int odp_pktio_close(odp_pktio_t hdl)
unlock_entry(entry);
+ ODP_DBG("interface: %s\n", entry->s.name); + return 0; }
@@ -488,6 +502,9 @@ int odp_pktio_start(odp_pktio_t hdl) sched_fn->pktio_start(_odp_pktio_index(hdl), num, index, odpq); }
+ ODP_DBG("interface: %s, input queues: %u, output queues: %u\n", + entry->s.name, entry->s.num_in_queue, entry->s.num_out_queue); + return res; }
@@ -526,6 +543,8 @@ int odp_pktio_stop(odp_pktio_t hdl) res = _pktio_stop(entry); unlock_entry(entry);
+ ODP_DBG("interface: %s\n", entry->s.name); + return res; }
commit c67dcec1c034a0c75c093b49e2a172bbd3d50def Author: Petri Savolainen petri.savolainen@linaro.org Date: Tue Mar 6 10:46:57 2018 +0200
linux-gen: sysinfo: add content to info string print
Added implementation details string and cpu mask to system info print out.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Reviewed-by: Balasubramanian Manoharan bala.manoharan@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/odp_system_info.c b/platform/linux-generic/odp_system_info.c index d460a198..d1cda1ea 100644 --- a/platform/linux-generic/odp_system_info.c +++ b/platform/linux-generic/odp_system_info.c @@ -489,26 +489,36 @@ int odp_cpu_count(void)
void odp_sys_info_print(void) { - int len; + int len, num_cpu; int max_len = 512; + odp_cpumask_t cpumask; + char cpumask_str[ODP_CPUMASK_STR_SIZE]; char str[max_len];
+ memset(cpumask_str, 0, sizeof(cpumask_str)); + + num_cpu = odp_cpumask_all_available(&cpumask); + odp_cpumask_to_str(&cpumask, cpumask_str, ODP_CPUMASK_STR_SIZE); + len = snprintf(str, max_len, "\n" "ODP system info\n" "---------------\n" - "ODP API version: %s\n" - "ODP impl name: %s\n" - "CPU model: %s\n" - "CPU freq (hz): %" PRIu64 "\n" - "Cache line size: %i\n" - "CPU count: %i\n" + "ODP API version: %s\n" + "ODP impl name: %s\n" + "ODP impl details: %s\n" + "CPU model: %s\n" + "CPU freq (hz): %" PRIu64 "\n" + "Cache line size: %i\n" + "CPU count: %i\n" + "CPU mask: %s\n" "\n", odp_version_api_str(), odp_version_impl_name(), + odp_version_impl_str(), odp_cpu_model_str(), odp_cpu_hz_max(), odp_sys_cache_line_size(), - odp_cpu_count()); + num_cpu, cpumask_str);
str[len] = '\0'; ODP_PRINT("%s", str);
commit 80b9a1e4d6a297ac916cbaf360e7b2114ef86a7a Author: Petri Savolainen petri.savolainen@linaro.org Date: Tue Mar 6 10:40:06 2018 +0200
linux-gen: version: implementation name content
Removed quotes from implementation name (from "odp-linux" to odp_linux). Added ODP_ prefix to name and build version macros.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Reviewed-by: Balasubramanian Manoharan bala.manoharan@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/configure.ac b/configure.ac index f9e7f73b..31f24aa8 100644 --- a/configure.ac +++ b/configure.ac @@ -240,7 +240,7 @@ AS_IF([test "${with_platform}" = "linux-generic"], [m4_include([./platform/linux-generic/m4/configure.m4])], [AC_MSG_ERROR([UNSUPPORTED PLATFORM: ${with_platform}])])
-AC_DEFINE_UNQUOTED([IMPLEMENTATION_NAME], ["$IMPLEMENTATION_NAME"], +AC_DEFINE_UNQUOTED([ODP_IMPLEMENTATION_NAME], ["$ODP_IMPLEMENTATION_NAME"], [Define to the name of the implementation])
########################################################################## @@ -385,7 +385,7 @@ AC_MSG_RESULT([ ODP Library version: ${ODP_LIBSO_VERSION} Helper Library version: ${ODPHELPER_LIBSO_VERSION}
- implementation_name: ${IMPLEMENTATION_NAME} + implementation_name: ${ODP_IMPLEMENTATION_NAME} host: ${host} ARCH_DIR ${ARCH_DIR} ARCH_ABI ${ARCH_ABI} diff --git a/platform/Makefile.inc b/platform/Makefile.inc index 9df96b12..ae4d52f2 100644 --- a/platform/Makefile.inc +++ b/platform/Makefile.inc @@ -17,7 +17,7 @@ else AM_LDFLAGS += -export-symbols-regex '^(_deprecated_)?_?odp_' endif
-AM_CFLAGS = "-DGIT_HASH=$(VERSION)" +AM_CFLAGS = "-DODP_VERSION_BUILD=$(VERSION)" AM_CFLAGS += $(VISIBILITY_CFLAGS)
AM_CFLAGS += @PTHREAD_CFLAGS@ diff --git a/platform/linux-generic/m4/configure.m4 b/platform/linux-generic/m4/configure.m4 index d2ddd495..e3f276af 100644 --- a/platform/linux-generic/m4/configure.m4 +++ b/platform/linux-generic/m4/configure.m4 @@ -1,4 +1,4 @@ -IMPLEMENTATION_NAME="odp-linux" +ODP_IMPLEMENTATION_NAME="odp-linux"
ODP_VISIBILITY ODP_ATOMIC diff --git a/platform/linux-generic/odp_impl.c b/platform/linux-generic/odp_impl.c index b6994295..227d5000 100644 --- a/platform/linux-generic/odp_impl.c +++ b/platform/linux-generic/odp_impl.c @@ -5,26 +5,11 @@ */
#include "config.h" - - -/** - * @file - * - * ODP Implementation information - */ - -#ifndef ODP_IMPL_H_ -#define ODP_IMPL_H_ - -#ifdef __cplusplus -extern "C" { -#endif - #include <odp/api/version.h>
#define ODP_VERSION_IMPL 0 #define ODP_VERSION_IMPL_STR \ - ODP_VERSION_TO_STR(IMPLEMENTATION_NAME) " " \ + ODP_IMPLEMENTATION_NAME " " \ ODP_VERSION_TO_STR(ODP_VERSION_API_GENERATION) "." \ ODP_VERSION_TO_STR(ODP_VERSION_API_MAJOR) "." \ ODP_VERSION_TO_STR(ODP_VERSION_API_MINOR) "-" \ @@ -32,10 +17,7 @@ extern "C" { ODP_VERSION_TO_STR(ODP_VERSION_API_GENERATION) "." \ ODP_VERSION_TO_STR(ODP_VERSION_API_MAJOR) "." \ ODP_VERSION_TO_STR(ODP_VERSION_API_MINOR) ") " \ - ODP_VERSION_TO_STR(GIT_HASH) - -#define ODP_VERSION_IMPL_NAME \ - ODP_VERSION_TO_STR(IMPLEMENTATION_NAME) + ODP_VERSION_TO_STR(ODP_VERSION_BUILD)
const char *odp_version_impl_str(void) { @@ -44,11 +26,5 @@ const char *odp_version_impl_str(void)
const char *odp_version_impl_name(void) { - return ODP_VERSION_IMPL_NAME; + return ODP_IMPLEMENTATION_NAME; } - -#ifdef __cplusplus -} -#endif - -#endif
commit 7135eda6854ba60d6379ca5799b4b58959e998b5 Author: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Date: Wed Feb 21 19:01:01 2018 +0300
validation: ipsec: verify TFC dummy packet generation
Signed-off-by: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/test/validation/api/ipsec/ipsec.c b/test/validation/api/ipsec/ipsec.c index 21eaf17b..3e2e743d 100644 --- a/test/validation/api/ipsec/ipsec.c +++ b/test/validation/api/ipsec/ipsec.c @@ -604,10 +604,15 @@ static int ipsec_send_out_one(const ipsec_test_part *part, hdr_len = part->out[0].pkt_out->l3_offset; CU_ASSERT_FATAL(hdr_len <= sizeof(hdr)); memcpy(hdr, part->out[0].pkt_out->data, hdr_len); - } else { + } else if (part->pkt_in->l3_offset != + ODP_PACKET_OFFSET_INVALID) { hdr_len = part->pkt_in->l3_offset; CU_ASSERT_FATAL(hdr_len <= sizeof(hdr)); memcpy(hdr, part->pkt_in->data, hdr_len); + } else { + /* Dummy header */ + hdr_len = 14; + memset(hdr, 0xff, hdr_len); } inline_param.pktio = suite_context.pktio; inline_param.outer_hdr.ptr = hdr; diff --git a/test/validation/api/ipsec/ipsec_test_out.c b/test/validation/api/ipsec/ipsec_test_out.c index 3db553b6..5089dfa7 100644 --- a/test/validation/api/ipsec/ipsec_test_out.c +++ b/test/validation/api/ipsec/ipsec_test_out.c @@ -997,6 +997,164 @@ static void test_out_ipv6_esp_udp_null_sha256(void) ipsec_sa_destroy(sa); }
+static void test_out_dummy_esp_null_sha256_tun_ipv4(void) +{ + uint32_t src = IPV4ADDR(10, 0, 111, 2); + uint32_t dst = IPV4ADDR(10, 0, 222, 2); + odp_ipsec_tunnel_param_t tunnel = { + .type = ODP_IPSEC_TUNNEL_IPV4, + .ipv4.src_addr = &src, + .ipv4.dst_addr = &dst, + .ipv4.ttl = 64, + }; + odp_ipsec_sa_param_t param; + odp_ipsec_sa_t sa; + odp_ipsec_sa_t sa2; + + /* This test will not work properly inbound inline mode. + * Packet might be dropped and we will not check for that. */ + if (suite_context.inbound_op_mode == ODP_IPSEC_OP_MODE_INLINE) + return; + + ipsec_sa_param_fill(¶m, + false, false, 123, &tunnel, + ODP_CIPHER_ALG_NULL, NULL, + ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256, + NULL); + + sa = odp_ipsec_sa_create(¶m); + + CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa); + + ipsec_sa_param_fill(¶m, + true, false, 123, &tunnel, + ODP_CIPHER_ALG_NULL, NULL, + ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256, + NULL); + + sa2 = odp_ipsec_sa_create(¶m); + + CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa2); + + ipsec_test_part test = { + .pkt_in = &pkt_test_nodata, + .num_opt = 1, + .opt = { .flag.tfc_dummy = 1, + .tfc_pad_len = 16, }, + .out_pkt = 1, + .out = { + { .status.warn.all = 0, + .status.error.all = 0, + .l3_type = ODP_PROTO_L3_TYPE_IPV4, + .l4_type = ODP_PROTO_L4_TYPE_NO_NEXT, + .pkt_out = NULL }, + }, + }; + + ipsec_test_part test_empty = { + .pkt_in = &pkt_test_emtpy, + .num_opt = 1, + .opt = { .flag.tfc_dummy = 1, + .tfc_pad_len = 16, }, + .out_pkt = 1, + .out = { + { .status.warn.all = 0, + .status.error.all = 0, + .l3_type = ODP_PROTO_L3_TYPE_IPV4, + .l4_type = ODP_PROTO_L4_TYPE_NO_NEXT, + .pkt_out = NULL }, + }, + }; + + ipsec_check_out_in_one(&test, sa, sa2); + ipsec_check_out_in_one(&test_empty, sa, sa2); + + ipsec_sa_destroy(sa2); + ipsec_sa_destroy(sa); +} + +static void test_out_dummy_esp_null_sha256_tun_ipv6(void) +{ + uint8_t src[16] = { + 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x11, 0x43, 0xff, 0xfe, 0x4a, 0xd7, 0x0a, + }; + uint8_t dst[16] = { + 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, + }; + odp_ipsec_tunnel_param_t tunnel = { + .type = ODP_IPSEC_TUNNEL_IPV6, + .ipv6.src_addr = src, + .ipv6.dst_addr = dst, + .ipv6.hlimit = 64, + }; + odp_ipsec_sa_param_t param; + odp_ipsec_sa_t sa; + odp_ipsec_sa_t sa2; + + /* This test will not work properly inbound inline mode. + * Packet might be dropped and we will not check for that. */ + if (suite_context.inbound_op_mode == ODP_IPSEC_OP_MODE_INLINE) + return; + + ipsec_sa_param_fill(¶m, + false, false, 123, &tunnel, + ODP_CIPHER_ALG_NULL, NULL, + ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256, + NULL); + + sa = odp_ipsec_sa_create(¶m); + + CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa); + + ipsec_sa_param_fill(¶m, + true, false, 123, &tunnel, + ODP_CIPHER_ALG_NULL, NULL, + ODP_AUTH_ALG_SHA256_HMAC, &key_5a_256, + NULL); + + sa2 = odp_ipsec_sa_create(¶m); + + CU_ASSERT_NOT_EQUAL_FATAL(ODP_IPSEC_SA_INVALID, sa2); + + ipsec_test_part test = { + .pkt_in = &pkt_test_nodata, + .num_opt = 1, + .opt = { .flag.tfc_dummy = 1, + .tfc_pad_len = 16, }, + .out_pkt = 1, + .out = { + { .status.warn.all = 0, + .status.error.all = 0, + .l3_type = ODP_PROTO_L3_TYPE_IPV4, + .l4_type = ODP_PROTO_L4_TYPE_NO_NEXT, + .pkt_out = NULL }, + }, + }; + + ipsec_test_part test_empty = { + .pkt_in = &pkt_test_emtpy, + .num_opt = 1, + .opt = { .flag.tfc_dummy = 1, + .tfc_pad_len = 16, }, + .out_pkt = 1, + .out = { + { .status.warn.all = 0, + .status.error.all = 0, + .l3_type = ODP_PROTO_L3_TYPE_IPV4, + .l4_type = ODP_PROTO_L4_TYPE_NO_NEXT, + .pkt_out = NULL }, + }, + }; + + ipsec_check_out_in_one(&test, sa, sa2); + ipsec_check_out_in_one(&test_empty, sa, sa2); + + ipsec_sa_destroy(sa2); + ipsec_sa_destroy(sa); +} + static void ipsec_test_capability(void) { odp_ipsec_capability_t capa; @@ -1056,5 +1214,9 @@ odp_testinfo_t ipsec_out_suite[] = { ipsec_check_esp_null_sha256), ODP_TEST_INFO_CONDITIONAL(test_out_ipv6_esp_udp_null_sha256, ipsec_check_esp_null_sha256), + ODP_TEST_INFO_CONDITIONAL(test_out_dummy_esp_null_sha256_tun_ipv4, + ipsec_check_esp_null_sha256), + ODP_TEST_INFO_CONDITIONAL(test_out_dummy_esp_null_sha256_tun_ipv6, + ipsec_check_esp_null_sha256), ODP_TEST_INFO_NULL, }; diff --git a/test/validation/api/ipsec/test_vectors.h b/test/validation/api/ipsec/test_vectors.h index 4d5ab3bd..5b357a16 100644 --- a/test/validation/api/ipsec/test_vectors.h +++ b/test/validation/api/ipsec/test_vectors.h @@ -1865,4 +1865,22 @@ static const ODP_UNUSED ipsec_test_packet }, };
+static const ipsec_test_packet pkt_test_emtpy = { + .len = 0, + .l2_offset = ODP_PACKET_OFFSET_INVALID, + .l3_offset = ODP_PACKET_OFFSET_INVALID, + .l4_offset = ODP_PACKET_OFFSET_INVALID, + .data = { 0 }, +}; + +static const ipsec_test_packet pkt_test_nodata = { + .len = 14, + .l2_offset = 0, + .l3_offset = ODP_PACKET_OFFSET_INVALID, + .l4_offset = ODP_PACKET_OFFSET_INVALID, + .data = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, + 0x0a, 0x0b, 0x0c, 0x0d, + }, +}; #endif
commit 017969502cd0247c9b25e80e002ac563860f5a5d Author: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Date: Wed Feb 21 19:00:30 2018 +0300
linux-gen: ipsec: support TFC dummy packet generation
Signed-off-by: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/odp_ipsec.c b/platform/linux-generic/odp_ipsec.c index 78814eeb..1e90cea0 100644 --- a/platform/linux-generic/odp_ipsec.c +++ b/platform/linux-generic/odp_ipsec.c @@ -476,6 +476,12 @@ static int ipsec_in_esp(odp_packet_t *pkt, state->in.hdr_len = _ODP_ESPHDR_LEN + ipsec_sa->esp_iv_len; state->in.trl_len = _ODP_ESPTRL_LEN + ipsec_sa->icv_len;
+ if (odp_unlikely(state->ip_tot_len < + state->ip_hdr_len + state->in.hdr_len + ipsec_sa->icv_len)) { + status->error.proto = 1; + return -1; + } + param->cipher_range.offset = ipsec_offset + state->in.hdr_len; param->cipher_range.length = state->ip_tot_len - state->ip_hdr_len - @@ -949,8 +955,10 @@ static int ipsec_out_tunnel_ipv4(odp_packet_t *pkt, state->ip_hdr_len = _ODP_IPV4HDR_LEN; if (state->is_ipv4) state->ip_next_hdr = _ODP_IPPROTO_IPIP; - else + else if (state->is_ipv6) state->ip_next_hdr = _ODP_IPPROTO_IPV6; + else + state->ip_next_hdr = _ODP_IPPROTO_NO_NEXT; state->ip_next_hdr_offset = state->ip_offset + _ODP_IPV4HDR_PROTO_OFFSET;
@@ -1008,8 +1016,10 @@ static int ipsec_out_tunnel_ipv6(odp_packet_t *pkt, state->ip_hdr_len = _ODP_IPV6HDR_LEN; if (state->is_ipv4) state->ip_next_hdr = _ODP_IPPROTO_IPIP; - else + else if (state->is_ipv6) state->ip_next_hdr = _ODP_IPPROTO_IPV6; + else + state->ip_next_hdr = _ODP_IPPROTO_NO_NEXT; state->ip_next_hdr_offset = state->ip_offset + _ODP_IPV6HDR_NHDR_OFFSET;
state->is_ipv4 = 0; @@ -1070,13 +1080,20 @@ static int ipsec_out_esp(odp_packet_t *pkt, uint32_t encrypt_len; uint16_t ip_data_len = state->ip_tot_len - state->ip_hdr_len; - uint16_t tfc_len = opt->flag.tfc_pad ? opt->tfc_pad_len : 0; + uint16_t tfc_len = (opt->flag.tfc_pad || opt->flag.tfc_dummy) ? + opt->tfc_pad_len : 0; uint32_t pad_block = ipsec_sa->esp_block_len; uint16_t ipsec_offset = state->ip_offset + state->ip_hdr_len; unsigned hdr_len; unsigned trl_len; + unsigned pkt_len, new_len; uint8_t proto = _ODP_IPPROTO_ESP;
+ if (odp_unlikely(opt->flag.tfc_dummy)) { + ip_data_len = 0; + state->ip_tot_len = state->ip_offset + state->ip_hdr_len; + } + /* ESP trailer should be 32-bit right aligned */ if (pad_block < 4) pad_block = 4; @@ -1131,19 +1148,34 @@ static int ipsec_out_esp(odp_packet_t *pkt, _odp_ipv4hdr_t *ipv4hdr = state->ip;
ipv4hdr->tot_len = _odp_cpu_to_be_16(state->ip_tot_len); - } else { + } else if (state->is_ipv6) { _odp_ipv6hdr_t *ipv6hdr = state->ip;
ipv6hdr->payload_len = _odp_cpu_to_be_16(state->ip_tot_len - _ODP_IPV6HDR_LEN); }
- if (odp_packet_extend_tail(pkt, trl_len, NULL, NULL) < 0 || - odp_packet_extend_head(pkt, hdr_len, NULL, NULL) < 0) { + if (odp_packet_extend_head(pkt, hdr_len, NULL, NULL) < 0) { status->error.alg = 1; return -1; }
+ pkt_len = odp_packet_len(*pkt); + new_len = state->ip_offset + state->ip_tot_len; + if (pkt_len >= new_len) { + if (odp_packet_trunc_tail(pkt, pkt_len - new_len, + NULL, NULL) < 0) { + status->error.alg = 1; + return -1; + } + } else { + if (odp_packet_extend_tail(pkt, new_len - pkt_len, + NULL, NULL) < 0) { + status->error.alg = 1; + return -1; + } + } + odp_packet_move_data(*pkt, 0, hdr_len, ipsec_offset);
uint32_t esptrl_offset = state->ip_offset + @@ -1167,6 +1199,8 @@ static int ipsec_out_esp(odp_packet_t *pkt, ipsec_offset + _ODP_ESPHDR_LEN, ipsec_sa->esp_iv_len, state->iv + ipsec_sa->salt_length); + /* 0xa5 is a good value to fill data instead of generating random data + * to create TFC padding */ _odp_packet_set_data(*pkt, esptrl_offset - esptrl.pad_len - tfc_len, 0xa5, tfc_len); odp_packet_copy_from_mem(*pkt, @@ -1176,6 +1210,12 @@ static int ipsec_out_esp(odp_packet_t *pkt, esptrl_offset, _ODP_ESPTRL_LEN, &esptrl);
+ if (odp_unlikely(state->ip_tot_len < + state->ip_hdr_len + hdr_len + ipsec_sa->icv_len)) { + status->error.proto = 1; + return -1; + } + param->cipher_range.offset = ipsec_offset + hdr_len; param->cipher_range.length = state->ip_tot_len - state->ip_hdr_len - @@ -1327,15 +1367,30 @@ static ipsec_sa_t *ipsec_out_single(odp_packet_t pkt, odp_ipsec_frag_mode_t frag_mode; uint32_t mtu;
- state.ip_offset = odp_packet_l3_offset(pkt); - ODP_ASSERT(ODP_PACKET_OFFSET_INVALID != state.ip_offset); - - state.ip = odp_packet_l3_ptr(pkt, NULL); - ODP_ASSERT(NULL != state.ip); - ipsec_sa = _odp_ipsec_sa_use(sa); ODP_ASSERT(NULL != ipsec_sa);
+ if (opt->flag.tfc_dummy) { + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); + + ODP_ASSERT(ODP_IPSEC_MODE_TUNNEL == ipsec_sa->mode); + pkt_hdr->p.l2_offset = ODP_PACKET_OFFSET_INVALID; + pkt_hdr->p.l3_offset = 0; + state.ip_offset = 0; + state.ip = NULL; + state.is_ipv4 = 0; + state.is_ipv6 = 0; + } else { + state.ip_offset = odp_packet_l3_offset(pkt); + ODP_ASSERT(ODP_PACKET_OFFSET_INVALID != state.ip_offset); + + state.ip = odp_packet_l3_ptr(pkt, NULL); + ODP_ASSERT(NULL != state.ip); + + state.is_ipv4 = (((uint8_t *)state.ip)[0] >> 4) == 0x4; + state.is_ipv6 = (((uint8_t *)state.ip)[0] >> 4) == 0x6; + } + frag_mode = opt->flag.frag_mode ? opt->frag_mode : ipsec_sa->out.frag_mode; if (frag_mode == ODP_IPSEC_FRAG_CHECK) @@ -1346,9 +1401,6 @@ static ipsec_sa_t *ipsec_out_single(odp_packet_t pkt, /* Initialize parameters block */ memset(¶m, 0, sizeof(param));
- state.is_ipv4 = (((uint8_t *)state.ip)[0] >> 4) == 0x4; - state.is_ipv6 = (((uint8_t *)state.ip)[0] >> 4) == 0x6; - if (ODP_IPSEC_MODE_TRANSPORT == ipsec_sa->mode) { if (state.is_ipv4) rc = ipsec_parse_ipv4(&state, pkt); @@ -1364,7 +1416,12 @@ static ipsec_sa_t *ipsec_out_single(odp_packet_t pkt, rc = ipsec_out_tunnel_parse_ipv4(&state, ipsec_sa); else if (state.is_ipv6) rc = ipsec_out_tunnel_parse_ipv6(&state, ipsec_sa); - else + else if (opt->flag.tfc_dummy) { + state.out_tunnel.ip_tos = 0; + state.out_tunnel.ip_df = 0; + state.out_tunnel.ip_flabel = 0; + rc = 0; + } else rc = -1; if (rc < 0) { status->error.alg = 1; @@ -1745,9 +1802,14 @@ int odp_ipsec_out_inline(const odp_packet_t pkt_in[], int num_in, else opt = ¶m->opt[opt_idx];
+ ipsec_sa = ipsec_out_single(pkt, sa, &pkt, opt, &status); + ODP_ASSERT(NULL != ipsec_sa); + hdr_len = inline_param[in_pkt].outer_hdr.len; ptr = inline_param[in_pkt].outer_hdr.ptr; offset = odp_packet_l3_offset(pkt); + if (odp_unlikely(offset == ODP_PACKET_OFFSET_INVALID)) + offset = 0; if (offset >= hdr_len) { if (odp_packet_trunc_head(&pkt, offset - hdr_len, NULL, NULL) < 0) @@ -1766,9 +1828,6 @@ int odp_ipsec_out_inline(const odp_packet_t pkt_in[], int num_in, ptr) < 0) status.error.alg = 1;
- ipsec_sa = ipsec_out_single(pkt, sa, &pkt, opt, &status); - ODP_ASSERT(NULL != ipsec_sa); - packet_subtype_set(pkt, ODP_EVENT_PACKET_IPSEC); result = ipsec_pkt_result(pkt); memset(result, 0, sizeof(*result));
commit 3a4f369fb2019761af5d4d7ad09d48f1e5d44f82 Author: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Date: Wed Feb 21 16:33:30 2018 +0300
linux-gen: ipsec: support tfc_pad_len IPsec option
Signed-off-by: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/odp_ipsec.c b/platform/linux-generic/odp_ipsec.c index fb852e70..78814eeb 100644 --- a/platform/linux-generic/odp_ipsec.c +++ b/platform/linux-generic/odp_ipsec.c @@ -1061,7 +1061,8 @@ static int ipsec_out_esp(odp_packet_t *pkt, ipsec_sa_t *ipsec_sa, odp_crypto_packet_op_param_t *param, odp_ipsec_op_status_t *status, - uint32_t mtu) + uint32_t mtu, + const odp_ipsec_out_opt_t *opt) { _odp_esphdr_t esp; _odp_esptrl_t esptrl; @@ -1069,6 +1070,7 @@ static int ipsec_out_esp(odp_packet_t *pkt, uint32_t encrypt_len; uint16_t ip_data_len = state->ip_tot_len - state->ip_hdr_len; + uint16_t tfc_len = opt->flag.tfc_pad ? opt->tfc_pad_len : 0; uint32_t pad_block = ipsec_sa->esp_block_len; uint16_t ipsec_offset = state->ip_offset + state->ip_hdr_len; unsigned hdr_len; @@ -1079,7 +1081,7 @@ static int ipsec_out_esp(odp_packet_t *pkt, if (pad_block < 4) pad_block = 4;
- encrypt_len = IPSEC_PAD_LEN(ip_data_len + _ODP_ESPTRL_LEN, + encrypt_len = IPSEC_PAD_LEN(ip_data_len + tfc_len + _ODP_ESPTRL_LEN, pad_block);
hdr_len = _ODP_ESPHDR_LEN + ipsec_sa->esp_iv_len; @@ -1120,7 +1122,7 @@ static int ipsec_out_esp(odp_packet_t *pkt, param->aad_ptr = (uint8_t *)&state->esp.aad;
memset(&esptrl, 0, sizeof(esptrl)); - esptrl.pad_len = encrypt_len - ip_data_len - _ODP_ESPTRL_LEN; + esptrl.pad_len = encrypt_len - ip_data_len - tfc_len - _ODP_ESPTRL_LEN; esptrl.next_header = state->ip_next_hdr;
odp_packet_copy_from_mem(*pkt, state->ip_next_hdr_offset, 1, &proto); @@ -1165,6 +1167,8 @@ static int ipsec_out_esp(odp_packet_t *pkt, ipsec_offset + _ODP_ESPHDR_LEN, ipsec_sa->esp_iv_len, state->iv + ipsec_sa->salt_length); + _odp_packet_set_data(*pkt, esptrl_offset - esptrl.pad_len - tfc_len, + 0xa5, tfc_len); odp_packet_copy_from_mem(*pkt, esptrl_offset - esptrl.pad_len, esptrl.pad_len, ipsec_padding); @@ -1384,7 +1388,8 @@ static ipsec_sa_t *ipsec_out_single(odp_packet_t pkt, }
if (ODP_IPSEC_ESP == ipsec_sa->proto) { - rc = ipsec_out_esp(&pkt, &state, ipsec_sa, ¶m, status, mtu); + rc = ipsec_out_esp(&pkt, &state, ipsec_sa, ¶m, status, mtu, + opt); } else if (ODP_IPSEC_AH == ipsec_sa->proto) { rc = ipsec_out_ah(&pkt, &state, ipsec_sa, ¶m, status, mtu); } else {
-----------------------------------------------------------------------
Summary of changes: configure.ac | 4 +- platform/Makefile.inc | 2 +- platform/linux-generic/m4/configure.m4 | 2 +- platform/linux-generic/odp_impl.c | 30 +----- platform/linux-generic/odp_ipsec.c | 108 +++++++++++++++---- platform/linux-generic/odp_packet_io.c | 23 +++- platform/linux-generic/odp_queue_basic.c | 56 ++++++---- platform/linux-generic/odp_system_info.c | 26 +++-- test/validation/api/ipsec/ipsec.c | 7 +- test/validation/api/ipsec/ipsec_test_out.c | 162 +++++++++++++++++++++++++++++ test/validation/api/ipsec/test_vectors.h | 18 ++++ 11 files changed, 351 insertions(+), 87 deletions(-)
hooks/post-receive