[systemd-devel] multiple starts for a socket-based service
Andrei Borzenkov
arvidjaar at gmail.com
Sun Aug 6 05:07:40 UTC 2023
On 06.08.2023 03:42, Ross Boylan wrote:
> On Fri, Aug 4, 2023 at 4:32 PM Kevin P. Fleming
> <lists.systemd-devel at kevin.km6g.us> wrote:
>>
>> On Fri, Aug 4, 2023, at 18:11, Ross Boylan wrote:
>>> Theory: since br0 has no associated IP address when socket creation is
>>> attempted, the socket creation fails. If so, I need to delay socket
>>> startup until br0 has an IP4 address, but I'm not sure how to do
>>> that--or even if that is the problem.
>>
>> This is almost certainly the cause, and the reason that the 'FreeBind' parameter can be set in .socket files :-)
>
> Thank you, Kevin. Setting FreeBind=yes results in successful socket
> activation on system startup
>
> I still find the description of FreeBind on the man page puzzling: "
> Controls whether the socket can be bound to non-local IP addresses."
> But 192.168.1.10 is a local IP address, and for that matter one can
> only directly create sockets on the local machine. The rest of the
> description makes clear the option is for my case, but I don't see how
> that relates to the quoted sentence. Presumably the problem is the
> meaning of "non-local IP addresses". Can anyone explain?
>
"non-local" address is an address not currently configured on any interface.
> Did I only run into this problem because I specified a BindToDevice
> directive?
No.
> It seemed like a good idea since there are potentially 2
> interfaces the socket could attach to, either the virtual interface
> br0 or the actual physical network interface that requests come in on.
> However, as far as I can tell from `ip addr`, the IP only goes with
> the bridge.
>
BindToDevice only makes sure your unit is not started before interface
appears. It does not imply your unit will also wait until IP address is
configured on this interface.
> The message
> systemd[1]: Listening on Socket to tickle to update family netboot config.
> still occurs interspersed with kernel messages from ~2s after boot,
> before IP addresses are configured.
>
> Ross
>
> Current config:
> # /etc/systemd/system/family.socket
> [Unit]
> Description=Socket to tickle to update family netboot config
>
> [Install]
> WantedBy=network-online.target
>
> [Socket]
> ListenStream=192.168.1.10:14987
> # want to run a new job, aka service, for each connection.
> Accept=Yes
> BindToDevice=br0
> # must wait until it has an IP address
> FreeBind=true
> # 2s is default
> TriggerLimitIntervalSec=5s
More information about the systemd-devel
mailing list