ofproto: Consistently use netdev's name instead of ofp_phy_port name.
[sliver-openvswitch.git] / ofproto / ofproto.c
index 8b8b28d..02f55f5 100644 (file)
@@ -57,7 +57,6 @@
 #include "shash.h"
 #include "sset.h"
 #include "stream-ssl.h"
-#include "svec.h"
 #include "tag.h"
 #include "timer.h"
 #include "timeval.h"
@@ -326,6 +325,7 @@ static const struct ofhooks default_ofhooks;
 static uint64_t pick_datapath_id(const struct ofproto *);
 static uint64_t pick_fallback_dpid(void);
 
+static void ofproto_flush_flows__(struct ofproto *);
 static int ofproto_expire(struct ofproto *);
 static void flow_push_stats(struct ofproto *, const struct rule *,
                             struct flow *, uint64_t packets, uint64_t bytes,
@@ -544,7 +544,7 @@ ofproto_set_desc(struct ofproto *p,
 }
 
 int
-ofproto_set_snoops(struct ofproto *ofproto, const struct svec *snoops)
+ofproto_set_snoops(struct ofproto *ofproto, const struct sset *snoops)
 {
     return connmgr_set_snoops(ofproto->connmgr, snoops);
 }
@@ -553,7 +553,7 @@ int
 ofproto_set_netflow(struct ofproto *ofproto,
                     const struct netflow_options *nf_options)
 {
-    if (nf_options && nf_options->collectors.n) {
+    if (nf_options && !sset_is_empty(&nf_options->collectors)) {
         if (!ofproto->netflow) {
             ofproto->netflow = netflow_create();
         }
@@ -668,8 +668,14 @@ ofproto_get_fail_mode(const struct ofproto *p)
     return connmgr_get_fail_mode(p->connmgr);
 }
 
+bool
+ofproto_has_snoops(const struct ofproto *ofproto)
+{
+    return connmgr_has_snoops(ofproto->connmgr);
+}
+
 void
-ofproto_get_snoops(const struct ofproto *ofproto, struct svec *snoops)
+ofproto_get_snoops(const struct ofproto *ofproto, struct sset *snoops)
 {
     connmgr_get_snoops(ofproto->connmgr, snoops);
 }
@@ -685,7 +691,7 @@ ofproto_destroy(struct ofproto *p)
 
     shash_find_and_delete(&all_ofprotos, dpif_name(p->dpif));
 
-    ofproto_flush_flows(p);
+    ofproto_flush_flows__(p);
     connmgr_destroy(p->connmgr);
     classifier_destroy(&p->cls);
     hmap_destroy(&p->facets);
@@ -906,7 +912,7 @@ int
 ofproto_port_del(struct ofproto *ofproto, uint16_t odp_port)
 {
     struct ofport *ofport = get_port(ofproto, odp_port);
-    const char *name = ofport ? ofport->opp.name : "<unknown>";
+    const char *name = ofport ? netdev_get_name(ofport->netdev) : "<unknown>";
     int error;
 
     error = dpif_port_del(ofproto->dpif, odp_port);
@@ -914,8 +920,8 @@ ofproto_port_del(struct ofproto *ofproto, uint16_t odp_port)
         VLOG_ERR("%s: failed to remove port %"PRIu16" (%s) interface (%s)",
                  dpif_name(ofproto->dpif), odp_port, name, strerror(error));
     } else if (ofport) {
-        /* 'name' is ofport->opp.name and update_port() is going to destroy
-         * 'ofport'.  Just in case update_port() refers to 'name' after it
+        /* 'name' is the netdev's name and update_port() is going to close the
+         * netdev.  Just in case update_port() refers to 'name' after it
          * destroys 'ofport', make a copy of it around the update_port()
          * call. */
         char *devname = xstrdup(name);
@@ -994,8 +1000,8 @@ ofproto_delete_flow(struct ofproto *ofproto, const struct cls_rule *target)
     }
 }
 
-void
-ofproto_flush_flows(struct ofproto *ofproto)
+static void
+ofproto_flush_flows__(struct ofproto *ofproto)
 {
     struct facet *facet, *next_facet;
     struct rule *rule, *next_rule;
@@ -1020,6 +1026,12 @@ ofproto_flush_flows(struct ofproto *ofproto)
     }
 
     dpif_flow_flush(ofproto->dpif);
+}
+
+void
+ofproto_flush_flows(struct ofproto *ofproto)
+{
+    ofproto_flush_flows__(ofproto);
     connmgr_flushed(ofproto->connmgr);
 }
 \f
@@ -1036,7 +1048,7 @@ reinit_ports(struct ofproto *p)
 
     sset_init(&devnames);
     HMAP_FOR_EACH (ofport, hmap_node, &p->ports) {
-        sset_add(&devnames, ofport->opp.name);
+        sset_add(&devnames, netdev_get_name(ofport->netdev));
     }
     DPIF_PORT_FOR_EACH (&dpif_port, &dump, p->dpif) {
         sset_add(&devnames, dpif_port.name);
@@ -1126,7 +1138,7 @@ ofport_equal(const struct ofport *a_, const struct ofport *b_)
 static void
 ofport_install(struct ofproto *p, struct ofport *ofport)
 {
-    const char *netdev_name = ofport->opp.name;
+    const char *netdev_name = netdev_get_name(ofport->netdev);
 
     netdev_monitor_add(p->netdev_monitor, ofport->netdev);
     hmap_insert(&p->ports, &ofport->hmap_node, hash_int(ofport->odp_port, 0));
@@ -1142,7 +1154,8 @@ ofport_remove(struct ofproto *p, struct ofport *ofport)
     netdev_monitor_remove(p->netdev_monitor, ofport->netdev);
     hmap_remove(&p->ports, &ofport->hmap_node);
     shash_delete(&p->port_by_name,
-                 shash_find(&p->port_by_name, ofport->opp.name));
+                 shash_find(&p->port_by_name,
+                            netdev_get_name(ofport->netdev)));
     if (p->sflow) {
         ofproto_sflow_del_port(p->sflow, ofport->odp_port);
     }