aboutsummaryrefslogtreecommitdiff
path: root/lib/packets.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2012-05-22 22:49:31 -0700
committerBen Pfaff <blp@nicira.com>2012-06-12 21:19:25 -0700
commitff0b06eef1d7044df8220ccbed718a6fae55fc10 (patch)
treef83e6f68d2c89a392711b51309586e3708e6ef0a /lib/packets.c
parentc08201d6645520f384bbfee3b490b99af8f2c149 (diff)
Allow general masking of IPv6 addresses rather than just CIDR masks.
OF1.2 and later make these fields fully maskable so we might as well also. Reviewed-by: Simon Horman <horms@verge.net.au> Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'lib/packets.c')
-rw-r--r--lib/packets.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/packets.c b/lib/packets.c
index 833074cc..57291674 100644
--- a/lib/packets.c
+++ b/lib/packets.c
@@ -350,7 +350,10 @@ ipv6_create_mask(int mask)
/* Given the IPv6 netmask 'netmask', returns the number of bits of the IPv6
* address that it specifies, that is, the number of 1-bits in 'netmask'.
- * 'netmask' must be a CIDR netmask (see ipv6_is_cidr()). */
+ * 'netmask' must be a CIDR netmask (see ipv6_is_cidr()).
+ *
+ * If 'netmask' is not a CIDR netmask (see ipv6_is_cidr()), the return value
+ * will still be in the valid range but isn't otherwise meaningful. */
int
ipv6_count_cidr_bits(const struct in6_addr *netmask)
{
@@ -358,8 +361,6 @@ ipv6_count_cidr_bits(const struct in6_addr *netmask)
int count = 0;
const uint8_t *netmaskp = &netmask->s6_addr[0];
- assert(ipv6_is_cidr(netmask));
-
for (i=0; i<16; i++) {
if (netmaskp[i] == 0xff) {
count += 8;