Skip to content

[base] Fix hierarchical duplicate IP validation #116#202

Open
Stoiicc wants to merge 1 commit intoopenwisp:masterfrom
Stoiicc:issues/116-ip-hierarchy-validation
Open

[base] Fix hierarchical duplicate IP validation #116#202
Stoiicc wants to merge 1 commit intoopenwisp:masterfrom
Stoiicc:issues/116-ip-hierarchy-validation

Conversation

@Stoiicc
Copy link
Copy Markdown

@Stoiicc Stoiicc commented Dec 9, 2025

Checklist

  • I have read the OpenWISP Contributing Guidelines.
  • I have manually tested the changes proposed in this pull request.
  • I have written new test cases for new code and/or updated existing tests for changes to existing code.
  • I have updated the documentation.

Reference to Existing Issue

Closes #116 .

Description of Changes

Previously, AbstractIpAddress.clean() only checked for duplicate IP addresses within the same subnet.
As discussed in issue #116, this allows invalid configurations where:

An IP exists in a child subnet, and
The same IP is created again in a parent subnet.

This PR introduces hierarchical subnet duplicate detection by:

  1. Identifying all related subnets

  2. A subnet is considered related if its network contains the IP being validated.
    This includes:

  • Parent subnets
  • Child subnets
  • Overlapping subnets
  • The subnet itself
  1. Validating duplicates across all related subnets

If the same IP exists in any related subnet, a ValidationError is raised.

Updates AbstractIpAddress.clean() to check for duplicate IP
addresses not only within the same subnet but also across any
subnet that contains the IP (parent, or child).

Added a corresponding test to ensure a ValidationError is raised
when an  IP exists in any related subnet.

Fixes openwisp#116
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.

[bug] IP Validation does not consider heirachical subnets

1 participant