Re: [PATCH RFC v2 11/15] ctlv: Add operation dispatch

From: Aneesh Kumar K . V

Date: Fri Dec 04 2026 - 08:04:21 EST


Jiri Pirko <jiri@xxxxxxxxxxx> writes:

> From: Jiri Pirko <jiri@xxxxxxxxxx>

[ ... 1027 lines skipped ... ]

> +/**
> + * ctlv_ext_fill - Delegate an extension-point output record.
> + * @ctx: operation context
> + * @request: validated request root
> + * @record: output record selected by the generated helper
> + *
> + * Return: filling callback result, or 0 for an unfilled point.
> + */
> +int ctlv_ext_fill(struct ctlv_op_ctx *ctx, const struct ctlv_cursor *request,
> + struct ctlv_cursor *record)
> +{
> + const struct ctlv_schema_tree *tree;
> + u32 index;
> +
> + if (WARN_ON_ONCE(!record->tree))
> + return -EINVAL;
> + tree = record->tree;
> +
> + for (index = 0; index < tree->ext_schemas_count; index++) {
> + const struct ctlv_ext_schema *ext_schema = &tree->ext_schemas[index];
> + const struct ctlv_cursor *filled_request = request;
> + const struct ctlv_ext_fill_schema *fill_schema;
> + const struct ctlv_ext_ops *ext_ops;
> + struct ctlv_cursor filled;
> + int ret;
> +
> + if (ext_schema->node != record->node)
> + continue;
> + ext_ops = ctlv_ext_ops_find(ctx->ctlv, ext_schema);
> + if (!ext_ops || !ext_ops->fill)
> + continue;
> +
> + if (request) {
> + fill_schema = ctlv_schema_fill(ctx->family, ext_schema->family_id,
> + ext_schema->ext_id);
> + if (WARN_ON_ONCE(!fill_schema))
> + return -EINVAL;
> + filled = *request;
> + if (ctlv_message_input_rebind(&filled, &fill_schema->members, 0))
> + filled_request = &filled;
> + else
> + filled_request = NULL;
> + }
> +
> + ret = ext_ops->fill(ctx->ctlv, ctx, filled_request, record);
> + if (ret)
> + return ret;
> + }
> + return 0;
> +}
> +EXPORT_SYMBOL_NS_GPL(ctlv_ext_fill, "CTLV");
> +

Could we also add a helper here to select the child family's schema when
decoding a request extension record?

I am using this for the SPDM changes, which extend the common
evidence-get request with device-session-id fields.

evidence-get:
type: action
request:
.....
# Optional family-specific collection parameters.
parameters?: extension evidence-parameters
reply:
# Optional family-specific evidence result metadata.
details?: extension evidence-details

and in ctlv-attestation-spdm.yaml

evidence-parameters:
# Connection or lock device session ID this collection belongs to.
device-session-id: uint
# Identity slot; captured host evidence requires the selected identity.
slot?: uint(..7)

# Fills the common evidence-details reply extension after bundle delivery.
evidence-details:
# Connection or lock device session ID of the delivered bundle.
device-session-id: uint

When evidence-get selects the parameters record, its cursor still uses
the common attestation schema. That schema does not define the SPDM
fields inside the record.

Reading those fields therefore triggers WARN_ON_ONCE() in
ctlv_message_input_slot()

-aneesh