Skip to content

[Bug]: IPv4-mapped IPv6 addresses lose their mapped identity #28216

Closed

Description

@Ariznawlll

Is there an existing issue for the same bug?

  • I have checked the existing issues.

The old implementation requests #23038 and #23044 are closed. No open issue covers loss of the IPv4-mapped IPv6 identity.

Branch Name

main

Commit ID

e7bb0572235ec4bac81eb098eb0ad8900f0065ab

Other Environment Information

  • Local standalone MatrixOne; reference MySQL 8.3.0

Actual Behavior

IPv4-mapped IPv6 addresses are collapsed into four-byte IPv4 values and lose their mapped identity across multiple functions:

SELECT HEX(INET6_ATON('::ffff:192.168.1.1'));
-- MatrixOne: C0A80101
-- MySQL:    00000000000000000000FFFFC0A80101

SELECT INET6_NTOA(UNHEX('00000000000000000000FFFFC0A80101'));
-- MatrixOne: 192.168.1.1
-- MySQL:    ::ffff:192.168.1.1

SELECT IS_IPV6('::ffff:192.168.1.1'),
       IS_IPV4_MAPPED(INET6_ATON('::ffff:192.168.1.1'));
-- MatrixOne: 0, 0
-- MySQL:    1, 1

IS_IPV4_MAPPED() itself returns 1 for an explicit 16-byte mapped value, proving that INET6_ATON() loses the prefix before classification. Constants and column values reproduce identically in three runs.

Expected Behavior

An IPv4-mapped IPv6 address must remain a 16-byte IPv6 value through parsing and formatting. IS_IPV6() and IS_IPV4_MAPPED() must classify it as IPv6 and mapped respectively.

Steps to Reproduce

SELECT HEX(INET6_ATON('::ffff:192.168.1.1'));
SELECT INET6_NTOA(UNHEX('00000000000000000000FFFFC0A80101'));
SELECT IS_IPV6('::ffff:192.168.1.1');
SELECT IS_IPV4_MAPPED(INET6_ATON('::ffff:192.168.1.1'));

Additional information

INET6_ATON calls ip.To4() and returns the four-byte result for mapped IPv6 input. INET6_NTOA explicitly formats mapped 16-byte input through ip4.String(). IS_IPV6 rejects every parsed address whose To4() is non-nil.

Activity

  1. added this to the MO-202609 milestone on Sep 5, 2026
  2. added
    kind/bug
    on Sep 5, 2026
  3. added theissue type on Sep 5, 2026
  4. self-assigned this
    on Sep 5, 2026
  5. Ariznawlll commented on Sep 8, 2026

    @Ariznawlll
    CollaboratorAuthor

    在最新 main f72ca9efbeb3a7c673701e4a135cc6670c33cfde 上重新覆盖了 IPv4-mapped IPv6 的常量、列值和函数组合,三轮行为一致:

    SELECT IS_IPV6('::ffff:192.0.2.1');
    -- MatrixOne: 0; MySQL 8.3: 1
    
    SELECT HEX(INET6_ATON('::ffff:192.0.2.1'));
    -- MatrixOne: C0000201
    -- MySQL 8.3: 00000000000000000000FFFFC0000201
    
    SELECT INET6_NTOA(UNHEX('00000000000000000000FFFFC0000201'));
    -- MatrixOne: 192.0.2.1
    -- MySQL 8.3: ::ffff:192.0.2.1

    显式 16 字节输入上的 IS_IPV4_MAPPED(...) 仍正确返回 1,普通 4 字节 IPv4、普通 16 字节 IPv6、IPv4-compatible IPv6 以及非法二进制长度的控制行为也正常。问题仍是 mapped 地址在字符串解析和格式化路径中被 To4() 折叠,未扩展到 mapped 前缀判定本身。

  6. Ariznawlll commented on Sep 12, 2026

    @Ariznawlll
    CollaboratorAuthor

    在当前 main 6875e4203519de1ed98b842c1cbc8c57f11dc326 上补充覆盖了 IPv4-mapped IPv6 的 PreparedStatement、两 CN、列值、View 和 CTAS 路径,三轮结果一致。

    SELECT HEX(INET6_ATON('::ffff:192.0.2.1')),
           INET6_NTOA(INET6_ATON('::ffff:192.0.2.1')),
           IS_IPV4_MAPPED(INET6_ATON('::ffff:192.0.2.1'));
    -- MatrixOne: C0000201, 192.0.2.1, 0
    -- MySQL 8.3: 00000000000000000000FFFFC0000201, ::ffff:192.0.2.1, 1

    同一映射地址的展开写法 0:0:0:0:0:ffff:192.0.2.1 也被折叠为相同的 4 字节值。普通 IPv4、IPv4-compatible IPv6(::192.0.2.1)和普通 IPv6 控制值保持各自预期的 4/16 字节表示。

    该折叠会继续传播到 View 和 CTAS 的结果列,使映射地址无法被 IS_IPV4_MAPPED(INET6_ATON(ip_text)) = 1 筛选出来;MySQL 该筛选命中 mapped 行,而 MatrixOne 没有命中。

  7. XuPeng-SH commented on Sep 12, 2026

    @XuPeng-SH
    Contributor

    PR #28800 preserves IPv4-mapped IPv6 values as 16-byte addresses through INET6_ATON, formats them with the ::ffff: prefix, and aligns IPv4/IPv6 classification with the address identity. Scalar, vector, and generated-column expectations are covered. The PR is open; local UT/BVT were not run because the isolated worktree lacks provenance-validated CGo artifacts, and exact-head CI is still running.

  8. added a commit that references this issue on Sep 15, 2026
    f0f61f0
  9. Ariznawlll commented on Sep 15, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

    • MatrixOne main:0c3a04f390adaf6281fd592a49778ea5b1155e67
    • 本地 standalone(1 CN / 1 TN / 1 LogService),2026-09-15。

    原问题验证

    IPv4-mapped IPv6 在 INET6_ATON/INET6_NTOA 往返后仍保留 ::ffff: mapped 语义。

    Happy Path 覆盖

    覆盖 ::ffff:192.168.1.1 二进制转换、文本往返与 mapped 分类。

    Unhappy Path 覆盖

    与 IPv4-compatible、普通 IPv6 路径对照,确认不发生类别混淆。

    白盒验证

    不适用:由公开 SQL 函数的往返结果覆盖。

    回归测试

    已加入 MOTR:issue_28214_28217_ipv4_semantics,见 motr#176。

    测试证据

    新 MOTR 用例连续运行 3 轮成功,mapped 地址输出与分类稳定正确。

    测试结论

    测试通过。

  10. added 3 commits that reference this issue on Sep 17, 2026
    110e659
    0f3d83f
    5119681
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/compatibilitykind/bug

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions