Skip to content

ACL Table IP Type Attribute - #2343

Open
AnandhiDhanabalan wants to merge 4 commits into
opencomputeproject:masterfrom
AnandhiDhanabalan:mrvl_acl_table_type
Open

AnandhiDhanabalan wants to merge 4 commits into
opencomputeproject:masterfrom
AnandhiDhanabalan:mrvl_acl_table_type

Conversation

@AnandhiDhanabalan

Copy link
Copy Markdown
Contributor

This PR introduces SAI_ACL_TABLE_ATTR_IP_TYPE, a new CREATE_ONLY ACL table attribute that allows the NOS to explicitly declare the packet domain (ANY/IP/IPV4/IPV6/NON_IP) of an ACL table at creation time. This enables implementations to select an optimal TCAM key profile upfront rather than inferring the packet domain from entry match fields.

Signed-off-by: Anandhi Dhanabalan <adhanabalan@marvell.com>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@AnandhiDhanabalan

Copy link
Copy Markdown
Contributor Author

@j-bos , Question asked during discussion if SONIC uses any of the SAI_ACL_IP_TYPE_xxx enums, especially for ARP

In orchagent/aclorch.cpp, AclOrch::initDefaultTableTypes() builds each default table type with an explicit list of supported SAI match fields. SAI_ACL_TABLE_ATTR_FIELD_ACL_IP_TYPE is registered for: L3, L3V6, L3V4V6, MCLAG, MIRROR, and MIRRORV6. A rule in these tables is allowed to carry an IP_TYPE match — it's part of that table type's declared capability. SONiC does not use it for any of the default rules.

MCLAG port-isolation ACL rules, auto-generated by mclagsyncd (not user-authored). In mclaglink.cpp:343, whenever an MCLAG peer link goes down and orphan ports need isolating, mclagsyncd programs the ACL rule with IP_TYPE = ANY

Also notable: cfgmgr/natmgr.cpp validates an IP_TYPE field on NAT-related ACL rules, restricting it to only IP or IPV4ANY (natmgr.cpp:7938-7946) — this is for user/NAT-orchestrator-authored ACL rules that block/forward NAT'd traffic, not a fully automatic default, but it's another consumer of the same IP_TYPE/SAI_ACL_IP_TYPE_xxx plumbing.

@kcudnik

kcudnik commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@tjchadaga tjchadaga added the reviewed PR is discussed in SAI Meeting label Sep 9, 2026
@AnandhiDhanabalan

Copy link
Copy Markdown
Contributor Author

@tjchadaga, could you approve this PR?

@tjchadaga

Copy link
Copy Markdown
Collaborator

@j-bos, @JaiOCP, @marian-pritsak, @eddyk-nvidia - could you please help review?

@AnandhiDhanabalan

Copy link
Copy Markdown
Contributor Author

@j-bos @JaiOCP @marian-pritsak @eddyk-nvidia - gentle reminder, can you review and approve this PR

@AnandhiDhanabalan

Copy link
Copy Markdown
Contributor Author

@j-bos @JaiOCP @marian-pritsak @eddyk-nvidia @tjchadaga

Could you please review and share your feedback, or let me know if someone else would be better suited to look into this?
We are targeting SAI v1.19 and would appreciate timely inputs.

@j-bos

j-bos commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Hi, there are a few items I want to check:

  • Some implementations may consider ARP to be non-IP.
  • In case an ACL may apply to a few types of listed traffic, e.g. one ACL for non-IP + IPv4, but separate ACL for ipv6, is that covered?

@AnandhiDhanabalan

Copy link
Copy Markdown
Contributor Author
  • Some implementations may consider ARP to be non-IP.

ARP classification: this is addressed in section 5.1 of the proposal doc.
Still if some vendor does not want to use SAI_ACL_TABLE_IP_TYPE_IPV4, they can use SAI_ACL_TABLE_IP_TYPE_ANY

  • In case an ACL may apply to a few types of listed traffic, e.g. one ACL for non-IP + IPv4, but separate ACL for ipv6, is that covered?

sai_acl_table_ip_type_t currently has five discrete values, ANY, IP, IPV4, IPV6, NON_IP, each describing one table's domain, so there isn't a composite option for something like "non-IP + IPv4 but not IPv6" in a single table today.
To cover that case you'd either use ANY (which also opens up IPv6) or split it into two tables, one IPV4 and one NON_IP, same as SONiC already does with separate L3/L3V6 table types.

