Skip to content

security_group.py: check cidr unstrictly to accept cidrs like 1.1.1.1/24#3701

Merged
yadvr merged 1 commit into
apache:masterfrom
ustcweizhou:4.14.0-sg-check-cidr-unstrictly
Nov 21, 2019
Merged

security_group.py: check cidr unstrictly to accept cidrs like 1.1.1.1/24#3701
yadvr merged 1 commit into
apache:masterfrom
ustcweizhou:4.14.0-sg-check-cidr-unstrictly

Conversation

@ustcweizhou
Copy link
Copy Markdown
Contributor

Description

When I add a security group rule with cidr like 1.1.1.1/24, the rule is not applied on kvm hypervisor.
Ths issue does not exist in 4.13.0.0 and previous versions.

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):

How Has This Been Tested?

It has been tested in advanced zone with security group.
It can be verified very easily in python3, see results below.

# python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

>>> import ipaddress
>>> ipaddress.ip_network("1.1.1.1/28")
IPv4Network('1.1.1.1/28')

>>> ipaddress.ip_network("1.1.1.1/24")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.6/ipaddress.py", line 74, in ip_network
    return IPv4Network(address, strict)
  File "/usr/lib/python3.6/ipaddress.py", line 1519, in __init__
    raise ValueError('%s has host bits set' % self)
ValueError: 1.1.1.1/24 has host bits set

>>> ipaddress.ip_network("1.1.1.1/24", False)
IPv4Network('1.1.1.0/24')

Copy link
Copy Markdown
Contributor

@wido wido left a comment

Choose a reason for hiding this comment

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

I understand where this comes from.

LGTM

@yadvr yadvr added this to the 4.14.0.0 milestone Nov 21, 2019
Copy link
Copy Markdown
Member

@yadvr yadvr left a comment

Choose a reason for hiding this comment

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

Works on Python3 - however, have we made packaging changes in both debian and centos7 packaging to ensure python3 is installed?

@wido
Copy link
Copy Markdown
Contributor

wido commented Nov 21, 2019

@rhtyd Yes, we have that in the RPM/DEB dependencies.

Python 3 is however also present by default on both CentOS and Ubuntu.

Copy link
Copy Markdown
Member

@GabrielBrascher GabrielBrascher left a comment

Choose a reason for hiding this comment

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

LGTM

@yadvr
Copy link
Copy Markdown
Member

yadvr commented Nov 21, 2019

Manually tested against python3, BO doesn't run test against SG env so I'll merge this based on reviews and manual testing.

@yadvr yadvr merged commit 24db4d8 into apache:master Nov 21, 2019
ustcweizhou added a commit to ustcweizhou/cloudstack that referenced this pull request Feb 28, 2020
…/24 (apache#3701)

When I add a security group rule with cidr like 1.1.1.1/24, the rule is not applied on kvm hypervisor.
Ths issue does not exist in 4.13.0.0 and previous versions.
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.

4 participants