1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Closes #7252: Validate IP range size does not exceed max supported value

This commit is contained in:
jeremystretch
2021-09-28 15:44:41 -04:00
parent bfb37d6283
commit ad65e06d0a
3 changed files with 9 additions and 0 deletions

View File

@ -600,6 +600,11 @@ class IPRange(PrimaryModel):
if overlapping_range:
raise ValidationError(f"Defined addresses overlap with range {overlapping_range} in VRF {self.vrf}")
# Validate maximum size
MAX_SIZE = 2 ** 32 - 1
if int(self.end_address.ip - self.start_address.ip) + 1 > MAX_SIZE:
raise ValidationError(f"Defined range exceeds maximum supported size ({MAX_SIZE})")
def save(self, *args, **kwargs):
# Record the range's size (number of IP addresses)