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

Message ID 1526106093-78092-1-git-send-email-vipin.varghese@intel.com (mailing list archive)
State Accepted, 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 12, 2018, 6:21 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>
---

Changes in V2:
unsigned instead of signed for dev_index - Stephen Hemminger
---
 drivers/net/tap/rte_eth_tap.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
  

Comments

Ferruh Yigit May 14, 2018, 4:01 p.m. UTC | #1
On 5/12/2018 7:21 AM, Vipin Varghese 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>

Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
  
Ferruh Yigit May 14, 2018, 4:12 p.m. UTC | #2
On 5/14/2018 5:01 PM, Ferruh Yigit wrote:
> On 5/12/2018 7:21 AM, Vipin Varghese 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>
> 
> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied to dpdk-next-net/master, thanks.
  

Patch

diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 172a7ba..48c61b3 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -65,7 +65,7 @@  static const char *valid_arguments[] = {
 };
 
 static int tap_unit;
-static int tun_unit;
+static unsigned int tun_unit;
 
 static int tap_type;
 static char tuntap_name[8];
@@ -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%u",
+		 DEFAULT_TUN_NAME, tun_unit++);
+
 	if (params && (params[0] != '\0')) {
 		TAP_LOG(DEBUG, "parameters (%s)", params);