Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

To fix ios_l3_interfaces resource module round trip failure backport for PR 61642 #62399

Merged
merged 2 commits into from Sep 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,3 @@
---
bugfixes:
- "To fix ios_l3_interfaces resource module round trip failure(https://github.com/ansible/ansible/pull/61642)"
2 changes: 2 additions & 0 deletions lib/ansible/module_utils/network/ios/utils/utils.py
Expand Up @@ -138,6 +138,8 @@ def validate_ipv6(value, module):
def validate_n_expand_ipv4(module, want):
# Check if input IPV4 is valid IP and expand IPV4 with its subnet mask
ip_addr_want = want.get('address')
if len(ip_addr_want.split(' ')) > 1:
return ip_addr_want
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I can merge this as it does fix the error being generated.... it seems like this opens up a different problem, though. This function documents that it will take an IPv4 address and subnet mask, validate it, and expand it. This is skipping the validation step so things like this could now be accepted, causing issues in other code: want = "127.0.0.1/21 1.0.0.0" or even want = "127 elephants party!"

It seems like this branch of the code should split on space, then validate that:

  • There are only two fields
  • The first field is a valid ipv4 address
  • The second field is a valid netmask
  • Then return ip_addr_want as you're doing now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Talked with @justjais on slack. He'll make these changes in a separate PR and backport that as well. I'll merge this for now to fix the error.

validate_ipv4(ip_addr_want, module)
ip = ip_addr_want.split('/')
if len(ip) == 2:
Expand Down