Skip to content

device packages: make USB the last gateway, not the first - #102

Merged
derekross merged 6 commits into
derekross:mainfrom
robotosaith:omamobile-usb-route
Oct 30, 2026
Merged

derekross merged 6 commits into
derekross:mainfrom
robotosaith:omamobile-usb-route

Conversation

@robotosaith

@robotosaith robotosaith commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

The USB gadget network gives usb0 the laptop as its Gateway=, so networkd makes it the default route at metric 0, ahead of Wi-Fi (600) and mobile data (700). With ConfigureWithoutCarrier=yes that route survives an unplug, so once the phone leaves the desk, IPv4 still goes into the dead cable. On raven, github.com (IPv4 only) failed on Wi-Fi while sites with IPv6 loaded fine.

The gateway is now a [Route] at metric 2000, so the laptop's shared connection is only the fallback. SSH over the cable is unaffected, since it uses the link's own subnet. raven, cheetah, felix and husky ship the same 20-usb-gadget.network, so all four get the change, and each package's tests now check that usb0 sets no metric-0 default route. Version bumps are left out.

Tested on raven by moving the route to metric 2000 live: github.com then went out over Wi-Fi, and SSH over USB kept working. cheetah, felix and husky are untested. tools/pr-check passes.

Fixes #103.

🤖 Generated with Claude Code

@robotosaith robotosaith changed the title device-raven, device-cheetah: make USB the last gateway, not the first device packages: make USB the last gateway, not the first Oct 28, 2026
@derekross

Copy link
Copy Markdown
Owner

Thanks for tracking this down; IPv4 going into a dead cable is a nasty one to notice. The reasoning holds on my Pixel 7 Pro too: 600 and 700 are really our Wi-Fi and mobile-data metrics, Address= stays in [Network] so SSH over the cable keeps its on-link route, and nothing reloads networkd at install, so it takes effect at the next boot. The four files are identical, and CI and the policy check pass.

Because this changes the reference phone's package, I'll run it on my cheetah before merging: a networkctl reload under a timer that puts the old file back, then a fresh login and ip route show default.

Two things from you:

  • Raven was tested by changing the route by hand rather than with the file itself. One networkctl reload with the shipped file (behind the same kind of undo timer), then ip route show default showing usb0 at metric 2000 and SSH still up, would close that.
  • The versions: CONTRIBUTING asks for a bump in each changed package, with the version in the subject. Since three of your device-raven PRs are open at once, I'll set them at merge (the next free version for each package) and put them in the squash subject, so you don't need to chase them.

A tools/phone-smoke report from raven with this in place would be welcome too. felix and husky are untested, as you said, and their owners will see it on their next boot.

@robotosaith

Copy link
Copy Markdown
Contributor Author

Tested the shipped file on raven (7.3.0-rc6-omamobile-push1-g244c690c1fd1), behind an undo timer: before networkctl reload, usb0's default route had no metric; after it, default via 172.16.42.2 dev usb0 proto static metric 2000, after Wi-Fi (600) and mobile data (700), and a fresh SSH login over USB still worked. The timer then put the old file back. Smoke report from the build: derekross/linux-omarchy-mobile#112 (comment).

@derekross

Copy link
Copy Markdown
Owner

One more package for this PR: the Pixel 7a's device package (packages/omamobile-device-lynx, merged this morning in #88) ships the same Gateway= file for usb0, and this head doesn't change it yet. Could you add lynx alongside cheetah, raven, felix and husky, with its version bump? Issue #103 is the same bug as seen on a phone.

@W4HO-ham W4HO-ham mentioned this pull request Oct 28, 2026
10 of 14 tasks
robotosaith and others added 3 commits October 28, 2026 16:30
20-usb-gadget.network gave usb0 the laptop as its Gateway=, which
networkd installs as the default route at metric 0, ahead of Wi-Fi (600)
and mobile data (700). With ConfigureWithoutCarrier=yes the route stays
after an unplug, and usb0 keeps its carrier then anyway. So once the
phone left the desk, IPv4 still went into the dead cable: on raven,
github.com (IPv4 only) failed on Wi-Fi while sites with IPv6 loaded.

