diff mbox series

[ovs-dev,RFC,1/5] actions: Add mac_cache_use action

Message ID 20230615140513.289357-2-amusil@redhat.com
State Superseded
Headers show
Series Add MAC binding aging timestamp refresh mechanism | 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 June 15, 2023, 2:05 p.m. UTC
The mac_cache_use is just resubmit to MAC use cache table,
which will be later on used by the timestamp refresh
mechanism.

This is a preparation for the MAC binding refresh mechanism.

Signed-off-by: Ales Musil <amusil@redhat.com>
---
 include/ovn/actions.h |  3 +++
 lib/actions.c         | 17 +++++++++++++++++
 ovn-sb.xml            |  8 ++++++++
 tests/ovn.at          |  4 ++++
 tests/test-ovn.c      |  1 +
 utilities/ovn-trace.c |  2 ++
 6 files changed, 35 insertions(+)
diff mbox series

Patch

diff --git a/include/ovn/actions.h b/include/ovn/actions.h
index 23a919049..04bb6ffd0 100644
--- a/include/ovn/actions.h
+++ b/include/ovn/actions.h
@@ -126,6 +126,7 @@  struct collector_set_ids;
     OVNACT(COMMIT_LB_AFF,     ovnact_commit_lb_aff)   \
     OVNACT(CHK_LB_AFF,        ovnact_result)          \
     OVNACT(SAMPLE,            ovnact_sample)          \
+    OVNACT(MAC_CACHE_USE,     ovnact_null)            \
 
 /* enum ovnact_type, with a member OVNACT_<ENUM> for each action. */
 enum OVS_PACKED_ENUM ovnact_type {
@@ -879,6 +880,8 @@  struct ovnact_encode_params {
                                    sends packets to controller. */
     uint32_t common_nat_ct_zone; /* When performing NAT in a common CT zone,
                                     this determines which CT zone to use */
+    uint32_t mac_cache_use_table; /* OpenFlow table for 'mac_cache_use'
+                                   * to resubmit. */
 };
 
 void ovnacts_encode(const struct ovnact[], size_t ovnacts_len,
diff --git a/lib/actions.c b/lib/actions.c
index 037172e60..4f67df13f 100644
--- a/lib/actions.c
+++ b/lib/actions.c
@@ -5224,6 +5224,20 @@  encode_CHK_LB_AFF(const struct ovnact_result *res,
                            MLF_USE_LB_AFF_SESSION_BIT, ofpacts);
 }
 
+static void
+format_MAC_CACHE_USE(const struct ovnact_null *null OVS_UNUSED, struct ds *s)
+{
+    ds_put_cstr(s, "mac_cache_use;");
+}
+
+static void
+encode_MAC_CACHE_USE(const struct ovnact_null *null OVS_UNUSED,
+                     const struct ovnact_encode_params *ep,
+                     struct ofpbuf *ofpacts)
+{
+    emit_resubmit(ofpacts, ep->mac_cache_use_table);
+}
+
 /* Parses an assignment or exchange or put_dhcp_opts action. */
 static void
 parse_set_action(struct action_context *ctx)
@@ -5429,9 +5443,12 @@  parse_action(struct action_context *ctx)
         parse_commit_lb_aff(ctx, ovnact_put_COMMIT_LB_AFF(ctx->ovnacts));
     } else if (lexer_match_id(ctx->lexer, "sample")) {
         parse_sample(ctx);
+    } else if (lexer_match_id(ctx->lexer, "mac_cache_use")) {
+        ovnact_put_MAC_CACHE_USE(ctx->ovnacts);
     } else {
         lexer_syntax_error(ctx->lexer, "expecting action");
     }
+
     lexer_force_match(ctx->lexer, LEX_T_SEMICOLON);
     return !ctx->lexer->error;
 }
diff --git a/ovn-sb.xml b/ovn-sb.xml
index f9dd13602..46aedf973 100644
--- a/ovn-sb.xml
+++ b/ovn-sb.xml
@@ -2790,6 +2790,14 @@  tcp.flags = RST;
             </dd>
           </dl>
         </dd>
+
+        <dt><code>mac_cache_use;</code></dt>
+        <dd>
+          <p>
+            This action resubmits to corresponding table which updates the
+            use statistics of MAC cache.
+          </p>
+        </dd>
       </dl>
     </column>
 
diff --git a/tests/ovn.at b/tests/ovn.at
index 544fba187..049f04502 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -2253,6 +2253,10 @@  sample(probability=0,collector_set=200,obs_domain=300,obs_point=foo);
 sample(probability=10,foo=bar,obs_domain=0,obs_point=1000);
     Syntax error at `foo' unknown argument.
 
+# mac_cache_use
+mac_cache_use;
+    encodes as resubmit(,79)
+
 # Miscellaneous negative tests.
 ;
     Syntax error at `;'.
diff --git a/tests/test-ovn.c b/tests/test-ovn.c
index 6c7754eac..1f1e27b51 100644
--- a/tests/test-ovn.c
+++ b/tests/test-ovn.c
@@ -1374,6 +1374,7 @@  test_parse_actions(struct ovs_cmdl_context *ctx OVS_UNUSED)
                 .common_nat_ct_zone = MFF_LOG_DNAT_ZONE,
                 .in_port_sec_ptable = OFTABLE_CHK_IN_PORT_SEC,
                 .out_port_sec_ptable = OFTABLE_CHK_OUT_PORT_SEC,
+                .mac_cache_use_table = OFTABLE_MAC_CACHE_USE,
                 .lflow_uuid.parts =
                     { 0xaaaaaaaa, 0xbbbbbbbb, 0xcccccccc, 0xdddddddd},
                 .dp_key = 0xabcdef,
diff --git a/utilities/ovn-trace.c b/utilities/ovn-trace.c
index fb54ed060..e6b161850 100644
--- a/utilities/ovn-trace.c
+++ b/utilities/ovn-trace.c
@@ -3353,6 +3353,8 @@  trace_actions(const struct ovnact *ovnacts, size_t ovnacts_len,
             break;
         case OVNACT_SAMPLE:
             break;
+        case OVNACT_MAC_CACHE_USE:
+            break;
         }
     }
     ofpbuf_uninit(&stack);