Skip to content

Linux-only:UDP通配套接字进程识别失败,导致Xray TUN下Hysteria2/XHTTP(h3)测速失败,但实际上可用 #7192

Closed

Description

@Anthrop44

完整性要求

  • 我读完了 issue 模板中的所有注释,确保填写符合要求。
  • 我保证阅读了文档,了解所有我编写的配置文件项的含义,而不是大量堆砌看似有用的选项或默认值。
  • 我提供了完整的配置文件和日志,而不是出于自己的判断只给出截取的部分。
  • 我搜索了 issues, 没有发现已提出的类似问题。
  • 问题在 Release 最新的版本上可以成功复现

描述

Linux v2rayN启用新版Xray TUN(关闭Legacy TUN Protect)后,Hysteria2和XHTTP(h3)的延迟测试返回-1,下载测速被跳过,但节点本身仍可能正常使用。最初在v2rayN中发现这个问题,但让AI研究代码后它说其实应该修Xray 2dust/v2rayN#10384

[Error] app/router: Unables to find local process name: common/net: connection for <TUN_IP>:<PORT> not found in /proc/net/udp
from udp:<TUN_IP>:<PORT> accepted udp:<REMOTE_IP>:443 [tun -> block]
下面是AI的分析,我自己搞不定

检查Xray-core 26.10.17源码后,发现以下调用链:

  1. transport/internet/system_dialer.go使用ListenPacket创建未连接的UDP套接字,默认绑定0.0.0.0或::
  2. Hysteria2和XHTTP的HTTP/3拨号均使用这条路径
  3. common/net/find_process_linux.go根据数据包的源IP和源端口,精确匹配/proc/net/udp中的本地地址
  4. 对于绑定0.0.0.0:<PORT>的套接字,实际发出的包具有具体源IP,但/proc/net/udp仍记录通配绑定地址,因此精确匹配失败

在本次环境中,主TUN配置包含将Xray进程流量直连的保护规则。进程识别失败后,这部分流量未命中保护规则,随后命中了UDP/443阻断规则

这里的UDP/443阻断是后续路由结果,疑似根因是此前的进程归属查询失败

独立复现

不启动v2rayN或TUN,也可以在Linux本机复现查询缺陷:

  1. 创建绑定0.0.0.0:0的未连接UDP套接字,取得分配的端口port
  2. 保持套接字打开,调用:
FindProcess("udp", "127.0.0.1", port, "127.0.0.1", 443)

预期识别出当前进程,实际返回在/proc/net/udp中找不到连接。显式绑定127.0.0.1的IPv4对照套接字可以成功识别

这说明进程查询缺陷可以脱离v2rayN复现,而相关查询代码也是Linux平台专用实现

补充验证与边界

对同一个XHTTP(h3)节点进行对照测试:临时测速内核未绑定出口网卡时,延迟返回-1;显式绑定实际出口网卡后,延迟为125–185ms,限量下载也得到有效速度。这与测速内核流量进入TUN后未能获得进程保护的解释一致,但单凭绑定网卡的结果不能完全证明根因

请确认Linux UDP进程查询对通配绑定套接字的处理是否正确,以及这一缺陷是否可以解释上述TUN测速现象

English ver

After enabling the new Xray TUN in Linux v2rayN (with Legacy TUN Protect disabled), latency tests for Hysteria2 and XHTTP (h3) return -1, download speed tests are skipped, but the node itself may still work normally. This issue was initially found in v2rayN, but after having AI study the code, it said fixing it in Xray would be more correct 2dust/v2rayN#10384

[Error] app/router: Unables to find local process name: common/net: connection for <TUN_IP>:<PORT> not found in /proc/net/udp
from udp:<TUN_IP>:<PORT> accepted udp:<REMOTE_IP>:443 [tun -> block]

After checking the Xray-core 26.10.17 source code, I found the following call chain:

  1. transport/internet/system_dialer.go uses ListenPacket to create an unconnected UDP socket, which binds to 0.0.0.0 or :: by default.
  2. Both Hysteria2 and XHTTP's HTTP/3 dialing use this path.
  3. common/net/find_process_linux.go exactly matches the local address in /proc/net/udp based on the packet's source IP and source port.
  4. For a socket bound to 0.0.0.0:<PORT>, the actual outgoing packet has a concrete source IP, but /proc/net/udp still records the wildcard bind address, so the exact match fails.

