Skip to content

UDF yang model definition.#26874

Open
srodd-nexthop wants to merge 3 commits into
sonic-net:masterfrom
nexthop-ai:srodd.nexthopai.udf.yang
Open

UDF yang model definition.#26874
srodd-nexthop wants to merge 3 commits into
sonic-net:masterfrom
nexthop-ai:srodd.nexthopai.udf.yang

Conversation

@srodd-nexthop
Copy link
Copy Markdown

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

HLD: sonic-net/SONiC#2299

Why I did it

Adds the YANG model for the new UDF (User-Defined Field) feature in SONiC. UDF allows ACLs to match on arbitrary byte offsets within a packet, enabling classification of protocols not covered by standard ACL fields (e.g., RoCEv2 BTH, GRE inner headers).

The companion orchagent implementation is in sonic-net/sonic-swss#4493. This PR adds only the YANG schema.

Work item tracking
  • Microsoft ADO (number only): N/A

How I did it

Added src/sonic-yang-models/yang-models/sonic-udf.yang defining two CONFIG_DB tables:

  • UDF — UDF field definition. Keys: UDF_NAME. Fields: length (1–255), field_type (GENERIC|HASH), description.
  • UDF_SELECTOR — per-packet-type extraction rule. Keys: UDF_NAME|SELECTOR_NAME. Flat CONFIG_DB fields:
    • select_base (enum L2|L3|L4, mandatory) and select_offset (uint8 0–255, mandatory) — extraction location
    • match_l2_type / match_l2_type_mask, match_l3_type / match_l3_type_mask, match_gre_type / match_gre_type_mask, match_l4_dst_port / match_l4_dst_port_mask — packet-match criteria (hex strings; at least one of the four type/port fields must be set)
    • match_priority (uint8 0–255, default 0) — selector priority when multiple match

UDF_SELECTOR.UDF_NAME is a leafref to UDF.UDF_NAME, so a selector cannot reference a non-existent UDF field.

Also updated:

  • src/sonic-yang-models/setup.py to register the new module.
  • src/sonic-yang-models/tests/files/sample_config_db.json with a UDF + UDF_SELECTOR example for validation.

How to verify it

cd src/sonic-yang-models
python3 setup.py test

The sample_config_db.json additions exercise the new leafref and per-field type/pattern validation; validation should pass cleanly.

Which release branch to backport (provide reason below if selected)

Not a backport — new feature.

  • 202305
  • 202311
  • 202405
  • 202411
  • 202505
  • 202511

Tested branch (Please provide the tested image version)

  • master

Description for the changelog

Add YANG model for UDF (UDF and UDF_SELECTOR tables) to support ACL matching on user-defined byte offsets.

@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.

  • ✅ login: srodd-nexthop / name: satishkumar rodd (ec20204)

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@srodd-nexthop srodd-nexthop force-pushed the srodd.nexthopai.udf.yang branch from 0de8e26 to 31eba2e Compare April 21, 2026 13:55
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@srodd-nexthop srodd-nexthop marked this pull request as ready for review April 21, 2026 14:33
@srodd-nexthop
Copy link
Copy Markdown
Author

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link
Copy Markdown

Commenter does not have sufficient privileges for PR 26874 in repo sonic-net/sonic-buildimage

srodd-nexthop added a commit to nexthop-ai/sonic-mgmt that referenced this pull request May 11, 2026
Adds tests/udf/test_udf.py covering the UDF feature added in
sonic-net/sonic-swss#4493 (UdfOrch), sonic-net/sonic-buildimage#26874
(YANG), and sonic-net/sonic-sairedis#1856 (meta validation).

Registers the suite under t0 and t1-lag in .azure-pipelines/pr_test_scripts.yaml.

