python / python/cpython

ipaddress: Two more IPv6 ranges (RFC 9602, 9780) missing from _private_networks

Đang mở
#151,749 5 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

stdlib type-bug
Ngôn ngữ chính
Python
Star
77.2k
Fork
35.9k
Chỉ số merge pull request
Chỉ số pull request đang chờ

Mô tả

Bug report

Bug description:

Description

This is a peer issue to gh-151049 / PR 151050, which is addressing RFC 9665 ranges.

In this case, we similarly have the following examples return True:

  • ipaddress.ip_address('5f00::1').is_global
  • ipaddress.ip_address('100:0:0:1::1').is_global

Both blocks are registered by IANA with Globally Reachable = False.

The companion is_private returns False, so the documented-safe not ip.is_global check treats these addresses as ordinary public addresses.

IANA registration

The IANA IPv6 Special-Purpose Address Registry lists both blocks as Globally Reachable = False:

Address Block Name RFC Globally Reachable
5f00::/16 Segment Routing (SRv6) SIDs RFC 9602 False
100:0:0:1::/64 Dummy IPv6 Prefix RFC 9780 False

Registry: https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml

Both were added after the table was last revised: RFC 9602 (Segment Routing over IPv6 SIDs) registered 5f00::/16 in 2024, and RFC 9780 registered the 100:0:0:1::/64 Dummy IPv6 Prefix. Note that 100:0:0:1::/64 is disjoint from the already-listed 100::/64 (RFC 6666 Discard-Only), so the existing 100::/64 entry does not cover it.

The bug

_IPv6Constants._private_networks enumerates the not-globally-reachable blocks. It lists, among others, 100::/64, 2001:db8::/32, 2002::/16, 3fff::/20, but is missing 5f00::/16 and 100:0:0:1::/64, so addresses in those blocks fall through to globally-reachable.

This is the same class as gh-124217 (which added 3fff::/20) and the IPv4 case in bpo-42937 (the 192.0.0.8 dummy address), and the GR=False complement of the in-flight #151050 (which adds the GR=True 2001:1::3/128 to the exceptions list).

Reproduce

On current main:

>>> import ipaddress
>>> ipaddress.ip_address('5f00::1').is_global
True          # expected: False (RFC 9602, IANA GR=False)
>>> ipaddress.ip_address('5f00::1').is_private
False         # expected: True
>>> ipaddress.ip_address('100:0:0:1::1').is_global
True          # expected: False (RFC 9780, IANA GR=False)
>>> ipaddress.ip_address('100:0:0:1::1').is_private
False         # expected: True
>>> ipaddress.ip_address('3fff::1').is_global      # already-fixed sibling, correct
False
>>> ipaddress.ip_address('100::1').is_global       # adjacent in-table block, correct
False
Fix

Add the two blocks to _IPv6Constants._private_networks, with RFC reference comments, e.g.:

        IPv6Network('5f00::/16'),       # RFC 9602 (SRv6 SIDs)
        IPv6Network('100:0:0:1::/64'),  # RFC 9780 (Dummy IPv6 Prefix)

and extend testReservedIpv6 to assert that 5f00::1 and 100:0:0:1::1 are not global and are private, and that an adjacent unregistered address (e.g. 100:0:0:2::1) stays unchanged so the carve-out is exact. A Misc/NEWS entry as usual. The exceptions framework and the related entries landed in GH-113179 (first shipped in 3.13), so this applies to 3.13+.

CPython versions tested on:

3.15, CPython main branch

Operating systems tested on:

Linux

Linked PRs
  • gh-151764

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu tại _IPv6Constants._private_networks và bài kiểm thử testReservedIpv6 được nêu trong báo cáo, sau đó xem xét PR được liên kết gh-151764 để xác định trạng thái triển khai hiện tại. Công việc được coi là hoàn tất khi hai phạm vi được liệt kê trong RFC có độ bao phủ, phạm vi chưa đăng ký liền kề vẫn không thay đổi và mục Misc/NEWS thông thường được thêm vào.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
networking
Loại issue
Lỗi
Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
30/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.