net/tap: fix vdev data sharing for tun
authorVipin Varghese <vipin.varghese@intel.com>
Tue, 22 May 2018 11:01:54 +0000 (16:31 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 22 May 2018 22:35:01 +0000 (00:35 +0200)
Enables TUN PMD sharing by attaching the port from the shared data.

Fixes: ee27edbe0c10 ("drivers/net: share vdev data to secondary process")

Signed-off-by: Vipin Varghese <vipin.varghese@intel.com>
Acked-by: Keith Wiles <keith.wiles@intel.com>
drivers/net/tap/rte_eth_tap.c

index 6bb7962..310c7d8 100644 (file)
@@ -1653,6 +1653,7 @@ rte_pmd_tun_probe(struct rte_vdev_device *dev)
        struct rte_kvargs *kvlist = NULL;
        char tun_name[RTE_ETH_NAME_MAX_LEN];
        char remote_iface[RTE_ETH_NAME_MAX_LEN];
+       struct rte_eth_dev *eth_dev;
 
        strcpy(tuntap_name, "TUN");
 
@@ -1660,6 +1661,17 @@ rte_pmd_tun_probe(struct rte_vdev_device *dev)
        params = rte_vdev_device_args(dev);
        memset(remote_iface, 0, RTE_ETH_NAME_MAX_LEN);
 
+       if (rte_eal_process_type() == RTE_PROC_SECONDARY &&
+           strlen(params) == 0) {
+               eth_dev = rte_eth_dev_attach_secondary(name);
+               if (!eth_dev) {
+                       TAP_LOG(ERR, "Failed to probe %s", name);
+                       return -1;
+               }
+               eth_dev->dev_ops = &ops;
+               return 0;
+       }
+
        snprintf(tun_name, sizeof(tun_name), "%s%u",
                 DEFAULT_TUN_NAME, tun_unit++);