Skip to content

Commit

Permalink
TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
dceara committed Oct 11, 2023
1 parent be51349 commit d3246d7
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 28 deletions.
4 changes: 2 additions & 2 deletions controller/ovn-controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -3949,8 +3949,8 @@ en_lflow_output_init(struct engine_node *node OVS_UNUSED,
{
struct ed_type_lflow_output *data = xzalloc(sizeof *data);
ovn_desired_flow_table_init(&data->flow_table);
ovn_extend_table_init(&data->group_table, OFPG_MAX);
ovn_extend_table_init(&data->meter_table, OFPM13_MAX);
ovn_extend_table_init(&data->group_table, "group-table", OFPG_MAX);
ovn_extend_table_init(&data->meter_table, "meter-table", OFPM13_MAX);
objdep_mgr_init(&data->lflow_deps_mgr);
lflow_conj_ids_init(&data->conj_ids);
uuidset_init(&data->objs_processed);
Expand Down
51 changes: 29 additions & 22 deletions lib/extend-table.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "extend-table.h"
#include "hash.h"
#include "id-pool.h"
#include "lib/uuid.h"
#include "openvswitch/vlog.h"

Expand All @@ -29,13 +30,17 @@ ovn_extend_table_delete_desired(struct ovn_extend_table *table,
struct ovn_extend_table_lflow_to_desired *l);

void
ovn_extend_table_init(struct ovn_extend_table *table, uint32_t max_id)
ovn_extend_table_init(struct ovn_extend_table *table, const char *table_name,
uint32_t max_id)
{
/* Table id 0 is invalid, set id-pool base to 1. */
table->table_ids = id_pool_create(1, max_id);
hmap_init(&table->desired);
hmap_init(&table->lflow_to_desired);
hmap_init(&table->existing);
*table = (struct ovn_extend_table) {
.name = table_name,
/* Table id 0 is invalid, set id-pool base to 1. */
.table_ids = id_pool_create(1, max_id),
.desired = HMAP_INITIALIZER(&table->desired),
.lflow_to_desired = HMAP_INITIALIZER(&table->lflow_to_desired),
.existing = HMAP_INITIALIZER(&table->existing),
};
}

static struct ovn_extend_table_info *
Expand Down Expand Up @@ -116,13 +121,13 @@ ovn_extend_table_add_desired_to_lflow(struct ovn_extend_table *table,
ovs_list_init(&l->desired);
hmap_insert(&table->lflow_to_desired, &l->hmap_node,
uuid_hash(lflow_uuid));
VLOG_DBG("%s: add new lflow_to_desired entry "UUID_FMT,
__func__, UUID_ARGS(lflow_uuid));
VLOG_DBG("%s: table %s: add new lflow_to_desired entry "UUID_FMT,
__func__, table->name, UUID_ARGS(lflow_uuid));
}

ovs_list_insert(&l->desired, &r->list_node);
VLOG_DBG("%s: lflow "UUID_FMT" use new item %s, id %"PRIu32,
__func__, UUID_ARGS(lflow_uuid), r->desired->name,
VLOG_DBG("%s: table %s: lflow "UUID_FMT" use new item %s, id %"PRIu32,
__func__, table->name, UUID_ARGS(lflow_uuid), r->desired->name,
r->desired->table_id);
}

Expand Down Expand Up @@ -159,10 +164,11 @@ ovn_extend_info_add_lflow_ref(struct ovn_extend_table *table,
}

static void
ovn_extend_info_del_lflow_ref(struct ovn_extend_table_lflow_ref *r)
ovn_extend_info_del_lflow_ref(struct ovn_extend_table *table,
struct ovn_extend_table_lflow_ref *r)
{
VLOG_DBG("%s: name %s, lflow "UUID_FMT" n %"PRIuSIZE, __func__,
r->desired->name, UUID_ARGS(&r->lflow_uuid),
VLOG_DBG("%s: table %s: name %s, lflow "UUID_FMT" n %"PRIuSIZE, __func__,
table->name, r->desired->name, UUID_ARGS(&r->lflow_uuid),
hmap_count(&r->desired->references));
hmap_remove(&r->desired->references, &r->hmap_node);
ovs_list_remove(&r->list_node);
Expand Down Expand Up @@ -190,7 +196,7 @@ ovn_extend_table_clear(struct ovn_extend_table *table, bool existing)
if (g->peer) {
g->peer->peer = NULL;
} else {
/* Unset the bitmap because the peer is deleted already. */
/* Unset the id because the peer is deleted already. */
id_pool_free_id(table->table_ids, g->table_id);
}
ovn_extend_table_info_destroy(g);
Expand Down Expand Up @@ -233,10 +239,10 @@ ovn_extend_table_delete_desired(struct ovn_extend_table *table,
struct ovn_extend_table_lflow_ref *r;
LIST_FOR_EACH_SAFE (r, list_node, &l->desired) {
struct ovn_extend_table_info *e = r->desired;
ovn_extend_info_del_lflow_ref(r);
ovn_extend_info_del_lflow_ref(table, r);
if (hmap_is_empty(&e->references)) {
VLOG_DBG("%s: %s, "UUID_FMT, __func__,
e->name, UUID_ARGS(&l->lflow_uuid));
VLOG_DBG("%s: table %s: %s, "UUID_FMT, __func__,
table->name, e->name, UUID_ARGS(&l->lflow_uuid));
hmap_remove(&table->desired, &e->hmap_node);
if (e->peer) {
e->peer->peer = NULL;
Expand Down Expand Up @@ -283,7 +289,7 @@ ovn_extend_table_sync(struct ovn_extend_table *table)
}
}

/* Assign a new table ID for the table information from the bitmap.
/* Assign a new table ID for the table information from the ID pool.
* If it already exists, return the old ID. */
uint32_t
ovn_extend_table_assign_id(struct ovn_extend_table *table, const char *name,
Expand All @@ -297,9 +303,9 @@ ovn_extend_table_assign_id(struct ovn_extend_table *table, const char *name,
/* Check whether we have non installed but allocated group_id. */
HMAP_FOR_EACH_WITH_HASH (table_info, hmap_node, hash, &table->desired) {
if (!strcmp(table_info->name, name)) {
VLOG_DBG("ovn_externd_table_assign_id: reuse old id %"PRIu32
" for %s, used by lflow "UUID_FMT,
table_info->table_id, table_info->name,
VLOG_DBG("ovn_extend_table_assign_id: table %s: "
"reuse old id %"PRIu32" for %s, used by lflow "UUID_FMT,
table->name, table_info->table_id, table_info->name,
UUID_ARGS(&lflow_uuid));
ovn_extend_info_add_lflow_ref(table, table_info, &lflow_uuid);
return table_info->table_id;
Expand All @@ -321,7 +327,8 @@ ovn_extend_table_assign_id(struct ovn_extend_table *table, const char *name,
/* Reserve a new id. */
if (!id_pool_alloc_id(table->table_ids, &table_id)) {
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1);
VLOG_ERR_RL(&rl, "%"PRIu32" out of table ids.", table_id);

VLOG_ERR_RL(&rl, "table %s: out of table ids.", table->name);
return EXT_TABLE_ID_INVALID;
}
}
Expand Down
8 changes: 6 additions & 2 deletions lib/extend-table.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@
#include "openvswitch/hmap.h"
#include "openvswitch/list.h"
#include "openvswitch/uuid.h"
#include "id-pool.h"

struct id_pool;

/* Used to manage expansion tables associated with Flow table,
* such as the Group Table or Meter Table. */
struct ovn_extend_table {
const char *name; /* Used to identify this table in a user friendly way,
* e.g., for logging. */
struct id_pool *table_ids; /* Used to allocated ids in either desired or
* existing (or both). If the same "name"
* exists in both desired and existing tables,
Expand Down Expand Up @@ -80,7 +83,8 @@ struct ovn_extend_table_lflow_ref {
struct ovn_extend_table_info *desired;
};

void ovn_extend_table_init(struct ovn_extend_table *, uint32_t max_id);
void ovn_extend_table_init(struct ovn_extend_table *, const char *table_name,
uint32_t max_id);

void ovn_extend_table_destroy(struct ovn_extend_table *);

Expand Down
4 changes: 2 additions & 2 deletions tests/test-ovn.c
Original file line number Diff line number Diff line change
Expand Up @@ -1300,11 +1300,11 @@ test_parse_actions(struct ovs_cmdl_context *ctx OVS_UNUSED)

/* Initialize group ids. */
struct ovn_extend_table group_table;
ovn_extend_table_init(&group_table, OFPG_MAX);
ovn_extend_table_init(&group_table, "group-table", OFPG_MAX);

/* Initialize meter ids for QoS. */
struct ovn_extend_table meter_table;
ovn_extend_table_init(&meter_table, OFPM13_MAX);
ovn_extend_table_init(&meter_table, "meter-table", OFPM13_MAX);

/* Initialize collector sets. */
struct flow_collector_ids collector_ids;
Expand Down

0 comments on commit d3246d7

Please sign in to comment.