@j-bos Let me know if a combined/bitmask value is actually needed for your use case. If yes, we can consider future extension of this PR

@j-bos

j-bos commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

I'm looking at it even in terms of the sonic use-case. For example, in aclorch, there is the below description of the table matching for mirror tables, where the non-ip rules (e.g. match ethertype) live in the table with the ipv4 rules, in case of separated v4/v6 model.

So in case of SONiC, it's not clear how they would configure TABLE_MIRROR, since that single table needs to handle v4 and non-ip.

If configured as ALL, I believe that would be a hint to the SDK that V6 exists as well in the first table and so it could not be relied on for optimizing the allocation.

It seems like the attribute may need to be a list of enum values, similar to the bind-point type list (and then ARP could probably also be solved by splitting it out from V4, to allow for V4 or V4+ARP).

    /*
     * Type of Tables and Supported Match Types (ASIC database)
     * |------------------------------------------------------------------|
     * |                   | TABLE_MIRROR | TABLE_MIRROR | TABLE_MIRRORV6 |
     * |    Match Type     |----------------------------------------------|
     * |                   |   combined   |          separated            |
     * |------------------------------------------------------------------|
     * | MATCH_SRC_IP      |      √       |      √       |                |
     * | MATCH_DST_IP      |      √       |      √       |                |
     * |------------------------------------------------------------------|
     * | MATCH_ICMP_TYPE   |      √       |      √       |                |
     * | MATCH_ICMP_CODE   |      √       |      √       |                |
     * |------------------------------------------------------------------|
     * | MATCH_SRC_IPV6    |      √       |              |       √        |
     * | MATCH_DST_IPV6    |      √       |              |       √        |
     * |------------------------------------------------------------------|
     * | MATCH_ICMPV6_TYPE |      √       |              |       √        |
     * | MATCH_ICMPV6_CODE |      √       |              |       √        |
     * |------------------------------------------------------------------|
     * | MATCH_IP_PROTOCOL |      √       |      √       |                |
     * | MATCH_NEXT_HEADER |      √       |              |       √        |
     * | -----------------------------------------------------------------|
     * | MATCH_ETHERTYPE   |      √       |      √       |                |
     * |------------------------------------------------------------------|
     * | MATCH_IN_PORTS    |      √       |      √       |                |
     * |------------------------------------------------------------------|
     */

@AnandhiDhanabalan

Copy link
Copy Markdown
Contributor Author

@j-bos , I see what you mean, We can discuss this over a meeting in community and decide on the best possible approach.

@AnandhiDhanabalan

AnandhiDhanabalan commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor Author

@j-bos, adding the following two enum values should address the mirror case you mentioned:

    /** NON_IP and IPv4 packets */
    SAI_ACL_TABLE_IP_TYPE_NON_IPV6,

    /** NON_IP and IPv6 packets */
    SAI_ACL_TABLE_IP_TYPE_NON_IPV4,

I specifically prefer not to use a list of enum values, as that could introduce backward-compatibility concerns.
Please share your thoughts on this approach.

@mclayto

mclayto commented Oct 16, 2026

Copy link
Copy Markdown

So with these additional enum values are we saying that ARP falls under NON_IP and then it can be used as intended with the NON_IPV6?

@AnandhiDhanabalan

Copy link
Copy Markdown
Contributor Author

So with these additional enum values are we saying that ARP falls under NON_IP and then it can be used as intended with the NON_IPV6?

@mclayto,
The new values don't say ARP falls under NON_IP. ARP placement is ASIC specific. Some ASICs classify it as IPv4 and others as non-IP. So the spec shouldn't fix it to either one.

SAI_ACL_TABLE_IP_TYPE_NON_IPV6 (NON_IP + IPv4) covers both cases. ARP falls inside the table's domain whichever bucket the ASIC uses, so the NOS doesn't need to know where the ASIC puts it. The same applies to ANY.

@AnandhiDhanabalan

Copy link
Copy Markdown
Contributor Author

@j-bos @mclayto @JaiOCP ,Thanks for your comments. I have now updated the header file and hld as per the recommendation to have the new attribute as list. Please review and share your feedback/approval

@AnandhiDhanabalan

Copy link
Copy Markdown
Contributor Author

@j-bos @mclayto @JaiOCP , Gentle reminder, do let me know if further discussion is needed for this

