Skip to content

[Bug]: Boot auto-start aborts when iptables rule setup fails (xtables.lock contention) #18

Open

Description

@Jonah-77

检查清单

  • 我已搜索过现有 Issues,没有重复
  • 我已阅读 README 并尝试过其中提到的解决方案
  • 我已使用最新版本模块(旧版本的 Bug 不受理)

设备与环境信息

Generic rooted Android device; module installed via a root-based module host. (Device model / Android version / root manager intentionally omitted.)

模块版本

v2.5.1 (125-5d29538-release)

相关配置

Default configuration. The relevant setting is run_http_meta_bypass_vpn="true" in sub_store.config (this is the module default / also explicitly set). No personal or sensitive values involved.

复现步骤

  1. Install/update the module to v2.4.0 or later (tested on v2.5.1) on a rooted device where another component also manipulates iptables during boot.
  2. Reboot and let the device start up.
  3. At boot, the other component holds the xtables lock while the module's start script runs.
  4. After boot, the module's node services are not running; the module does not auto-start.
  5. Running the module's start script manually afterwards succeeds, so the service works until the next reboot where the same contention occurs.

The failure is intermittent (timing-dependent), which is why it may not appear on every boot after upgrading. Versions before v2.4.0 never showed this because their boot path did not touch iptables at all.

期望行为

A transient iptables/ip6tables failure at boot should not prevent the core services from starting. The VPN-bypass rule setup should either wait/retry for the xtables lock, or be best-effort (log a warning and continue) instead of aborting the whole start sequence.

实际行为

The node services are never launched at boot.

Root cause in scripts/sub_store.service -> start_bin():

if ! setup_http_meta_bypass_vpn; then
  return 1
fi

setup_http_meta_bypass_vpn() is called BEFORE the node processes are launched. It applies iptables/ip6tables mangle+raw rules for the http-meta VPN-bypass feature. If any single rule fails, it cleans up and returns 1, which aborts the whole start sequence, so no node is started.

None of the iptables calls use the -w (wait for xtables lock) flag, there is no retry and no graceful-degrade path.

At boot another component on the device also writes iptables rules at roughly the same time and holds the lock, so the rules fail with:

Can't lock /system/etc/xtables.lock: Try again
Another app is currently holding the xtables lock. Perhaps you want to use the -w option?

and run.log shows the corresponding IPv6 bypass rule error. Manual start later works fine.

Notes:

  • v2.4.0 changelog has "fix: tolerate missing IPv6 iptables", but that only handles the case where the ip6tables binary is absent, not the case where it exists but the lock is busy.
  • Affected v2.4.0 - v2.5.1. The current upstream main/module/scripts/sub_store.service is byte-identical to 2.5.1 and still has the same code, so updating alone does not fix it.

相关日志

run.log (boot time, paths/names redacted):

[Info]: starting sub_store_node service.
[Info]: 降权方式: su (Sub-Store: uid 2000 + inet group 3003)
[Info]: 降权方式: su (http-meta: uid 2000 + gid 9999)
[Error]: 无法添加 http-meta IPv6 VPN 绕过规则

run_error.log:

Can't lock /system/etc/xtables.lock: Try again
Another app is currently holding the xtables lock. Perhaps you want to use the -w option?

Comparing the module versions: scripts/sub_store.service has 0 iptables calls in v2.3.1 and earlier, and 13 in v2.4.0 onwards. Current upstream main has 30 iptables calls, none using -w, and still aborts on failure.

Activity

  1. added
    bug
    on Nov 16, 2026
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

    bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions