DanielLavrushin 报告 b4 手动路由表与透明代理表可能冲突
DanielLavrushin 报告,b4 手动固定 set 的 fwmark/table 若恰好等于透明代理选中的表,两类默认路由会相互替换,重建或监控时可能切换哪一方失效。触发还要求启用使用代理表的 set,且代理在手动 set 已安装路由前选表;若手动路由已存在,分配器会避开该表。他指出这些手动字段没有 UI 控件,MCP 与 hub 也不携带;代理分配器会避开已命名、外部规则或已有路由的表,但未避开配置中预留的表,TUN 分配器则已处理后者。他建议补充双向冲突检查。已合并的 #737 只解决崩溃清扫一侧,未解决此处运行时冲突。
作者原文@DanielLavrushinProblem
A set pinned with
routing.fwmarkandrouting.tableto the table the transparent proxy uses shares that table with the proxy, and their routes replace each other there.
- The proxy table is picked once, when the first set that needs it is built (routing_proxy.go#L273): 252, then 251, 250 and 300-399 (routing_tablealloc.go#L244). Sets with an upstream proxy, Reuse WSSIZE connection and the Telegram bridge all use it (
config.RoutingUsesTProxy).routePickProxyTableExecskips a table that is named, looked up by a foreign rule or holds routes (routing_tablealloc.go#L255-L289), but not a table a set pins in the configuration.routeResolveIDsreturns a pinned pair after checking only the mark (routing.go#L3354-L3371), so a pinned table equal to the chosen proxy table is accepted.The TUN engine already refuses this: its table picker treats a table pinned by a set as taken (tun/routetables.go#L39, #L61).
When it happens
All of:
- a set with a hand-set
routing.fwmarkandrouting.table(no UI control; MCP and the hub do not carry them),- the pinned table in the proxy's range, and equal to the table the proxy picked,
- a set that uses the proxy table is enabled,
- the proxy picks its table before the pinned set has routes there. If the pinned set's default route is already in the table, the picker sees it as holding routes and takes the next candidate. So it depends on the order the sets come up, and on whether the pinned set's interface is up at that moment.
Measured
In a private network namespace, the two routes b4 writes into one table replace each other:
ip route replace local 0.0.0.0/0 dev lo table 252 # proxy ip route replace default dev wg0 proto 155 table 252 # pinned set ip route show table 252 -> default dev wg0 proto 155 scope link ip route replace local 0.0.0.0/0 dev lo table 252 # proxy again ip route show table 252 -> local default dev lo scope hostOnly one of the two is in the table at a time, so one of the two sets does not work, and each rebuild or monitor pass can flip which one.
Suggested direction
routePickProxyTableExecskips the tables that enabled sets pin, as the TUN picker does withpinnedSetTables.routeResolveIDsrefuses a pinned table equal to the chosen proxy table with a warning and assigns a table instead, like the existing refused-mark cases.- The "Pinned values" row of
docs/docs/guides/marks.md(and its Russian mirror) lists the new condition.The crash sweep side, where a leftover rule for each kind into one table left the pinned set's routes behind, is fixed in #737.