puppetlabs/puppetlabs-firewall — pull request #80 by dcarley (2012-05-28 07:54:14+00:00)
Title: (#10274) Nullify addresses with zero prefixlen

Modify the behaviour of Util::Firewall.host_to_ip, as used by the type to
parse source and destination addresses, to return nil if the resulting CIDR
represented address has a prefix length of zero. Includes type and provider
tests for IPv4 and IPv6.

IPtables silently omits rules with source and destination addresses that
have a prefix length of zero (eg. 0.0.0.0/0) because they are functionally
equivialent to not specifying any address. This was causing rules to be
unecessarily reloaded.

The behaviour of Util::IPcidr remains the same. Now includes some additional
tests for it's identification of zero prefixlen IPv4 and IPv6 addresses.

--

This is a rework of @nanliu's private branch which we didn't have a PR for. I've moved the logic up from the type to `Firewall.host_to_ip` so that:

1. More DRY.
1. We retain the ability to resolve hostnames.
1. We have access to `IPCidr.cidr` to properly identify the prefixlen.