Support Restapi/gnmi control plane acls#9
Merged
ZhaohuiS merged 4 commits intosonic-net:masterfrom Aug 30, 2022
Merged
Conversation
Signed-off-by: Zhaohui Sun <zhaohuisun@microsoft.com>
prsunny
reviewed
Aug 15, 2022
scripts/caclmgrd
Outdated
| }, | ||
| "EXTERNAL_CLIENT": { | ||
| "ip_protocols": ["tcp"], | ||
| "dst_ports": ["8081"], |
Contributor
There was a problem hiding this comment.
Let this be triggered via config
Signed-off-by: Zhaohui Sun <zhaohuisun@microsoft.com>
prsunny
approved these changes
Aug 25, 2022
Contributor
prsunny
left a comment
There was a problem hiding this comment.
lgtm, lets add some unit tests
Contributor
Author
@prsunny Sure, will do. |
Contributor
…ort range for ipv4 and ipv6 Signed-off-by: Zhaohui Sun <zhaohuisun@microsoft.com>
Contributor
Author
7 tasks
Contributor
|
@ZhaohuiS , we need to get this for 202205. Can you please have the submodule update for 202205? |
Contributor
Author
This was referenced Sep 4, 2022
Contributor
Author
@prsunny I submitted in sonic-net/sonic-buildimage#11962 for 202205 branch. Please review, thanks. |
ZhaohuiS
added a commit
to sonic-net/sonic-buildimage
that referenced
this pull request
Sep 5, 2022
For the Restapi/gnmi use-cases, Sonic has to support a new Table: EXTERNAL_CLIENT of type CTRLPLANE, stage ingress This shall match on 'src ip prefix' and dst port '8080'. Caclmgrd must parse this from acl.json and install as in the below example: iptables -A INPUT -s 20.20.20.20/27 -p tcp --dport 8080 -j ACCEPT or ip6tables if the 'src ip prefix' is IPv6. This change for master branch is in PR sonic-net/sonic-host-services#9 Signed-off-by: Zhaohui Sun <zhaohuisun@microsoft.com>
ZhaohuiS
added a commit
that referenced
this pull request
Sep 8, 2022
…_warning_log In #9 , I added a new EXTERNAL_CLIENT table for supporting Restapi/gnmi control plane acls. But if dest port is not defined, it will print traceback in syslog. Avoiding this scenario, we add a default empty list for dst_ports and print a warning log and skip processing EXTERNAL_CLIENT table. Signed-off-by: Zhaohui Sun zhaohuisun@microsoft.com
ZhaohuiS
added a commit
to sonic-net/sonic-buildimage
that referenced
this pull request
Sep 8, 2022
For the Restapi/gnmi use-cases, Sonic has to support a new Table: EXTERNAL_CLIENT of type CTRLPLANE, stage ingress This shall match on 'src ip prefix' and dst port '8080'. Caclmgrd must parse this from acl.json and install as in the below example: iptables -A INPUT -s 20.20.20.20/27 -p tcp --dport 8080 -j ACCEPT or ip6tables if the 'src ip prefix' is IPv6. This change for master branch is in PR sonic-net/sonic-host-services#9 Signed-off-by: Zhaohui Sun <zhaohuisun@microsoft.com>
ganglyu
pushed a commit
that referenced
this pull request
Feb 13, 2023
For the Restapi/gnmi use-cases, Sonic has to support a new Table: EXTERNAL_CLIENT of type CTRLPLANE, stage ingress This shall match on 'src ip prefix' and dst port '8080'. Caclmgrd must parse this from acl.json and install as in the below example: iptables -A INPUT -s 20.20.20.20/27 -p tcp --dport 8080 -j ACCEPT or ip6tables if the 'src ip prefix' is IPv6. This change for master branch is in PR #9 Signed-off-by: Zhaohui Sun <zhaohuisun@microsoft.com>
8 tasks
wangxin
pushed a commit
to sonic-net/sonic-mgmt
that referenced
this pull request
Jul 11, 2024
What is the motivation for this PR? Original test_cacl only covers parts of SNMP or SSH protocol test, sonic-net/sonic-host-services#9 introduce EXTERNAL_CLIENT, we have to cover it in GCU test_cacl How did you do it? Enhance many functions to support different protocols and add a fixture cacl_protocol to test SSH, SNMP,NTP, EXTERNAL_CLIENT one by one. Also add T1 topology in mark topology list. Test steps: TC1 cacl table: 1. Test to add a new cacl table, which should expect success 2. test add duplicated cacl table, which should expect success 3. Test replace some variable in existing cacl table, which should expect success 4. Test add invalid cacl table, which should expect failure 5. Test remove non-existed cacl table, which should expect failure 6. Test remove cacl table, , which should expect success, 7. Test previous steps for SSH, SNMP,NTP, EXTERNAL_CLIENT one by one TC2 cacl rule: 1. Test to add a new cacl rule, which should expect success and iptables rules are expected 2. test add duplicated cacl rule, which should expect success and iptables rules are expected 3. Test replace some variable in existing cacl rule, which should expect success and iptables rules are expected 4. Test add cacl rule into non-existed cacl table, which should expect failure 5. Test remove cacl table which has cacl rules, which should expect failure 6. Test remove non-existed cacl rule, which should expect success, 7. Test remove ACL_RULE path, which should expect success and none of unexpected iptables rules exists 8. Test previous steps for SSH, SNMP,NTP, EXTERNAL_CLIENT one by one How did you verify/test it? collected 8 items generic_config_updater/test_cacl.py::test_cacl_tc1_acl_table_suite[SSH] PASSED [ 12%] generic_config_updater/test_cacl.py::test_cacl_tc2_acl_rule_test[SSH] PASSED [ 25%] generic_config_updater/test_cacl.py::test_cacl_tc1_acl_table_suite[NTP] PASSED [ 37%] generic_config_updater/test_cacl.py::test_cacl_tc2_acl_rule_test[NTP] PASSED [ 50%] generic_config_updater/test_cacl.py::test_cacl_tc1_acl_table_suite[SNMP] PASSED [ 62%] generic_config_updater/test_cacl.py::test_cacl_tc2_acl_rule_test[SNMP] PASSED [ 75%] generic_config_updater/test_cacl.py::test_cacl_tc1_acl_table_suite[EXTERNAL_CLIENT] PASSED [ 87%] generic_config_updater/test_cacl.py::test_cacl_tc2_acl_rule_test[EXTERNAL_CLIENT] PASSED [100%] ============================================================================================================ warnings summary ============================================================================================================ Any platform specific information? Run tests/generic_config_updater/test_cacl.py Signed-off-by: Zhaohui Sun <zhaohuisun@microsoft.com>
arista-hpandya
pushed a commit
to arista-hpandya/sonic-mgmt
that referenced
this pull request
Oct 2, 2024
What is the motivation for this PR? Original test_cacl only covers parts of SNMP or SSH protocol test, sonic-net/sonic-host-services#9 introduce EXTERNAL_CLIENT, we have to cover it in GCU test_cacl How did you do it? Enhance many functions to support different protocols and add a fixture cacl_protocol to test SSH, SNMP,NTP, EXTERNAL_CLIENT one by one. Also add T1 topology in mark topology list. Test steps: TC1 cacl table: 1. Test to add a new cacl table, which should expect success 2. test add duplicated cacl table, which should expect success 3. Test replace some variable in existing cacl table, which should expect success 4. Test add invalid cacl table, which should expect failure 5. Test remove non-existed cacl table, which should expect failure 6. Test remove cacl table, , which should expect success, 7. Test previous steps for SSH, SNMP,NTP, EXTERNAL_CLIENT one by one TC2 cacl rule: 1. Test to add a new cacl rule, which should expect success and iptables rules are expected 2. test add duplicated cacl rule, which should expect success and iptables rules are expected 3. Test replace some variable in existing cacl rule, which should expect success and iptables rules are expected 4. Test add cacl rule into non-existed cacl table, which should expect failure 5. Test remove cacl table which has cacl rules, which should expect failure 6. Test remove non-existed cacl rule, which should expect success, 7. Test remove ACL_RULE path, which should expect success and none of unexpected iptables rules exists 8. Test previous steps for SSH, SNMP,NTP, EXTERNAL_CLIENT one by one How did you verify/test it? collected 8 items generic_config_updater/test_cacl.py::test_cacl_tc1_acl_table_suite[SSH] PASSED [ 12%] generic_config_updater/test_cacl.py::test_cacl_tc2_acl_rule_test[SSH] PASSED [ 25%] generic_config_updater/test_cacl.py::test_cacl_tc1_acl_table_suite[NTP] PASSED [ 37%] generic_config_updater/test_cacl.py::test_cacl_tc2_acl_rule_test[NTP] PASSED [ 50%] generic_config_updater/test_cacl.py::test_cacl_tc1_acl_table_suite[SNMP] PASSED [ 62%] generic_config_updater/test_cacl.py::test_cacl_tc2_acl_rule_test[SNMP] PASSED [ 75%] generic_config_updater/test_cacl.py::test_cacl_tc1_acl_table_suite[EXTERNAL_CLIENT] PASSED [ 87%] generic_config_updater/test_cacl.py::test_cacl_tc2_acl_rule_test[EXTERNAL_CLIENT] PASSED [100%] ============================================================================================================ warnings summary ============================================================================================================ Any platform specific information? Run tests/generic_config_updater/test_cacl.py Signed-off-by: Zhaohui Sun <zhaohuisun@microsoft.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently Sonic supports the following ACL tables.
IPV6_SNMP_ACL
EVERFLOW
SSH_ONLY
..
For the Restapi/gnmi use-cases, Sonic has to support a new Table: EXTERNAL_CLIENT of type CTRLPLANE, stage ingress
This shall match on 'src ip prefix' and dst port '8080'. Caclmgrd must parse this from acl.json and install as in the below example:
iptables -A INPUT -s 20.20.20.20/27 -p tcp --dport 8080 -j ACCEPT
or ip6tables if the 'src ip prefix' is IPv6.
Steps:
acl-loader update full external_acl.jsonexternal_acl.json looks like this:
IPv4:
IPv6:
IPv4:
IPv6:
Signed-off-by: Zhaohui Sun zhaohuisun@microsoft.com