diff mbox series

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

Message ID da713e24232a7b771f7a754860f8372689d6f7d8.1664888003.git.lorenzo.bianconi@redhat.com
State Superseded
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 fail github build: failed

Commit Message

Lorenzo Bianconi Oct. 4, 2022, 1:02 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.

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(+)

Comments

Mark Michelson Oct. 12, 2022, 7:05 p.m. UTC | #1
I found just one tiny grammatical problem in this one. Otherwise,

Acked-by: Mark Michelson <mmichels@redhat.com>

On 10/4/22 09:02, Lorenzo Bianconi wrote:
> 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.
> 
> 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 --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 5c68e5c3a..582ad289c 100644
> --- a/lib/actions.c
> +++ b/lib/actions.c
> @@ -4960,6 +4960,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_COMMIT_LB_AFF_BIT,
> +                           ofpacts);
> +}
> +
>   /* Parses an assignment or exchange or put_dhcp_opts action. */
>   static void
>   parse_set_action(struct action_context *ctx)
> @@ -5044,6 +5067,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 fae62c09d..6eeda70a6 100644
> --- a/ovn-sb.xml
> +++ b/ovn-sb.xml
> @@ -2659,6 +2659,15 @@ tcp.flags = RST;
>               load-balancer.
>             </p>
>           </dd>
> +
> +        <dt><code><var>R</var> = chk_lb_aff();</code></dt>
> +        <dd>
> +          <p>
> +            This action checks if the packet under consideration matches
> +            the any flow in table 78. If it is so, then the 1-bit destination

s/the any/any/

> +            register <var>R</var> is set to 1.
> +          </p>
> +        </dd>
>         </dl>
>       </column>
>   
> diff --git a/tests/ovn.at b/tests/ovn.at
> index fbf281494..98951e0f3 100644
> --- a/tests/ovn.at
> +++ b/tests/ovn.at
> @@ -2132,6 +2132,10 @@ commit_lb_aff(vip = "172.16.0.123:8080", backend = "10.0.0.3:8080", proto = tcp,
>   commit_lb_aff(vip = "[::1]:8080", backend = "[::2]:8080", proto = tcp, timeout = 30);
>       encodes as learn(table=78,idle_timeout=30,delete_learned,eth_type=0x86dd,NXM_NX_IPV6_SRC[],ipv6_dst=::1,nw_proto=6,NXM_OF_TCP_DST[],load:0x1->NXM_NX_REG10[14],load:0x2->NXM_NX_XXREG1[],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 5adfd2521..9b728ebd9 100644
> --- a/utilities/ovn-trace.c
> +++ b/utilities/ovn-trace.c
> @@ -3300,6 +3300,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);
Lorenzo Bianconi Oct. 13, 2022, 9:01 a.m. UTC | #2
> I found just one tiny grammatical problem in this one. Otherwise,
> 
> Acked-by: Mark Michelson <mmichels@redhat.com>
> 
> On 10/4/22 09:02, Lorenzo Bianconi wrote:
> > 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.
> > 
> > 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 --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 5c68e5c3a..582ad289c 100644
> > --- a/lib/actions.c
> > +++ b/lib/actions.c
> > @@ -4960,6 +4960,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_COMMIT_LB_AFF_BIT,
> > +                           ofpacts);
> > +}
> > +
> >   /* Parses an assignment or exchange or put_dhcp_opts action. */
> >   static void
> >   parse_set_action(struct action_context *ctx)
> > @@ -5044,6 +5067,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 fae62c09d..6eeda70a6 100644
> > --- a/ovn-sb.xml
> > +++ b/ovn-sb.xml
> > @@ -2659,6 +2659,15 @@ tcp.flags = RST;
> >               load-balancer.
> >             </p>
> >           </dd>
> > +
> > +        <dt><code><var>R</var> = chk_lb_aff();</code></dt>
> > +        <dd>
> > +          <p>
> > +            This action checks if the packet under consideration matches
> > +            the any flow in table 78. If it is so, then the 1-bit destination
> 
> s/the any/any/

ack, I will fix it in v2.

Regards,
Lorenzo

> 
> > +            register <var>R</var> is set to 1.
> > +          </p>
> > +        </dd>
> >         </dl>
> >       </column>
> > diff --git a/tests/ovn.at b/tests/ovn.at
> > index fbf281494..98951e0f3 100644
> > --- a/tests/ovn.at
> > +++ b/tests/ovn.at
> > @@ -2132,6 +2132,10 @@ commit_lb_aff(vip = "172.16.0.123:8080", backend = "10.0.0.3:8080", proto = tcp,
> >   commit_lb_aff(vip = "[::1]:8080", backend = "[::2]:8080", proto = tcp, timeout = 30);
> >       encodes as learn(table=78,idle_timeout=30,delete_learned,eth_type=0x86dd,NXM_NX_IPV6_SRC[],ipv6_dst=::1,nw_proto=6,NXM_OF_TCP_DST[],load:0x1->NXM_NX_REG10[14],load:0x2->NXM_NX_XXREG1[],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 5adfd2521..9b728ebd9 100644
> > --- a/utilities/ovn-trace.c
> > +++ b/utilities/ovn-trace.c
> > @@ -3300,6 +3300,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);
>
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 5c68e5c3a..582ad289c 100644
--- a/lib/actions.c
+++ b/lib/actions.c
@@ -4960,6 +4960,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_COMMIT_LB_AFF_BIT,
+                           ofpacts);
+}
+
 /* Parses an assignment or exchange or put_dhcp_opts action. */
 static void
 parse_set_action(struct action_context *ctx)
@@ -5044,6 +5067,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 fae62c09d..6eeda70a6 100644
--- a/ovn-sb.xml
+++ b/ovn-sb.xml
@@ -2659,6 +2659,15 @@  tcp.flags = RST;
             load-balancer.
           </p>
         </dd>
+
+        <dt><code><var>R</var> = chk_lb_aff();</code></dt>
+        <dd>
+          <p>
+            This action checks if the packet under consideration matches
+            the 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 fbf281494..98951e0f3 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -2132,6 +2132,10 @@  commit_lb_aff(vip = "172.16.0.123:8080", backend = "10.0.0.3:8080", proto = tcp,
 commit_lb_aff(vip = "[::1]:8080", backend = "[::2]:8080", proto = tcp, timeout = 30);
     encodes as learn(table=78,idle_timeout=30,delete_learned,eth_type=0x86dd,NXM_NX_IPV6_SRC[],ipv6_dst=::1,nw_proto=6,NXM_OF_TCP_DST[],load:0x1->NXM_NX_REG10[14],load:0x2->NXM_NX_XXREG1[],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 5adfd2521..9b728ebd9 100644
--- a/utilities/ovn-trace.c
+++ b/utilities/ovn-trace.c
@@ -3300,6 +3300,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);