-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix hostapd's place in systemd dependency tree. #45464
Conversation
Here is the dependency graph that I get with this PR. Notice that br0-netdev.service depends on network-link-wlp4s0.service which depends on hostapd.service which depends on sys-subsystem-net-devices-wlp4s0.device. You can generate this graph yourself with:
|
|
||
after = [ "${cfg.interface}-cfg.service" "nat.service" "bind.service" "dhcpd.service" "sys-subsystem-net-devices-${cfg.interface}.device" ]; | ||
after = [ "sys-subsystem-net-devices-${cfg.interface}.device" ]; | ||
requiredBy = [ "network-link-${cfg.interface}.service" ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it should also add BindsTo=sys-subsystem-net-devices-wlan0.device
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arch does After=network.target
, but I guess they just cannot add more specific requirements because they don't know which interface will be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, BindsTo
seems appropriate. I'll switch after
to BindsTo
as BindsTo
is already implies the effects of after
.
after=network.target
is not correct, as this potentially would hoist hostapd to the top of the dependency tree and causes the race to reappear. To get a visual idea of that, please look at the pdf attached in my PR comment. Also after=network.target
gives a cyclic after
chain of hostapd->network->br0-netdev->network-link-wl4s0->hostapd
. Somebody in #16090 said they had the same bridge race with Arch. Maybe that's the reason. I'll ping this PR to them.
e68f914
to
b8d1638
Compare
@clefru your patch does not work here probosed solutionmerge our patches as this:
i've tried with these configs seem to use a combination of
with only your patchpatch:
outcome:
journalctl -u hostapd
then it works with our patches combined
boot log:
journalctl -u hostapd
|
* nat/bind/dhcp.service: Remove. Those services have nothing to do with a link-level service. * sys-subsystem-net-devices-${if}.device: Add as BindsTo dependency as this will make hostapd stop when the device is unplugged. * network-link-${if}.service: Add hostapd as dependency for this service via requiredBy clause, so that the network link is only considered to be established only after hostapd has started. * network.target: Remove this from wantedBy clause as this is already implied from dependencies stacked above hostapd. And if it's not implied than starting hostapd is not required for this particular network configuration.
b8d1638
to
4b14f01
Compare
@qknight I have updated the PR as you suggested (retaining the after clause). Thanks for you analysis. (Also I reread the systemd.unit manpage, and my assertation above that "BindsTo" effects subsume those of "after" is wrong, hence it's still needed) |
@clefru ok, when you think the PR is ready i evaluate it once more, then we merge |
@qknight Please re-evaluate the PR as I updated it with your suggestions. Thank you! |
* nat/bind/dhcp.service: Remove. Those services have nothing to do with a link-level service. * sys-subsystem-net-devices-${if}.device: Add as BindsTo dependency as this will make hostapd stop when the device is unplugged. * network-link-${if}.service: Add hostapd as dependency for this service via requiredBy clause, so that the network link is only considered to be established only after hostapd has started. * network.target: Remove this from wantedBy clause as this is already implied from dependencies stacked above hostapd. And if it's not implied than starting hostapd is not required for this particular network configuration. (cherry picked from commit 725fcde)
Fix hostapd's place in systemd dependency tree. (#45464)
This broke hostapd when using systemd-networkd, because |
after clause:
requiredBy clause:
wantedBy clause:
stacked above hostapd. And if it's not implied than starting hostapd is not required
for this particular network configuration.
Motivation for this change
bridge setup races with hostapd, and if it wins, the bridge fails to start, see: #16090
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)