Skip to content

Commit

Permalink
incremental
Browse files Browse the repository at this point in the history
  • Loading branch information
dceara committed Aug 7, 2024
1 parent 33d04aa commit 20b2b02
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 48 deletions.
26 changes: 0 additions & 26 deletions lib/ovn-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -469,32 +469,6 @@ void sorted_array_apply_diff(const struct sorted_array *a1,
bool add),
const void *arg);

/* A wrapper that holds strings */
struct string_wrapper
{
char *str;
bool owns_string;
};

#define EMPTY_STRING_WRAPPER (struct string_wrapper){NULL, false}

static inline struct string_wrapper
string_wrapper_create(char *str, bool take_ownership)
{
return (struct string_wrapper) {
.str = str,
.owns_string = take_ownership,
};
}

static inline void
string_wrapper_destroy(struct string_wrapper *s)
{
if (s->owns_string) {
free(s->str);
}
}

/* Utilities around properly handling exit command. */
struct ovn_exit_args {
struct unixctl_conn **conns;
Expand Down
19 changes: 8 additions & 11 deletions northd/lflow-mgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static void ovn_lflow_init(struct ovn_lflow *, struct ovn_datapath *od,
uint16_t priority, char *match,
char *actions, char *io_port,
char *ctrl_meter, char *stage_hint,
const char *where, struct string_wrapper flow_desc);
const char *where, const char *flow_desc);
static struct ovn_lflow *ovn_lflow_find(const struct hmap *lflows,
enum ovn_stage stage,
uint16_t priority, const char *match,
Expand All @@ -53,7 +53,7 @@ static struct ovn_lflow *do_ovn_lflow_add(
const char *actions, const char *io_port,
const char *ctrl_meter,
const struct ovsdb_idl_row *stage_hint,
const char *where, struct string_wrapper flow_desc);
const char *where, const char *flow_desc);


