From: Guduri Prathyusha Date: Wed, 6 Sep 2017 07:15:41 +0000 (+0530) Subject: service: fix lcore stop X-Git-Tag: spdx-start~2154 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=aee62e906f5e59a8fac65c78cac811958aa11657;p=dpdk.git service: fix lcore stop lcore_states store the state of the lcore. Fixing the invalid dereference of lcore_states with service number Unit test case service_lcore_start_stop fails with the above fix. Service core was stopped without stopping the service. This commit fixes the test by adding negative and positive cases of stopping the service lcore before and after stopping the service respectively Fixes: 21698354c832 ("service: introduce service cores concept") Fixes: f038a81e1c56 ("service: add unit tests") Signed-off-by: Guduri Prathyusha Reviewed-by: Harry van Haaren --- diff --git a/lib/librte_eal/common/rte_service.c b/lib/librte_eal/common/rte_service.c index 2b5f9bdebe..43716bb6d2 100644 --- a/lib/librte_eal/common/rte_service.c +++ b/lib/librte_eal/common/rte_service.c @@ -625,9 +625,9 @@ rte_service_lcore_stop(uint32_t lcore) return -EALREADY; uint32_t i; + uint64_t service_mask = lcore_states[lcore].service_mask; for (i = 0; i < RTE_SERVICE_NUM_MAX; i++) { - int32_t enabled = - lcore_states[i].service_mask & (UINT64_C(1) << i); + int32_t enabled = service_mask & (UINT64_C(1) << i); int32_t service_running = rte_service_runstate_get(i); int32_t only_core = rte_services[i].num_mapped_cores == 1; diff --git a/test/test/test_service_cores.c b/test/test/test_service_cores.c index ddea7f0ba1..ee8313ef69 100644 --- a/test/test/test_service_cores.c +++ b/test/test/test_service_cores.c @@ -576,6 +576,10 @@ service_lcore_start_stop(void) "Service core expected to poll service but it didn't"); /* core stop */ + TEST_ASSERT_EQUAL(-EBUSY, rte_service_lcore_stop(slcore_id), + "Service core running a service should return -EBUSY"); + TEST_ASSERT_EQUAL(0, rte_service_runstate_set(sid, 0), + "Stopping valid service failed"); TEST_ASSERT_EQUAL(-EINVAL, rte_service_lcore_stop(100000), "Invalid Service core stop should return -EINVAL"); TEST_ASSERT_EQUAL(0, rte_service_lcore_stop(slcore_id),