Code review comment for lp:~gmb/maas/restrict-dynamic-range-to-slash-16-bug-1382190

Revision history for this message
Graham Binns (gmb) wrote :

On 30 October 2014 02:35, Julian Edwards <email address hidden> wrote:
>> + if ip_range.size > 256 ** 2:
>> + raise ValidationError(ERROR_MESSAGE_DYNAMIC_RANGE_TOO_LARGE)
>> +
>
> This check assumes that the IP values will be on exact boundaries. You could straddle more than a /16 and it won't notice, even though the IP range is under 65536 addresses.

How? I don't see the assumption. For example:

In [12]: netaddr.IPRange('10.0.0.55', '10.1.0.55').size > 256 ** 2
Out[12]: True

Am I missing something?

> I am not familiar with your GENERATE branch so I don't know if this is going to break it or not, but I'm raising the point for your consideration.

Well, if you tried to put an oversize network through it, you'll get
an AssertionError. Actually, I think that should change so that
creating the GENERATEs becomes a no-op in that case (otherwise, how do
we handle networks > /16 that people already have — say if they've
been testing with the 1.7 betas), and I'll take care of that as a
drive-by in this branch.

« Back to merge proposal