In this environment, the main TUN configuration includes a protection rule that routes Xray process traffic directly. After process identification fails, this traffic does not hit the protection rule and subsequently hits the UDP/443 block rule.

The UDP/443 block here is a downstream routing result; the suspected root cause is the preceding process ownership lookup failure.

Independent reproduction

The lookup defect can also be reproduced locally on Linux without starting v2rayN or TUN:

  1. Create an unconnected UDP socket bound to 0.0.0.0:0 and obtain the assigned port port.
  2. Keep the socket open and call:
FindProcess("udp", "127.0.0.1", port, "127.0.0.1", 443)

It is expected to identify the current process, but it actually returns that no connection is found in /proc/net/udp. An IPv4 control socket explicitly bound to 127.0.0.1 can be identified successfully.

This shows that the process lookup defect can be reproduced independently of v2rayN, and the relevant lookup code is also a Linux-specific implementation.

Supplementary verification and boundaries

A control test was performed on the same XHTTP (h3) node: when the temporary speed-test core was not bound to the egress NIC, latency returned -1; after explicitly binding it to the actual egress NIC, latency was 125–185 ms, and the limited download also achieved a valid speed. This is consistent with the explanation that the speed-test core's traffic enters the TUN and fails to obtain process protection, but the NIC-binding result alone cannot fully prove the root cause.

Please confirm whether Linux UDP process lookup handles wildcard-bound sockets correctly, and whether this defect can explain the above TUN speed-test phenomenon.

重现方式

在任意Linux操作系统里,对一个hysteria2或xhttp alpn=h3节点在v2rayN中点一下测速

客户端配置

Details ```jsonc Xray client speed-test configuration (XHTTP over h3) All node credentials, server names, addresses, and custom path values are anonymized placeholders.

{
"log": {
"access": "/home/user/.local/share/v2rayN/guiLogs/Vaccess_2026-10-18.txt",
"error": "/home/user/.local/share/v2rayN/guiLogs/Verror_2026-10-18.txt",
"loglevel": "warning"
},
"inbounds": [
{
"tag": "socks10829",
"port": 10829,
"listen": "127.0.0.1",
"protocol": "mixed",
"settings": {
"auth": "noauth",
"udp": true
}
}
],
"outbounds": [
{
"tag": "proxy",
"protocol": "vless",
"settings": {
"address": "host-028.example.invalid",
"port": 443,
"email": "[email protected]",
"id": "655dede1-6d31-487e-ae32-4821691e01b3",
"encryption": "none"
},
"streamSettings": {
"network": "xhttp",
"security": "tls",
"tlsSettings": {
"serverName": "host-028.example.invalid",
"alpn": [
"h3"
],
"fingerprint": "chrome"
},
"xhttpSettings": {
"path": "/redacted",
"mode": "auto",
"extra": {
"mode": "auto",
"xPaddingBytes": "100-1000"
}
}
},
"mux": {
"enabled": false,
"concurrency": -1
}
},
{
"tag": "direct",
"protocol": "freedom"
},
{
"tag": "block",
"protocol": "blackhole"
},
{
"tag": "dns",
"protocol": "dns"
}
],
"routing": {
"domainStrategy": "AsIs",
"rules": [
{
"type": "field",
"network": "tcp,udp",
"outboundTag": "proxy"
}
]
}
}

</details>

### 服务端配置

irrelevant

### 客户端日志

<details>
```log
Xray client log excerpt during two XHTTP(h3) delay tests
Relevant events only; IPs, hosts, and ephemeral ports are anonymized.

2026/10/18 09:16:01.462608 from tcp:127.0.0.1:<PORT> accepted tcp:<SERVER_HOST>:443 [socks10829 -> proxy]
2026/10/18 09:16:01.845888 [Error] app/router: Unables to find local process name: connection for <TUN_IP>:<PORT> not found in /proc/net/udp
2026/10/18 09:16:01.845946 from udp:<TUN_IP>:<PORT> accepted udp:<REMOTE_IP>:443 [tun -> block]
2026/10/18 09:16:08.219686 from tcp:127.0.0.1:<PORT> accepted tcp:<SERVER_HOST>:443 [socks10829 -> proxy]
2026/10/18 09:16:08.253353 from udp:<TUN_IP>:<PORT> accepted udp:<REMOTE_IP>:443 [tun -> block]
2026/10/18 09:16:08.253356 [Error] app/router: Unables to find local process name: connection for <TUN_IP>:<PORT> not found in /proc/net/udp

服务端日志

irrelevant

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions