Skip to content

[3.12] gh-117566: fix IPv6Address.is_loopback for IPv4-mapped loopbacks (GH-117567) - #118391

Merged
encukou merged 1 commit into
python:3.12from
miss-islington:backport-fb7f79b-3.12
Apr 29, 2024
Merged

encukou merged 1 commit into
python:3.12from
miss-islington:backport-fb7f79b-3.12

Conversation

@miss-islington

@miss-islington miss-islington commented Apr 29, 2024 •

Copy link
Copy Markdown
Contributor

While properties like IPv6Address.is_private account for IPv4-mapped
IPv6 addresses, such as for example:

>>> ipaddress.ip_address("192.168.0.1").is_private
True
>>> ipaddress.ip_address("::ffff:192.168.0.1").is_private
True

...the same doesn't currently apply to the is_loopback property:
>>> ipaddress.ip_address("127.0.0.1").is_loopback
True
>>> ipaddress.ip_address("::ffff:127.0.0.1").is_loopback
False

At minimum, this inconsistency between different properties is
counter-intuitive. Moreover, ::ffff:127.0.0.0/104 is for all intents and
purposes a loopback address, and should be treated as such.
(cherry picked from commit fb7f79b)

Co-authored-by: Faidon Liambotis paravoid@debian.org

pythonGH-117567)

While properties like IPv6Address.is_private account for IPv4-mapped
IPv6 addresses, such as for example:

    >>> ipaddress.ip_address("192.168.0.1").is_private
    True
    >>> ipaddress.ip_address("::ffff:192.168.0.1").is_private
    True
...the same doesn't currently apply to the is_loopback property:
    >>> ipaddress.ip_address("127.0.0.1").is_loopback
    True
    >>> ipaddress.ip_address("::ffff:127.0.0.1").is_loopback
    False

At minimum, this inconsistency between different properties is
counter-intuitive. Moreover, ::ffff:127.0.0.0/104 is for all intents and
purposes a loopback address, and should be treated as such.
(cherry picked from commit fb7f79b)

Co-authored-by: Faidon Liambotis <paravoid@debian.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants