ofproto-dpif: Query port existence by name to prevent warnings.
[openvswitch] / ofproto / ofproto-dpif.c
index 283aea98d58989103c60d359f2867384a20ead66..cc37d947fb6d871c67633ec2b6aae3a9d28b1834 100644 (file)
@@ -780,6 +780,12 @@ del(const char *type, const char *name)
     return error;
 }
 \f
+static const char *
+port_open_type(const char *datapath_type, const char *port_type)
+{
+    return dpif_port_open_type(datapath_type, port_type);
+}
+
 /* Type functions. */
 
 static int
@@ -1532,19 +1538,17 @@ port_destruct(struct ofport *port_)
 {
     struct ofport_dpif *port = ofport_dpif_cast(port_);
     struct ofproto_dpif *ofproto = ofproto_dpif_cast(port->up.ofproto);
-    struct dpif_port dpif_port;
+    const char *devname = netdev_get_name(port->up.netdev);
 
-    if (!dpif_port_query_by_number(ofproto->backer->dpif,
-                                   port->odp_port, &dpif_port)) {
+    if (dpif_port_exists(ofproto->backer->dpif, devname)) {
         /* The underlying device is still there, so delete it.  This
          * happens when the ofproto is being destroyed, since the caller
          * assumes that removal of attached ports will happen as part of
          * destruction. */
         dpif_port_del(ofproto->backer->dpif, port->odp_port);
-        dpif_port_destroy(&dpif_port);
     }
 
-    sset_find_and_delete(&ofproto->ports, netdev_get_name(port->up.netdev));
+    sset_find_and_delete(&ofproto->ports, devname);
     hmap_remove(&ofproto->backer->odp_to_ofport_map, &port->odp_port_node);
     ofproto->need_revalidate = REV_RECONFIGURE;
     bundle_remove(port_);
@@ -5170,7 +5174,7 @@ send_packet(const struct ofport_dpif *ofport, struct ofpbuf *packet)
     struct flow flow;
     int error;
 
-    flow_extract(packet, 0, NULL, 0, &flow);
+    flow_extract(packet, 0, NULL, OFPP_LOCAL, &flow);
     odp_port = vsp_realdev_to_vlandev(ofproto, ofport->odp_port,
                                       flow.vlan_tci);
     if (odp_port != ofport->odp_port) {
@@ -7865,6 +7869,7 @@ const struct ofproto_class ofproto_dpif_class = {
     enumerate_types,
     enumerate_names,
     del,
+    port_open_type,
     type_run,
     type_run_fast,
     type_wait,