static struct ovs_mutex *lflow_hash_lock(const struct hmap *lflow_table,
Expand Down Expand Up @@ -174,7 +174,7 @@ struct ovn_lflow {
* 'dpg_bitmap'. */
struct ovn_dp_group *dpg; /* Link to unique Sb datapath group. */
const char *where;
struct string_wrapper flow_desc;
const char *flow_desc;

struct uuid sb_uuid; /* SB DB row uuid, specified by northd. */
struct ovs_list referenced_by; /* List of struct lflow_ref_node. */
Expand Down Expand Up @@ -661,7 +661,7 @@ lflow_table_add_lflow(struct lflow_table *lflow_table,
const char *match, const char *actions,
const char *io_port, const char *ctrl_meter,
const struct ovsdb_idl_row *stage_hint,
const char *where, struct string_wrapper flow_desc,
const char *where, const char *flow_desc,
struct lflow_ref *lflow_ref)
OVS_EXCLUDED(fake_hash_mutex)
{
Expand Down Expand Up @@ -735,7 +735,7 @@ lflow_table_add_lflow_default_drop(struct lflow_table *lflow_table,
{
lflow_table_add_lflow(lflow_table, od, NULL, 0, stage, 0, "1",
debug_drop_action(), NULL, NULL, NULL,
where, EMPTY_STRING_WRAPPER, lflow_ref);
where, NULL, lflow_ref);
}

struct ovn_dp_group *
Expand Down Expand Up @@ -859,7 +859,7 @@ ovn_lflow_init(struct ovn_lflow *lflow, struct ovn_datapath *od,
size_t dp_bitmap_len, enum ovn_stage stage, uint16_t priority,
char *match, char *actions, char *io_port, char *ctrl_meter,
char *stage_hint, const char *where,
struct string_wrapper flow_desc)
const char *flow_desc)
{
lflow->dpg_bitmap = bitmap_allocate(dp_bitmap_len);
lflow->od = od;
Expand Down Expand Up @@ -950,7 +950,6 @@ ovn_lflow_destroy(struct lflow_table *lflow_table, struct ovn_lflow *lflow)
free(lflow->io_port);
free(lflow->stage_hint);
free(lflow->ctrl_meter);
string_wrapper_destroy(&lflow->flow_desc);
ovn_lflow_clear_dp_refcnts_map(lflow);
struct lflow_ref_node *lrn;
LIST_FOR_EACH_SAFE (lrn, ref_list_node, &lflow->referenced_by) {
Expand All @@ -965,7 +964,7 @@ do_ovn_lflow_add(struct lflow_table *lflow_table, size_t dp_bitmap_len,
const char *match, const char *actions,
const char *io_port, const char *ctrl_meter,
const struct ovsdb_idl_row *stage_hint,
const char *where, struct string_wrapper flow_desc)
const char *where, const char *flow_desc)
OVS_REQUIRES(fake_hash_mutex)
{
struct ovn_lflow *old_lflow;
Expand Down Expand Up @@ -1056,9 +1055,7 @@ sync_lflow_to_sb(struct ovn_lflow *lflow,
sbrec_logical_flow_set_priority(sbflow, lflow->priority);
sbrec_logical_flow_set_match(sbflow, lflow->match);
sbrec_logical_flow_set_actions(sbflow, lflow->actions);
if (lflow->flow_desc.str) {
sbrec_logical_flow_set_flow_desc(sbflow, lflow->flow_desc.str);
}
sbrec_logical_flow_set_flow_desc(sbflow, lflow->flow_desc);
if (lflow->io_port) {
struct smap tags = SMAP_INITIALIZER(&tags);
smap_add(&tags, "in_out_port", lflow->io_port);
Expand Down
19 changes: 8 additions & 11 deletions northd/lflow-mgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void lflow_table_add_lflow(struct lflow_table *, const struct ovn_datapath *,
const char *actions, const char *io_port,
const char *ctrl_meter,
const struct ovsdb_idl_row *stage_hint,
const char *where, struct string_wrapper flow_desc,
const char *where, const char *flow_desc,
struct lflow_ref *);
void lflow_table_add_lflow_default_drop(struct lflow_table *,
const struct ovn_datapath *,
Expand All @@ -92,20 +92,20 @@ void lflow_table_add_lflow_default_drop(struct lflow_table *,
STAGE_HINT, LFLOW_REF) \
lflow_table_add_lflow(LFLOW_TABLE, OD, NULL, 0, STAGE, PRIORITY, MATCH, \
ACTIONS, IN_OUT_PORT, CTRL_METER, STAGE_HINT, \
OVS_SOURCE_LOCATOR, EMPTY_STRING_WRAPPER, LFLOW_REF)
OVS_SOURCE_LOCATOR, NULL, LFLOW_REF)

#define ovn_lflow_add_with_hint(LFLOW_TABLE, OD, STAGE, PRIORITY, MATCH, \
ACTIONS, STAGE_HINT, LFLOW_REF) \
lflow_table_add_lflow(LFLOW_TABLE, OD, NULL, 0, STAGE, PRIORITY, MATCH, \
ACTIONS, NULL, NULL, STAGE_HINT, \
OVS_SOURCE_LOCATOR, EMPTY_STRING_WRAPPER, LFLOW_REF)
OVS_SOURCE_LOCATOR, NULL, LFLOW_REF)

#define ovn_lflow_add_with_dp_group(LFLOW_TABLE, DP_BITMAP, DP_BITMAP_LEN, \
STAGE, PRIORITY, MATCH, ACTIONS, \
STAGE_HINT, LFLOW_REF) \
lflow_table_add_lflow(LFLOW_TABLE, NULL, DP_BITMAP, DP_BITMAP_LEN, STAGE, \
PRIORITY, MATCH, ACTIONS, NULL, NULL, STAGE_HINT, \
OVS_SOURCE_LOCATOR, EMPTY_STRING_WRAPPER, LFLOW_REF)
OVS_SOURCE_LOCATOR, NULL, LFLOW_REF)

#define ovn_lflow_add_default_drop(LFLOW_TABLE, OD, STAGE, LFLOW_REF) \
lflow_table_add_lflow_default_drop(LFLOW_TABLE, OD, STAGE, \
Expand All @@ -127,29 +127,26 @@ void lflow_table_add_lflow_default_drop(struct lflow_table *,
STAGE_HINT, LFLOW_REF) \
lflow_table_add_lflow(LFLOW_TABLE, OD, NULL, 0, STAGE, PRIORITY, MATCH, \
ACTIONS, IN_OUT_PORT, NULL, STAGE_HINT, \
OVS_SOURCE_LOCATOR, EMPTY_STRING_WRAPPER, LFLOW_REF)
OVS_SOURCE_LOCATOR, NULL, LFLOW_REF)

#define ovn_lflow_add(LFLOW_TABLE, OD, STAGE, PRIORITY, MATCH, ACTIONS, \
LFLOW_REF) \
lflow_table_add_lflow(LFLOW_TABLE, OD, NULL, 0, STAGE, PRIORITY, MATCH, \
ACTIONS, NULL, NULL, NULL, OVS_SOURCE_LOCATOR, \
EMPTY_STRING_WRAPPER, LFLOW_REF)
NULL, LFLOW_REF)

#define ovn_lflow_add_drop_with_desc(LFLOW_TABLE, OD, STAGE, PRIORITY, MATCH, \
DESCRIPTION, LFLOW_REF) \
lflow_table_add_lflow(LFLOW_TABLE, OD, NULL, 0, STAGE, PRIORITY, MATCH, \
debug_drop_action(), NULL, NULL, NULL, \
OVS_SOURCE_LOCATOR, \
string_wrapper_create(DESCRIPTION, false), LFLOW_REF)
OVS_SOURCE_LOCATOR, DESCRIPTION, LFLOW_REF)

#define ovn_lflow_add_drop_with_lport_hint_and_desc(LFLOW_TABLE, OD, STAGE, \
PRIORITY, MATCH, IN_OUT_PORT, \
STAGE_HINT, DESCRIPTION, LFLOW_REF) \
lflow_table_add_lflow(LFLOW_TABLE, OD, NULL, 0, STAGE, PRIORITY, MATCH, \
debug_drop_action(), IN_OUT_PORT, NULL, STAGE_HINT, \
OVS_SOURCE_LOCATOR, \
string_wrapper_create(DESCRIPTION, false), \
LFLOW_REF)
OVS_SOURCE_LOCATOR, DESCRIPTION, LFLOW_REF)

#define ovn_lflow_metered(LFLOW_TABLE, OD, STAGE, PRIORITY, MATCH, ACTIONS, \
CTRL_METER, LFLOW_REF) \
Expand Down

0 comments on commit 20b2b02

Please sign in to comment.