Skip to content

gh-155140: Fix ipaddress.IPv6Address.is_link_local to require the strict fe80::/64 range - #155384

Open
Sudeep-A-Kulkarni wants to merge 2 commits into
python:mainfrom
Sudeep-A-Kulkarni:patch-1
Open

gh-155140: Fix ipaddress.IPv6Address.is_link_local to require the strict fe80::/64 range#155384
Sudeep-A-Kulkarni wants to merge 2 commits into
python:mainfrom
Sudeep-A-Kulkarni:patch-1

Conversation

@Sudeep-A-Kulkarni

Copy link
Copy Markdown

Fixes gh-155140.

Bug description:

ipaddress.IPv6Address.is_link_local currently checks membership in the broad fe80::/10 block, but per RFC 4291 section 2.5.6 a true link-local address must have the first 64 bits equal to fe80:: exactly (10-bit prefix followed by 54 zero bits). This means addresses that fall inside fe80::/10 but outside fe80::/64 are incorrectly reported as link-local.

Reproducer:

import ipaddress
ipaddress.IPv6Address("fe80:6666:6666:6666:6666:6666:6666:6666").is_link_local

Current output on main: True
Expected output: False

Fix:

Change _IPv6Constants._linklocal_network from fe80::/10 to fe80::/64, matching the strict RFC 4291 definition.

Testing:

Updated the existing testReservedIpv6 assertions for fea0:: and febf:ffff:: (previously expected True, now correctly False since they fall outside fe80::/64), and added regression tests for fe80:: (still True) and the originally reported fe80:6666:... address (now False), for both ipaddress.ip_network and ipaddress.ip_address.

@bedevere-app

bedevere-app Bot commented Aug 8, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@simitana

This comment was marked as low quality.

@picnixz

picnixz commented Aug 8, 2026

Copy link
Copy Markdown
Member

@simitana Avoid low-quality review comments entirely generated by an LLM, it neither gives confidence in the comment nor does it actually help. It also restates unnecessary constraints that the OP can clearly see by looking at the CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"fe80:6666:6666:6666:6666:6666:6666:6666" is not a valid IPv6 link-local address

3 participants