table: Avoid segmentation fault when printing an empty cell in JSON format.
[sliver-openvswitch.git] / lib / dpif.c
index a95985a..a01b998 100644 (file)
@@ -68,6 +68,7 @@ struct registered_dpif_class {
     int refcount;
 };
 static struct shash dpif_classes = SHASH_INITIALIZER(&dpif_classes);
+static struct sset dpif_blacklist = SSET_INITIALIZER(&dpif_blacklist);
 
 /* Rate limit for individual messages going to or from the datapath, output at
  * DBG level.  This is very high because, if these are enabled, it is because
@@ -108,6 +109,12 @@ dp_register_provider(const struct dpif_class *new_class)
 {
     struct registered_dpif_class *registered_class;
 
+    if (sset_contains(&dpif_blacklist, new_class->type)) {
+        VLOG_DBG("attempted to register blacklisted provider: %s",
+                 new_class->type);
+        return EINVAL;
+    }
+
     if (shash_find(&dpif_classes, new_class->type)) {
         VLOG_WARN("attempted to register duplicate datapath provider: %s",
                   new_class->type);
@@ -151,6 +158,14 @@ dp_unregister_provider(const char *type)
     return 0;
 }
 
+/* Blacklists a provider.  Causes future calls of dp_register_provider() with
+ * a dpif_class which implements 'type' to fail. */
+void
+dp_blacklist_provider(const char *type)
+{
+    sset_add(&dpif_blacklist, type);
+}
+
 /* Clears 'types' and enumerates the types of all currently registered datapath
  * providers into it.  The caller must first initialize the sset. */
 void
@@ -388,33 +403,6 @@ dpif_get_dp_stats(const struct dpif *dpif, struct dpif_dp_stats *stats)
     return error;
 }
 
-/* Retrieves the current IP fragment handling policy for 'dpif' into
- * '*drop_frags': true indicates that fragments are dropped, false indicates
- * that fragments are treated in the same way as other IP packets (except that
- * the L4 header cannot be read).  Returns 0 if successful, otherwise a
- * positive errno value. */
-int
-dpif_get_drop_frags(const struct dpif *dpif, bool *drop_frags)
-{
-    int error = dpif->dpif_class->get_drop_frags(dpif, drop_frags);
-    if (error) {
-        *drop_frags = false;
-    }
-    log_operation(dpif, "get_drop_frags", error);
-    return error;
-}
-
-/* Changes 'dpif''s treatment of IP fragments to 'drop_frags', whose meaning is
- * the same as for the get_drop_frags member function.  Returns 0 if
- * successful, otherwise a positive errno value. */
-int
-dpif_set_drop_frags(struct dpif *dpif, bool drop_frags)
-{
-    int error = dpif->dpif_class->set_drop_frags(dpif, drop_frags);
-    log_operation(dpif, "set_drop_frags", error);
-    return error;
-}
-
 /* Attempts to add 'netdev' as a port on 'dpif'.  If successful, returns 0 and
  * sets '*port_nop' to the new port's port number (if 'port_nop' is non-null).
  * On failure, returns a positive errno value and sets '*port_nop' to
@@ -974,7 +962,7 @@ dpif_execute(struct dpif *dpif,
 
     if (!(error ? VLOG_DROP_WARN(&error_rl) : VLOG_DROP_DBG(&dpmsg_rl))) {
         struct ds ds = DS_EMPTY_INITIALIZER;
-        char *packet = ofp_packet_to_string(buf->data, buf->size, buf->size);
+        char *packet = ofp_packet_to_string(buf->data, buf->size);
         ds_put_format(&ds, "%s: execute ", dpif_name(dpif));
         format_odp_actions(&ds, actions, actions_len);
         if (error) {
@@ -1110,7 +1098,6 @@ dpif_recv(struct dpif *dpif, struct dpif_upcall *upcall)
         char *packet;
 
         packet = ofp_packet_to_string(upcall->packet->data,
-                                      upcall->packet->size,
                                       upcall->packet->size);
 
         ds_init(&flow);
@@ -1122,6 +1109,8 @@ dpif_recv(struct dpif *dpif, struct dpif_upcall *upcall)
 
         ds_destroy(&flow);
         free(packet);
+    } else if (error && error != EAGAIN) {
+        log_operation(dpif, "recv", error);
     }
     return error;
 }
@@ -1156,9 +1145,9 @@ dpif_get_netflow_ids(const struct dpif *dpif,
 }
 
 /* Translates OpenFlow queue ID 'queue_id' (in host byte order) into a priority
- * value for use in the OVS_ACTION_ATTR_SET_PRIORITY action.  On success,
- * returns 0 and stores the priority into '*priority'.  On failure, returns a
- * positive errno value and stores 0 into '*priority'. */
+ * value used for setting packet priority.
+ * On success, returns 0 and stores the priority into '*priority'.
+ * On failure, returns a positive errno value and stores 0 into '*priority'. */
 int
 dpif_queue_to_priority(const struct dpif *dpif, uint32_t queue_id,
                        uint32_t *priority)