diff mbox series

[ovs-dev,v6,2/3] actions: introduce chk_lb_aff action

Message ID 85e869fd9f14412fcf7551df0503d95215393aec.1667404277.git.lorenzo.bianconi@redhat.com
State Changes Requested
Headers show
Series Introduce lb affinity timeout support | expand

Checks

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

Commit Message

Lorenzo Bianconi Nov. 2, 2022, 3:57 p.m. UTC
chk_lb_aff action checks if the packet under consideration matches the
new flow in table OFTABLE_CHK_LB_AFFINITY. If so, then the 1-bit
destination register is set to 1.
chk_lb_aff will be used to add affinity timeout support to load balancer
connections.

Acked-by: Mark Michelson <mmichels@redhat.com>
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
---
 include/ovn/actions.h |  1 +
 lib/actions.c         | 27 +++++++++++++++++++++++++++
 ovn-sb.xml            |  9 +++++++++
 tests/ovn.at          |  4 ++++
 utilities/ovn-trace.c |  2 ++
 5 files changed, 43 insertions(+)
diff mbox series

Patch

diff --git a/include/ovn/actions.h b/include/ovn/actions.h
index 597cbb8e3..fdb6ab08b 100644
--- a/include/ovn/actions.h
+++ b/include/ovn/actions.h
@@ -122,6 +122,7 @@  struct ovn_extend_table;
     OVNACT(CHK_ECMP_NH_MAC,   ovnact_result)          \
     OVNACT(CHK_ECMP_NH,       ovnact_result)          \
     OVNACT(COMMIT_LB_AFF,     ovnact_commit_lb_aff)   \
+    OVNACT(CHK_LB_AFF,        ovnact_result)   \
 
 /* enum ovnact_type, with a member OVNACT_<ENUM> for each action. */
 enum OVS_PACKED_ENUM ovnact_type {
diff --git a/lib/actions.c b/lib/actions.c
index de9c69860..96e6ddea6 100644
--- a/lib/actions.c
+++ b/lib/actions.c
@@ -4985,6 +4985,29 @@  ovnact_commit_lb_aff_free(struct ovnact_commit_lb_aff *ecmp_nh OVS_UNUSED)
 {
 }
 
+static void
+parse_chk_lb_aff(struct action_context *ctx, const struct expr_field *dst,
+                 struct ovnact_result *res)
+{
+    parse_ovnact_result(ctx, "chk_lb_aff", NULL, dst, res);
+}
+
+static void
+format_CHK_LB_AFF(const struct ovnact_result *res, struct ds *s)
+{
+    expr_field_format(&res->dst, s);
+    ds_put_cstr(s, " = chk_lb_aff();");
+}
+
+static void
+encode_CHK_LB_AFF(const struct ovnact_result *res,
+                  const struct ovnact_encode_params *ep OVS_UNUSED,
+                  struct ofpbuf *ofpacts)
+{
+    encode_result_action__(res, OFTABLE_CHK_LB_AFFINITY,
+                           MLF_USE_LB_AFF_SESSION_BIT, ofpacts);
+}
+
 /* Parses an assignment or exchange or put_dhcp_opts action. */
 static void
 parse_set_action(struct action_context *ctx)
@@ -5069,6 +5092,10 @@  parse_set_action(struct action_context *ctx)
                    && lexer_lookahead(ctx->lexer) == LEX_T_LPAREN) {
             parse_chk_ecmp_nh(ctx, &lhs,
                     ovnact_put_CHK_ECMP_NH(ctx->ovnacts));
+        } else if (!strcmp(ctx->lexer->token.s, "chk_lb_aff") &&
+                   lexer_lookahead(ctx->lexer) == LEX_T_LPAREN) {
+            parse_chk_lb_aff(ctx, &lhs,
+                    ovnact_put_CHK_LB_AFF(ctx->ovnacts));
         } else {
             parse_assignment_action(ctx, false, &lhs);
         }
diff --git a/ovn-sb.xml b/ovn-sb.xml
index 985e27fa9..c20c7a7a4 100644
--- a/ovn-sb.xml
+++ b/ovn-sb.xml
@@ -2659,6 +2659,15 @@  tcp.flags = RST;
             load-balacer with affinity timeout configured.
           </p>
         </dd>
+
+        <dt><code><var>R</var> = chk_lb_aff();</code></dt>
+        <dd>
+          <p>
+            This action checks if the packet under consideration matches any
+            flow in table 78. If it is so, then the 1-bit destination
+            register <var>R</var> is set to 1.
+          </p>
+        </dd>
       </dl>
     </column>
 
diff --git a/tests/ovn.at b/tests/ovn.at
index 966971e7a..f90bd02bb 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -2135,6 +2135,10 @@  commit_lb_aff(vip = "172.16.0.123", backend = "10.0.0.3", timeout = 30);
 commit_lb_aff(vip = "[::1]:8080", backend = "[::2]:8080", proto = tcp, timeout = 30);
     encodes as learn(table=78,idle_timeout=30,delete_learned,OXM_OF_METADATA[],eth_type=0x86dd,NXM_NX_IPV6_SRC[],ipv6_dst=::1,nw_proto=6,tcp_dst=8080,load:0x1->NXM_NX_REG10[14],load:0x2->NXM_NX_XXREG0[],load:0x1f90->NXM_NX_REG8[0..15])
 
+# chk_lb_aff()
+reg9[6] = chk_lb_aff();
+    encodes as set_field:0/0x4000->reg10,resubmit(,78),move:NXM_NX_REG10[14]->OXM_OF_PKT_REG4[6]
+
 # push/pop
 push(xxreg0);push(xxreg1[10..20]);push(eth.src);pop(xxreg0[0..47]);pop(xxreg0[48..57]);pop(xxreg1);
     formats as push(xxreg0); push(xxreg1[10..20]); push(eth.src); pop(xxreg0[0..47]); pop(xxreg0[48..57]); pop(xxreg1);
diff --git a/utilities/ovn-trace.c b/utilities/ovn-trace.c
index 8f6628646..8e3a8d9ca 100644
--- a/utilities/ovn-trace.c
+++ b/utilities/ovn-trace.c
@@ -3292,6 +3292,8 @@  trace_actions(const struct ovnact *ovnacts, size_t ovnacts_len,
             break;
         case OVNACT_COMMIT_LB_AFF:
             break;
+        case OVNACT_CHK_LB_AFF:
+            break;
         }
     }
     ofpbuf_uninit(&stack);