diff mbox

[API-NEXT,2/2] linux-generic: pktio: check pool type is ODP_POOL_PACKET

Message ID 1441361788-2723-2-git-send-email-stuart.haslam@linaro.org
State Accepted
Commit 0036672a535d17a8ae90622c1eb825cc1399b5aa
Headers show

Commit Message

Stuart Haslam Sept. 4, 2015, 10:16 a.m. UTC
Signed-off-by: Stuart Haslam <stuart.haslam@linaro.org>
---
 platform/linux-generic/odp_packet_io.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
diff mbox

Patch

diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c
index 4e07766..58d4764 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -248,11 +248,26 @@  static odp_pktio_t setup_pktio_entry(const char *dev, odp_pool_t pool,
 	return id;
 }
 
+static int pool_type_is_packet(odp_pool_t pool)
+{
+	odp_pool_info_t pool_info;
+
+	if (pool == ODP_POOL_INVALID)
+		return 0;
+
+	if (odp_pool_info(pool, &pool_info) != 0)
+		return 0;
+
+	return pool_info.params.type == ODP_POOL_PACKET;
+}
+
 odp_pktio_t odp_pktio_open(const char *dev, odp_pool_t pool,
 			   const odp_pktio_param_t *param)
 {
 	odp_pktio_t id;
 
+	ODP_ASSERT(pool_type_is_packet(pool));
+
 	id = odp_pktio_lookup(dev);
 	if (id != ODP_PKTIO_INVALID) {
 		/* interface is already open */