Skip to content

Add protocol number support for security group rules#3736

Merged
andrijapanicsb merged 1 commit into
apache:masterfrom
ravening:feature_protocol_number_support
Jan 8, 2020
Merged

Add protocol number support for security group rules#3736
andrijapanicsb merged 1 commit into
apache:masterfrom
ravening:feature_protocol_number_support

Conversation

@ravening

@ravening ravening commented Dec 3, 2019

Copy link
Copy Markdown
Member

Description

Currently while creating ingress/egress rule for a security group,
we can specify only TCP/UDP/ICMP. Sometimes we need to add rules
for different protocol numbers or rules for all the above three
mentioned protocols.

In this new feature, users can specify the protocol number or select
"ALL" option which will apply rules for TCP/UDP/ICMP in one shot

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)

Screenshots (if appropriate):

Navigate to "Networks" and select "Security groups" from the drop-down menu on the top left
Select any security group name and click on either "ingress" or "egress" tab

Screenshot 2019-12-03 at 09 44 05

Screenshot 2019-12-03 at 09 45 11

Screenshot 2019-12-03 at 09 45 44

How Has This Been Tested?

Adding a rule for a particular protocol number

  1. Create a VM and note down the security group name to which it belongs to
  2. Navigate to "Network" and select "Security groups" from the drop-down menu on the top left.
  3. Select the security group which is obtained from step 1.
  4. Click on either ingress or egress tab
  5. Try to create a new rule by selecting "Protocol number" from the drop-down list.
    For ex: Enter protocol number as 47 and cidr as "99.99.99.99/32"

Screenshot 2019-12-03 at 10 12 57

  1. Now get the hostname on which the VM is running and ssh to it.
  2. Run the iptables-save command to ensure that there is a new rule for the protocol number you mentioned above.
    The output should be as shown below
# iptables-save | grep 99.99.99
-A i-2-118-VM -s 99.99.99.99/32 -p gre -j ACCEPT

Adding a rule to all TCP/UDP/ICMP at a time

  1. Create a VM and note down the security group name to which it belongs to
  2. By default, there will be a drop action for the three protocols.
  3. Navigate to "Network" and select "Security groups" from the drop-down menu on the top left.
  4. Select the security group which is obtained from step 1.
  5. Click on either ingress or egress tab
  6. Try to create a new rule by selecting "ALL" from the drop-down list.

Screenshot 2019-12-03 at 10 17 06

  1. Now get the hostname on which the VM is running and ssh to it.
  2. Run the iptables-save command to ensure that the below rule should be applied.
# iptables-save | grep i-2-118-VM
-A i-2-118-VM -s 88.88.88.88/32 -m state --state NEW -j ACCEPT

New integration test has been added in test/integration/component/test_protocol_number_security_group.py

Integration test can be run using

nosetests --with-marvin --marvin-config=<config file> test/integration/component/test_protocol_number_security_group.py

Currently while creating ingress/egress rule for a security group,
we can specify only TCP/UDP/ICMP. Sometimes we need to add rules
for different protocol number or rules for all the above three
mentioned protocols.

In this new feature users can specify the protocol number or select
"ALL" option which will apply rules for TCP/UDP/ICMP

@weizhouapache weizhouapache left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I have reviewed all changes, and tested it manually.
The integration test works fine as well.

else:
dport = " --dport " + str(start) + ":" + str(end)

if protocol != 'all' and protocol != 'icmp' and protocol != 'tcp' and protocol != 'udp':

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.

For ip6tables it's not 'icmp' which is used for the protocol, it's icmpv6, so don't we need to add a check there?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

In the UI, we only have options for "TCP", "UDP", "ICMP" and "ALL". There is no option for "ICMPv6" in UI. Once this is added in ui, we can have that check here as well.

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.

@rakgenius I'm aware, but underneath we translate ICMP to ICMPv6 when the CIDR/IP is an IPv6 adress. That's what we need to check.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@wido the protocol is "icmp" in cloudstack, no matter the ip/cidr is ipv4 or ipv6.

look at the code below
https://github.com/apache/cloudstack/pull/3736/files/c27fdfee8c9f5ab06cf18dd6dc41ba356d75f4c4#diff-d10df45583c471e8de4a64128f95c802R1066-R1070

@ravening

Copy link
Copy Markdown
Member Author

@wido @rhtyd @GabrielBrascher guys, can you review this when you get time?

@weizhouapache

Copy link
Copy Markdown
Member

@DaanHoogland this PR has two approvals. could you kick off a trillian test ?

@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@DaanHoogland a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result: ✖centos6 ✔centos7 ✔debian. JID-543

@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@DaanHoogland a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@blueorangutan

Copy link
Copy Markdown

Trillian test result (tid-713)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 29736 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr3736-t713-kvm-centos7.zip
Intermittent failure detected: /marvin/tests/smoke/test_routers_network_ops.py
Intermittent failure detected: /marvin/tests/smoke/test_host_maintenance.py
Intermittent failure detected: /marvin/tests/smoke/test_hostha_kvm.py
Smoke tests completed. 77 look OK, 0 have error(s)
Only failed tests results shown below:

Test Result Time (s) Test File

@andrijapanicsb
andrijapanicsb merged commit dfd950c into apache:master Jan 8, 2020
ustcweizhou pushed a commit to ustcweizhou/cloudstack that referenced this pull request Feb 28, 2020
Currently while creating ingress/egress rule for a security group,
we can specify only TCP/UDP/ICMP. Sometimes we need to add rules
for different protocol number or rules for all the above three
mentioned protocols.

In this new feature users can specify the protocol number or select
"ALL" option which will apply rules for TCP/UDP/ICMP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants