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, and LISTEN_PID after consuming
them to prevent propagation to child processes.

Co-authored-by: Lubomir Rintel <[email protected]>
Signed-off-by: Lubomir Rintel <[email protected]>
Signed-off-by: Timothy Redaelli <[email protected]>
---
 utilities/ovs-ctl.in | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/utilities/ovs-ctl.in b/utilities/ovs-ctl.in
index c65c76812..dff416f08 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
+            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
-- 
2.53.0

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to