const struct dpif_class dpif_linux_class = {
"", /* This is the default class. */
"linux",
+ NULL, /* run */
+ NULL, /* wait */
dpif_linux_open,
dpif_linux_close,
dpif_linux_delete,
/* Class name, for use in error messages. */
const char *name;
+ /* Performs periodic work needed by dpifs of this class, if any is
+ * necessary. */
+ void (*run)(void);
+
+ /* Arranges for poll_block() to wake up if the "run" member function needs
+ * to be called. */
+ void (*wait)(void);
+
/* Attempts to open an existing dpif, if 'create' is false, or to open an
* existing dpif or create a new one, if 'create' is true. 'name' is the
* full dpif name provided by the user, e.g. "udatapath:/var/run/mypath".
static bool should_log_flow_message(int error);
static void check_rw_odp_flow(struct odp_flow *);
+/* Performs periodic work needed by all the various kinds of dpifs.
+ *
+ * If your program opens any dpifs, it must call this function within its main
+ * poll loop. */
+void
+dp_run(void)
+{
+ int i;
+ for (i = 0; i < N_DPIF_CLASSES; i++) {
+ const struct dpif_class *class = dpif_classes[i];
+ if (class->run) {
+ class->run();
+ }
+ }
+}
+
+/* Arranges for poll_block() to wake up when dp_run() needs to be called.
+ *
+ * If your program opens any dpifs, it must call this function within its main
+ * poll loop. */
+void
+dp_wait(void)
+{
+ int i;
+ for (i = 0; i < N_DPIF_CLASSES; i++) {
+ const struct dpif_class *class = dpif_classes[i];
+ if (class->wait) {
+ class->wait();
+ }
+ }
+}
+
static int
do_open(const char *name_, bool create, struct dpif **dpifp)
{
struct dpif;
struct ofpbuf;
+void dp_run(void);
+void dp_wait(void);
+
int dpif_open(const char *name, struct dpif **);
int dpif_create(const char *name, struct dpif **);
void dpif_close(struct dpif *);
ovs_fatal(error, "unrecoverable datapath error");
}
unixctl_server_run(unixctl);
+ dp_run();
ofproto_wait(ofproto);
unixctl_server_wait(unixctl);
+ dp_wait();
poll_block();
}
#include "command-line.h"
#include "compiler.h"
#include "daemon.h"
+#include "dpif.h"
#include "fault.h"
#include "leak-checker.h"
#include "mgmt.h"
need_reconfigure = true;
}
unixctl_server_run(unixctl);
+ dp_run();
if (need_reconfigure) {
poll_immediate_wake();
mgmt_wait();
bridge_wait();
unixctl_server_wait(unixctl);
+ dp_wait();
poll_block();
}