diff mbox

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

Message ID 1438788402-9250-1-git-send-email-stuart.haslam@linaro.org
State New
Headers show

Commit Message

Stuart Haslam Aug. 5, 2015, 3:26 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(-)

Comments

Bill Fischofer Aug. 5, 2015, 6:30 p.m. UTC | #1
On Wed, Aug 5, 2015 at 10:26 AM, Stuart Haslam <stuart.haslam@linaro.org>
wrote:

> 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 --git a/platform/linux-generic/include/odp_packet_io_internal.h
> b/platform/linux-generic/include/odp_packet_io_internal.h
> index f5a5824..14532a3 100644
> --- a/platform/linux-generic/include/odp_packet_io_internal.h
> +++ b/platform/linux-generic/include/odp_packet_io_internal.h
> @@ -28,6 +28,8 @@ extern "C" {
>  #include <odp/hints.h>
>  #include <net/if.h>
>
> +#define PKTIO_NAME_LEN 64
>

Given the name string structure for PCAP types, is 64 sufficient?  By my
count the basic "overhead" of the pcap name string is 20 characters
(pcap:in=:out=:loops=), so I'd think 128 would be a more reasonable limit
here.


> +
>  /* Forward declaration */
>  struct pktio_if_ops;
>
> @@ -51,7 +53,7 @@ struct pktio_entry {
>                                                  *   API for IO */
>         };
>         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() */
>  };
>
> diff --git a/platform/linux-generic/odp_packet_io.c
> b/platform/linux-generic/odp_packet_io.c
> index f3a4543..57db6e3 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;
>         }
>
> @@ -236,7 +236,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);
>                 unlock_entry_classifier(pktio_entry);
>         }
>
> @@ -301,7 +302,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);
> --
> 2.1.1
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
>
Stuart Haslam Aug. 6, 2015, 9:25 a.m. UTC | #2
On Wed, Aug 05, 2015 at 01:30:38PM -0500, Bill Fischofer wrote:
> On Wed, Aug 5, 2015 at 10:26 AM, Stuart Haslam <stuart.haslam@linaro.org>
> wrote:
> 
> > 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 --git a/platform/linux-generic/include/odp_packet_io_internal.h
> > b/platform/linux-generic/include/odp_packet_io_internal.h
> > index f5a5824..14532a3 100644
> > --- a/platform/linux-generic/include/odp_packet_io_internal.h
> > +++ b/platform/linux-generic/include/odp_packet_io_internal.h
> > @@ -28,6 +28,8 @@ extern "C" {
> >  #include <odp/hints.h>
> >  #include <net/if.h>
> >
> > +#define PKTIO_NAME_LEN 64
> >
> 
> Given the name string structure for PCAP types, is 64 sufficient?  By my
> count the basic "overhead" of the pcap name string is 20 characters
> (pcap:in=:out=:loops=), so I'd think 128 would be a more reasonable limit
> here.
> 

Yes you're right, I'll change it.
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 f5a5824..14532a3 100644
--- a/platform/linux-generic/include/odp_packet_io_internal.h
+++ b/platform/linux-generic/include/odp_packet_io_internal.h
@@ -28,6 +28,8 @@  extern "C" {
 #include <odp/hints.h>
 #include <net/if.h>
 
+#define PKTIO_NAME_LEN 64
+
 /* Forward declaration */
 struct pktio_if_ops;
 
@@ -51,7 +53,7 @@  struct pktio_entry {
 						 *   API for IO */
 	};
 	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() */
 };
 
diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c
index f3a4543..57db6e3 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;
 	}
 
@@ -236,7 +236,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);
 		unlock_entry_classifier(pktio_entry);
 	}
 
@@ -301,7 +302,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);