Skip to content

Generic prefix sets (used in ACL src/dst prefix) - #3831

Open
ipspace wants to merge 3 commits into
devfrom
prefixset
Open

Generic prefix sets (used in ACL src/dst prefix)#3831
ipspace wants to merge 3 commits into
devfrom
prefixset

Conversation

@ipspace

@ipspace ipspace commented Aug 26, 2026

Copy link
Copy Markdown
Owner

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

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
@ipspace
ipspace requested review from DanPartelly and a lite review from Copilot August 26, 2026 16:51
@ipspace ipspace linked an issue Aug 26, 2026 that may be closed by this pull request
@ipspace

ipspace commented Aug 26, 2026

Copy link
Copy Markdown
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 ;)

This comment was marked as resolved.

* 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

Copilot AI left a comment

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.

🟡 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 thread netsim/data/types.py
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)
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.

Additional ACL prefix-generating attributes

2 participants