[ovs-dev,RFC,v2,3/4] netdev-offload: Allow offloading to netdev without ifindex.
diff mbox series

Message ID 20191115201349.31841-4-i.maximets@ovn.org
State Superseded
Headers show
Series
  • netdev-offload: Prerequisites of vport offloading via DPDK.
Related show

Commit Message

Ilya Maximets Nov. 15, 2019, 8:13 p.m. UTC
Virtual interfaces like vports or dpdk vhost-user ports has no
proper ifindex, but could support some kind of offloading.

This is a prerequisite for tunneling vport offloading with DPDK
flow API.

Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
---
 lib/netdev-offload.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

Patch
diff mbox series

diff --git a/lib/netdev-offload.c b/lib/netdev-offload.c
index 00fb083fc..ed4392f77 100644
--- a/lib/netdev-offload.c
+++ b/lib/netdev-offload.c
@@ -525,10 +525,6 @@  netdev_ports_insert(struct netdev *netdev, const char *dpif_type,
     struct port_to_netdev_data *data;
     int ifindex = netdev_get_ifindex(netdev);
 
-    if (ifindex < 0) {
-        return ENODEV;
-    }
-
     ovs_rwlock_wrlock(&netdev_hmap_rwlock);
     if (netdev_ports_lookup(dpif_port->port_no, dpif_type)) {
         ovs_rwlock_unlock(&netdev_hmap_rwlock);
@@ -538,13 +534,18 @@  netdev_ports_insert(struct netdev *netdev, const char *dpif_type,
     data = xzalloc(sizeof *data);
     data->netdev = netdev_ref(netdev);
     dpif_port_clone(&data->dpif_port, dpif_port);
-    data->ifindex = ifindex;
+
+    if (ifindex >= 0) {
+        data->ifindex = ifindex;
+        hmap_insert(&ifindex_to_port, &data->ifindex_node, ifindex);
+    } else {
+        data->ifindex = -1;
+    }
 
     netdev_set_dpif_type(netdev, dpif_type);
 
     hmap_insert(&port_to_netdev, &data->portno_node,
                 netdev_ports_hash(dpif_port->port_no, dpif_type));
-    hmap_insert(&ifindex_to_port, &data->ifindex_node, ifindex);
     ovs_rwlock_unlock(&netdev_hmap_rwlock);
 
     netdev_init_flow_api(netdev);
@@ -580,7 +581,9 @@  netdev_ports_remove(odp_port_t port_no, const char *dpif_type)
         dpif_port_destroy(&data->dpif_port);
         netdev_close(data->netdev); /* unref and possibly close */
         hmap_remove(&port_to_netdev, &data->portno_node);
-        hmap_remove(&ifindex_to_port, &data->ifindex_node);
+        if (data->ifindex >= 0) {
+            hmap_remove(&ifindex_to_port, &data->ifindex_node);
+        }
         free(data);
         ret = 0;
     }