Users' reports, review round: uninstall.ps1 never reads past the eMMC either, and the rebind re-bridges only what was a port

uninstall.ps1 had the same unguarded superblock probe as the shell uninstaller (a 32 GB variant, or any table that reaches the disk's end, hung its dd from Windows); it gets RegionOnDisk as install.ps1 did. The hook's re-enumeration used to put usb0 into br-lan unconditionally on every LAN ifup, which undid a user's own choice to take it out for an interface of its own: now only a netdev that was a bridge port before the rebind is made one again (rndis0 is, having joined before the removal loop). FINDINGS 38: the functions the installers actually share, the rebind described as a guard rather than a mechanism that was seen, fw4 offloads the zone devices that exist, and mu300-vpn's own firewall reload named among the reloads 5.4 still fails.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DqKKtBQZCfxYnHuBCuDqqn
This commit is contained in:
Abdurrahman Kaan DikeçandClaude Fable 5.1 committed 2026-10-09 09:33:24 +03:00
1 parent bde23d0033
commit 486856cd20
4 files changed
+44 -16

No files matched your search

+16 -10
View File
@@ -2973,10 +2973,11 @@ held the SoC at 97 °C in #65 until a reboot. #52 (the Magisk installer, OpenWrt
`region_find_existing` without seeing why. The legacy offset is the same trap on the 32 GB variant: it lies
beyond that eMMC altogether and was read all the same.
Fixed in `tools/storage.sh` (which `install.sh`, `uninstall.sh`, `tools/reset-password.sh` and the Magisk
installer share) and in `install.ps1`: a region whose boundaries cross is an empty one (`SIZE=0`; the installers
Fixed in `tools/storage.sh` (`region_find_existing`, which `install.sh` and the Magisk installer share, and
`region_on_disk`, which the probe loops of `uninstall.sh` and `tools/reset-password.sh` call), in `install.ps1` and
in `uninstall.ps1` (`RegionOnDisk`): a region whose boundaries cross is an empty one (`SIZE=0`; the installers
then offer the card or the repartitioning, as they do for any region that is too small), and a candidate
superblock is read only when it lies on the disk (`region_on_disk`, `RegionOnDisk`). The SD-card installation of
superblock is read only when it lies on the disk. The SD-card installation of
#52 and #65 goes through without a single read past the end. `tests/test_installer.py` (`Region`) runs the
layout of #65 against the functions and checks that no `dd` crosses the disk's last byte.
@@ -2995,10 +2996,12 @@ only looks at ports: `rndis0` was not one yet, kept `192.168.77.1/24`, and then
one of its ports with the same address, two equal routes, and the device could not reach its own Wi-Fi client
nor the USB host, with the serial console the only way in. MRWOODEN measured it on an F50 (6.18, `openwrt-luci`,
Windows without `UsbNcm.sys`) and sent the fix: join first, then take the address off; and after the hook's own
re-enumeration of the gadget (K10), which destroys the function's netdev and binds a new one, put the gadget
netdevs back into the bridge, since netifd re-adds a port it has in its configuration (`usb0`) and never one it
never had. Applied as sent, with the regression test (`test_early_dhcp`: the RNDIS netdev that is not a port
yet). Verified on the reporter's device: `br-lan` the only holder of the address, both the Wi-Fi client and the
re-enumeration of the gadget (K10) put the gadget netdevs back into the bridge, in case the rebind left one bare
(with a configfs gadget the netdev is made with the function and should survive an UDC rebind, so this is a
guard, not a mechanism that was seen; netifd would re-add a port it has in its configuration, `usb0`, and never
one it never had). Applied as sent, except that only a netdev that was a port before the rebind is made one
again: a user who took `usb0` out of `br-lan` for an interface of its own keeps it that way. With the regression
tests (`test_early_dhcp`: the RNDIS netdev that is not a port yet; the `usb0` that is not a port stays out). Verified on the reporter's device: `br-lan` the only holder of the address, both the Wi-Fi client and the
USB host served by the one `dnsmasq`, `rndis0` still a port after the rebind.
#### 38c. fw4 on 5.4: the boot ruleset without the LAN, and a reload that always fails (#67, #61)
@@ -3019,7 +3022,9 @@ renders both. Two things stack:
list without regard to the pending deletion (the check skips inactive entries from 5.13 on). `flowtable ft {
... } Error: Resource busy`, the whole transaction is rejected, and the S19 ruleset stays. The flowtable exists
from S19 on because the `earlyusb` zone names `usb0`, which init has made by then, and fw4 puts every zone
device into `ft`. The first ruleset is therefore the one with the flowtable and without the LAN, and nothing
device that exists into `ft` (a device without a `/sys/class/net` entry is left out, see
`openwrt/patches/fw4-sipa-offload.patch`; that is what makes naming `br-lan` and `sipa_eth0` in the zones
safe at S19). The first ruleset is therefore the one with the flowtable and without the LAN, and nothing
after it can replace it. Deleting the flowtable on its own (`nft delete flowtable inet fw4 ft`), in a
transaction that is committed before the reload, is enough: the reload then creates it afresh.
@@ -3038,8 +3043,9 @@ Two fixes, both in `openwrt/overlay`:
reload, under the same conditions 20-firewall reloads on: an ifup of an interface that is in a zone. The reload
succeeds; the offloaded flows of the moment take the ordinary path until the flowtable is back.
Not covered on 5.4: a reload that is not an ifup's - the firewall saved in LuCI, `fw4 reload` by hand - still
fails while the flowtable is there. Until a cleaner hook is found (the flowtable deleted from fw4's own reload
Not covered on 5.4: a reload that is not an ifup's - the firewall saved in LuCI, `fw4 reload` by hand, and
`mu300-vpn`'s own `/etc/init.d/firewall reload` after it adds the tunnel to the wan zone (the clients get no
forwarding into the VPN until the next ifup of a zone interface) - still fails while the flowtable is there. Until a cleaner hook is found (the flowtable deleted from fw4's own reload
path), the way to apply a firewall change on 5.4 is `nft delete flowtable inet fw4 ft; fw4 reload`, or a reboot.
Turning software flow offloading off would end that, at the cost of the fast path on the one kernel that has
none other.
@@ -47,16 +47,21 @@ g=$C/usb_gadget/linux
[ -e $g/UDC ] || exit 0
udc=$(cat $g/UDC)
[ -n "$udc" ] || udc=$(ls /sys/class/udc | head -1)
# The gadget netdevs that are bridge ports now: after the rebind they are made ports again, should the rebind have
# left one bare (a netdev with no server, the early one being gone, and no LAN for the USB host; netifd puts back a
# port that is in its configuration, usb0, never one it never had, rndis0 - issue #45). A netdev that is not a port
# stays out: a user who took usb0 out of br-lan for an interface of its own keeps it that way.
ports=
for nic in usb0 rndis0; do
ip -o link show dev "$nic" 2>/dev/null | grep -q 'master br-lan' && ports="$ports $nic"
done
(
sleep 2
echo "" > $g/UDC 2>/dev/null
sleep 1
echo "$udc" > $g/UDC && logger -t mu300 "usb gadget re-enumerated on $udc"
# The rebind took the function's netdev away and bound a new one, which has to be a bridge port again, or the
# USB host is left on a bare netdev with no server (the early one is gone) and no LAN. netifd puts back a port
# that is in its configuration (usb0), never one it never had (rndis0) - issue #45.
sleep 1
for nic in usb0 rndis0; do
for nic in $ports; do
[ -e /sys/class/net/$nic ] || continue
ip link set "$nic" master br-lan 2>/dev/null
ip link set "$nic" up 2>/dev/null
+15 -2
View File
@@ -239,7 +239,7 @@ class EarlyUsbOpenWrt(ShellTest):
# --- hotplug iface/10-mu300-usb (K9; K10 rejected: the re-enumeration stays)
def hotplug(self, shell, stamp_age=None, bridge='10.1.2.1/24', port='10.1.2.1/24', rndis_port='yes',
rndis_addr=''):
rndis_addr='', usb0_port='yes'):
(self.tmp / 'run' / 'mu300-early-udhcpd.pid').write_text('4242\n')
(self.tmp / 'uptime').write_text('100.50 90.00\n')
(self.tmp / 'mounts').write_text(f'configfs {self.tmp}/cfg configfs rw 0 0\n')
@@ -255,7 +255,8 @@ class EarlyUsbOpenWrt(ShellTest):
f'rp={rndis_port}; grep -q "^ip link set rndis0 master br-lan$" "$STUBLOG/ip.log" && rp=yes\n'
'case "$*" in\n'
f'"-4 -o addr show dev br-lan") echo "9: br-lan inet {bridge} scope global br-lan" ;;\n'
'"-o link show dev usb0") echo "7: usb0: <UP> mtu 1500 master br-lan state UP" ;;\n'
f'"-o link show dev usb0") [ "{usb0_port}" = yes ] && echo "7: usb0: <UP> mtu 1500 master br-lan state UP" ||'
' echo "7: usb0: <UP> mtu 1500 state UP" ;;\n'
'"-o link show dev rndis0") [ "$rp" = yes ] && echo "8: rndis0: <UP> mtu 1500 master br-lan state UP" ||'
' echo "8: rndis0: <UP> mtu 1500 state UP" ;;\n'
f'"-4 -o addr show dev usb0") echo "7: usb0 inet {port} scope global usb0" ;;\n'
@@ -303,6 +304,18 @@ class EarlyUsbOpenWrt(ShellTest):
self.assertEqual(2, ip.count('ip link set rndis0 master br-lan\n'))
self.tearDown(); self.setUp()
def test_a_netdev_that_is_not_a_port_stays_out_after_the_rebind(self):
"""Only a gadget netdev that was a bridge port before the re-enumeration is made one again afterwards: a
user who took usb0 out of br-lan for an interface of its own keeps it that way, on every LAN ifup."""
for shell in self.each_shell():
self.netdevs('usb0', 'rndis0')
self.hotplug(shell, port='', usb0_port='no', rndis_port='no')
ip = (self.tmp / 'ip.log').read_text()
self.assertNotIn('ip link set usb0 master br-lan\n', ip)
# rndis0 joined before the removal loop, so it is a port and comes back after the rebind
self.assertEqual(2, ip.count('ip link set rndis0 master br-lan\n'))
self.tearDown(); self.setUp()
def test_port_prefix_other_than_the_bridge(self):
# I1: br-lan has the LAN as /16, preinit left a /24 on usb0 - its route would beat the bridge's
for shell in self.each_shell():
+4
View File
@@ -178,7 +178,11 @@ if ($parts.Count -ne 2) { Die 'could not read the partition table from the devic
[int64]$lastEnd = $parts[0]; [int64]$disk = $parts[1]
[int64]$OFF = 0; [int64]$SIZE = 0
[int64]$start = [math]::Floor($lastEnd / 4096 + 1) * 4096 * 512
# a candidate past the end of the eMMC (a table that reaches the disk's end, issues #52/#65) is never read: that dd
# never returns on the device
function RegionOnDisk([int64]$bytes) { [math]::Floor(($bytes + 2048) / 512) -le $disk }
foreach ($cand in @($start, 27762098176)) {
if (-not (RegionOnDisk $cand)) { continue }
$m = (SuDo "dd if=/dev/block/mmcblk0 bs=1 skip=$($cand + 1080) count=2 2>/dev/null | od -An -tx1") -replace '\s', ''
$l = (SuDo "dd if=/dev/block/mmcblk0 bs=1 skip=$($cand + 1144) count=16 2>/dev/null") -replace '\0', ''
if ($m -eq '53ef' -and $l.Trim() -eq 'mu300root') {