diff mbox series

[ovs-dev,branch-22.06,v2,1/8] northd, controller: Add timestamp column to MAC_Binding table

Message ID 20221104080342.248001-1-amusil@redhat.com
State Deferred
Headers show
Series [ovs-dev,branch-22.06,v2,1/8] northd, controller: Add timestamp column to MAC_Binding table | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test fail github build: failed
ovsrobot/github-robot-_ovn-kubernetes fail github build: failed

Commit Message

Ales Musil Nov. 4, 2022, 8:03 a.m. UTC
The new timestamp column in MAC_Binding is
populated with current time whenever the row is
created or the MAC address is updated.
This can be utilized by MAC binding aging mechanism,
when we can check if enough time has passed since the
creation/update.

Reported-at: https://bugzilla.redhat.com/2084668
Acked-By: Ihar Hrachyshka <ihrachys@redhat.com>
Acked-by: Dumitru Ceara <dceara@redhat.com>
Acked-by: Mark Michelson <mmichels@redhat.com>
Acked-by: Han Zhou <hzhou@ovn.org>
Signed-off-by: Ales Musil <amusil@redhat.com>
---
v2: Fix the SBDB schema version
---
 controller/pinctrl.c | 2 ++
 northd/ovn-northd.c  | 2 +-
 ovn-sb.ovsschema     | 5 +++--
 ovn-sb.xml           | 6 ++++++
 4 files changed, 12 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/controller/pinctrl.c b/controller/pinctrl.c
index 9fe7859d5..ad79cda6e 100644
--- a/controller/pinctrl.c
+++ b/controller/pinctrl.c
@@ -4212,8 +4212,10 @@  mac_binding_add_to_sb(struct ovsdb_idl_txn *ovnsb_idl_txn,
         sbrec_mac_binding_set_ip(b, ip);
         sbrec_mac_binding_set_mac(b, mac_string);
         sbrec_mac_binding_set_datapath(b, dp);
+        sbrec_mac_binding_set_timestamp(b, time_wall_msec());
     } else if (strcmp(b->mac, mac_string)) {
         sbrec_mac_binding_set_mac(b, mac_string);
+        sbrec_mac_binding_set_timestamp(b, time_wall_msec());
     }
 }
 
diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c
index ab28756af..bd35802ed 100644
--- a/northd/ovn-northd.c
+++ b/northd/ovn-northd.c
@@ -115,7 +115,7 @@  static const char *rbac_port_binding_update[] =
 static const char *rbac_mac_binding_auth[] =
     {""};
 static const char *rbac_mac_binding_update[] =
-    {"logical_port", "ip", "mac", "datapath"};
+    {"logical_port", "ip", "mac", "datapath", "timestamp"};
 
 static const char *rbac_svc_monitor_auth[] =
     {""};
diff --git a/ovn-sb.ovsschema b/ovn-sb.ovsschema
index 3b78ea6f6..de1a3c113 100644
--- a/ovn-sb.ovsschema
+++ b/ovn-sb.ovsschema
@@ -1,7 +1,7 @@ 
 {
     "name": "OVN_Southbound",
-    "version": "20.23.0",
-    "cksum": "4045988377 28575",
+    "version": "20.24.0",
+    "cksum": "1811467130 28634",
     "tables": {
         "SB_Global": {
             "columns": {
@@ -260,6 +260,7 @@ 
                 "logical_port": {"type": "string"},
                 "ip": {"type": "string"},
                 "mac": {"type": "string"},
+                "timestamp": {"type": {"key": "integer"}},
                 "datapath": {"type": {"key": {"type": "uuid",
                                               "refTable": "Datapath_Binding"}}}},
             "indexes": [["logical_port", "ip"]],
diff --git a/ovn-sb.xml b/ovn-sb.xml
index 42b3d4d68..1a555175c 100644
--- a/ovn-sb.xml
+++ b/ovn-sb.xml
@@ -3672,6 +3672,12 @@  tcp.flags = RST;
     <column name="mac">
       The Ethernet address to which the IP is bound.
     </column>
+
+    <column name="timestamp">
+      The timestamp in msec when the MAC binding was added or updated.
+      Records that existed before this column will have 0.
+    </column>
+
     <column name="datapath">
       The logical datapath to which the logical port belongs.
     </column>