Skip to content

[HLD] User Defined Fields(UDF) feature in SONiC#2299

Open
srodd-nexthop wants to merge 5 commits intosonic-net:masterfrom
nexthop-ai:srodd.nexthopai-udf
Open

[HLD] User Defined Fields(UDF) feature in SONiC#2299
srodd-nexthop wants to merge 5 commits intosonic-net:masterfrom
nexthop-ai:srodd.nexthopai-udf

Conversation

@srodd-nexthop
Copy link
Copy Markdown

@srodd-nexthop srodd-nexthop commented Apr 17, 2026

Description:

Adds HLD for the UDF feature in SONiC, covering:

CONFIG_DB schema for UDF and UDF_SELECTOR tables
UdfOrch orchestration for SAI UDF Group, Match, and UDF object lifecycle
ACL integration with udf_field name resolution
YANG model validation, match deduplication, and dependency ordering

Yang changes: sonic-net/sonic-buildimage#26874
Swss changes: sonic-net/sonic-swss#4493
sairedis changes: sonic-net/sonic-sairedis#1856

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented Apr 17, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

No pipelines are associated with this pull request.

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

No pipelines are associated with this pull request.

Comment thread doc/udf/UDF_HLD.md

### Object Roles(one-liner)

- **UDF** = WHERE and how big (udf_field position/length in ACL key)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is position defined?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Position" here means the slot index in the ACL key where the extracted udf_field bytes are written, not a property of the UDF object itself. Hence its called out as position in acl key

