diff mbox

[PATCHv3,1/4] linux-generic: pktio: extend maximum devname length

Message ID 1444824388-25708-2-git-send-email-stuart.haslam@linaro.org
State Accepted
Commit 5185d35325b541d1183df86174db54bd7cdbd260
Headers show

Commit Message

Stuart Haslam Oct. 14, 2015, 12:06 p.m. UTC
Signed-off-by: Stuart Haslam <stuart.haslam@linaro.org>
---
 platform/linux-generic/include/odp_packet_io_internal.h | 4 +++-
 platform/linux-generic/odp_packet_io.c                  | 9 +++++----
 2 files changed, 8 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h
index 353b40d..590b816 100644
--- a/platform/linux-generic/include/odp_packet_io_internal.h
+++ b/platform/linux-generic/include/odp_packet_io_internal.h
@@ -30,6 +30,8 @@  extern "C" {
 #include <odp/hints.h>
 #include <net/if.h>
 
+#define PKTIO_NAME_LEN 256
+
 /* Forward declaration */
 struct pktio_if_ops;
 
@@ -58,7 +60,7 @@  struct pktio_entry {
 		STATE_STOP
 	} state;
 	classifier_t cls;		/**< classifier linked with this pktio*/
-	char name[IF_NAMESIZE];		/**< name of pktio provided to
+	char name[PKTIO_NAME_LEN];	/**< name of pktio provided to
 					   pktio_open() */
 	odp_pktio_param_t param;
 };
diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c
index fa0817a..07bcf78 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -203,10 +203,10 @@  static odp_pktio_t setup_pktio_entry(const char *dev, odp_pool_t pool,
 	int ret = -1;
 	int pktio_if;
 
-	if (strlen(dev) >= IF_NAMESIZE) {
+	if (strlen(dev) >= PKTIO_NAME_LEN - 1) {
 		/* ioctl names limitation */
 		ODP_ERR("pktio name %s is too big, limit is %d bytes\n",
-			dev, IF_NAMESIZE);
+			dev, PKTIO_NAME_LEN - 1);
 		return ODP_PKTIO_INVALID;
 	}
 
@@ -238,7 +238,8 @@  static odp_pktio_t setup_pktio_entry(const char *dev, odp_pool_t pool,
 		id = ODP_PKTIO_INVALID;
 		ODP_ERR("Unable to init any I/O type.\n");
 	} else {
-		snprintf(pktio_entry->s.name, IF_NAMESIZE, "%s", dev);
+		snprintf(pktio_entry->s.name,
+			 sizeof(pktio_entry->s.name), "%s", dev);
 		pktio_entry->s.state = STATE_STOP;
 		unlock_entry_classifier(pktio_entry);
 	}
@@ -343,7 +344,7 @@  odp_pktio_t odp_pktio_lookup(const char *dev)
 		lock_entry(entry);
 
 		if (!is_free(entry) &&
-		    strncmp(entry->s.name, dev, IF_NAMESIZE) == 0)
+		    strncmp(entry->s.name, dev, sizeof(entry->s.name)) == 0)
 			id = _odp_cast_scalar(odp_pktio_t, i);
 
 		unlock_entry(entry);