COVERAGE_DEFINE(facet_suppress);
COVERAGE_DEFINE(subfacet_install_fail);
+/* Number of implemented OpenFlow tables. */
+enum { N_TABLES = 255 };
+enum { TBL_INTERNAL = N_TABLES - 1 }; /* Used for internal hidden rules. */
+BUILD_ASSERT_DECL(N_TABLES >= 2 && N_TABLES <= 255);
+
struct flow_miss;
struct facet;
static void rule_get_stats(struct rule *, uint64_t *packets, uint64_t *bytes);
static void rule_invalidate(const struct rule_dpif *);
+struct ofbundle {
+ struct hmap_node hmap_node; /* In struct ofproto's "bundles" hmap. */
+ struct ofproto_dpif *ofproto; /* Owning ofproto. */
+ void *aux; /* Key supplied by ofproto's client. */
+ char *name; /* Identifier for log messages. */
+
+ /* Configuration. */
+ struct list ports; /* Contains "struct ofport"s. */
+ enum port_vlan_mode vlan_mode; /* VLAN mode */
+ int vlan; /* -1=trunk port, else a 12-bit VLAN ID. */
+ unsigned long *trunks; /* Bitmap of trunked VLANs, if 'vlan' == -1.
+ * NULL if all VLANs are trunked. */
+ struct lacp *lacp; /* LACP if LACP is enabled, otherwise NULL. */
+ struct bond *bond; /* Nonnull iff more than one port. */
+ bool use_priority_tags; /* Use 802.1p tag for frames in VLAN 0? */
+
+ /* Status. */
+ bool floodable; /* True if no port has OFPUTIL_PC_NO_FLOOD set. */
+};
+
static void bundle_remove(struct ofport *);
static void bundle_update(struct ofbundle *);
static void bundle_destroy(struct ofbundle *);
struct facet {
/* Owners. */
struct hmap_node hmap_node; /* In owning ofproto's 'facets' hmap. */
- struct list list_node; /* In owning rule's 'facets' list. */
- struct rule_dpif *rule; /* Owning rule. */
+ struct ofproto_dpif *ofproto;
/* Owned data. */
struct list subfacets;
uint8_t tcp_flags; /* TCP flags seen for this 'rule'. */
struct xlate_out xout;
+ bool fail_open; /* Facet matched the fail open rule. */
/* Storage for a single subfacet, to reduce malloc() time and space
* overhead. (A facet always has at least one subfacet and in the common
static bool facet_is_controller_flow(struct facet *);
+struct ofport_dpif {
+ struct hmap_node odp_port_node; /* In dpif_backer's "odp_to_ofport_map". */
+ struct ofport up;
+
+ odp_port_t odp_port;
+ struct ofbundle *bundle; /* Bundle that contains this port, if any. */
+ struct list bundle_node; /* In struct ofbundle's "ports" list. */
+ struct cfm *cfm; /* Connectivity Fault Management, if any. */
+ struct bfd *bfd; /* BFD, if any. */
+ tag_type tag; /* Tag associated with this port. */
+ bool may_enable; /* May be enabled in bonds. */
+ bool is_tunnel; /* This port is a tunnel. */
+ long long int carrier_seq; /* Carrier status changes. */
+ struct ofport_dpif *peer; /* Peer if patch port. */
+
+ /* Spanning tree. */
+ struct stp_port *stp_port; /* Spanning Tree Protocol, if any. */
+ enum stp_state stp_state; /* Always STP_DISABLED if STP not in use. */
+ long long int stp_state_entered;
+
+ struct hmap priorities; /* Map of attached 'priority_to_dscp's. */
+
+ /* Linux VLAN device support (e.g. "eth0.10" for VLAN 10.)
+ *
+ * This is deprecated. It is only for compatibility with broken device
+ * drivers in old versions of Linux that do not properly support VLANs when
+ * VLAN devices are not used. When broken device drivers are no longer in
+ * widespread use, we will delete these interfaces. */
+ ofp_port_t realdev_ofp_port;
+ int vlandev_vid;
+};
+
/* Node in 'ofport_dpif''s 'priorities' map. Used to maintain a map from
* 'priority' (the datapath's term for QoS queue) to the dscp bits which all
* traffic egressing the 'ofport' with that priority should be marked with. */
static void vsp_remove(struct ofport_dpif *);
static void vsp_add(struct ofport_dpif *, ofp_port_t realdev_ofp_port, int vid);
+static odp_port_t ofp_port_to_odp_port(const struct ofproto_dpif *,
+ ofp_port_t);
+
static ofp_port_t odp_port_to_ofp_port(const struct ofproto_dpif *,
- odp_port_t odp_port);
+ odp_port_t);
static struct ofport_dpif *
ofport_dpif_cast(const struct ofport *ofport)
struct ofoperation *op;
};
+/* Extra information about a classifier table.
+ * Currently used just for optimized flow revalidation. */
+struct table_dpif {
+ /* If either of these is nonnull, then this table has a form that allows
+ * flows to be tagged to avoid revalidating most flows for the most common
+ * kinds of flow table changes. */
+ struct cls_table *catchall_table; /* Table that wildcards all fields. */
+ struct cls_table *other_table; /* Table with any other wildcard set. */
+ uint32_t basis; /* Keeps each table's tags separate. */
+};
+
/* Reasons that we might need to revalidate every facet, and corresponding
* coverage counters.
*
odp_port_to_ofport(const struct dpif_backer *, odp_port_t odp_port);
static void update_moving_averages(struct dpif_backer *backer);
+struct ofproto_dpif {
+ struct hmap_node all_ofproto_dpifs_node; /* In 'all_ofproto_dpifs'. */
+ struct ofproto up;
+ struct dpif_backer *backer;
+
+ /* Special OpenFlow rules. */
+ struct rule_dpif *miss_rule; /* Sends flow table misses to controller. */
+ struct rule_dpif *no_packet_in_rule; /* Drops flow table misses. */
+ struct rule_dpif *drop_frags_rule; /* Used in OFPC_FRAG_DROP mode. */
+
+ /* Bridging. */
+ struct netflow *netflow;
+ struct dpif_sflow *sflow;
+ struct dpif_ipfix *ipfix;
+ struct hmap bundles; /* Contains "struct ofbundle"s. */
+ struct mac_learning *ml;
+ bool has_bonded_bundles;
+ struct mbridge *mbridge;
+
+ /* Facets. */
+ struct classifier facets; /* Contains 'struct facet's. */
+ long long int consistency_rl;
+
+ /* Revalidation. */
+ struct table_dpif tables[N_TABLES];
+
+ /* Support for debugging async flow mods. */
+ struct list completions;
+
+ struct netdev_stats stats; /* To account packets generated and consumed in
+ * userspace. */
+
+ /* Spanning tree. */
+ struct stp *stp;
+ long long int stp_last_tick;
+
+ /* VLAN splinters. */
+ struct hmap realdev_vid_map; /* (realdev,vid) -> vlandev. */
+ struct hmap vlandev_map; /* vlandev -> (realdev,vid). */
+
+ /* Ports. */
+ struct sset ports; /* Set of standard port names. */
+ struct sset ghost_ports; /* Ports with no datapath port. */
+ struct sset port_poll_set; /* Queued names for port_poll() reply. */
+ int port_poll_errno; /* Last errno for port_poll() reply. */
+
+ /* Per ofproto's dpif stats. */
+ uint64_t n_hit;
+ uint64_t n_missed;
+};
+
/* Defer flow mod completion until "ovs-appctl ofproto/unclog"? (Useful only
* for debugging the asynchronous flow_mod implementation.) */
static bool clogged;
static void ofproto_dpif_unixctl_init(void);
+static inline struct ofproto_dpif *
+ofproto_dpif_cast(const struct ofproto *ofproto)
+{
+ ovs_assert(ofproto->ofproto_class == &ofproto_dpif_class);
+ return CONTAINER_OF(ofproto, struct ofproto_dpif, up);
+}
+
+static struct ofport_dpif *get_ofp_port(const struct ofproto_dpif *ofproto,
+ ofp_port_t ofp_port);
+
/* Upcalls. */
#define FLOW_MISS_MAX_BATCH 50
static int handle_upcalls(struct dpif_backer *, unsigned int max_batch);
/* Initial mappings of port to bridge mappings. */
static struct shash init_ofp_ports = SHASH_INITIALIZER(&init_ofp_ports);
+
+int
+ofproto_dpif_flow_mod(struct ofproto_dpif *ofproto,
+ struct ofputil_flow_mod *fm)
+{
+ return ofproto_flow_mod(&ofproto->up, fm);
+}
+
+void
+ofproto_dpif_send_packet_in(struct ofproto_dpif *ofproto,
+ struct ofputil_packet_in *pin)
+{
+ connmgr_send_packet_in(ofproto->up.connmgr, pin);
+}
\f
/* Factory functions. */
continue;
}
+ if (need_revalidate) {
+ struct ofport_dpif *ofport;
+ struct ofbundle *bundle;
+
+ xlate_ofproto_set(ofproto, ofproto->up.name, ofproto->ml,
+ ofproto->mbridge, ofproto->sflow,
+ ofproto->ipfix, ofproto->up.frag_handling,
+ ofproto->up.forward_bpdu,
+ connmgr_has_in_band(ofproto->up.connmgr),
+ ofproto->netflow != NULL,
+ ofproto->stp != NULL);
+
+ HMAP_FOR_EACH (bundle, hmap_node, &ofproto->bundles) {
+ xlate_bundle_set(ofproto, bundle, bundle->name,
+ bundle->vlan_mode, bundle->vlan,
+ bundle->trunks, bundle->use_priority_tags,
+ bundle->bond, bundle->lacp,
+ bundle->floodable);
+ }
+
+ HMAP_FOR_EACH (ofport, up.hmap_node, &ofproto->up.ports) {
+ xlate_ofport_set(ofproto, ofport->bundle, ofport,
+ ofport->up.ofp_port, ofport->odp_port,
+ ofport->up.netdev, ofport->cfm,
+ ofport->bfd, ofport->peer,
+ ofport->up.pp.config, ofport->stp_state,
+ ofport->is_tunnel, ofport->may_enable);
+ }
+ }
+
cls_cursor_init(&cursor, &ofproto->facets, NULL);
CLS_CURSOR_FOR_EACH_SAFE (facet, next, cr, &cursor) {
if (need_revalidate
struct oftable *table;
ofproto->backer->need_revalidate = REV_RECONFIGURE;
+ xlate_remove_ofproto(ofproto);
+
hmap_remove(&all_ofproto_dpifs, &ofproto->all_ofproto_dpifs_node);
complete_operations(ofproto);
n_batch = 0;
HMAP_FOR_EACH_SAFE (subfacet, next_subfacet, hmap_node,
&ofproto->backer->subfacets) {
- if (ofproto_dpif_cast(subfacet->facet->rule->up.ofproto) != ofproto) {
+ if (subfacet->facet->ofproto != ofproto) {
continue;
}
const char *dp_port_name;
ofproto->backer->need_revalidate = REV_RECONFIGURE;
+ xlate_ofport_remove(port);
dp_port_name = netdev_vport_get_dpif_port(port->up.netdev, namebuf,
sizeof namebuf);
ofproto = bundle->ofproto;
mbridge_unregister_bundle(ofproto->mbridge, bundle->aux);
+ xlate_bundle_remove(bundle);
+
LIST_FOR_EACH_SAFE (port, next_port, bundle_node, &bundle->ports) {
bundle_del_port(port);
}
\f
/* Ports. */
-struct ofport_dpif *
+static struct ofport_dpif *
get_ofp_port(const struct ofproto_dpif *ofproto, ofp_port_t ofp_port)
{
struct ofport *ofport = ofproto_get_port(&ofproto->up, ofp_port);
return ofport ? ofport_dpif_cast(ofport) : NULL;
}
-struct ofport_dpif *
+static struct ofport_dpif *
get_odp_port(const struct ofproto_dpif *ofproto, odp_port_t odp_port)
{
struct ofport_dpif *port = odp_port_to_ofport(ofproto->backer, odp_port);
/* Helper for handle_flow_miss_without_facet() and
* handle_flow_miss_with_facet(). */
static void
-handle_flow_miss_common(struct rule_dpif *rule,
- struct ofpbuf *packet, const struct flow *flow)
+handle_flow_miss_common(struct ofproto_dpif *ofproto, struct ofpbuf *packet,
+ const struct flow *flow, bool fail_open)
{
- struct ofproto_dpif *ofproto = ofproto_dpif_cast(rule->up.ofproto);
-
- if (rule->up.cr.priority == FAIL_OPEN_PRIORITY) {
+ if (fail_open) {
/*
* Extra-special case for fail-open mode.
*
COVERAGE_INC(facet_suppress);
- handle_flow_miss_common(rule, packet, &miss->flow);
+ handle_flow_miss_common(miss->ofproto, packet, &miss->flow,
+ rule->up.cr.priority == FAIL_OPEN_PRIORITY);
if (xout->slow) {
struct xlate_in xin;
long long int now, struct dpif_flow_stats *stats,
struct flow_miss_op *ops, size_t *n_ops)
{
- struct ofproto_dpif *ofproto = ofproto_dpif_cast(facet->rule->up.ofproto);
enum subfacet_path want_path;
struct subfacet *subfacet;
struct ofpbuf *packet;
- subfacet = subfacet_create(facet, miss, now);
want_path = facet->xout.slow ? SF_SLOW_PATH : SF_FAST_PATH;
- if (stats) {
- subfacet_update_stats(subfacet, stats);
- }
LIST_FOR_EACH (packet, list_node, &miss->packets) {
struct flow_miss_op *op = &ops[*n_ops];
- handle_flow_miss_common(facet->rule, packet, &miss->flow);
+ handle_flow_miss_common(miss->ofproto, packet, &miss->flow,
+ facet->fail_open);
if (want_path != SF_FAST_PATH) {
+ struct rule_dpif *rule;
struct xlate_in xin;
- xlate_in_init(&xin, ofproto, &miss->flow, facet->rule, 0, packet);
+ rule = rule_dpif_lookup(facet->ofproto, &facet->flow, NULL);
+ xlate_in_init(&xin, facet->ofproto, &miss->flow, rule, 0, packet);
xlate_actions_for_side_effects(&xin);
}
}
}
+ /* Don't install the flow if it's the result of the "userspace"
+ * action for an already installed facet. This can occur when a
+ * datapath flow with wildcards has a "userspace" action and flows
+ * sent to userspace result in a different subfacet, which will then
+ * be rejected as overlapping by the datapath. */
+ if (miss->upcall_type == DPIF_UC_ACTION
+ && !list_is_empty(&facet->subfacets)) {
+ if (stats) {
+ facet->used = MAX(facet->used, stats->used);
+ facet->packet_count += stats->n_packets;
+ facet->byte_count += stats->n_bytes;
+ facet->tcp_flags |= stats->tcp_flags;
+ }
+ return;
+ }
+
+ subfacet = subfacet_create(facet, miss, now);
+ if (stats) {
+ subfacet_update_stats(subfacet, stats);
+ }
+
if (miss->upcall_type == DPIF_UC_MISS || subfacet->path != want_path) {
struct flow_miss_op *op = &ops[(*n_ops)++];
struct dpif_flow_put *put = &op->dpif_op.u.flow_put;
put->actions = facet->xout.odp_actions.data;
put->actions_len = facet->xout.odp_actions.size;
} else {
- compose_slow_path(ofproto, &miss->flow, facet->xout.slow,
+ compose_slow_path(facet->ofproto, &miss->flow, facet->xout.slow,
op->slow_stub, sizeof op->slow_stub,
&put->actions, &put->actions_len);
}
COVERAGE_INC(subfacet_install_fail);
+ /* Zero-out subfacet counters when installation failed, but
+ * datapath reported hits. This should not happen and
+ * indicates a bug, since if the datapath flow exists, we
+ * should not be attempting to create a new subfacet. A
+ * buggy datapath could trigger this, so just zero out the
+ * counters and log an error. */
+ if (subfacet->dp_packet_count || subfacet->dp_byte_count) {
+ VLOG_ERR_RL(&rl, "failed to install subfacet for which "
+ "datapath reported hits");
+ subfacet->dp_packet_count = subfacet->dp_byte_count = 0;
+ }
+
subfacet->path = SF_NOT_INSTALLED;
}
const struct dpif_flow_stats *stats)
{
struct facet *facet = subfacet->facet;
- struct ofproto_dpif *ofproto = ofproto_dpif_cast(facet->rule->up.ofproto);
struct dpif_flow_stats diff;
diff.tcp_flags = stats->tcp_flags;
diff.n_bytes = 0;
}
- ofproto->n_hit += diff.n_packets;
+ facet->ofproto->n_hit += diff.n_packets;
subfacet->dp_packet_count = stats->n_packets;
subfacet->dp_byte_count = stats->n_bytes;
subfacet_update_stats(subfacet, &diff);
static void
rule_expire(struct rule_dpif *rule)
{
- struct facet *facet, *next_facet;
long long int now;
uint8_t reason;
COVERAGE_INC(ofproto_dpif_expired);
- /* Update stats. (This is a no-op if the rule expired due to an idle
- * timeout, because that only happens when the rule has no facets left.) */
- LIST_FOR_EACH_SAFE (facet, next_facet, list_node, &rule->facets) {
- facet_remove(facet);
- }
-
/* Get rid of the rule. */
ofproto_rule_expire(&rule->up, reason);
}
struct match match;
facet = xzalloc(sizeof *facet);
+ facet->ofproto = miss->ofproto;
facet->packet_count = facet->prev_packet_count = stats->n_packets;
facet->byte_count = facet->prev_byte_count = stats->n_bytes;
facet->tcp_flags = stats->tcp_flags;
facet->used = stats->used;
facet->flow = miss->flow;
facet->learn_rl = time_msec() + 500;
- facet->rule = rule;
- list_push_back(&facet->rule->facets, &facet->list_node);
list_init(&facet->subfacets);
netflow_flow_init(&facet->nf_flow);
netflow_flow_update_time(ofproto->netflow, &facet->nf_flow, facet->used);
classifier_insert(&ofproto->facets, &facet->cr);
facet->nf_flow.output_iface = facet->xout.nf_output_iface;
+ facet->fail_open = rule->up.cr.priority == FAIL_OPEN_PRIORITY;
return facet;
}
static void
facet_remove(struct facet *facet)
{
- struct ofproto_dpif *ofproto = ofproto_dpif_cast(facet->rule->up.ofproto);
struct subfacet *subfacet, *next_subfacet;
ovs_assert(!list_is_empty(&facet->subfacets));
&facet->subfacets) {
subfacet_destroy__(subfacet);
}
- classifier_remove(&ofproto->facets, &facet->cr);
+ classifier_remove(&facet->ofproto->facets, &facet->cr);
cls_rule_destroy(&facet->cr);
- list_remove(&facet->list_node);
facet_free(facet);
}
static void
facet_account(struct facet *facet)
{
- struct ofproto_dpif *ofproto = ofproto_dpif_cast(facet->rule->up.ofproto);
const struct nlattr *a;
unsigned int left;
ovs_be16 vlan_tci;
uint64_t n_bytes;
- if (!facet->xout.has_normal || !ofproto->has_bonded_bundles) {
+ if (!facet->xout.has_normal || !facet->ofproto->has_bonded_bundles) {
return;
}
n_bytes = facet->byte_count - facet->accounted_bytes;
switch (nl_attr_type(a)) {
case OVS_ACTION_ATTR_OUTPUT:
- port = get_odp_port(ofproto, nl_attr_get_odp_port(a));
+ port = get_odp_port(facet->ofproto, nl_attr_get_odp_port(a));
if (port && port->bundle && port->bundle->bond) {
bond_account(port->bundle->bond, &facet->flow,
vlan_tci_to_vid(vlan_tci), n_bytes);
facet_is_controller_flow(struct facet *facet)
{
if (facet) {
- const struct rule *rule = &facet->rule->up;
- const struct ofpact *ofpacts = rule->ofpacts;
- size_t ofpacts_len = rule->ofpacts_len;
+ struct ofproto_dpif *ofproto = facet->ofproto;
+ const struct rule_dpif *rule = rule_dpif_lookup(ofproto, &facet->flow,
+ NULL);
+ const struct ofpact *ofpacts = rule->up.ofpacts;
+ size_t ofpacts_len = rule->up.ofpacts_len;
if (ofpacts_len > 0 &&
ofpacts->type == OFPACT_CONTROLLER &&
static void
facet_flush_stats(struct facet *facet)
{
- struct ofproto_dpif *ofproto = ofproto_dpif_cast(facet->rule->up.ofproto);
+ struct ofproto_dpif *ofproto = facet->ofproto;
struct subfacet *subfacet;
LIST_FOR_EACH (subfacet, list_node, &facet->subfacets) {
{
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 15);
- struct ofproto_dpif *ofproto = ofproto_dpif_cast(facet->rule->up.ofproto);
-
struct xlate_out xout;
struct xlate_in xin;
struct rule_dpif *rule;
- bool ok;
-
- /* Check the rule for consistency. */
- rule = rule_dpif_lookup(ofproto, &facet->flow, NULL);
- if (rule != facet->rule) {
- if (!VLOG_DROP_WARN(&rl)) {
- struct ds s = DS_EMPTY_INITIALIZER;
-
- flow_format(&s, &facet->flow);
- ds_put_format(&s, ": facet associated with wrong rule (was "
- "table=%"PRIu8",", facet->rule->up.table_id);
- cls_rule_format(&facet->rule->up.cr, &s);
- ds_put_format(&s, ") (should have been table=%"PRIu8",",
- rule->up.table_id);
- cls_rule_format(&rule->up.cr, &s);
- ds_put_char(&s, ')');
-
- VLOG_WARN("%s", ds_cstr(&s));
- ds_destroy(&s);
- }
- return false;
- }
+ bool ok, fail_open;
/* Check the datapath actions for consistency. */
- xlate_in_init(&xin, ofproto, &facet->flow, rule, 0, NULL);
+ rule = rule_dpif_lookup(facet->ofproto, &facet->flow, NULL);
+ xlate_in_init(&xin, facet->ofproto, &facet->flow, rule, 0, NULL);
xlate_actions(&xin, &xout);
+ fail_open = rule->up.cr.priority == FAIL_OPEN_PRIORITY;
ok = ofpbuf_equal(&facet->xout.odp_actions, &xout.odp_actions)
- && facet->xout.slow == xout.slow;
+ && facet->xout.slow == xout.slow
+ && facet->fail_open == fail_open;
if (!ok && !VLOG_DROP_WARN(&rl)) {
struct ds s = DS_EMPTY_INITIALIZER;
ds_put_format(&s, " slow path incorrect. should be %d", xout.slow);
}
- VLOG_WARN("%s", ds_cstr(&s));
+ if (facet->fail_open != fail_open) {
+ ds_put_format(&s, " fail open incorrect. should be %s",
+ fail_open ? "true" : "false");
+ }
ds_destroy(&s);
}
xlate_out_uninit(&xout);
static bool
facet_revalidate(struct facet *facet)
{
- struct ofproto_dpif *ofproto = ofproto_dpif_cast(facet->rule->up.ofproto);
+ struct ofproto_dpif *ofproto = facet->ofproto;
struct rule_dpif *new_rule;
struct subfacet *subfacet;
struct flow_wildcards wc;
facet->xout.nf_output_iface = xout.nf_output_iface;
facet->xout.mirrors = xout.mirrors;
facet->nf_flow.output_iface = facet->xout.nf_output_iface;
-
- if (facet->rule != new_rule) {
- COVERAGE_INC(facet_changed_rule);
- list_remove(&facet->list_node);
- list_push_back(&new_rule->facets, &facet->list_node);
- facet->rule = new_rule;
- facet->used = new_rule->up.created;
- facet->prev_used = facet->used;
- }
+ facet->used = MAX(facet->used, new_rule->up.created);
+ facet->fail_open = new_rule->up.cr.priority == FAIL_OPEN_PRIORITY;
xlate_out_uninit(&xout);
return true;
stats.tcp_flags = facet->tcp_flags;
if (may_learn || stats.n_packets || facet->used > facet->prev_used) {
- struct ofproto_dpif *ofproto =
- ofproto_dpif_cast(facet->rule->up.ofproto);
-
+ struct ofproto_dpif *ofproto = facet->ofproto;
struct ofport_dpif *in_port;
+ struct rule_dpif *rule;
struct xlate_in xin;
facet->prev_packet_count = facet->packet_count;
netdev_vport_inc_rx(in_port->up.netdev, &stats);
}
- rule_credit_stats(facet->rule, &stats);
+ rule = rule_dpif_lookup(ofproto, &facet->flow, NULL);
+ rule_credit_stats(rule, &stats);
netflow_flow_update_time(ofproto->netflow, &facet->nf_flow,
facet->used);
netflow_flow_update_flags(&facet->nf_flow, facet->tcp_flags);
mirror_update_stats(ofproto->mbridge, facet->xout.mirrors,
stats.n_packets, stats.n_bytes);
- xlate_in_init(&xin, ofproto, &facet->flow, facet->rule,
- stats.tcp_flags, NULL);
+ xlate_in_init(&xin, ofproto, &facet->flow, rule, stats.tcp_flags,
+ NULL);
xin.resubmit_stats = &stats;
xin.may_learn = may_learn;
xlate_actions_for_side_effects(&xin);
subfacet_destroy__(struct subfacet *subfacet)
{
struct facet *facet = subfacet->facet;
- struct ofproto_dpif *ofproto = ofproto_dpif_cast(facet->rule->up.ofproto);
+ struct ofproto_dpif *ofproto = facet->ofproto;
/* Update ofproto stats before uninstall the subfacet. */
ofproto->backer->subfacet_del_count++;
struct dpif_flow_stats *stats)
{
struct facet *facet = subfacet->facet;
- struct ofproto_dpif *ofproto = ofproto_dpif_cast(facet->rule->up.ofproto);
enum subfacet_path path = facet->xout.slow ? SF_SLOW_PATH : SF_FAST_PATH;
const struct nlattr *actions = odp_actions->data;
size_t actions_len = odp_actions->size;
}
if (path == SF_SLOW_PATH) {
- compose_slow_path(ofproto, &facet->flow, facet->xout.slow,
+ compose_slow_path(facet->ofproto, &facet->flow, facet->xout.slow,
slow_path_stub, sizeof slow_path_stub,
&actions, &actions_len);
}
subfacet_uninstall(struct subfacet *subfacet)
{
if (subfacet->path != SF_NOT_INSTALLED) {
- struct rule_dpif *rule = subfacet->facet->rule;
- struct ofproto_dpif *ofproto = ofproto_dpif_cast(rule->up.ofproto);
+ struct ofproto_dpif *ofproto = subfacet->facet->ofproto;
struct dpif_flow_stats stats;
int error;
rule->packet_count = 0;
rule->byte_count = 0;
- victim = rule_dpif_cast(ofoperation_get_victim(rule->up.pending));
- if (victim && !list_is_empty(&victim->facets)) {
- struct facet *facet;
-
- rule->facets = victim->facets;
- list_moved(&rule->facets);
- LIST_FOR_EACH (facet, list_node, &rule->facets) {
- /* XXX: We're only clearing our local counters here. It's possible
- * that quite a few packets are unaccounted for in the datapath
- * statistics. These will be accounted to the new rule instead of
- * cleared as required. This could be fixed by clearing out the
- * datapath statistics for this facet, but currently it doesn't
- * seem worth it. */
- facet_reset_counters(facet);
- facet->rule = rule;
- }
- } else {
- /* Must avoid list_moved() in this case. */
- list_init(&rule->facets);
- }
-
table_id = rule->up.table_id;
+ victim = rule_dpif_cast(ofoperation_get_victim(rule->up.pending));
if (victim) {
rule->tag = victim->tag;
} else if (table_id == 0) {
}
static void
-rule_destruct(struct rule *rule_)
+rule_destruct(struct rule *rule)
{
- struct rule_dpif *rule = rule_dpif_cast(rule_);
- struct facet *facet, *next_facet;
-
- LIST_FOR_EACH_SAFE (facet, next_facet, list_node, &rule->facets) {
- facet_revalidate(facet);
- }
-
- complete_operation(rule);
+ complete_operation(rule_dpif_cast(rule));
}
static void
unixctl_command_reply(conn, "table successfully flushed");
}
+static struct ofport_dpif *
+ofbundle_get_a_port(const struct ofbundle *bundle)
+{
+ return CONTAINER_OF(list_front(&bundle->ports), struct ofport_dpif,
+ bundle_node);
+}
+
static void
ofproto_unixctl_fdb_show(struct unixctl_conn *conn, int argc OVS_UNUSED,
const char *argv[], void *aux OVS_UNUSED)
HMAP_FOR_EACH (subfacet, hmap_node, &ofproto->backer->subfacets) {
struct facet *facet = subfacet->facet;
+ struct odputil_keybuf maskbuf;
+ struct ofpbuf mask;
- if (ofproto_dpif_cast(facet->rule->up.ofproto) != ofproto) {
+ if (facet->ofproto != ofproto) {
continue;
}
- odp_flow_key_format(subfacet->key, subfacet->key_len, &ds);
+ ofpbuf_use_stack(&mask, &maskbuf, sizeof maskbuf);
+ if (enable_megaflows) {
+ odp_flow_key_from_mask(&mask, &facet->xout.wc.masks,
+ &facet->flow, UINT32_MAX);
+ }
+
+ odp_flow_format(subfacet->key, subfacet->key_len,
+ mask.data, mask.size, &ds);
ds_put_format(&ds, ", packets:%"PRIu64", bytes:%"PRIu64", used:",
subfacet->dp_packet_count, subfacet->dp_byte_count);
return hash_2words(ofp_to_u16(realdev_ofp_port), vid);
}
+bool
+ofproto_has_vlan_splinters(const struct ofproto_dpif *ofproto)
+{
+ return !hmap_is_empty(&ofproto->realdev_vid_map);
+}
+
/* Returns the OFP port number of the Linux VLAN device that corresponds to
* 'vlan_tci' on the network device with port number 'realdev_ofp_port' in
* 'struct ofport_dpif'. For example, given 'realdev_ofp_port' of eth0 and
}
}
-odp_port_t
+static odp_port_t
ofp_port_to_odp_port(const struct ofproto_dpif *ofproto, ofp_port_t ofp_port)
{
const struct ofport_dpif *ofport = get_ofp_port(ofproto, ofp_port);