Skip to content

Commit ad65e06

Browse files
committed
Closes #7252: Validate IP range size does not exceed max supported value
1 parent bfb37d6 commit ad65e06

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

docs/models/ipam/iprange.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ IP also ranges share the same functional roles as prefixes and VLANs, although t
99
* Deprecated - No longer in use
1010

1111
The status of a range does _not_ have any impact on its member IP addresses, which may have their statuses modified separately.
12+
13+
!!! note
14+
The maximum supported size of an IP range is 2^32 - 1.

docs/release-notes/version-3.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
### Bug Fixes
1515

16+
* [#7252](https://github.com/netbox-community/netbox/issues/7252) - Validate IP range size does not exceed max supported value
1617
* [#7294](https://github.com/netbox-community/netbox/issues/7294) - Fix SVG rendering for cable traces ending at unoccupied front ports
1718
* [#7304](https://github.com/netbox-community/netbox/issues/7304) - Require explicit values for all required choice fields during CSV import
1819
* [#7321](https://github.com/netbox-community/netbox/issues/7321) - Don't overwrite multi-select custom fields during bulk edit

netbox/ipam/models/ip.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,11 @@ def clean(self):
600600
if overlapping_range:
601601
raise ValidationError(f"Defined addresses overlap with range {overlapping_range} in VRF {self.vrf}")
602602

603+
# Validate maximum size
604+
MAX_SIZE = 2 ** 32 - 1
605+
if int(self.end_address.ip - self.start_address.ip) + 1 > MAX_SIZE:
606+
raise ValidationError(f"Defined range exceeds maximum supported size ({MAX_SIZE})")
607+
603608
def save(self, *args, **kwargs):
604609

605610
# Record the range's size (number of IP addresses)

0 commit comments

Comments
 (0)