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 <[email protected]>
Acked-by: Dumitru Ceara <[email protected]>
Acked-by: Mark Michelson <[email protected]>
Acked-by: Han Zhou <[email protected]>
Signed-off-by: Ales Musil <[email protected]>
---
 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 --git a/controller/pinctrl.c b/controller/pinctrl.c
index 2f930c33c..40ed7747b 100644
--- a/controller/pinctrl.c
+++ b/controller/pinctrl.c
@@ -4190,8 +4190,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 4d2baefe4..6256bc1bb 100644
--- a/northd/ovn-northd.c
+++ b/northd/ovn-northd.c
@@ -105,7 +105,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 122614dd5..c2b86e4f2 100644
--- a/ovn-sb.ovsschema
+++ b/ovn-sb.ovsschema
@@ -1,7 +1,7 @@
 {
     "name": "OVN_Southbound",
-    "version": "20.21.0",
-    "cksum": "2362446865 26963",
+    "version": "20.22.0",
+    "cksum": "2915287929 27022",
     "tables": {
         "SB_Global": {
             "columns": {
@@ -244,6 +244,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 d36f55236..8c30eb8db 100644
--- a/ovn-sb.xml
+++ b/ovn-sb.xml
@@ -3494,6 +3494,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>
-- 
2.37.3

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to