Coverage (18 test classes, 30+ test methods):

  - Baseline ASIC_DB programming and CONFIG_DB schema
  - UDP traffic match through UDF-backed ACL fields
  - ACL rule create/delete with UDF dependencies
  - UDF/ACL teardown ordering (correct-order and wrong-order recovery)
  - ACL rule priority shadowing
  - Forward reference resolution (TABLE_TYPE configured before SELECTOR)
  - Multiple selectors per UDF group, distinct OIDs
  - Invalid CONFIG_DB rejection (negative tests)
  - SAI UDF_MATCH/UDF attribute round-trip from CONFIG_DB
  - L3-type auto-mask, L4-port-zero match presence detection
  - Match type filtering at packet level
  - Selector field validation (missing/unknown base, missing match)
  - Selector immutability and idempotent SET handling
  - UDF_MATCH refcount sharing across selectors (dedup)
  - UDF_GROUP refcount layering (TABLE_TYPE / TABLE / multi-table)
  - ACL rule blocking selector deletion
  - Edge cases (rule with UDF not in table, double-delete, type-vs-table
    deletion ordering)
  - End-to-end traffic with full UDF + ACL pipeline

All config done directly via sonic-cfggen -j -w; SAI object lifecycle
verified via ASIC_DB OID diffing.  Module-scoped LogAnalyzer captures
unexpected orchagent errors in non-failing mode (negative tests
deliberately trigger SWSS_LOG_ERRORs that are ignored via regex).

conftest.py overrides yang_validation_check with a UDF-scoped equivalent
that validates only UDF/UDF_SELECTOR tables against sonic-udf.yang
(avoids spurious failures from FLEX_COUNTER_TABLE entries not covered by
installed YANG models on some platforms).

Signed-off-by: satishkumar <srodd@nexthop.ai>
srodd-nexthop added a commit to nexthop-ai/sonic-mgmt that referenced this pull request May 11, 2026
Adds tests/udf/test_udf.py covering the UDF feature added in
sonic-net/sonic-swss#4493 (UdfOrch), sonic-net/sonic-buildimage#26874
(YANG), and sonic-net/sonic-sairedis#1856 (meta validation).

Registers the suite under t0 and t1-lag in .azure-pipelines/pr_test_scripts.yaml.

Coverage (18 test classes, 30+ test methods):

  - Baseline ASIC_DB programming and CONFIG_DB schema
  - UDP traffic match through UDF-backed ACL fields
  - ACL rule create/delete with UDF dependencies
  - UDF/ACL teardown ordering (correct-order and wrong-order recovery)
  - ACL rule priority shadowing
  - Forward reference resolution (TABLE_TYPE configured before SELECTOR)
  - Multiple selectors per UDF group, distinct OIDs
  - Invalid CONFIG_DB rejection (negative tests)
  - SAI UDF_MATCH/UDF attribute round-trip from CONFIG_DB
  - L3-type auto-mask, L4-port-zero match presence detection
  - Match type filtering at packet level
  - Selector field validation (missing/unknown base, missing match)
  - Selector immutability and idempotent SET handling
  - UDF_MATCH refcount sharing across selectors (dedup)
  - UDF_GROUP refcount layering (TABLE_TYPE / TABLE / multi-table)
  - ACL rule blocking selector deletion
  - Edge cases (rule with UDF not in table, double-delete, type-vs-table
    deletion ordering)
  - End-to-end traffic with full UDF + ACL pipeline

All config done directly via sonic-cfggen -j -w; SAI object lifecycle
verified via ASIC_DB OID diffing.  Module-scoped LogAnalyzer captures
unexpected orchagent errors in non-failing mode (negative tests
deliberately trigger SWSS_LOG_ERRORs that are ignored via regex).

Signed-off-by: satishkumar <srodd@nexthop.ai>
srodd-nexthop added a commit to nexthop-ai/sonic-mgmt that referenced this pull request May 11, 2026
Adds tests/udf/test_udf.py covering the UDF feature added in
sonic-net/sonic-swss#4493 (UdfOrch), sonic-net/sonic-buildimage#26874
(YANG), and sonic-net/sonic-sairedis#1856 (meta validation).

