[openstack-dev] [Neutron] netaddr and abbreviated CIDR format

Sean M. Collins sean at coreitpro.com
Fri Aug 21 18:34:41 UTC 2015


[Resending - since I don't think my mail client actually sent this the
first time]


While reviewing https://review.openstack.org/#/c/204459/ - I noticed
that one of the unit tests is passing an IP address "1/32" - so I went
and looked up the constructor for netaddr.IPNetwork, which has a feature that 
expands a string into a prefix.

http://pythonhosted.org//netaddr/api.html?highlight=abbreviated%20cidr#ip-networks-and-subnets

Putting it into my REPL:

http://paste.openstack.org/show/421041/


So - is this an actual IP address? I could be horribly wrong, but it
doesn't look like one to me - especially since built in tools like ping
don't appear to like it.

scollins at Sean-Collins-MBPr15 ~ » ping 1/32
ping: cannot resolve 1/32: Unknown host

Although, ping has it's own interesting behavior.

scollins at Sean-Collins-MBPr15 ~ » ping 1                                                         68 ↵
PING 1 (0.0.0.1): 56 data bytes
ping: sendto: No route to host
ping: sendto: No route to host
Request timeout for icmp_seq 0
^C
--- 1 ping statistics ---
2 packets transmitted, 0 packets received, 100.0% packet loss
scollins at Sean-Collins-MBPr15 ~ » ping 60                                                         2 ↵
PING 60 (0.0.0.60): 56 data bytes
ping: sendto: No route to host
ping: sendto: No route to host
Request timeout for icmp_seq 0
^C
--- 60 ping statistics ---
2 packets transmitted, 0 packets received, 100.0% packet loss


Oh, also spelunking through the code of Netaddr, it looks like this
option is going to be deprecated?

https://github.com/drkjam/netaddr/blob/bfba0b80c2e88b6e00ca7a870998b630d7c29734/netaddr/ip/__init__.py#L776

Which calls into:

https://github.com/drkjam/netaddr/blob/bfba0b80c2e88b6e00ca7a870998b630d7c29734/netaddr/ip/__init__.py#L1438

So - the tl;dr is that I don't think that we should accept inputs like
the following:

x       -> 192
x/y     -> 10/8
x.x/y   -> 192.168/16
x.x.x/y -> 192.168.0/24

which are equivalent to::

x.0.0.0/y   -> 192.0.0.0/24
x.0.0.0/y   -> 10.0.0.0/8
x.x.0.0/y   -> 192.168.0.0/16
x.x.x.0/y   -> 192.168.0.0/24

-- 
Sean M. Collins



More information about the OpenStack-dev mailing list