On 18 Nov 2026, at 22:56, Aaron Conole wrote:

> This includes a test ct offload provider built on the existing dummy
> dpif offload class, along with system tests exercising the full path.
>
> The dummy provider is registered at module initialization time, and
> opened/closed together with the "dummy" dpif offload class (that is,
> when hw-offload=true is set on a dummy datapath), providing an
> end-to-end integration path through the dpif-offload infrastructure.
>
> The system tests cover both directions: a forward packet on p1
> triggers conn add (with p1's netdev as netdev_fwd_in), and a reply
> packet on p2 triggers conn established (with p2's netdev as
> netdev_rev_in), verifying that the input netdev is correctly
> propagated through the full conntrack offload path in each direction.
> The tests also check the provider coverage counters, flow offload
> state via dpctl/dump-flows, and conntrack offload state via
> dpctl/dump-conntrack.  Additionally, tests around various expirations
> help to exercise common hardware events (like eviction, and
> fallbacks).
>
> Signed-off-by: Aaron Conole <[email protected]>

Hi Aaron,

See my inline comments below. I feel like this needs most of the rework,
to make it more clear how this stuff integrated.

//Eelco

> ---
>  lib/automake.mk               |   2 +
>  lib/conntrack.c               |   1 +
>  lib/ct-dpif.c                 |   3 +
>  lib/ct-dpif.h                 |   3 +
>  lib/ct-offload-dummy.c        | 307 ++++++++++++++++++++++++++++++++++
>  lib/ct-offload-dummy.h        |  32 ++++
>  lib/ct-offload.c              |  14 +-
>  lib/ct-offload.h              |   1 +
>  lib/dpif-offload-dummy.c      |  53 ++++--
>  lib/dpif-offload.c            |   4 +
>  tests/dpif-netdev.at          | 135 +++++++++++++++
>  utilities/checkpatch_dict.txt |   2 +
>  12 files changed, 542 insertions(+), 15 deletions(-)
>  create mode 100644 lib/ct-offload-dummy.c
>  create mode 100644 lib/ct-offload-dummy.h
>
> diff --git a/lib/automake.mk b/lib/automake.mk
> index dc165f4153..b22b69d01b 100644
> --- a/lib/automake.mk
> +++ b/lib/automake.mk
> @@ -59,6 +59,8 @@ lib_libopenvswitch_la_SOURCES = \
>       lib/conntrack.h \
>       lib/ct-offload.c \
>       lib/ct-offload.h \
> +     lib/ct-offload-dummy.c \
> +     lib/ct-offload-dummy.h \
>       lib/cooperative-multitasking.c \
>       lib/cooperative-multitasking.h \
>       lib/cooperative-multitasking-private.h \
> diff --git a/lib/conntrack.c b/lib/conntrack.c
> index a55ebf7400..96ef513518 100644
> --- a/lib/conntrack.c
> +++ b/lib/conntrack.c
> @@ -2847,6 +2847,7 @@ conn_to_ct_dpif_entry(const struct conn *conn, struct 
> ct_dpif_entry *entry,
>      ovs_mutex_lock(&conn->lock);
>      entry->mark = conn->mark;
>      memcpy(&entry->labels, &conn->label, sizeof entry->labels);
> +    entry->offloaded = ct_offload_conn_is_tracked(conn);

Should this use ct_offload_conn_is_hw_confirmed()? Tracked only means
that ADD was accepted; it does not mean the CT entry is confirmed in
hardware.

>      long long expiration = conn_expiration(conn) - now;
>
> diff --git a/lib/ct-dpif.c b/lib/ct-dpif.c
> index 5a836b6683..7acacea8eb 100644
> --- a/lib/ct-dpif.c
> +++ b/lib/ct-dpif.c
> @@ -607,6 +607,9 @@ ct_dpif_format_entry(const struct ct_dpif_entry *entry, 
> struct ds *ds,
>      }
>      ct_dpif_format_protoinfo(ds, ",protoinfo=", &entry->protoinfo, verbose);
>      ct_dpif_format_helper(ds, ",helper=", &entry->helper);
> +    if (entry->offloaded) {
> +        ds_put_cstr(ds, ",offloaded");
> +    }

Would it make sense to report which provider it is offloaded to, or
should this be addressed in a future patch?

>      if (verbose && entry->tuple_parent.l3_type != 0) {
>          ds_put_cstr(ds, ",parent=(");
>          ct_dpif_format_tuple(ds, &entry->tuple_parent);
> diff --git a/lib/ct-dpif.h b/lib/ct-dpif.h
> index c3786d5ae5..6d8a0f08cf 100644
> --- a/lib/ct-dpif.h
> +++ b/lib/ct-dpif.h
> @@ -213,6 +213,9 @@ struct ct_dpif_entry {
>      uint32_t timeout;
>      uint32_t mark;
>      uint32_t bkt;       /* CT bucket number. */
> +    /* Set by userspace datapaths when the connection is tracked by a CT
> +     * offload provider.  Never set for kernel datapaths. */

See my earlier comment. I think this should report the connection as
offloaded only when it is hardware-confirmed, not merely tracked.

I think the comment could be as follows. The reference to kernel
datapaths seems redundant.

    /* Set when a userspace CT offload provider confirms the connection
     * in hardware. */

Or even shorter;

    bool offloaded; /* True if a userspace CT entry is hardware-confirmed. */

> +    bool offloaded;
>  };
>
>  enum {
> diff --git a/lib/ct-offload-dummy.c b/lib/ct-offload-dummy.c
> new file mode 100644
> index 0000000000..85514d9cd0
> --- /dev/null
> +++ b/lib/ct-offload-dummy.c
> @@ -0,0 +1,307 @@
> +/*
> + * Copyright (c) 2026 Red Hat, Inc.
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at:
> + *
> + *     http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + */
> +
> +#include <config.h>
> +
> +#include <errno.h>
> +
> +#include "ct-offload-dummy.h"

According to coding style these two needs to be swapped.

> +
> +#include "conntrack-private.h"
> +#include "coverage.h"
> +#include "ct-offload.h"
> +#include "dummy.h"
> +#include "netdev.h"
> +#include "netdev-provider.h"
> +#include "openvswitch/list.h"
> +#include "openvswitch/vlog.h"
> +#include "ovs-atomic.h"
> +#include "ovs-thread.h"
> +#include "timeval.h"
> +#include "unixctl.h"
> +
> +VLOG_DEFINE_THIS_MODULE(ct_offload_dummy);
> +
> +static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20);
> +
> +COVERAGE_DEFINE(ct_offload_dummy_add);
> +COVERAGE_DEFINE(ct_offload_dummy_del);
> +COVERAGE_DEFINE(ct_offload_dummy_upd);
> +COVERAGE_DEFINE(ct_offload_dummy_est);
> +
> +/* Test knobs for UPD reporting: "active" (default) reports a fresh
> + * last_used (connections never expire in software), "idle" reports no
> + * activity (normal expiry), "evicted" reports ENOENT (demotion). */

I had to read the comment multiple times before I got it, maybe:

/* Test controls for UPD responses: active (default) reports a current
 * timestamp, idle reports no activity, and evicted reports ENOENT. */

> +static atomic_bool dummy_hw_idle;
> +static atomic_bool dummy_hw_evicted;

Could we avoid both test flags by recording when the dummy entry was
last used and giving it a simulated hardware eviction timeout? The test
could inject traffic to refresh last_used or advance time without
traffic to age it. Once the hardware timeout has passed, UPD could
remove the dummy entry and report ENOENT.

> +
> +/* Per-connection state.  Port names are copies: ctx.netdev_in is only
> + * valid during the submit, and ports may be deleted while tracked. */

Could we remove this comment? The lifetime of ctx.netdev_in is already
documented by the ct-offload API, and the code clearly copies the port
names before retaining them.

> +struct ct_dummy_entry {
> +    struct ovs_list list_node;
> +    const struct conn *conn;
> +    char *fwd_in_name;              /* Input port of the original
> +                                     * direction. */
> +    char *rev_in_name;              /* Input port of the reply
> +                                     * direction. */

Could we reduce the comment indentation so these declarations fit on one
line? For example:

    char *fwd_in_name;         /* Input port of the original direction. */
    char *rev_in_name;         /* Input port of the reply direction. */

> +};
> +
> +/* Frees 'e' and the strings it owns. */

Useless comment, please remove.

> +static void
> +dummy_entry_destroy(struct ct_dummy_entry *e)
> +{
> +    free(e->fwd_in_name);
> +    free(e->rev_in_name);
> +    free(e);
> +}
> +
> +/* List of offloaded connections, protected by dummy_mutex. */
> +static struct ovs_mutex dummy_mutex = OVS_MUTEX_INITIALIZER;
> +static struct ovs_list dummy_conns OVS_GUARDED_BY(dummy_mutex)
> +    = OVS_LIST_INITIALIZER(&dummy_conns);
> +
> +/* Lookup must be called with dummy_mutex held. */

Could we remove this comment? OVS_REQUIRES(dummy_mutex) already
documents that the mutex must be held.

> +static struct ct_dummy_entry *
> +dummy_find__(const struct conn *conn)
> +    OVS_REQUIRES(dummy_mutex)
> +{
> +    struct ct_dummy_entry *e;
> +
> +    LIST_FOR_EACH (e, list_node, &dummy_conns) {
> +        if (e->conn == conn) {
> +            return e;
> +        }
> +    }
> +    return NULL;
> +}
> +
> +/* Returns 'name', or "(nil)" if it is NULL. */

Could we remove this comment? The helper’s name and implementation are
self-explanatory.

> +static const char *
> +dummy_netdev_name(const char *name)
> +{
> +    return name ? name : "(nil)";
> +}
> +
> +/* Only dummy-netdev ports, mirroring the dpif-offload-dummy
> + * can_offload check. */
> +static bool
> +dummy_netdev_offloadable(const struct netdev *netdev)
> +{
> +    return netdev && is_dummy_netdev_class(netdev_get_class(netdev));

The netdev class alone does not show whether this port is serviced by
the matching dpif-offload provider. Could we use the netdev's associated
dpif-offload provider for this check instead?

> +}
> +
> +static bool
> +dummy_flow_might_offload(const struct ct_offload_flow_ctx *ctx)
> +{
> +    return dummy_netdev_offloadable(ctx->netdev_in);
> +}
> +
> +static void
> +dummy_op_add(struct ct_offload_op *op)
> +{
> +    const struct ct_offload_ctx *ctx = &op->ctx;
> +
> +    ovs_assert(ctx->conn);
> +
> +    if (!dummy_netdev_offloadable(ctx->netdev_in)) {
> +        /* Decline: leave the pre-filled result untouched. */
> +        return;
> +    }
> +
> +    char *in_name = ctx->netdev_in
> +                    ? xstrdup(netdev_get_name(ctx->netdev_in)) : NULL;
> +
> +    struct ct_dummy_entry *e = xmalloc(sizeof *e);
> +
> +    e->conn = ctx->conn;
> +    e->fwd_in_name = in_name;
> +    e->rev_in_name = NULL;
> +
> +    ovs_mutex_lock(&dummy_mutex);
> +    if (dummy_find__(ctx->conn)) {
> +        ovs_mutex_unlock(&dummy_mutex);
> +        dummy_entry_destroy(e);
> +        VLOG_WARN_RL(&rl, "conn %p added twice", ctx->conn);

Could we say "already exists" instead of "added twice"? This check
catches any duplicate ADD.

    VLOG_WARN_RL(&rl, "conn %p already exists", ctx->conn);

> +        op->error = EEXIST;
> +        return;
> +    }
> +    ovs_list_push_back(&dummy_conns, &e->list_node);
> +    ovs_mutex_unlock(&dummy_mutex);
> +
> +    op->error = 0;
> +
> +    COVERAGE_INC(ct_offload_dummy_add);
> +    VLOG_DBG("conn add: conn=%p fwd_in=%s", ctx->conn,
> +             dummy_netdev_name(in_name));
> +}
> +
> +static void
> +dummy_op_del(struct ct_offload_op *op)
> +{
> +    const struct ct_offload_ctx *ctx = &op->ctx;
> +
> +    ovs_assert(ctx->conn);
> +
> +    ovs_mutex_lock(&dummy_mutex);
> +    struct ct_dummy_entry *e = dummy_find__(ctx->conn);
> +
> +    if (e) {
> +        ovs_list_remove(&e->list_node);
> +        dummy_entry_destroy(e);
> +    }
> +    ovs_mutex_unlock(&dummy_mutex);
> +
> +    op->error = 0;
> +    COVERAGE_INC(ct_offload_dummy_del);
> +    VLOG_DBG("conn del: conn=%p", ctx->conn);

Could we clarify when providers should set op->error? If this provider
does not recognize the connection, it should leave op->error untouched.
Setting it to 0 here could overwrite another provider's result. See my
earlier comments on CT_OFFLOAD_OP_DEL.

> +}
> +
> +static void
> +dummy_op_establish(struct ct_offload_op *op)
> +{
> +    const struct ct_offload_ctx *ctx = &op->ctx;
> +
> +    ovs_assert(ctx->conn);
> +
> +    char *rev_in_name = ctx->netdev_in
> +                        ? xstrdup(netdev_get_name(ctx->netdev_in)) : NULL;
> +    char *log_fwd_name = NULL;
> +    char *log_rev_name = NULL;
> +
> +    ovs_mutex_lock(&dummy_mutex);
> +    struct ct_dummy_entry *e = dummy_find__(ctx->conn);
> +
> +    if (e) {
> +        if (!e->rev_in_name) {
> +            e->rev_in_name = rev_in_name;
> +            rev_in_name = NULL;        /* Ownership transferred to 'e'. */
> +            op->hw_confirmed = true;
> +            COVERAGE_INC(ct_offload_dummy_est);
> +        }
> +        log_fwd_name = e->fwd_in_name ? xstrdup(e->fwd_in_name) : NULL;
> +        log_rev_name = e->rev_in_name ? xstrdup(e->rev_in_name) : NULL;
> +    }
> +    ovs_mutex_unlock(&dummy_mutex);
> +
> +    VLOG_DBG("conn established: conn=%p fwd_in=%s rev_in=%s",
> +             ctx->conn, dummy_netdev_name(log_fwd_name),
> +             dummy_netdev_name(log_rev_name));

This looks more complex than necessary for test code. Could we move
the debug log before ovs_mutex_unlock() and pass the port names
directly while holding dummy_mutex? For example:

    dummy_netdev_name(e ? e->fwd_in_name : NULL)

> +    free(log_fwd_name);
> +    free(log_rev_name);
> +    free(rev_in_name);
> +}
> +
> +static void
> +dummy_op_upd(struct ct_offload_op *op)
> +{
> +    const struct ct_offload_ctx *ctx = &op->ctx;
> +
> +    ovs_assert(ctx->conn);
> +
> +    ovs_mutex_lock(&dummy_mutex);
> +    bool found = dummy_find__(ctx->conn) != NULL;
> +    ovs_mutex_unlock(&dummy_mutex);
> +
> +    if (found) {
> +        bool hw_evicted, hw_idle;
> +
> +        atomic_read_relaxed(&dummy_hw_evicted, &hw_evicted);
> +        atomic_read_relaxed(&dummy_hw_idle, &hw_idle);
> +        COVERAGE_INC(ct_offload_dummy_upd);
> +        if (hw_evicted) {
> +            op->error = ENOENT;
> +        } else {
> +            op->error = 0;
> +            op->last_used = hw_idle ? 0 : time_msec();
> +        }

Could UPD report a per-connection last_used timestamp that
dpif-offload-dummy refreshes when it processes traffic for that
connection? Returning time_msec() on every UPD makes an idle
connection look active.

UPD shout set hw_confirmed, it should do so only after both directions
are programmed. Otherwise, it could suppress the ESTABLISHED
notification that supplies the reverse port.

> +    }
> +    VLOG_DBG("conn update: conn=%p last_used=%lld", ctx->conn,
> +             op->last_used);
> +}
> +
> +static void
> +dummy_batch_submit(const struct ct_offload_op_batch *batch)
> +{
> +    struct ct_offload_op *op;
> +
> +    CT_OFFLOAD_BATCH_OP_FOR_EACH (batch, i, op) {
> +        switch (op->type) {
> +        case CT_OFFLOAD_OP_ADD:

Could we skip operations already handled by another provider? Every
provider receives the same batch, so this needs to be checked per
operation. See my earlier comment on how providers claim an operation.

If op->error is the claim marker, every provider that handles an
operation must set it, including when ESTABLISHED sets hw_confirmed.

> +            break;
> +        case CT_OFFLOAD_OP_DEL:
> +            dummy_op_del(op);
> +            break;
> +        case CT_OFFLOAD_OP_UPD:
> +            dummy_op_upd(op);
> +            break;
> +        case CT_OFFLOAD_OP_ESTABLISHED:
> +            dummy_op_establish(op);
> +            break;
> +        }
> +    }
> +}
> +
> +/* Drops all tracked connections on last close. */

No need for this comment.

> +static void
> +dummy_close(void)
> +{
> +    struct ct_dummy_entry *e;
> +
> +    ovs_mutex_lock(&dummy_mutex);
> +    LIST_FOR_EACH_POP (e, list_node, &dummy_conns) {
> +        dummy_entry_destroy(e);
> +    }
> +    ovs_mutex_unlock(&dummy_mutex);
> +}
> +
> +/* "ct-offload-dummy/set-hw-activity" (see the knobs above). */

No need for this comment.

> +static void
> +ct_offload_dummy_set_hw_activity(struct unixctl_conn *conn,
> +                                 int argc OVS_UNUSED,
> +                                 const char *argv[], void *aux OVS_UNUSED)
> +{
> +    if (!strcmp(argv[1], "active")) {
> +        atomic_store_relaxed(&dummy_hw_idle, false);
> +        atomic_store_relaxed(&dummy_hw_evicted, false);
> +    } else if (!strcmp(argv[1], "idle")) {
> +        atomic_store_relaxed(&dummy_hw_idle, true);
> +        atomic_store_relaxed(&dummy_hw_evicted, false);
> +    } else if (!strcmp(argv[1], "evicted")) {
> +        atomic_store_relaxed(&dummy_hw_evicted, true);
> +    } else {
> +        unixctl_command_reply_error(conn, "invalid mode; expected active, "
> +                                    "idle or evicted");
> +        return;
> +    }
> +    unixctl_command_reply(conn, NULL);
> +}
> +
> +void
> +ct_offload_dummy_init(void)

Could we use the class's .init callback to register the dummy unixctl
command? ct_offload_register() already calls it, so this function could
be static, return 0, and replace the direct call in
ct_offload_module_init().

> +{
> +    unixctl_command_register("ct-offload-dummy/set-hw-activity",
> +                             "active|idle|evicted", 1, 1,
> +                             ct_offload_dummy_set_hw_activity, NULL);
> +}
> +
> +const struct ct_offload_class ct_offload_dummy_class = {
> +    .name         = "dummy",
       .init         = ct_offload_module_init(),
> +    .open         = NULL,
> +    .close        = dummy_close,
> +    .batch_submit = dummy_batch_submit,
> +    .flow_might_offload = dummy_flow_might_offload,
> +};
> diff --git a/lib/ct-offload-dummy.h b/lib/ct-offload-dummy.h
> new file mode 100644
> index 0000000000..fbe0c601c8
> --- /dev/null
> +++ b/lib/ct-offload-dummy.h
> @@ -0,0 +1,32 @@
> +/*
> + * Copyright (c) 2026 Red Hat, Inc.
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at:
> + *
> + *     http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + */
> +
> +#ifndef CT_OFFLOAD_DUMMY_H
> +#define CT_OFFLOAD_DUMMY_H 1
> +
> +#include "ct-offload.h"
> +
> +/* Software-only CT offload provider used together with the dpif-offload
> + * dummy provider.  It is registered when the matching "dummy" dpif offload
> + * class is registered, and activated or deactivated by that provider
> + * through ct_offload_open() and ct_offload_close(). */

Could we remove this comment? The dummy provider's registration and
activation are already documented where they happen.

> +extern const struct ct_offload_class ct_offload_dummy_class;
> +
> +/* Registers the ct-offload-dummy unixctl commands; called from
> + * ct_offload_module_init(). */
> +void ct_offload_dummy_init(void);

Could we use the class's .init callback to register the dummy unixctl
command? ct_offload_register() already calls it, so this function could
be static, return 0, and replace the direct call in
ct_offload_module_init().

> +
> +#endif /* CT_OFFLOAD_DUMMY_H */
> diff --git a/lib/ct-offload.c b/lib/ct-offload.c
> index 8c1ac79dca..f4451e0e14 100644
> --- a/lib/ct-offload.c
> +++ b/lib/ct-offload.c
> @@ -22,6 +22,7 @@
>
>  #include "conntrack.h"
>  #include "conntrack-private.h"
> +#include "ct-offload-dummy.h"
>  #include "dpif-offload.h"
>  #include "ovs-thread.h"
>  #include "timeval.h"
> @@ -33,11 +34,12 @@
>  VLOG_DEFINE_THIS_MODULE(ct_offload);
>
>  /* Built-in CT offload provider classes.  Only those whose name matches a
> - * registered dpif offload class are activated by ct_offload_module_init(),
> - * tying CT offload to the active hardware offload provider.  Populated as
> - * concrete providers are added in later patches. */
> -static const struct ct_offload_class *base_ct_offload_classes[]
> -    OVS_UNUSED = {
> + * registered dpif offload class are registered by ct_offload_module_init(),
> + * tying CT offload to the active hardware offload provider.  Registration
> + * only makes the provider known; the matching dpif-offload provider
> + * activates it through ct_offload_open(). */
> +static const struct ct_offload_class *base_ct_offload_classes[] = {
> +    &ct_offload_dummy_class,
>  };
>
>  /* Private slot for storing per-connection offload state.  Allocated when
> @@ -249,6 +251,8 @@ ct_offload_module_init(void)
>  {
>      size_t n_classes = ARRAY_SIZE(base_ct_offload_classes);
>
> +    ct_offload_dummy_init();
> +
>      for (size_t i = 0; i < n_classes; i++) {
>          const struct ct_offload_class *class = base_ct_offload_classes[i];
>
> diff --git a/lib/ct-offload.h b/lib/ct-offload.h
> index 830a39b548..85eda902d9 100644
> --- a/lib/ct-offload.h
> +++ b/lib/ct-offload.h
> @@ -207,6 +207,7 @@ void ct_offload_close(const char *name);
>   * slot used to track offload state. */
>  void ct_offload_module_init(void);
>
> +

Guess this is a left over new line.

>  /* Returns true when CT offload is enabled (delegates to
>   * dpif_offload_enabled()). */
>  bool ct_offload_enabled(void);
> diff --git a/lib/dpif-offload-dummy.c b/lib/dpif-offload-dummy.c
> index 99f2b37338..53ea711132 100644
> --- a/lib/dpif-offload-dummy.c
> +++ b/lib/dpif-offload-dummy.c
> @@ -18,6 +18,8 @@
>  #include <errno.h>
>
>  #include "dpif.h"
> +#include "ct-offload.h"
> +#include "ct-offload-dummy.h"

Could we move ct-offload-dummy.h and ct-offload.h above dpif.h to keep
the OVS headers in alphabetical order?

>  #include "dpif-offload.h"
>  #include "dpif-offload-provider.h"
>  #include "dummy.h"
> @@ -423,6 +425,14 @@ dummy_offload_open(const struct dpif_offload_class 
> *offload_class,
>      offload->unreference_cb = NULL;
>
>      *dpif_offload = &offload->offload;
> +
> +    /* Activate the matching CT offload provider.  Failure is not fatal:
> +     * flow offload still works, only conntrack offload stays inactive. */

Could we drop this comment? The warning and the unconditional return 0
make it clear that the failure is nonfatal. Please also move the error
declaration to the top of the function to match the surrounding style.

> +    int error = ct_offload_open(ct_offload_dummy_class.name);
> +    if (error) {
> +        VLOG_WARN("failed to open ct-offload provider %s: %s",
> +                  ct_offload_dummy_class.name, ovs_strerror(error));
> +    }
>      return 0;
>  }
>
> @@ -432,6 +442,8 @@ dummy_offload_close(struct dpif_offload *dpif_offload)
>      struct dummy_offload *offload = dummy_offload_cast(dpif_offload);
>      struct dpif_offload_port *port;
>
> +    ct_offload_close(ct_offload_dummy_class.name);
> +
>      /* The ofproto layer may not call dpif_port_del() for all ports,
>       * especially internal ones, so we need to clean up any remaining ports. 
> */
>      DPIF_OFFLOAD_PORT_FOR_EACH (port, dpif_offload) {
> @@ -642,6 +654,7 @@ dummy_offload_udp_tnl_get_src_port(
>
>  static bool
>  dummy_offload_are_all_actions_supported(const struct dpif_offload *offload_,
> +                                        const struct match *match,
>                                          odp_port_t in_odp,
>                                          const struct nlattr *actions,
>                                          size_t actions_len)
> @@ -649,14 +662,16 @@ dummy_offload_are_all_actions_supported(const struct 
> dpif_offload *offload_,
>      const struct nlattr *nla;
>      size_t left;
>
> -    /* Can we fully offload this flow? For now, only output actions are
> -     * supported, and only to dummy-pmd netdevs where the egress port differs
> -     * from the ingress port.  The latter restriction ensures that the 
> partial
> -     * offload test cases pass.
> +    /* Can we fully offload this flow?  Output actions are supported for
> +     * dummy-pmd netdevs where the egress port differs from the ingress port.
> +     * CT actions are fully offloadable only when a CT offload provider
> +     * claims flows with this key on this port; otherwise the flow is
> +     * partially offloaded and ct() stays in software.  Recirc is not
> +     * yet supported at the hardware offload layer.
>       *
> -     * The reason for supporting only dummy-pmd netdevs as output targets is
> -     * that they provide full protection when calling netdev_send() from any
> -     * thread, via a netdev-level mutex. */
> +     * The reason for restricting output to dummy-pmd netdevs is that they
> +     * provide full protection when calling netdev_send() from any thread,
> +     * via a netdev-level mutex. */
>      NL_ATTR_FOR_EACH (nla, left, actions, actions_len) {
>          enum ovs_action_attr action = nl_attr_type(nla);
>
> @@ -685,6 +700,17 @@ dummy_offload_are_all_actions_supported(const struct 
> dpif_offload *offload_,
>              break;
>          }
>
> +        case OVS_ACTION_ATTR_CT: {
> +            struct dummy_offload_port *ct_port =
> +                dummy_offload_get_port_by_odp_port(offload_, in_odp);
> +            struct netdev *netdev = ct_port ? ct_port->pm_port.netdev : NULL;
> +
> +            if (!ct_offload_flow_offloadable(netdev, match, nla)) {
> +                return false;
> +            }
> +            break;
> +        }
> +
>          case OVS_ACTION_ATTR_UNSPEC:
>          case OVS_ACTION_ATTR_USERSPACE:
>          case OVS_ACTION_ATTR_SET:
> @@ -696,7 +722,6 @@ dummy_offload_are_all_actions_supported(const struct 
> dpif_offload *offload_,
>          case OVS_ACTION_ATTR_PUSH_MPLS:
>          case OVS_ACTION_ATTR_POP_MPLS:
>          case OVS_ACTION_ATTR_SET_MASKED:
> -        case OVS_ACTION_ATTR_CT:
>          case OVS_ACTION_ATTR_TRUNC:
>          case OVS_ACTION_ATTR_PUSH_ETH:
>          case OVS_ACTION_ATTR_POP_ETH:
> @@ -777,6 +802,14 @@ dummy_offload_hw_process_pkt(const struct dpif_offload 
> *offload_,
>              break;
>          }
>
> +        case OVS_ACTION_ATTR_CT:
> +            /* Connection tracking is performed by the "hardware": the
> +             * connection was established in software by the first
> +             * packet (before the flow was fully offloaded) and is
> +             * mirrored by the ct-offload provider.  Nothing to do
> +             * per-packet. */

Could we move the simulated CT table to dpif-offload-dummy-ct.c and
expose a private API in dpif-offload-dummy-private.h? ct-offload-dummy.c
could use it to program and remove entries, and this path could look up
packets and refresh last_used on hits.

The UDP test uses CT with recirculation. Could the simulator apply the
CT metadata and look up the next flow using the recirculation ID? We
should only mark the flow fully offloaded if the simulator can execute
that path correctly.

This is more work, but it would let the test verify that actual traffic
through the simulator keeps the CT entry alive and that the entry
expires when traffic stops. This will also help showing how the API fits
together.

> +            break;
> +
>          case OVS_ACTION_ATTR_UNSPEC:
>          case OVS_ACTION_ATTR_USERSPACE:
>          case OVS_ACTION_ATTR_SET:
> @@ -788,7 +821,6 @@ dummy_offload_hw_process_pkt(const struct dpif_offload 
> *offload_,
>          case OVS_ACTION_ATTR_PUSH_MPLS:
>          case OVS_ACTION_ATTR_POP_MPLS:
>          case OVS_ACTION_ATTR_SET_MASKED:
> -        case OVS_ACTION_ATTR_CT:
>          case OVS_ACTION_ATTR_TRUNC:
>          case OVS_ACTION_ATTR_PUSH_ETH:
>          case OVS_ACTION_ATTR_POP_ETH:
> @@ -835,7 +867,8 @@ dummy_flow_put(const struct dpif_offload *offload_, 
> struct netdev *netdev,
>      }
>
>      full_offload = dummy_offload_are_all_actions_supported(
> -                        offload_, put->match->flow.in_port.odp_port,
> +                        offload_, put->match,
> +                        put->match->flow.in_port.odp_port,
>                          put->actions, put->actions_len);
>
>      ovs_mutex_lock(&port->port_mutex);
> diff --git a/lib/dpif-offload.c b/lib/dpif-offload.c
> index fbf252dd25..a040e60537 100644
> --- a/lib/dpif-offload.c
> +++ b/lib/dpif-offload.c
> @@ -177,6 +177,9 @@ dpif_offload_module_init(void)
>          dpif_offload_register_provider(base_dpif_offload_classes[i]);
>      }
>
> +    /* Register the CT offload providers that match a dpif offload class. */
> +    ct_offload_module_init();
> +
>      ovsthread_once_done(&once);
>  }
>
> @@ -843,6 +846,7 @@ dpif_offload_set_global_cfg(const struct 
> ovsrec_open_vswitch *cfg)
>              }
>          }
>      }
> +

No need for a new line.

>  }
>
>  void
> diff --git a/tests/dpif-netdev.at b/tests/dpif-netdev.at
> index 14f238e622..7eaa1a866d 100644
> --- a/tests/dpif-netdev.at
> +++ b/tests/dpif-netdev.at
> @@ -74,6 +74,31 @@ filter_flow_dump () {
>  strip_metadata () {
>      sed 's/metadata=0x[0-9a-f]*/metadata=0x0/'
>  }
> +filter_ct_offload_dummy_conn_add () {
> +    grep 'ct_offload_dummy.*conn add:' | sed 's/.*|DBG|//' | sort | uniq
> +}
> +
> +filter_ct_offload_dummy_conn_del () {
> +    grep 'ct_offload_dummy.*conn del:' | sed 's/.*|DBG|//' | sort | uniq
> +}
> +
> +filter_ct_offload_dummy_conn_established () {
> +    grep 'ct_offload_dummy.*conn established:' | sed 's/.*|DBG|//' \
> +        | sort | uniq
> +}
> +
> +strip_ct_dump_flows () {
> +    sed '
> +    /^flow-dump from/d
> +    s/ufid:[-0-9a-f]*, //
> +    s/, packets:[0-9]*//
> +    s/, bytes:[0-9]*//
> +    s/, used:[^ ,]*//
> +    s/[^,]*(0\/0),//g
> +    s/, dp-extra-info.*//
> +    s/^[[:space:]]*//' | sort
> +}
> +

One new line to many.

>  ]
>  m4_divert_pop([PREPARE_TESTS])
>
> @@ -3774,3 +3799,113 @@ OVS_VSWITCHD_STOP(["dnl
>    /.*failed to put.*$/d
>    /.*failed to flow_del.*$/d"])
>  AT_CLEANUP
> +
> +dnl Test that the CT offload dummy provider receives conn add, established,
> +dnl and del operations when packets traverse a conntrack commit flow in both
> +dnl directions on a dummy datapath with hw-offload enabled.  It also checks
> +dnl that the input netdev is propagated in each direction, and that both the
> +dnl conntrack entry and the datapath flows report their offload state.
> +AT_SETUP([dpif-netdev - conntrack offload dummy])
> +AT_KEYWORDS([conntrack offload])
> +OVS_VSWITCHD_START(
> +  [add-port br0 p1 -- \
> +   set interface p1 type=dummy-pmd ofport_request=1 \
> +                    options:ifindex=1100 -- \
> +   add-port br0 p2 -- \
> +   set interface p2 type=dummy-pmd ofport_request=2 \
> +                    options:ifindex=1101 -- \
> +   set bridge br0 datapath-type=dummy \
> +                  other-config:datapath-id=1234 fail-mode=secure], [], [], \
> +  [--dummy-numa="0,0,0,0,1,1,1,1"])
> +
> +AT_CHECK([ovs-appctl vlog/set dpif_offload_dummy:file:dbg 
> ct_offload_dummy:file:dbg])
> +AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:hw-offload=true])
> +OVS_WAIT_UNTIL([grep "Flow HW offload is enabled" ovs-vswitchd.log])
> +
> +AT_CHECK([ovs-ofctl add-flow br0 \
> +  
> 'table=0,priority=100,in_port=p1,ip,ct_state=-trk,actions=ct(commit,table=1)'])
> +AT_CHECK([ovs-ofctl add-flow br0 \
> +  'table=1,priority=100,in_port=p1,ip,ct_state=+trk,actions=output:p2'])
> +AT_CHECK([ovs-ofctl add-flow br0 \
> +  'table=0,priority=100,in_port=p2,ip,ct_state=-trk,actions=ct(table=1)'])
> +AT_CHECK([ovs-ofctl add-flow br0 \
> +  'table=1,priority=100,in_port=p2,ip,ct_state=+trk,actions=output:p1'])
> +
> +flow_s="eth_src=50:54:00:00:00:01,eth_dst=50:54:00:00:00:02,udp,ip_src=10.0.0.1,ip_dst=10.0.0.2,ip_frag=no,udp_src=1000,udp_dst=2000"
> +pkt=$(ovs-ofctl compose-packet --bare "${flow_s}")
> +AT_CHECK([ovs-appctl netdev-dummy/receive p1 "${pkt}"])
> +
> +OVS_WAIT_UNTIL([grep 'ct_offload_dummy.*conn add:' ovs-vswitchd.log])
> +AT_CHECK([filter_ct_offload_dummy_conn_add < ovs-vswitchd.log | wc -l | tr 
> -d ' '],
> +  [0], [1
> +])
> +AT_CHECK([filter_ct_offload_dummy_conn_add < ovs-vswitchd.log \
> +  | grep -c 'fwd_in=p1'], [0], [1
> +])
> +
> +reply_flow_s="eth_src=50:54:00:00:00:02,eth_dst=50:54:00:00:00:01,udp,ip_src=10.0.0.2,ip_dst=10.0.0.1,ip_frag=no,udp_src=2000,udp_dst=1000"
> +reply_pkt=$(ovs-ofctl compose-packet --bare "${reply_flow_s}")
> +AT_CHECK([ovs-appctl netdev-dummy/receive p2 "${reply_pkt}"])
> +
> +OVS_WAIT_UNTIL([grep 'ct_offload_dummy.*conn established:' ovs-vswitchd.log])
> +AT_CHECK([filter_ct_offload_dummy_conn_established < ovs-vswitchd.log \
> +  | wc -l | tr -d ' '], [0], [1
> +])

Could we add a short comment explaining what this checks? The filter
deduplicates identical lines, so this verifies one distinct ESTABLISHED
log message, not that the callback ran exactly once.

> +AT_CHECK([filter_ct_offload_dummy_conn_established < ovs-vswitchd.log \
> +  | grep -c 'rev_in=p2'], [0], [1
> +])
> +
> +OVS_WAIT_UNTIL([ovs-appctl coverage/show | grep ct_offload_dummy_add])
> +OVS_WAIT_UNTIL([ovs-appctl coverage/show | grep ct_offload_dummy_est])

Could we use coverage/read-counter and check that both counters are 1?
Grepping coverage/show does not verify the counts.
ct_offload_dummy_est counts confirmations recorded by the dummy provider,
not every ESTABLISHED notification it receives.

> +OVS_WAIT_UNTIL([ovs-appctl dpctl/dump-conntrack | grep offloaded])

Could we verify that the expected UDP connection is marked offloaded
by checking its original and reply tuples? Grepping for offloaded alone
does not verify which connection was marked.

> +
> +dnl The CT datapath flows are offloaded too; the ct() passes only partially
> +dnl offload, while the post-recirculation flows fully offload.
> +OVS_WAIT_UNTIL([test "$(grep -c 'succeed to add netdev flow' 
> ovs-vswitchd.log)" -ge 4])
> +AT_CHECK([ovs-appctl dpctl/dump-flows -m | strip_ct_dump_flows],

Could we clarify that "fully offloaded" applies only to the
post-recirculation output flows? The dummy provider still runs ct()
and recirc in software, so this test does not exercise hardware CT
activity. How would we test refreshing the CT entry's last_used from
simulated hardware traffic? I guess we need to figure this out.
See earlier comment, as we should run the CT packet trough the
simulated HW, currently it's not.

> +  [0], [dnl
> +recirc_id(0),in_port(p1),ct_state(0/0x20),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:01/00:00:00:00:00:00,dst=50:54:00:00:00:02/00:00:00:00:00:00),eth_type(0x0800),ipv4(src=10.0.0.1/0.0.0.0,dst=10.0.0.2/0.0.0.0,proto=17/0,tos=0/0,ttl=0/0,frag=no),udp(src=1000/0,dst=2000/0),
> offloaded:partial, dp:ovs, actions:ct(commit),recirc(0x1)
> +recirc_id(0),in_port(p2),ct_state(0/0x20),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:02/00:00:00:00:00:00,dst=50:54:00:00:00:01/00:00:00:00:00:00),eth_type(0x0800),ipv4(src=10.0.0.2/0.0.0.0,dst=10.0.0.1/0.0.0.0,proto=17/0,tos=0/0,ttl=0/0,frag=no),udp(src=2000/0,dst=1000/0),
> offloaded:partial, dp:ovs, actions:ct,recirc(0x2)
> +recirc_id(0x1),in_port(p1),ct_state(0x21/0x20),ct_tuple4(src=10.0.0.1/0.0.0.0,dst=10.0.0.2/0.0.0.0,proto=17/0,tp_src=1000/0,tp_dst=2000/0),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:01/00:00:00:00:00:00,dst=50:54:00:00:00:02/00:00:00:00:00:00),eth_type(0x0800),ipv4(src=10.0.0.1/0.0.0.0,dst=10.0.0.2/0.0.0.0,proto=17/0,tos=0/0,ttl=0/0,frag=no),udp(src=1000/0,dst=2000/0),
> offloaded:yes, dp:dummy, actions:p2
> +recirc_id(0x2),in_port(p2),ct_state(0x2a/0x20),ct_tuple4(src=10.0.0.1/0.0.0.0,dst=10.0.0.2/0.0.0.0,proto=17/0,tp_src=1000/0,tp_dst=2000/0),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:02/00:00:00:00:00:00,dst=50:54:00:00:00:01/00:00:00:00:00:00),eth_type(0x0800),ipv4(src=10.0.0.2/0.0.0.0,dst=10.0.0.1/0.0.0.0,proto=17/0,tos=0/0,ttl=0/0,frag=no),udp(src=2000/0,dst=1000/0),
> offloaded:yes, dp:dummy, actions:p1
> +])
> +
> +dnl Verify the expiration guarantee of offloaded connections.  While the
> +dnl dummy simulates active hardware, the connection survives past its
> +dnl software timeout; once it simulates idle hardware, the connection
> +dnl expires normally.
> +AT_CHECK([ovs-appctl dpctl/ct-set-sweep-interval 100 >/dev/null])

Could we use AT_CHECK's [ignore] for stdout instead of redirecting it?

    AT_CHECK([ovs-appctl dpctl/ct-set-sweep-interval 100], [0], [ignore])

> +AT_CHECK([ovs-appctl ct-offload-dummy/set-hw-activity active])
> +ovs-appctl time/warp 60000
> +OVS_WAIT_UNTIL([ovs-appctl coverage/show | grep ct_offload_dummy_upd])

As above, could we use coverage/read-counter and verify that the UPD
counter increased after advancing time?

> +AT_CHECK([ovs-appctl dpctl/dump-conntrack | grep -c offloaded], [0], [1
> +])
> +

As above, could we check the expected connection by tuple? After the
idle timeout, check that the entry is gone, not just that it no longer
has the offloaded flag.

Earlier comments might apply below too.

> +AT_CHECK([ovs-appctl ct-offload-dummy/set-hw-activity idle])
> +ovs-appctl time/warp 60000
> +OVS_WAIT_UNTIL([test "$(ovs-appctl dpctl/dump-conntrack | grep -c 
> offloaded)" = "0"])
> +dnl Verify the eviction path: a provider reporting ENOENT (hardware
> +dnl table eviction) demotes the connection to software-only tracking
> +dnl instead of destroying it; the demoted connection then expires
> +dnl through the normal path on a later sweep.
> +AT_CHECK([ovs-appctl vlog/set ct_offload:file:dbg])
> +AT_CHECK([ovs-appctl ct-offload-dummy/set-hw-activity evicted])
> +AT_CHECK([ovs-appctl netdev-dummy/receive p1 "${pkt}"])
> +AT_CHECK([ovs-appctl netdev-dummy/receive p2 "${reply_pkt}"])
> +OVS_WAIT_UNTIL([ovs-appctl dpctl/dump-conntrack | grep offloaded])
> +ovs-appctl time/warp 60000
> +OVS_WAIT_UNTIL([grep 'conn demoted' ovs-vswitchd.log])
> +OVS_WAIT_UNTIL([test "$(ovs-appctl dpctl/dump-conntrack | wc -l)" = "0"])
> +
> +AT_CHECK([ovs-appctl dpctl/flush-conntrack])
> +OVS_WAIT_UNTIL([grep 'ct_offload_dummy.*conn del:' ovs-vswitchd.log])
> +dnl Exactly one conn del: the demoted connection's cleanup finds it
> +dnl untracked and skips the DEL op, since the provider already dropped
> +dnl its state when it reported the eviction.
> +AT_CHECK([filter_ct_offload_dummy_conn_del < ovs-vswitchd.log | wc -l | tr 
> -d ' '],
> +  [0], [1
> +])
> +
> +OVS_VSWITCHD_STOP
> +AT_CLEANUP
> diff --git a/utilities/checkpatch_dict.txt b/utilities/checkpatch_dict.txt
> index fe6365d5f7..89a0b4484c 100644
> --- a/utilities/checkpatch_dict.txt
> +++ b/utilities/checkpatch_dict.txt
> @@ -78,7 +78,9 @@ ethernet
>  ethertype
>  ethtool
>  eventmask
> +expirations
>  faq
> +fallbacks
>  fastpath
>  fd
>  fdb
> --
> 2.56.1
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to