Skip to content

[acl]: test different subnet masks#481

Merged
lguohan merged 7 commits intosonic-net:masterfrom
simone-dell:SubnetMaskAclTest
Jun 8, 2018
Merged

[acl]: test different subnet masks#481
lguohan merged 7 commits intosonic-net:masterfrom
simone-dell:SubnetMaskAclTest

Conversation

@simone-dell
Copy link
Copy Markdown
Contributor

What I did
Added a test case that checks that different subnet mask for dest/src ip addresses in ACL rules are programmed correctly in the ASICDB

Why I did it
Part of the ACL test cases propsed by Dell and approved by Microsoft

How I verified it
Ran the python test script in the repo

Details if related
Output of test attatched
subnet_test_logs.txt

Added a test case with ACL rules with different mask /8 /19 ,etc.  Verified the proper subnet masks were reflected in the ASICDB.

time.sleep(2)

subnet_mask_rules = 0
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 use for loop to simplify the logic? there are quite a few redundant code here.

Copy link
Copy Markdown
Contributor

@lguohan lguohan left a comment

Choose a reason for hiding this comment

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

can you simply the code logic by uisng for loop?

@lguohan lguohan requested a review from prsunny April 23, 2018 07:32
(status, fvs) = atbl.get(entry)
assert status == True
assert len(fvs) == 6
if ('SAI_ACL_ENTRY_ATTR_FIELD_SRC_IP', '23.103.0.0&mask:255.255.192.0') in fvs:
Copy link
Copy Markdown
Contributor

@lguohan lguohan May 3, 2018

Choose a reason for hiding this comment

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

there is code redundancy in the block as well.

can you define a function as below as use the function to check all entries in acl_entry?

check_rule_existence(entry, rules):
      for rule in rules:
          check if src_ip in the rule match the entry
          check if action of the rule match the entry
          check if priority of the rule match the entry
          if all match:
              then return the True
    if none of the rule match, return false

Copy link
Copy Markdown
Contributor

@lguohan lguohan left a comment

Choose a reason for hiding this comment

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

further improve the code efficiency.

@lguohan lguohan merged commit 44309ef into sonic-net:master Jun 8, 2018
oleksandrivantsiv pushed a commit to oleksandrivantsiv/sonic-swss that referenced this pull request Mar 1, 2023
* [vslib] add ACL action capabilities support
* [meta] add support for SAI_ATTR_VALUE_TYPE_ACL_CAPABILITY set operation

This is needed for SWSS integration testing
e.g: use setReadOnlyAttr from VS test suite to modify
SAI_SWITCH_ATTR_ACL_STAGE_INGRESS/EGRESS to test orchagent
flows

Signed-off-by: Stepan Blyschak <[email protected]>
Janetxxx pushed a commit to Janetxxx/sonic-swss that referenced this pull request Nov 10, 2025
* Add files via upload

* Test case: ACL rule with diff subnet masks

Added a test case with ACL rules with different mask /8 /19 ,etc.  Verified the proper subnet masks were reflected in the ASICDB.

* changing addition of acl rules to a loop to avoid redundancy

* added a helper function to improve code efficiency

* Update test_acl.py
jianyuewu pushed a commit to jianyuewu/sonic-swss that referenced this pull request Dec 24, 2025
…c-net#481)

The PR sonic-net/sonic-buildimage#6920 adds the support for swsscommon in `hostcfgd`. The PR test failure are seen because the `config_db.subscribe` doesnt work with swsscommon. This PR adds the support for the following python APIs
 - `config_db.subscribe`
 - `config_db.unsubscribe`
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