meta-google: networking: Remove systemd daemon-reload
The daemon-reload operation is particularly expensive on the init
manager during bootup and ends up re-triggering services unnecessarily
that cause the system to become more flaky. We can avoid this by using
enviornment files, as they get re-read every time the service is
started.
Tested: Ran on a machine with and without a smartnic to verify the
arguments to the daemons are correct in both instances.
Change-Id: Ib3e554d12a7a3ce379f449bcae3532314b06821c
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/meta-google/recipes-google/ncsi/files/gbmc-ncsi-dhcrelay.service.in b/meta-google/recipes-google/ncsi/files/gbmc-ncsi-dhcrelay.service.in
index 078d1e2..c085cbc 100644
--- a/meta-google/recipes-google/ncsi/files/gbmc-ncsi-dhcrelay.service.in
+++ b/meta-google/recipes-google/ncsi/files/gbmc-ncsi-dhcrelay.service.in
@@ -7,9 +7,11 @@
LogRateLimitBurst=100
[Service]
+Environment="RP_FLAG=-rp 3967"
+EnvironmentFile=-/run/gbmc-ncsi-dhcrelay.env
Restart=always
RestartSec=5
-ExecStart=/usr/sbin/dhcrelay -d --no-pid -rp 3967 -l gbmcncsidhcp -u ff02::1:2%%@NCSI_IF@
+ExecStart=/usr/sbin/dhcrelay -d --no-pid $RP_FLAG -l gbmcncsidhcp -u ff02::1:2%%@NCSI_IF@
[Install]
WantedBy=multi-user.target
diff --git a/meta-google/recipes-google/ncsi/files/gbmc-ncsi-smartnic-wa.sh.in b/meta-google/recipes-google/ncsi/files/gbmc-ncsi-smartnic-wa.sh.in
index 9aa9b42..c05e239 100644
--- a/meta-google/recipes-google/ncsi/files/gbmc-ncsi-smartnic-wa.sh.in
+++ b/meta-google/recipes-google/ncsi/files/gbmc-ncsi-smartnic-wa.sh.in
@@ -16,31 +16,15 @@
HAS_DHCRELAY='@GBMC_DHCP_RELAY@'
if [ "$HAS_DHCRELAY" = 1 ]; then
- override=/run/systemd/system/gbmc-ncsi-dhcrelay.service.d/10-nosp.conf
- mkdir -p "$(dirname "$override")"
- echo '[Service]' >"$override"
- echo 'ExecStart=' >>"$override"
# Remove the source relay port from the relay, bringing it back to run on
# the default port 547. Our relays don't support the source port option needed
# to run on 3967 for our legacy NICs.
- grep '^ExecStart=' /lib/systemd/system/gbmc-ncsi-dhcrelay.service | \
- sed 's, -rp 3967,,' >>"$override"
-fi
-
-override=/run/systemd/system/gbmc-br-dhcp.service.d/10-direct.conf
-mkdir -p "$(dirname "$override")"
-echo '[Service]' >"$override"
-echo 'ExecStart=' >>"$override"
-# Switch the gbmcbr interface for the NCSI one to avoid passing the SOLICIT
-# message through the BMC relay.
-grep '^ExecStart=' /lib/systemd/system/gbmc-br-dhcp.service | \
- sed 's, -i gbmcbr, -i @NCSI_IF@,' >>"$override"
-
-systemctl daemon-reload
-if [ "$HAS_DHCRELAY" = 1 ]; then
+ echo 'RP_FLAG=' >/run/gbmc-ncsi-dhcrelay.env
systemctl reset-failed gbmc-ncsi-dhcrelay
systemctl restart --no-block gbmc-ncsi-dhcrelay
fi
+
+echo 'INTF=@NCSI_IF@' >/run/gbmc-br-dhcp.env
systemctl reset-failed gbmc-br-dhcp
systemctl restart --no-block gbmc-br-dhcp
diff --git a/meta-google/recipes-google/networking/gbmc-bridge/gbmc-br-dhcp.service b/meta-google/recipes-google/networking/gbmc-bridge/gbmc-br-dhcp.service
index c361181..48f53ab 100644
--- a/meta-google/recipes-google/networking/gbmc-bridge/gbmc-br-dhcp.service
+++ b/meta-google/recipes-google/networking/gbmc-bridge/gbmc-br-dhcp.service
@@ -6,10 +6,12 @@
StartLimitBurst=3
[Service]
+Environment=INTF=gbmcbr
+EnvironmentFile=-/run/gbmc-br-dhcp.env
Restart=on-failure
RestartSec=5
ExecStartPre=/usr/bin/update-dhcp-status 'ONGOING' 'Starting dhcp process'
-ExecStart=/usr/bin/udhcpc6 -f -q -O fqdn -O bootfile_url -O bootfile_param -i gbmcbr -s /usr/libexec/gbmc-br-dhcp.sh
+ExecStart=/usr/bin/udhcpc6 -f -q -O fqdn -O bootfile_url -O bootfile_param -i $INTF -s /usr/libexec/gbmc-br-dhcp.sh
[Install]
WantedBy=multi-user.target