The gateway is now a [Route] at metric 2000: the laptop's shared
connection is the fallback when there is no Wi-Fi or mobile data, and
SSH over the cable is unaffected (it uses the link's own subnet). Both
packages' tests check that usb0 sets no metric-0 default route.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
felix and husky ship the same 20-usb-gadget.network as raven and
cheetah, with the laptop as usb0's Gateway= at metric 0, a route that
outlives an unplug. They get the same fix: the gateway is a [Route] at
metric 2000, after Wi-Fi (600) and mobile data (700), and the same test.
Not tested on those phones.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lynx's package (derekross#88) ships the same 20-usb-gadget.network as the
others, with the laptop as usb0's Gateway= at metric 0, a route that
outlives an unplug. It gets the same fix: the gateway is a [Route] at
metric 2000, after Wi-Fi (600) and mobile data (700), and the same
test. Not tested on a Pixel 7a.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@robotosaith

Copy link
Copy Markdown
Contributor Author

Added lynx in device-lynx 0.2.1: make USB the last gateway, not the first, the same file and test as the others, and rebased onto main. Not tested on a Pixel 7a.

@derekross

Copy link
Copy Markdown
Owner

Thanks for adding the Pixel 7a and for testing the shipped file on raven behind an undo timer. That's the check I was after. The five 20-usb-gadget.network files match: cheetah's and raven's are identical, and felix's, husky's and lynx's differ only in saying "seen on raven". Each package's tests pass, and the new check fails as it should if I put Gateway= back under [Network] or drop the metric to 500. lynx's 0.2.1 is fine.

Next I'll run it on my Pixel 7 Pro, under a timer that undoes the change, and then merge. At the squash I'll set the other four versions to the next free ones and put them all in the subject, so there's nothing more you need to do here.

derekross added a commit that referenced this pull request Oct 28, 2026
…ry work

Open PRs hold device-cheetah 0.1.35 (#102) and omamobile-shell 0.2.33
to 0.2.36 (#99, #115, #117, #124); this branch takes the next free ones.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
derekross added a commit that referenced this pull request Oct 28, 2026
…ry work

Open PRs hold device-cheetah 0.1.35 (#102) and omamobile-shell 0.2.33
to 0.2.36 (#99, #115, #117, #124); this branch takes the next free ones.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jkjoplin

Copy link
Copy Markdown
Contributor

Tested on a Pixel 7 Pro (cheetah): omamobile-device-cheetah 0.1.34, kernel 7.3.0-rc6-omamobile-push1-g1cb4bd36f3be, Wi-Fi connected. This reproduces #103 there, and this PR's file fixes it.

A probe on the phone logged every 3-4 s:

  • the carrier and operstate of usb0;
  • the IPv4 default routes, and ip -4 route get 1.1.1.1;
  • three fetches: curl -4 https://github.com/, curl -6 https://www.google.com/ and curl -4 https://1.1.1.1/ (no DNS involved).

The unplug and replug times below are from the laptop's kernel log.

Before, with the package's file (Gateway= in [Network], metric 0). Unplugged from 23:19:13 to 23:21:02.

  • usb0 stayed carrier=1 oper=up throughout, and IPv4 kept going to dev usb0.
  • All 10 probes taken while the cable was out timed out on github.com and on 1.1.1.1 over IPv4, while google.com over IPv6 loaded.
  • Within 5 s of the replug, everything loaded again.
  • networkd logged "Lost carrier" and "Gained carrier" together at the replug, and nothing at the unplug.

After, with this PR's cheetah file. The file was byte for byte the one at 40a9a82. I put it in /run/systemd/network/ as a volatile override (not /etc, so it can't outlive a reboot or shadow the package), then ran networkctl reload and networkctl reconfigure usb0, with a 120 s revert armed and cancelled after a fresh SSH login.

  • The routes became wlp1s0 metric 600, then usb0 metric 2000, and 1.1.1.1 routes via wlp1s0.
  • Unplugged from 23:24:17 to 23:25:24: all 17 probes in that window loaded github.com over IPv4, google.com over IPv6 and 1.1.1.1 over IPv4.
  • usb0 still read carrier=1 while unplugged.
  • SSH over USB worked before and after the replug.

Not tested: a package built from this branch, a reboot with it, and the other phones' files.

@derekross

Copy link
Copy Markdown
Owner

Thanks for keeping this current with main. And thank you, Jeremy, for the Pixel 7 Pro run: reproducing #103 with the package's file first, then fixing it with this PR's file behind an undo timer, is exactly the evidence this change needed on that phone. All five changed files and their tests pass here, and so does CI.

One more package, I'm afraid: the Pixel 7's device package (packages/omamobile-device-panther, merged in #145) ships the same 20-usb-gadget.network with Gateway= under [Network], so it has the same bug. Could you add it with the same file and test, as you did for lynx? I'll set its version at the squash with the others. If you'd rather keep this PR as it is, say so, and I'll fix panther in a follow-up straight after merging. (The 9a's package already has its gateway in a [Route] at metric 2048, so it needs nothing.)

On my side, I'll run the cheetah file on my own Pixel 7 Pro under an undo timer, as planned, then merge. At the squash I'll put the versions in the subject and write the message myself, so the merge commit from main doesn't land in it.

@derekross

Copy link
Copy Markdown
Owner

Ran it on my Pixel 7 Pro as planned: the PR's cheetah file as a /run/systemd/network override, a 120 s undo timer, the reconfigure detached, then a fresh login. Before: usb0 was the bare default route ahead of Wi-Fi at 600. After: Wi-Fi at 600 and usb0 at 2000, ip route get 1.1.1.1 via Wi-Fi, curl to github.com 200, and the laptop link still up. So cheetah is proven on two phones now. The only thing left is panther's file (or your go-ahead for me to do it in a follow-up), then I'll merge.

robotosaith and others added 2 commits October 30, 2026 13:58
panther shipped the same 20-usb-gadget.network with Gateway= under
[Network]; it gets felix's [Route] block at metric 2000 and the same test.
Versions: cheetah 0.1.35, raven 0.1.28, felix 0.1.5, husky 0.1.1,
panther 0.1.2 (lynx was already 0.2.1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@derekross
derekross merged commit 6c1cf70 into derekross:main Oct 30, 2026
2 checks passed
@derekross

Copy link
Copy Markdown
Owner

Thanks again, both of you. Since I hadn't heard back on the Pixel 7's file, I added it myself with the same [Route] block and test as the other five, set every package's next version, and merged. Fixes #103.

@robotosaith

Copy link
Copy Markdown
Contributor Author

Thanks you so much @derekross

@derekross

Copy link
Copy Markdown
Owner

You're welcome 🫂🤙🏻💜

@robotosaith
robotosaith deleted the omamobile-usb-route branch November 2, 2026 14:51
robertzas pushed a commit to robertzas/omarchy-mobile that referenced this pull request Nov 14, 2026
…e-husky 0.1.1, device-lynx 0.2.1, device-panther 0.1.2: USB is the last gateway (derekross#102)

usb0's network file set Gateway= under [Network], a metric-0 default route ahead of Wi-Fi (600) and mobile data (700). Its route outlives an unplug, so with the cable out IPv4 went into a dead link (derekross#103). Each device package now puts the gateway in a [Route] at metric 2000, so USB is the last way out; each package test checks it. Tegu already had its gateway in a [Route] at 2048. Behaviour change: with a SIM and no Wi-Fi, traffic now goes over mobile data rather than the laptop.

Tested on two Pixel 7 Pros (2026-10-30): with the file as a /run override behind an undo timer, Wi-Fi at 600 and usb0 at 2000, route to 1.1.1.1 via Wi-Fi, HTTPS to github.com 200, the laptop link still up; one owner's unplug test kept IPv4 working.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Some websites stop loading on Wi-Fi after unplugging the USB cable

3 participants