#define SUBFACET_DESTROY_MAX_BATCH 50
-static struct subfacet *subfacet_create(struct facet *, struct flow_miss *);
+static struct subfacet *subfacet_create(struct facet *, struct flow_miss *,
+ uint32_t key_hash);
static struct subfacet *subfacet_find(struct dpif_backer *,
const struct nlattr *key, size_t key_len,
uint32_t key_hash);
ovs_mutex_init(&ofproto->stats_mutex);
ovs_mutex_init(&ofproto->vsp_mutex);
- classifier_init(&ofproto->facets);
+ classifier_init(&ofproto->facets, NULL);
ofproto->consistency_rl = LLONG_MIN;
guarded_list_init(&ofproto->pins);
{
enum subfacet_path want_path;
struct subfacet *subfacet;
+ uint32_t key_hash;
+ /* Update facet stats. */
facet->packet_count += miss->stats.n_packets;
facet->prev_packet_count += miss->stats.n_packets;
facet->byte_count += miss->stats.n_bytes;
facet->prev_byte_count += miss->stats.n_bytes;
- want_path = facet->xout.slow ? SF_SLOW_PATH : SF_FAST_PATH;
+ /* Look for an existing subfacet. If we find one, update its used time. */
+ key_hash = odp_flow_key_hash(miss->key, miss->key_len);
+ if (!list_is_empty(&facet->subfacets)) {
+ subfacet = subfacet_find(miss->ofproto->backer,
+ miss->key, miss->key_len, key_hash);
+ if (subfacet) {
+ if (subfacet->facet == facet) {
+ subfacet->used = MAX(subfacet->used, miss->stats.used);
+ } else {
+ /* This shouldn't happen. */
+ VLOG_ERR_RL(&rl, "subfacet with wrong facet");
+ subfacet_destroy(subfacet);
+ subfacet = NULL;
+ }
+ }
+ } else {
+ subfacet = NULL;
+ }
/* Don't install the flow if it's the result of the "userspace"
* action for an already installed facet. This can occur when a
return;
}
- subfacet = subfacet_create(facet, miss);
+ /* Create a subfacet, if we don't already have one. */
+ if (!subfacet) {
+ subfacet = subfacet_create(facet, miss, key_hash);
+ }
+
+ /* Install the subfacet, if it's not already installed. */
+ want_path = facet->xout.slow ? SF_SLOW_PATH : SF_FAST_PATH;
if (subfacet->path != want_path) {
struct flow_miss_op *op = &ops[(*n_ops)++];
struct dpif_flow_put *put = &op->dpif_op.u.flow_put;
in_port = get_ofp_port(ofproto, flow->in_port.ofp_port);
if (in_port && in_port->is_tunnel) {
netdev_vport_inc_rx(in_port->up.netdev, stats);
+ if (in_port->bfd) {
+ bfd_account_rx(in_port->bfd, stats);
+ }
}
xlate_in_init(&xin, ofproto, flow, NULL, stats->tcp_flags, NULL);
return NULL;
}
-/* Searches 'facet' (within 'ofproto') for a subfacet with the specified
- * 'key_fitness', 'key', and 'key_len' members in 'miss'. Returns the
- * existing subfacet if there is one, otherwise creates and returns a
- * new subfacet. */
+/* Creates and returns a new subfacet within 'facet' for the flow in 'miss'.
+ * 'key_hash' must be a hash over miss->key. The caller must have already
+ * ensured that no subfacet subfacet already exists. */
static struct subfacet *
-subfacet_create(struct facet *facet, struct flow_miss *miss)
+subfacet_create(struct facet *facet, struct flow_miss *miss, uint32_t key_hash)
{
struct dpif_backer *backer = miss->ofproto->backer;
const struct nlattr *key = miss->key;
size_t key_len = miss->key_len;
- uint32_t key_hash;
struct subfacet *subfacet;
- key_hash = odp_flow_key_hash(key, key_len);
-
- if (list_is_empty(&facet->subfacets)) {
- subfacet = &facet->one_subfacet;
- } else {
- subfacet = subfacet_find(backer, key, key_len, key_hash);
- if (subfacet) {
- if (subfacet->facet == facet) {
- return subfacet;
- }
-
- /* This shouldn't happen. */
- VLOG_ERR_RL(&rl, "subfacet with wrong facet");
- subfacet_destroy(subfacet);
- }
-
- subfacet = xmalloc(sizeof *subfacet);
- }
+ subfacet = (list_is_empty(&facet->subfacets)
+ ? &facet->one_subfacet
+ : xmalloc(sizeof *subfacet));
COVERAGE_INC(subfacet_create);
hmap_insert(&backer->subfacets, &subfacet->hmap_node, key_hash);
ds_put_char_multiple(result, '\t', level);
ds_put_format(result, "%s:", title);
for (i = 0; i < FLOW_N_REGS; i++) {
- ds_put_format(result, " reg%zu=0x%"PRIx32, i, trace->flow.regs[i]);
+ ds_put_format(result, " reg%"PRIuSIZE"=0x%"PRIx32, i, trace->flow.regs[i]);
}
ds_put_char(result, '\n');
}
}
/* OpenFlow 1.1 and later suggest that the switch enforces certain forms of
- * consistency between the flow and the actions, so enforce these by
- * default if the actions can only work in OF1.1 or later. */
- enforce_consistency = !(usable_protocols & OFPUTIL_P_OF10_ANY);
+ * consistency between the flow and the actions. With -consistent, we
+ * enforce consistency even for a flow supported in OpenFlow 1.0. */
if (!strcmp(argv[1], "-consistent")) {
enforce_consistency = true;
argv++;
argc--;
+ } else {
+ enforce_consistency = false;
}
error = parse_flow_and_packet(argc, argv, &ofproto, &flow, &packet);
unixctl_command_reply_error(conn, "invalid in_port");
goto exit;
}
- retval = ofpacts_check(ofpacts.data, ofpacts.size, &flow,
- enforce_consistency,
- u16_to_ofp(ofproto->up.max_ports), 0, 0);
+ if (enforce_consistency) {
+ retval = ofpacts_check_consistency(ofpacts.data, ofpacts.size, &flow,
+ u16_to_ofp(ofproto->up.max_ports),
+ 0, 0, usable_protocols);
+ } else {
+ retval = ofpacts_check(ofpacts.data, ofpacts.size, &flow,
+ u16_to_ofp(ofproto->up.max_ports), 0, 0,
+ &usable_protocols);
+ }
+
if (retval) {
ds_clear(&result);
ds_put_format(&result, "Bad actions: %s", ofperr_to_string(retval));
ds_put_format(ds, "%s: hit:%"PRIu64" missed:%"PRIu64"\n",
dpif_name(backer->dpif), n_hit, n_missed);
- ds_put_format(ds, "\tflows: cur: %zu, avg: %u, max: %u,"
+ ds_put_format(ds, "\tflows: cur: %"PRIuSIZE", avg: %u, max: %u,"
" life span: %lldms\n", hmap_count(&backer->subfacets),
backer->avg_n_subfacet, backer->max_n_subfacet,
backer->avg_subfacet_life);
CLS_CURSOR_FOR_EACH (facet, cr, &cursor) {
cls_rule_format(&facet->cr, &ds);
ds_put_cstr(&ds, ", ");
- ds_put_format(&ds, "n_subfacets:%zu, ", list_size(&facet->subfacets));
+ ds_put_format(&ds, "n_subfacets:%"PRIuSIZE", ", list_size(&facet->subfacets));
ds_put_format(&ds, "used:%.3fs, ", (now - facet->used) / 1000.0);
ds_put_cstr(&ds, "Datapath actions: ");
if (facet->xout.slow) {