2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 06:15:47 +00:00

ofproto: Use ofproto_mutex for groups and keep track of referring flows.

Adding groups support for bundles is simpler if also groups are
modified under ofproto_mutex.

Eliminate the search for rules when deleting a group so that we will
not keep the mutex for too long.

Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
This commit is contained in:
Jarno Rajahalme
2016-07-29 16:52:02 -07:00
parent 9bab38ff20
commit cc0992685b
3 changed files with 221 additions and 85 deletions

View File

@@ -214,12 +214,52 @@ ofpact_end(const struct ofpact *ofpacts, size_t ofpacts_len)
return (void *) ((uint8_t *) ofpacts + ofpacts_len);
}
static inline const struct ofpact *
ofpact_find_type(const struct ofpact *a, enum ofpact_type type,
const struct ofpact * const end)
{
while (a < end) {
if (a->type == type) {
return a;
}
a = ofpact_next(a);
}
return NULL;
}
#define OFPACT_FIND_TYPE(A, TYPE, END) \
ofpact_get_##TYPE##_nullable(ofpact_find_type(A, OFPACT_##TYPE, END))
static inline const struct ofpact *
ofpact_find_type_flattened(const struct ofpact *a, enum ofpact_type type,
const struct ofpact * const end)
{
while (a < end) {
if (a->type == type) {
return a;
}
a = ofpact_next_flattened(a);
}
return NULL;
}
#define OFPACT_FIND_TYPE_FLATTENED(A, TYPE, END) \
ofpact_get_##TYPE##_nullable( \
ofpact_find_type_flattened(A, OFPACT_##TYPE, END))
/* Assigns POS to each ofpact, in turn, in the OFPACTS_LEN bytes of ofpacts
* starting at OFPACTS. */
#define OFPACT_FOR_EACH(POS, OFPACTS, OFPACTS_LEN) \
for ((POS) = (OFPACTS); (POS) < ofpact_end(OFPACTS, OFPACTS_LEN); \
(POS) = ofpact_next(POS))
#define OFPACT_FOR_EACH_TYPE(POS, TYPE, OFPACTS, OFPACTS_LEN) \
for ((POS) = OFPACT_FIND_TYPE(OFPACTS, TYPE, \
ofpact_end(OFPACTS, OFPACTS_LEN)); \
(POS); \
(POS) = OFPACT_FIND_TYPE(ofpact_next(&(POS)->ofpact), TYPE, \
ofpact_end(OFPACTS, OFPACTS_LEN)))
/* Assigns POS to each ofpact, in turn, in the OFPACTS_LEN bytes of ofpacts
* starting at OFPACTS.
*
@@ -228,6 +268,14 @@ ofpact_end(const struct ofpact *ofpacts, size_t ofpacts_len)
#define OFPACT_FOR_EACH_FLATTENED(POS, OFPACTS, OFPACTS_LEN) \
for ((POS) = (OFPACTS); (POS) < ofpact_end(OFPACTS, OFPACTS_LEN); \
(POS) = ofpact_next_flattened(POS))
#define OFPACT_FOR_EACH_TYPE_FLATTENED(POS, TYPE, OFPACTS, OFPACTS_LEN) \
for ((POS) = OFPACT_FIND_TYPE_FLATTENED(OFPACTS, TYPE, \
ofpact_end(OFPACTS, OFPACTS_LEN)); \
(POS); \
(POS) = OFPACT_FIND_TYPE_FLATTENED( \
ofpact_next_flattened(&(POS)->ofpact), TYPE, \
ofpact_end(OFPACTS, OFPACTS_LEN)))
/* Action structure for each OFPACT_*. */
@@ -977,6 +1025,13 @@ void *ofpact_finish(struct ofpbuf *, struct ofpact *);
} \
\
static inline struct STRUCT * \
ofpact_get_##ENUM##_nullable(const struct ofpact *ofpact) \
{ \
ovs_assert(!ofpact || ofpact->type == OFPACT_##ENUM); \
return ALIGNED_CAST(struct STRUCT *, ofpact); \
} \
\
static inline struct STRUCT * \
ofpact_put_##ENUM(struct ofpbuf *ofpacts) \
{ \
return ofpact_put(ofpacts, OFPACT_##ENUM, \