[dpdk-dev] net/tap: add default name to tun

Message ID 1526028119-142177-1-git-send-email-vipin.varghese@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Varghese, Vipin May 11, 2018, 8:41 a.m. UTC
  The change adds default name to reflect TUN PMD instance. if option
name is not passed, the default dtun is taken.

Signed-off-by: Vipin Varghese <vipin.varghese@intel.com>
---
 drivers/net/tap/rte_eth_tap.c | 3 +++
 1 file changed, 3 insertions(+)
  

Comments

Stephen Hemminger May 11, 2018, 3:24 p.m. UTC | #1
On Fri, 11 May 2018 14:11:59 +0530
Vipin Varghese <vipin.varghese@intel.com> wrote:

> The change adds default name to reflect TUN PMD instance. if option
> name is not passed, the default dtun is taken.
> 
> Signed-off-by: Vipin Varghese <vipin.varghese@intel.com>
> ---
>  drivers/net/tap/rte_eth_tap.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
> index 172a7ba..fa59a76 100644
> --- a/drivers/net/tap/rte_eth_tap.c
> +++ b/drivers/net/tap/rte_eth_tap.c
> @@ -1665,6 +1665,9 @@ rte_pmd_tun_probe(struct rte_vdev_device *dev)
>  	params = rte_vdev_device_args(dev);
>  	memset(remote_iface, 0, RTE_ETH_NAME_MAX_LEN);
>  
> +	snprintf(tun_name, sizeof(tun_name), "%s%d",
> +		 DEFAULT_TUN_NAME, tun_unit++);

Use unsigned to avoid integer wraparound?
  
Varghese, Vipin May 12, 2018, 6:22 a.m. UTC | #2
Thanks Stephen, for pointing this out. I have shared a V2 for the same.

> -----Original Message-----
> From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> Sent: Friday, May 11, 2018 8:55 PM
> To: Varghese, Vipin <vipin.varghese@intel.com>
> Cc: Yigit, Ferruh <ferruh.yigit@intel.com>; Wang, Zhihong
> <zhihong.wang@intel.com>; dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH] net/tap: add default name to tun
> 
> On Fri, 11 May 2018 14:11:59 +0530
> Vipin Varghese <vipin.varghese@intel.com> wrote:
> 
> > The change adds default name to reflect TUN PMD instance. if option
> > name is not passed, the default dtun is taken.
> >
> > Signed-off-by: Vipin Varghese <vipin.varghese@intel.com>
> > ---
> >  drivers/net/tap/rte_eth_tap.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/net/tap/rte_eth_tap.c
> > b/drivers/net/tap/rte_eth_tap.c index 172a7ba..fa59a76 100644
> > --- a/drivers/net/tap/rte_eth_tap.c
> > +++ b/drivers/net/tap/rte_eth_tap.c
> > @@ -1665,6 +1665,9 @@ rte_pmd_tun_probe(struct rte_vdev_device *dev)
> >  	params = rte_vdev_device_args(dev);
> >  	memset(remote_iface, 0, RTE_ETH_NAME_MAX_LEN);
> >
> > +	snprintf(tun_name, sizeof(tun_name), "%s%d",
> > +		 DEFAULT_TUN_NAME, tun_unit++);
> 
> Use unsigned to avoid integer wraparound?
  

Patch

diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 172a7ba..fa59a76 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -1665,6 +1665,9 @@  rte_pmd_tun_probe(struct rte_vdev_device *dev)
 	params = rte_vdev_device_args(dev);
 	memset(remote_iface, 0, RTE_ETH_NAME_MAX_LEN);
 
+	snprintf(tun_name, sizeof(tun_name), "%s%d",
+		 DEFAULT_TUN_NAME, tun_unit++);
+
 	if (params && (params[0] != '\0')) {
 		TAP_LOG(DEBUG, "parameters (%s)", params);