Skip to content

Commit

Permalink
northd, controller: Add timestamp column to FDB table
Browse files Browse the repository at this point in the history
Add timestamp column which will store timestamp when the
FDB row is created or updated. This can be utilized by
FDB aging mechanism.

Signed-off-by: Ales Musil <amusil@redhat.com>
Acked-by: Mark Michelson <mmichels@redhat.com>
Signed-off-by: Mark Michelson <mmichels@redhat.com>
  • Loading branch information
almusil authored and putnopvut committed Jun 8, 2023
1 parent 27c7691 commit 41a6afe
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
23 changes: 20 additions & 3 deletions controller/pinctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ struct pinctrl {
/* Latch to destroy the 'pinctrl_thread' */
struct latch pinctrl_thread_exit;
bool mac_binding_can_timestamp;
bool fdb_can_timestamp;
};

static struct pinctrl pinctrl;
Expand Down Expand Up @@ -3458,15 +3459,25 @@ pinctrl_update(const struct ovsdb_idl *idl, const char *br_int_name)
ovs_mutex_lock(&pinctrl_mutex);
pinctrl_set_br_int_name_(br_int_name);

bool can_timestamp = sbrec_server_has_mac_binding_table_col_timestamp(idl);
if (can_timestamp != pinctrl.mac_binding_can_timestamp) {
pinctrl.mac_binding_can_timestamp = can_timestamp;
bool can_mb_timestamp =
sbrec_server_has_mac_binding_table_col_timestamp(idl);
if (can_mb_timestamp != pinctrl.mac_binding_can_timestamp) {
pinctrl.mac_binding_can_timestamp = can_mb_timestamp;

/* Notify pinctrl_handler that mac binding timestamp column
* availability has changed. */
notify_pinctrl_handler();
}

bool can_fdb_timestamp = sbrec_server_has_fdb_table_col_timestamp(idl);
if (can_fdb_timestamp != pinctrl.fdb_can_timestamp) {
pinctrl.fdb_can_timestamp = can_fdb_timestamp;

/* Notify pinctrl_handler that fdb timestamp column
* availability has changed. */
notify_pinctrl_handler();
}

ovs_mutex_unlock(&pinctrl_mutex);
}

Expand Down Expand Up @@ -8104,6 +8115,12 @@ run_put_fdb(struct ovsdb_idl_txn *ovnsb_idl_txn,
sbrec_fdb_set_mac(sb_fdb, mac_string);
}
sbrec_fdb_set_port_key(sb_fdb, fdb_e->port_key);

/* For backward compatibility check if timestamp column is available
* in SB DB. */
if (pinctrl.fdb_can_timestamp) {
sbrec_fdb_set_timestamp(sb_fdb, time_wall_msec());
}
}

static void
Expand Down
2 changes: 1 addition & 1 deletion northd/ovn-northd.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ static const char *rbac_controller_event_update[] =
static const char *rbac_fdb_auth[] =
{""};
static const char *rbac_fdb_update[] =
{"dp_key", "mac", "port_key"};
{"dp_key", "mac", "port_key", "timestamp"};

static const char *rbac_port_binding_auth[] =
{""};
Expand Down
7 changes: 4 additions & 3 deletions ovn-sb.ovsschema
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "OVN_Southbound",
"version": "20.27.2",
"cksum": "1291808617 30462",
"version": "20.27.3",
"cksum": "800899756 30521",
"tables": {
"SB_Global": {
"columns": {
Expand Down Expand Up @@ -576,7 +576,8 @@
"port_key": {
"type": {"key": {"type": "integer",
"minInteger": 1,
"maxInteger": 16777215}}}},
"maxInteger": 16777215}}},
"timestamp": {"type": {"key": "integer"}}},
"indexes": [["mac", "dp_key"]],
"isRoot": true},
"Static_MAC_Binding": {
Expand Down
5 changes: 5 additions & 0 deletions ovn-sb.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5006,6 +5006,11 @@ tcp.flags = RST;
<column name="port_key">
The key of the port binding on which this FDB was learnt.
</column>

<column name="timestamp">
The timestamp in msec when the FDB was added or updated.
Records that existed before this column will have 0.
</column>
</table>

<table name="Static_MAC_Binding" title="IP to MAC bindings">
Expand Down

0 comments on commit 41a6afe

Please sign in to comment.