Comment thread doc/udf/UDF_HLD.md Outdated
{
// UDF definition
"UDF": { "BTH_RESERVED": { "field_type": "GENERIC", "length": "1" } },
"UDF_SELECTOR": { "BTH_RESERVED|roce_v1": { "match": { "l2_type": "0x8915", "l2_type_mask": "0xFFFF", "priority": "100" }, "select": { "base": "L2", "offset": "22" } },
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose base defined the start point of UDF object. But I think L2, L3 or L4 could be misleading sometimes. For example, there could be encapsulated frames, including VXLAN, IPinIP, and different IP hearers.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference between GENERIC and hash?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the base here are looking for the outer headers and for inner header we have to rely on the offset. Its been documented as an example in sonic-sairedis/SAI/doc/ACL/UDF-based-ACL.md

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GENERIC is used for ACL integration
HASH is to define fields for ECMP hashing.

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

No pipelines are associated with this pull request.

Comment thread doc/udf/UDF_HLD.md Outdated
// UDF definition
"UDF": { "BTH_RESERVED": { "field_type": "GENERIC", "length": "1" } },
"UDF_SELECTOR": { "BTH_RESERVED|roce_v1": { "match": { "l2_type": "0x8915", "l2_type_mask": "0xFFFF", "priority": "100" }, "select": { "base": "L2", "offset": "22" } },
"BTH_RESERVED|roce_v2": { "match": { "l3_type": "0x11", "l3_type_mask": "0xFF", "priority": "100" }, "select": { "base": "L4", "offset": "16" } } },
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please clarify how match and select work together?
I suppose match + select = When this packet type appears, extract bytes from HERE. Is that correct?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, match acts as a filter and select acts as a pointer from where the field has to be extracted.

Comment thread doc/udf/UDF_HLD.md
Comment thread doc/udf/UDF_HLD.md Outdated

### 8.2 CLI

CLI configuration for UDF is **not implemented**. Configuration is applied directly via CONFIG_DB using `sonic-cfggen` or `redis-cli`:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GCU (Generic Config Update) should be the preferred mechanism if CLI is not in plan.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks — your json-in-config_db comment pushed me to drop the JSON-string model. select and match are now flat CONFIG_DB fields (select_base, select_offset, match_l2_type, …), so GCU, sonic-cfggen, and YANG all work natively.

Comment thread doc/udf/UDF_HLD.md Outdated

#### Why `select` and `match` are JSON values rather than flat fields

CONFIG_DB stores each row as a flat Redis hash — one key, string-valued fields. Modeling `select` and `match` as nested containers would require splitting them into separate tables (e.g., `UDF_SELECTOR_SELECT`, `UDF_SELECTOR_MATCH`) keyed by the same `<udf>|<selector>`. We chose to keep the selector as a single atomic row so that a SET/DEL on one key represents one complete selector, and `match`/`select` cannot drift out of sync across tables. The tradeoff is that their internal structure lives inside a JSON value instead of the YANG tree.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to confirm and verify this json-in-config_db model is supported by GCU and other CLI, like sonic-cfggen.
YANG model validation can be another challenge as the json value will be handled as a pure string.

Comment thread doc/udf/UDF_HLD.md Outdated
// UDF definition
"UDF": { "BTH_RESERVED": { "field_type": "GENERIC", "length": "1" } },
"UDF_SELECTOR": { "BTH_RESERVED|roce_v1": { "match": { "l2_type": "0x8915", "l2_type_mask": "0xFFFF", "priority": "100" }, "select": { "base": "L2", "offset": "22" } },
"BTH_RESERVED|roce_v2": { "match": { "l3_type": "0x11", "l3_type_mask": "0xFF", "priority": "100" }, "select": { "base": "L4", "offset": "16" } } },
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May need some clarification on the priority, including

  1. Is higher number = higher priority or lower?
  2. What happens when two selectors have the SAME priority and both match?
  3. Is priority globally unique required, or just per-field?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the question, I'll validate the behavior on HW and update the HLD with concrete answers.

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

No pipelines are associated with this pull request.

Signed-off-by: satishkumar rodd <srodd@nexthop.ai>
Signed-off-by: satishkumar rodd <srodd@nexthop.ai>
Signed-off-by: satishkumar rodd <srodd@nexthop.ai>
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

No pipelines are associated with this pull request.

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

No pipelines are associated with this pull request.

Signed-off-by: satishkumar rodd <srodd@nexthop.ai>
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

No pipelines are associated with this pull request.

@prsunny prsunny requested a review from kperumalbfn April 21, 2026 15:30
Comment thread doc/udf/UDF_HLD.md
- Udf: Dependency handling, offset/base validation
- UdfOrch: CONFIG_DB subscription, group OID resolution, ref-count tracking

### 10.2 System Tests
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you elaborate this with scenarios and expectation. Also, please update PR link for sonic-mgmt tests.

e.g - https://github.com/sonic-net/SONiC/blob/master/doc/vxlan/Overlay%20ECMP%20with%20BFD.md#281-overlay-ecmp

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

No pipelines are associated with this pull request.

Replaces the high-level test categories in section 10 with explicit
test scenarios drawn from the sonic-mgmt UDF suite, following the
Step / Goal / Expected results format used in the Overlay ECMP HLD.

10.2 System Tests now covers:
  - Baseline programming
  - End-to-end traffic
  - UDF/ACL dependency and teardown order
  - ACL rule priority
  - Forward reference resolution
  - Multiple selectors per group
  - SAI attribute correctness (all 4 match types, 3 bases, auto-mask,
    match-presence regressions)
  - Match-type traffic filtering (L2 / L4 / IPv6)
  - Reference counting (UDF_MATCH dedup, UDF_GROUP refcount layers,
    ACL_RULE refcount on selectors)
  - Immutability and idempotency
  - Validation edge cases

10.3 Negative Tests:
  - Invalid CONFIG_DB
  - Selector field validation

Each subsection references the corresponding test class(es) in the
sonic-mgmt suite (tests/udf/test_udf.py, parallel PR -- Open Item #9).

Addresses prsunny review comment.

Signed-off-by: Satishkumar Rodd <srodd@nexthop.ai>
@srodd-nexthop srodd-nexthop force-pushed the srodd.nexthopai-udf branch from 320c343 to bcd2d5d Compare May 11, 2026 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants