uint64_t dp_byte_count; /* Last known byte count in the datapath. */
enum subfacet_path path; /* Installed in datapath? */
-
- /* Datapath port the packet arrived on. This is needed to remove
- * flows for ports that are no longer part of the bridge. Since the
- * flow definition only has the OpenFlow port number and the port is
- * no longer part of the bridge, we can't determine the datapath port
- * number needed to delete the flow from the datapath. */
- uint32_t odp_in_port;
};
#define SUBFACET_DESTROY_MAX_BATCH 50
struct tag_set revalidate_set; /* Revalidate only matching facets. */
struct hmap drop_keys; /* Set of dropped odp keys. */
+ bool recv_set_enable; /* Enables or disables receiving packets. */
};
/* All existing ofproto_backer instances, indexed by ofproto->up.type. */
static struct ofport_dpif *
odp_port_to_ofport(const struct dpif_backer *, uint32_t odp_port);
-static void dpif_stats_update_hit_count(struct ofproto_dpif *ofproto,
- uint64_t delta);
struct avg_subfacet_rates {
double add_rate; /* Moving average of new flows created per minute. */
double del_rate; /* Moving average of flows deleted per minute. */
const struct ofproto_dpif *);
static double avg_subfacet_count(const struct ofproto_dpif *ofproto);
static void update_moving_averages(struct ofproto_dpif *ofproto);
-static void dpif_stats_update_hit_count(struct ofproto_dpif *ofproto,
- uint64_t delta);
static void update_max_subfacet_count(struct ofproto_dpif *ofproto);
/* Defer flow mod completion until "ovs-appctl ofproto/unclog"? (Useful only
push_all_stats();
}
+ /* If vswitchd started with other_config:flow_restore_wait set as "true",
+ * and the configuration has now changed to "false", enable receiving
+ * packets from the datapath. */
+ if (!backer->recv_set_enable && !ofproto_get_flow_restore_wait()) {
+ backer->recv_set_enable = true;
+
+ error = dpif_recv_set(backer->dpif, backer->recv_set_enable);
+ if (error) {
+ VLOG_ERR("Failed to enable receiving packets in dpif.");
+ return error;
+ }
+ dpif_flow_flush(backer->dpif);
+ backer->need_revalidate = REV_RECONFIGURE;
+ }
+
if (backer->need_revalidate
|| !tag_set_is_empty(&backer->revalidate_set)) {
struct tag_set revalidate_set = backer->revalidate_set;
}
}
- if (timer_expired(&backer->next_expiration)) {
+ if (!backer->recv_set_enable) {
+ /* Wake up before a max of 1000ms. */
+ timer_set_duration(&backer->next_expiration, 1000);
+ } else if (timer_expired(&backer->next_expiration)) {
int delay = expire(backer);
timer_set_duration(&backer->next_expiration, delay);
}
{
unsigned int work;
+ /* If recv_set_enable is false, we should not handle upcalls. */
+ if (!backer->recv_set_enable) {
+ return 0;
+ }
+
/* Handle one or more batches of upcalls, until there's nothing left to do
* or until we do a fixed total amount of work.
*
backer->need_revalidate = 0;
simap_init(&backer->tnl_backers);
tag_set_init(&backer->revalidate_set);
+ backer->recv_set_enable = !ofproto_get_flow_restore_wait();
*backerp = backer;
- dpif_flow_flush(backer->dpif);
+ if (backer->recv_set_enable) {
+ dpif_flow_flush(backer->dpif);
+ }
/* Loop through the ports already on the datapath and remove any
* that we don't need anymore. */
shash_add(&all_dpif_backers, type, backer);
- error = dpif_recv_set(backer->dpif, true);
+ error = dpif_recv_set(backer->dpif, backer->recv_set_enable);
if (error) {
VLOG_ERR("failed to listen on datapath of type %s: %s",
type, strerror(error));
struct ofproto_dpif *ofproto = ofproto_dpif_cast(ofproto_);
struct ofport_dpif *ofport;
+ /* Do not perform any periodic activity required by 'ofproto' while
+ * waiting for flow restore to complete. */
+ if (ofproto_get_flow_restore_wait()) {
+ return 0;
+ }
+
HMAP_FOR_EACH (ofport, up.hmap_node, &ofproto->up.ports) {
port_run_fast(ofport);
}
complete_operations(ofproto);
}
+ /* Do not perform any periodic activity below required by 'ofproto' while
+ * waiting for flow restore to complete. */
+ if (ofproto_get_flow_restore_wait()) {
+ return 0;
+ }
+
error = run_fast(ofproto_);
if (error) {
return error;
poll_immediate_wake();
}
+ if (ofproto_get_flow_restore_wait()) {
+ return;
+ }
+
dpif_wait(ofproto->backer->dpif);
dpif_recv_wait(ofproto->backer->dpif);
if (ofproto->sflow) {
struct initial_vals initial_vals;
struct list packets;
enum dpif_upcall_type upcall_type;
- uint32_t odp_in_port;
};
struct flow_miss_op {
if (error == ENODEV) {
struct drop_key *drop_key;
- /* Received packet on port for which we couldn't associate
- * an ofproto. This can happen if a port is removed while
- * traffic is being received. Print a rate-limited message
+ /* Received packet on datapath port for which we couldn't
+ * associate an ofproto. This can happen if a port is removed
+ * while traffic is being received. Print a rate-limited message
* in case it happens frequently. Install a drop flow so
* that future packets of the flow are inexpensively dropped
* in the kernel. */
- VLOG_INFO_RL(&rl, "received packet on unassociated port %"PRIu32,
- flow.in_port);
+ VLOG_INFO_RL(&rl, "received packet on unassociated datapath port "
+ "%"PRIu32, odp_in_port);
drop_key = drop_key_lookup(backer, upcall->key, upcall->key_len);
if (!drop_key) {
miss->key = upcall->key;
miss->key_len = upcall->key_len;
miss->upcall_type = upcall->type;
- miss->odp_in_port = odp_in_port;
list_init(&miss->packets);
n_misses++;
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;
subfacet->dp_packet_count = stats->n_packets;
subfacet->dp_byte_count = stats->n_bytes;
subfacet_update_stats(subfacet, &diff);
subfacet = subfacet_find(ofproto, key, key_len, key_hash);
switch (subfacet ? subfacet->path : SF_NOT_INSTALLED) {
case SF_FAST_PATH:
- /* Update ofproto_dpif's hit count. */
- if (stats->n_packets > subfacet->dp_packet_count) {
- uint64_t delta = stats->n_packets - subfacet->dp_packet_count;
- dpif_stats_update_hit_count(ofproto, delta);
- }
-
update_subfacet_stats(subfacet, stats);
break;
subfacet->dp_packet_count = 0;
subfacet->dp_byte_count = 0;
subfacet->path = SF_NOT_INSTALLED;
- subfacet->odp_in_port = miss->odp_in_port;
ofproto->subfacet_add_count++;
return subfacet;
}
}
-static void
-dpif_stats_update_hit_count(struct ofproto_dpif *ofproto, uint64_t delta)
-{
- ofproto->n_hit += delta;
-}
-
const struct ofproto_class ofproto_dpif_class = {
init,
enumerate_types,