void
rule_credit_stats(struct rule_dpif *rule, const struct dpif_flow_stats *stats)
{
+ ovs_mutex_lock(&rule->stats_mutex);
rule->packet_count += stats->n_packets;
rule->byte_count += stats->n_bytes;
ofproto_rule_update_used(&rule->up, stats->used);
+ ovs_mutex_unlock(&rule->stats_mutex);
}
\f
/* Subfacets. */
rule_construct(struct rule *rule_)
{
struct rule_dpif *rule = rule_dpif_cast(rule_);
+ ovs_mutex_init(&rule->stats_mutex, PTHREAD_MUTEX_NORMAL);
+ ovs_mutex_lock(&rule->stats_mutex);
rule->packet_count = 0;
rule->byte_count = 0;
+ ovs_mutex_unlock(&rule->stats_mutex);
complete_operation(rule);
return 0;
}
static void
-rule_destruct(struct rule *rule)
+rule_destruct(struct rule *rule_)
{
- complete_operation(rule_dpif_cast(rule));
+ struct rule_dpif *rule = rule_dpif_cast(rule_);
+ complete_operation(rule);
+ ovs_mutex_destroy(&rule->stats_mutex);
}
static void
/* Start from historical data for 'rule' itself that are no longer tracked
* in facets. This counts, for example, facets that have expired. */
+ ovs_mutex_lock(&rule->stats_mutex);
*packets = rule->packet_count;
*bytes = rule->byte_count;
+ ovs_mutex_unlock(&rule->stats_mutex);
}
static void
#include "hmapx.h"
#include "ofproto/ofproto-provider.h"
+#include "ovs-thread.h"
#include "timer.h"
#include "util.h"
* packet_count or byte_count member or that can be obtained from the
* datapath by, e.g., dpif_flow_get() for any subfacet.
*/
- uint64_t packet_count; /* Number of packets received. */
- uint64_t byte_count; /* Number of bytes received. */
+ struct ovs_mutex stats_mutex;
+ uint64_t packet_count OVS_GUARDED; /* Number of packets received. */
+ uint64_t byte_count OVS_GUARDED; /* Number of bytes received. */
};
static inline struct rule_dpif *rule_dpif_cast(const struct rule *rule)