Comment thread inc/saiacl.h Resolved

@bandaru-viswanath bandaru-viswanath left a comment

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.

The PR introduces a new attribute that becomes another source of truth for determining the table details, the existing source being the list of qualifiers. SAI, in general, avoids defining such multiple sources. Some of the inherent issues are commented as inline comments below. Perhaps we can solve the problem differently ?

The new attribute is optional and defaults to an empty list.

An empty list means the attribute is not configured. The table is unrestricted: it behaves as if all packet types were listed, no packet-type validation is applied to entries, and the implementation selects the table resources.

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.

This default behaviour of "unrestricted" can conflict with other Qualifiers set for the table.

"empty list" can't mean "not configured" and "unrestricted" both, at the same time. The problem is because the other qualifiers are also in place and they will determine.

  • Imagine a table created without this attribute, but for an IPv6 qualifier set. A GET on this attribute is supposed to return the default value (being not configured), but that mean it is unrestricted and it is wrong. Returning non-default value for an not-configured attribute is against the spec.

  • If a Table is created with "IPv4" in the list (of this attribute) but has "IPv6" qualifiers in the create parameters, how to handle that situation ?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think the point of this PR is that an "IPv6 qualifier set" does not restrict a table to IPv6. If it did, there would be no need for this PR. My example:

Table: FIELD_SRC_IPV6 (only IPv6 fields specified)
Entry: FIELD_SRC_IPV6 --> Matches only IPv6 packets with that SIP
Entry: <no qualifiers> --> Matches All other packets including IPv4 & non-IP

I agree that the second bullet should be clear. Is it an error to specify a field that cannot be matched by the table type or is it just a useless field?

@bandaru-viswanath bandaru-viswanath Nov 6, 2026 •

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.

IMO, the example provided is not the right behaviour.

If a Table has FIELD_SRC_IPV6 (and no V4 for example), then no entry in that table should match a non-IPv6 packet. The wildcards in the entries are constrained by the table definition. Otherwise, the table definition doesn't have a purpose and is not required.

For example, if the table definition has FIELD_SRC_IPV6 and FIELD_DST_UDP_PORT, and an entry in that table has "match all packets to UDP port X", and if it starts matching IPv4 packets with that udp-port X, as well, it becomes a mockery of the table definition. There is an expectation of IPv6 packets here from the table definition.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Interesting - Is this documented somewhere? If this is the community consensus then I agree we don't need this PR. To be clear, we have this interpretation but I always considered it an imperfect heuristic to accommodate SONiC table types without wasting resources. I find that the tricky part is determining when non-IP is included or not (we've adjusted our interpretation of ETHER_TYPE over time). If we're documenting this as proper SAI behavior, I suggest we capture how each field affects the interpreted table type.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actually, I will push back on this statement though: "Otherwise, the table definition doesn't have a purpose and is not required."
This may be true for devices with a fixed key, but not for devices with dynamic key definitions. We still need a predefined set of fields that will be used to construct the keys for this ACL.

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.

SAI spec is defined for the hypothetical SAI pipeline. It needs to be mapped to individual ASIC's from each vendor. So the Spec's Table definition is provided for the SAI pipeline via qualifiers. So, my point is that the definition in the spec has a purpose, and we shouldn't add attributes bypassing that purpose.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@bandaru-viswanath , I agree with @mclayto.
The below interpretation of yours is not documented in SAI, and this implementation proves we need a attribute to identify the table type explicitly.

"For example, if the table definition has FIELD_SRC_IPV6 and FIELD_DST_UDP_PORT, and an entry in that table has "match all packets to UDP port X", and if it starts matching IPv4 packets with that udp-port X, as well, it becomes a mockery of the table definition. There is an expectation of IPv6 packets here from the table definition."


# 1. Overview

SAI currently defines the packet type of an ACL entry through `SAI_ACL_ENTRY_ATTR_FIELD_ACL_IP_TYPE`, but does not provide an ACL-table-level attribute to declare the intended packet domain of the table.

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.

The Table qualifier set is used, today, to derive the packet types. In the review meeting, it was suggested to list the specific reasons that required this attribute being introduced. Could you please update the doc ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@bandaru-viswanath , thanks for your comments.
I am re-working on this proposal to capture all points discussed, will call for a offline discussion soon with these points answered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

reviewed PR is discussed in SAI Meeting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants