IPv6 support

From MediaWiki.org

Jump to: navigation, search

Contents

[edit] Usage

Although the global transition to IPv6 is coming very slowly, it will be necessary to support the new IP format in the future. MediaWiki will require changes to IP.php and some of the block/checkuser code. Possible schema changes are likely to get the indexing to work well in the future.

[edit] Current code

A number of functions have been added for IPv6 support for blocks:

  • sanitizeIP() - expands IPs and set them to all-caps
  • IPv4toIPv6()
  • toOctet() - creates an IPv6 octet from an integer
  • parseCIDR6()
  • parseRange6()
  • normaliseRange6()

Additionally, there a some new validation functions which use some IPv6 validation regexps:

  • isIPAddress()
  • isIPv6()
  • isIPv4()

Some of the current functions for IPv4 now check for IPv6 IPs and return output from the correct function if an IPv6 IP is given. Additionally, they all avoid the use of native bit functions and operations due to their 32 bit limits. Using them will cause garbage or invalid output.

[edit] Normalization/storage issues

As of MW 1.11, all user and user talk page for IPv6 IPs are normalized. This is due to the fact that given user of upper/lower case, '::' usage, and other permutations, there are many different ways to represent the same IP.

For consistency, sanitizeIP() should be used when storing and checking against IPs in the database. This function expands "::" abbreviations, removes leading bloc zeroes, and sets to all caps IPv6 addresses (other addresses or strings are return as is).

However the issue of indexing and performance remains. Currently, we have:

INDEX ipb_range (ipb_range_start(8), ipb_range_end(8))

In tables.sql.

This is problematic as IPv6 addresses, when padded out, are 32 characters, rather than 8 for IPv4. The "v6-" prefix adds 3 characters too, making it 35. This partial index will likely be fine for a long time, as there are few range blocks, usually they are not permanent, and few are IPv6.

[edit] See also