Registers the suite under t0 and t1-lag in .azure-pipelines/pr_test_scripts.yaml.

Coverage (18 test classes, 30+ test methods):

  - Baseline ASIC_DB programming and CONFIG_DB schema
  - UDP traffic match through UDF-backed ACL fields
  - ACL rule create/delete with UDF dependencies
  - UDF/ACL teardown ordering (correct-order and wrong-order recovery)
  - ACL rule priority shadowing
  - Forward reference resolution (TABLE_TYPE configured before SELECTOR)
  - Multiple selectors per UDF group, distinct OIDs
  - Invalid CONFIG_DB rejection (negative tests)
  - SAI UDF_MATCH/UDF attribute round-trip from CONFIG_DB
  - L3-type auto-mask, L4-port-zero match presence detection
  - Match type filtering at packet level
  - Selector field validation (missing/unknown base, missing match)
  - Selector immutability and idempotent SET handling
  - UDF_MATCH refcount sharing across selectors (dedup)
  - UDF_GROUP refcount layering (TABLE_TYPE / TABLE / multi-table)
  - ACL rule blocking selector deletion
  - Edge cases (rule with UDF not in table, double-delete, type-vs-table
    deletion ordering)
  - End-to-end traffic with full UDF + ACL pipeline

All config done directly via sonic-cfggen -j -w; SAI object lifecycle
verified via ASIC_DB OID diffing.  Module-scoped LogAnalyzer captures
unexpected orchagent errors in non-failing mode (negative tests
deliberately trigger SWSS_LOG_ERRORs that are ignored via regex).

Signed-off-by: satishkumar <srodd@nexthop.ai>
Signed-off-by: satishkumar rodd <srodd@nexthop.ai>
@srodd-nexthop srodd-nexthop force-pushed the srodd.nexthopai.udf.yang branch from 31eba2e to ec20204 Compare May 11, 2026 17:14
@yijingyan2
Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

srodd-nexthop added a commit to nexthop-ai/sonic-mgmt that referenced this pull request May 12, 2026
Adds tests/udf/test_udf.py covering the UDF feature added in
sonic-net/sonic-swss#4493 (UdfOrch), sonic-net/sonic-buildimage#26874
(YANG), and sonic-net/sonic-sairedis#1856 (meta validation).

Registers the suite under t0 and t1-lag in .azure-pipelines/pr_test_scripts.yaml.

Coverage (18 test classes, 30+ test methods):

  - Baseline ASIC_DB programming and CONFIG_DB schema
  - UDP traffic match through UDF-backed ACL fields
  - ACL rule create/delete with UDF dependencies
  - UDF/ACL teardown ordering (correct-order and wrong-order recovery)
  - ACL rule priority shadowing
  - Forward reference resolution (TABLE_TYPE configured before SELECTOR)
  - Multiple selectors per UDF group, distinct OIDs
  - Invalid CONFIG_DB rejection (negative tests)
  - SAI UDF_MATCH/UDF attribute round-trip from CONFIG_DB
  - L3-type auto-mask, L4-port-zero match presence detection
  - Match type filtering at packet level
  - Selector field validation (missing/unknown base, missing match)
  - Selector immutability and idempotent SET handling
  - UDF_MATCH refcount sharing across selectors (dedup)
  - UDF_GROUP refcount layering (TABLE_TYPE / TABLE / multi-table)
  - ACL rule blocking selector deletion
  - Edge cases (rule with UDF not in table, double-delete, type-vs-table
    deletion ordering)
  - End-to-end traffic with full UDF + ACL pipeline

All config done directly via sonic-cfggen -j -w; SAI object lifecycle
verified via ASIC_DB OID diffing.  Module-scoped LogAnalyzer captures
unexpected orchagent errors in non-failing mode (negative tests
deliberately trigger SWSS_LOG_ERRORs that are ignored via regex).

Signed-off-by: satishkumar <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.sonic-buildimage

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

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.

3 participants