Skip to content

Commit

Permalink
dpif: Refactor dpif_probe_feature()
Browse files Browse the repository at this point in the history
Allow actions to be part of the probe. No functional changes.
Future patch will make use this new API.

Signed-off-by: Andy Zhou <azhou@ovn.org>
Acked-by: Joe Stringer <joe@ovn.org>
  • Loading branch information
azhou-nicira committed Mar 11, 2017
1 parent 489b23f commit bb71c96
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
8 changes: 6 additions & 2 deletions lib/dpif.c
Expand Up @@ -897,19 +897,23 @@ dpif_flow_flush(struct dpif *dpif)
*/
bool
dpif_probe_feature(struct dpif *dpif, const char *name,
const struct ofpbuf *key, const ovs_u128 *ufid)
const struct ofpbuf *key, const struct ofpbuf *actions,
const ovs_u128 *ufid)
{
struct dpif_flow flow;
struct ofpbuf reply;
uint64_t stub[DPIF_FLOW_BUFSIZE / 8];
bool enable_feature = false;
int error;
const struct nlattr *nl_actions = actions ? actions->data : NULL;
const size_t nl_actions_size = actions ? actions->size : 0;

/* Use DPIF_FP_MODIFY to cover the case where ovs-vswitchd is killed (and
* 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,
key->data, key->size, NULL, 0, NULL, 0,
key->data, key->size, NULL, 0,
nl_actions, nl_actions_size,
ufid, NON_PMD_CORE_ID, NULL);
if (error) {
if (error != EINVAL) {
Expand Down
3 changes: 2 additions & 1 deletion lib/dpif.h
Expand Up @@ -519,7 +519,8 @@ enum dpif_flow_put_flags {
};

bool dpif_probe_feature(struct dpif *, const char *name,
const struct ofpbuf *key, const ovs_u128 *ufid);
const struct ofpbuf *key, const struct ofpbuf *actions,
const ovs_u128 *ufid);
void dpif_flow_hash(const struct dpif *, const void *key, size_t key_len,
ovs_u128 *hash);
int dpif_flow_flush(struct dpif *);
Expand Down
8 changes: 4 additions & 4 deletions ofproto/ofproto-dpif.c
Expand Up @@ -822,7 +822,7 @@ check_recirc(struct dpif_backer *backer)
ofpbuf_use_stack(&key, &keybuf, sizeof keybuf);
odp_flow_key_from_flow(&odp_parms, &key);
enable_recirc = dpif_probe_feature(backer->dpif, "recirculation", &key,
NULL);
NULL, NULL);

if (enable_recirc) {
VLOG_INFO("%s: Datapath supports recirculation",
Expand Down Expand Up @@ -859,7 +859,7 @@ check_ufid(struct dpif_backer *backer)
odp_flow_key_from_flow(&odp_parms, &key);
dpif_flow_hash(backer->dpif, key.data, key.size, &ufid);

enable_ufid = dpif_probe_feature(backer->dpif, "UFID", &key, &ufid);
enable_ufid = dpif_probe_feature(backer->dpif, "UFID", &key, NULL, &ufid);

if (enable_ufid) {
VLOG_INFO("%s: Datapath supports unique flow ids",
Expand Down Expand Up @@ -973,7 +973,7 @@ check_max_mpls_depth(struct dpif_backer *backer)

ofpbuf_use_stack(&key, &keybuf, sizeof keybuf);
odp_flow_key_from_flow(&odp_parms, &key);
if (!dpif_probe_feature(backer->dpif, "MPLS", &key, NULL)) {
if (!dpif_probe_feature(backer->dpif, "MPLS", &key, NULL, NULL)) {
break;
}
}
Expand Down Expand Up @@ -1166,7 +1166,7 @@ check_##NAME(struct dpif_backer *backer) \
\
ofpbuf_use_stack(&key, &keybuf, sizeof keybuf); \
odp_flow_key_from_flow(&odp_parms, &key); \
enable = dpif_probe_feature(backer->dpif, #NAME, &key, NULL); \
enable = dpif_probe_feature(backer->dpif, #NAME, &key, NULL, NULL); \
\
if (enable) { \
VLOG_INFO("%s: Datapath supports "#NAME, dpif_name(backer->dpif)); \
Expand Down

0 comments on commit bb71c96

Please sign in to comment.