/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "coverage.h"
#include "dpctl.h"
#include "dp-packet.h"
+#include "dpif-netdev.h"
#include "dynamic-string.h"
#include "flow.h"
#include "netdev.h"
#include "tnl-arp-cache.h"
#include "tnl-ports.h"
#include "util.h"
+#include "uuid.h"
#include "valgrind.h"
#include "openvswitch/vlog.h"
dp_register_provider__(const struct dpif_class *new_class)
{
struct registered_dpif_class *registered_class;
+ int error;
if (sset_contains(&dpif_blacklist, new_class->type)) {
VLOG_DBG("attempted to register blacklisted provider: %s",
return EEXIST;
}
+ error = new_class->init ? new_class->init() : 0;
+ if (error) {
+ VLOG_WARN("failed to initialize %s datapath class: %s",
+ new_class->type, ovs_strerror(error));
+ return error;
+ }
+
registered_class = xmalloc(sizeof *registered_class);
registered_class->dpif_class = new_class;
registered_class->refcount = 0;
ovsthread_once_done(&once);
}
hash_bytes128(key, key_len, secret, hash);
+ uuid_set_bits_v4((struct uuid *)hash);
}
/* Deletes all flows from 'dpif'. Returns 0 if successful, otherwise a
* restarted) at just the right time such that feature probes from the
* previous run are still present in the datapath. */
error = dpif_flow_put(dpif, DPIF_FP_CREATE | DPIF_FP_MODIFY | DPIF_FP_PROBE,
- ofpbuf_data(key), ofpbuf_size(key), NULL, 0, NULL, 0,
+ key->data, key->size, NULL, 0, NULL, 0,
ufid, PMD_ID_NULL, NULL);
if (error) {
if (error != EINVAL) {
}
ofpbuf_use_stack(&reply, &stub, sizeof stub);
- error = dpif_flow_get(dpif, ofpbuf_data(key), ofpbuf_size(key), ufid,
+ error = dpif_flow_get(dpif, key->data, key->size, ufid,
PMD_ID_NULL, &reply, &flow);
if (!error
- && (!ufid || (flow.ufid_present && ovs_u128_equal(ufid, &flow.ufid)))) {
+ && (!ufid || (flow.ufid_present
+ && ovs_u128_equals(ufid, &flow.ufid)))) {
enable_feature = true;
}
- error = dpif_flow_del(dpif, ofpbuf_data(key), ofpbuf_size(key), ufid,
+ error = dpif_flow_del(dpif, key->data, key->size, ufid,
PMD_ID_NULL, NULL);
if (error) {
VLOG_WARN("%s: failed to delete %s feature probe flow",
int
dpif_flow_get(struct dpif *dpif,
const struct nlattr *key, size_t key_len, const ovs_u128 *ufid,
- const int pmd_id, struct ofpbuf *buf, struct dpif_flow *flow)
+ const unsigned pmd_id, struct ofpbuf *buf, struct dpif_flow *flow)
{
struct dpif_op *opp;
struct dpif_op op;
const struct nlattr *key, size_t key_len,
const struct nlattr *mask, size_t mask_len,
const struct nlattr *actions, size_t actions_len,
- const ovs_u128 *ufid, const int pmd_id,
+ const ovs_u128 *ufid, const unsigned pmd_id,
struct dpif_flow_stats *stats)
{
struct dpif_op *opp;
int
dpif_flow_del(struct dpif *dpif,
const struct nlattr *key, size_t key_len, const ovs_u128 *ufid,
- const int pmd_id, struct dpif_flow_stats *stats)
+ const unsigned pmd_id, struct dpif_flow_stats *stats)
{
struct dpif_op *opp;
struct dpif_op op;
ovs_assert(cnt == 1);
switch ((enum ovs_action_attr)type) {
+ case OVS_ACTION_ATTR_CT:
case OVS_ACTION_ATTR_OUTPUT:
case OVS_ACTION_ATTR_TUNNEL_PUSH:
case OVS_ACTION_ATTR_TUNNEL_POP:
odp_put_tunnel_action(&md->tunnel, &execute_actions);
ofpbuf_put(&execute_actions, action, NLA_ALIGN(action->nla_len));
- execute.actions = ofpbuf_data(&execute_actions);
- execute.actions_len = ofpbuf_size(&execute_actions);
+ execute.actions = execute_actions.data;
+ execute.actions_len = execute_actions.size;
} else {
execute.actions = action;
execute.actions_len = NLA_ALIGN(action->nla_len);
return error;
}
+void
+dpif_register_dp_purge_cb(struct dpif *dpif, dp_purge_callback *cb, void *aux)
+{
+ if (dpif->dpif_class->register_dp_purge_cb) {
+ dpif->dpif_class->register_dp_purge_cb(dpif, cb, aux);
+ }
+}
+
void
dpif_register_upcall_cb(struct dpif *dpif, upcall_callback *cb, void *aux)
{
bool
dpif_supports_tnl_push_pop(const struct dpif *dpif)
{
- return !strcmp(dpif->dpif_class->type, "netdev") ||
- !strcmp(dpif->dpif_class->type, "dummy");
+ return dpif_is_netdev(dpif);
}