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

[BUG] We need 'pure_address' use type for IP address validation #1831

Open
ipspace opened this issue Jan 24, 2025 · 4 comments
Open

[BUG] We need 'pure_address' use type for IP address validation #1831

ipspace opened this issue Jan 24, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@ipspace
Copy link
Owner

ipspace commented Jan 24, 2025

Next hops in static routes are another example of IP addresses that cannot be prefixes and cannot take int or bool values. Looks like we have to differentiate between 'subnet_address' (which can be int or bool) and 'address' (which must be a string but without the prefix length).

I will try to change all current validation definitions to use 'subnet_address', and use 'address' for real IP addresses. This seems cleaner than inventing another 'really_an_address' keyword.

@ipspace ipspace added the bug Something isn't working label Jan 24, 2025
@jbemmel
Copy link
Collaborator

jbemmel commented Jan 26, 2025

We could follow ipaddr: https://docs.ansible.com/ansible/latest/collections/ansible/utils/docsite/filters_ipaddr.html

  • address for a "pure_address"
  • host_prefix for an address with host bits set and a subnet prefix
  • subnet_prefix for an address with host bits cleared

@ddutt
Copy link
Collaborator

ddutt commented Jan 26, 2025

Why not use native python types?

@ipspace
Copy link
Owner Author

ipspace commented Jan 26, 2025

Why not use native python types?

We are using native python types (and libraries) behind the scenes, but we also have to do data structure validation, and because I didn't want to go full-YANG, I wrote my own validator.

That thing can validate (among other things) IPv4 and IPv6 addresses and prefixes, but you have to specify how you plan to use them -- prefixes can't have host bits, addresses can't have all-zero or all-one host bits. Then there's the option of having unnumbered interface addresses and specifying interface IP address as int (offset in subnet), whereas these same options are not valid for an IPv4/IPv6 address used as a next hop in a static route.

@ddutt
Copy link
Collaborator

ddutt commented Jan 26, 2025

Oh, so these are just types that you're using for validation? I missed that. I was responding to the last message in the thread. Sorry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants