fix(docker): use configured gateways for VLAN networks#2634
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughAdds a bash helper, configured_gateway(), which parses ChangesDocker Custom Network Gateway Configuration
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
🔧 PR Test Plugin AvailableA test plugin has been generated for this PR that includes the modified files. Version: 📥 Installation Instructions:Install via Unraid Web UI:
Alternative: Direct Download
|
f9dc3d2 to
be65432
Compare
- Purpose: keep Docker custom networks on VLAN and secondary interfaces from losing their configured gateway during automatic network recreation. - Before: rc.docker only read the gateway from a default route on the interface, so VLANs without an interface-specific default route created Docker networks without --gateway. - Why that was a problem: Docker could claim the first subnet address as the macvlan/ipvlan gateway, colliding with real VLAN gateways such as 192.168.10.1 and breaking DHCP or static-IP containers. - What the new change accomplishes: automatic Docker network creation now falls back to the configured IPv4 or IPv6 gateway stored in network.ini when no live default route exists. - How it works: configured_gateway maps br/bond network names back to their eth network.ini section, resolves VLAN IDs to their indexed entries, and returns the matching GATEWAY or GATEWAY6 value before network create arguments are assembled.
be65432 to
d56c259
Compare
Summary
configured_gatewayfallback for automatic Docker custom network creation.GATEWAY/GATEWAY6values from/boot/config/network.cfgwhen no interface-specific default route exists.rc.inet1.conf, with associative arrays declared before import, instead of parsing generatednetwork.initext.Root Cause
rc.dockerrecreates automatic custom Docker networks from the live interface state. For VLANs and secondary interfaces,ip route show to default dev <network>can be empty even though Unraid has a configured gateway for that network.When Docker creates a macvlan/ipvlan network without
--gateway, Docker may select the first address in the subnet as the gateway. On common VLANs this can collide with the real router address, for example192.168.10.1, breaking containers that depend on DHCP or static IP reachability.Impact
This keeps VLAN and secondary-NIC Docker custom networks from losing their configured gateway during automatic network recreation, addressing reports where containers on VLANs stopped receiving DHCP or became unreachable after upgrading.
Validation
bash -n etc/rc.d/rc.docker.git diff --check.configured_gatewaylocally against syntheticnetwork.cfginputs for:eth0,br0,br0.10,eth0.30,br1.20,eth1.20,br2.40, andbond2.40IPv4 gateway lookupbr0.10IPv6 gateway lookupGATEWAY/GATEWAY6lookup forbr0andbond0network.cfgimport throughfromdosIPADDR[0,1]andUSE_DHCP[1,1]root@unraid.localusing its real Bash/fromdos environment.root@unraid.local, waited for Docker startup after the array was unlocked, then reproduced the missing-default-route case with temporary VLAN interfaces and verified Docker network creation used the configured gateway:192.0.2.254and Docker inspect reportedgateway=192.0.2.254ipvlanandmacvlan; each reportedgateway=192.0.3.254root@unraid.localasbr0.30using DHCP with route metric999:br0.30received192.168.30.166/24from gateway192.168.30.1rc.dockeron the dev server and ran/etc/rc.d/rc.docker restartbr0.30asmacvlanwith parentbr0.30, subnet192.168.30.0/24, gateway192.168.30.1, and aux addressserver=192.168.30.166DOCKER_USER_NETWORKS="remove":my-codex-vlan30-webgui.xmlwith<Network>br0.30</Network>,<MyIP>192.168.30.250</MyIP>, and fixed<MyMAC>/usr/local/emhttp/plugins/dynamix.docker.manager/scripts/rebuild_container, which uses the same template-to-command code as the Docker WebGUIbr0.30with IP192.168.30.250and MAC02:42:c0:a8:1e:fa, and could ping192.168.30.1/etc/rc.d/rc.docker restart;br0.30network ID changed fromace392...tob5f728..., proving it was removed and recreated rather than preservedbr0.30with the same IP/MAC and could still ping192.168.30.1ipvlan(DOCKER_NETWORK_TYPE="1"):br0.30was recreated asipvlanwith gateway192.168.30.1ipvlan interfaces do not support custom mac address assignment<MyIP>192.168.30.250</MyIP>and empty<MyMAC/>), the WebGUI-template container started onbr0.30and could ping192.168.30.1/etc/rc.d/rc.docker restart;br0.30was removed/recreated asipvlan,rc.dockerloggedconnecting codex-vlan30-webgui-ipvlan-ip to network br0.30, and the container reconnected with192.168.30.250/24and could still ping192.168.30.1failed to create the ipvlan port: device or resource busy. This appears independent of the gateway fallback change.rc.dockeronroot@unraid.localto validate the negative path:198.51.100.254, and no live default route, the pre-PR logic produced no--gatewayargumentGateway=invalid IP, reproducing the missing-gateway failure pathrc.dockerand reran the same setup;configured_gatewayresolved198.51.100.254, Docker was created with--gateway=198.51.100.254, and inspect reportedgateway=198.51.100.254codex-gw*Docker networks or interfaces remained after validation.