On Tue, 26 Sept 2023 at 13:44, Mantas Mikulėnas <grawity@xxxxxxxxx> wrote:
I think you're confusing two different states, which have similar indications – "administrative" up/down that you control (the "<UP>" flag, with nothing shown when down) and "operational" up/down that represents the actual interface status (the "<RUNNING>" vs "<NO_CARRIER>" flags and/or the "state XXX" field).
Yes I am, thanks for clarifying.
"state DOWN" is *not* directly controlled by `ip link set up` – it's the result of the interface being operative for any other reason even though it is administratively <UP> (i.e. turned on).I'm still not entirely sure of the situation but right now it sounds like the configuration is okay but the Ethernet interface is failing to establish a physical link on the first try. Does it also show "<UP,NO_CARRIER>" within the interface flags?
eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
I've done a lot more testing now and there's a race condition somewhere as it does sometimes (rarely) boot OK and get an IP address with no config changes.
`systemctl cat` for direct configuration and `systemctl list-dependencies --after` (if I remember it right) should be a good start.
So here is what I now have. My unit is now this:
[Unit]
Before=network-pre.target dhcpcd.service
Wants=network-pre.target
[Service]
Type=oneshot
ExecStart=/path/to/script
[Install]
RequiredBy=network.target
Before=network-pre.target dhcpcd.service
Wants=network-pre.target
[Service]
Type=oneshot
ExecStart=/path/to/script
[Install]
RequiredBy=network.target
Note I added dhcpcd.service to Before as it consistently starts too early otherwise.
The dhcpcd unit config is (I haven't changed anything here):
[Unit]
Wants=network.target
Before=network.target
[Service]
Type=forking
PIDFile=/run/dhcpcd.pid
ExecStart=/usr/lib/dhcpcd5/dhcpcd -q -b
ExecStop=/sbin/dhcpcd -x
[Install]
WantedBy=multi-user.target
Alias=dhcpcd5.service
Wants=network.target
Before=network.target
[Service]
Type=forking
PIDFile=/run/dhcpcd.pid
ExecStart=/usr/lib/dhcpcd5/dhcpcd -q -b
ExecStop=/sbin/dhcpcd -x
[Install]
WantedBy=multi-user.target
Alias=dhcpcd5.service
In this state dhcpcd consistently starts after my script but the DHCP issue I'm trying to fix continues, so the race may not related to dhcpcd after all.
--
Mark Rogers