diff mbox series

[ovs-dev,v2,2/5] ovs-ctl: Detect systemd socket activation.

Message ID 1b626d8576fb86cf7911c224c19a469c3509a906.1774960196.git.tredaelli@redhat.com
State Accepted
Commit f0ec9b7a287aff11d042271ec193ad011f6e8ead
Delegated to: aaron conole
Headers show
Series Add systemd socket activation for ovsdb-server | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test warning github build: warning

Commit Message

Timothy Redaelli March 31, 2026, 12:34 p.m. UTC
When systemd socket-activates ovsdb-server, it sets LISTEN_FDNAMES
to the socket unit name and passes the listening socket as fd 3.
Detect this in do_start_ovsdb() and use --remote=pfd:3 instead of
--remote=punix:$DB_SOCK.

Validate LISTEN_PID against the current shell's PID, as required by
sd_listen_fds(3), to ensure the variables were set for this process
and not inherited from a parent.

Unset LISTEN_FDS, LISTEN_FDNAMES, LISTEN_PID, and LISTEN_PIDFDID after
consuming them to prevent propagation to child processes.

Co-authored-by: Lubomir Rintel <lkundrak@v3.sk>
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
---
 utilities/ovs-ctl.in | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/utilities/ovs-ctl.in b/utilities/ovs-ctl.in
index c65c76812..8ebd720dc 100644
--- a/utilities/ovs-ctl.in
+++ b/utilities/ovs-ctl.in
@@ -149,7 +149,13 @@  do_start_ovsdb () {
             set "$@" --no-self-confinement
         fi
         set "$@" -vconsole:emer -vsyslog:err -vfile:info
-        set "$@" --remote=punix:"$DB_SOCK"
+        if test X"$LISTEN_PID" = X"$$" && \
+           test X"$LISTEN_FDNAMES" = X"ovsdb-server.socket"; then
+            unset LISTEN_FDS LISTEN_FDNAMES LISTEN_PID LISTEN_PIDFDID
+            set "$@" --remote=pfd:3
+        else
+            set "$@" --remote=punix:"$DB_SOCK"
+        fi
         set "$@" --private-key=db:Open_vSwitch,SSL,private_key
         set "$@" --certificate=db:Open_vSwitch,SSL,certificate
         set "$@" --bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert