Conversation
Based on the ideas discussed in #3810, this PR adds a new data type: generic prefix. It can be an IPv4/IPv6 address/prefix, or a named prefix, vlan prefix, address pool, link prefix, or a set of prefixes from links with specified role (I'm pretty sure we'll get further ideas ;). It's currently used in ACLs, but could be integrated into prefix lists and static routes. The PR includes: * A new type validator and corresponding coverage test * The 'eval_prefixset' code that transforms a named prefix into a list of ipv4/ipv6 addresses * Updated documentation end-user and developer documentation
Owner
Author
|
@DanPartelly -- this is the best I could do to implement #3810 without breaking existing functionality. In the end, I think it's not too shabby ;) |
* Sync validation/evaluation/documented namespaces * Do prefixset evalution through a lookup table (enabling potential customization/expansion) * Add prefixset debugging * Add a coverage test for the prefixset functionality
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
There are confirmed correctness/usability issues in the new prefixset expansion/validation logic that can lead to runtime errors and misleading validation messages.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 7/11 changed files
- Comments generated: 2
- Review effort level: Lite
Comment on lines
+17
to
+21
| if 'prefix' not in link: | ||
| continue | ||
| for af in log.AF_LIST: | ||
| if af in link.prefix: | ||
| append_to_list(result,af,link.prefix[af]) |
Comment on lines
+1113
to
+1134
| dotcount = value.count('.') | ||
| if dotcount <= 1 and ':' not in value: | ||
| if not dotcount: | ||
| p_value = value | ||
| p_type = 'prefix' | ||
| else: | ||
| (p_type,p_value) = value.split('.',1) | ||
| if p_type not in ['prefix','vlan','link','role','pool']: | ||
| result = { | ||
| '_value': 'a prefix within a valid prefix namespace', | ||
| '_more_data': f'Found {p_type} as namespace'} | ||
| else: | ||
| result = _id_validator(p_value) | ||
| if '_type' in result or '_value' in result: | ||
| result = { | ||
| '_value': 'a prefix in format namespace.identifier', | ||
| '_more_data': f'found {p_value} as identifier'} | ||
| else: | ||
| if value.count(':') > 0: | ||
| result = _ipv6_validator(value,use=use) | ||
| elif dotcount > 1: | ||
| result = _ipv4_validator(value,use=use) |
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.
Based on the ideas discussed in #3810, this PR adds a new data type: generic prefix. It can be an IPv4/IPv6 address/prefix, or a named prefix, vlan prefix, address pool, link prefix, or a set of prefixes from links with specified role (I'm pretty sure we'll get further ideas ;).
It's currently used in ACLs, but could be integrated into prefix lists and static routes.
The PR includes: