Package: networkd-dispatcher
Version: 2.1-2
Severity: normal
Tags: patch
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu kinetic ubuntu-patch

Hi Julian,

Since Ubuntu installs networkd-dispatcher by default as part of a complete
replacement for the ifupdown user experience (i.e. support for post-up hook
scripts), the fact that networkd-dispatcher is running by default even when
it has nothing to do has a significant impact on the memory footprint of the
smallest Ubuntu deployments (VMs and containers): it is the fourth largest
process in 'top' output in a pristine Ubuntu container sorted by memory
usage.

I've therefore applied the attached patch to networkd-dispatcher in Ubuntu,
so that the systemd unit for networkd-dispatcher will only start if
networkd-dispatcher has been configured on the system.

Although Debian doesn't use networkd-dispatcher by default, I think it's
good practice to not start systemd units when they are not useful.

The only notable difference vs existing behavior is that this patch does not
watch the contents of the config directories; so on first configuration, the
user will have to either reboot the system, or manually start the
networkd-dispatcher service, in order for the changes to take effect.

If you think this difference is important, I am happy to prepare an
additional .path unit which would watch these directories for additions and
start the service dynamically.

Thanks for consdering,
-- 
Steve Langasek                   Give me a lever long enough and a Free OS
Debian Developer                   to set it on, and I can move the world.
Ubuntu Developer                                   https://www.debian.org/
slanga...@ubuntu.com                                     vor...@debian.org
diff -Nru networkd-dispatcher-2.1/debian/patches/no-start-by-default.patch 
networkd-dispatcher-2.1/debian/patches/no-start-by-default.patch
--- networkd-dispatcher-2.1/debian/patches/no-start-by-default.patch    
1969-12-31 16:00:00.000000000 -0800
+++ networkd-dispatcher-2.1/debian/patches/no-start-by-default.patch    
2022-07-08 13:33:54.000000000 -0700
@@ -0,0 +1,19 @@
+Description: Don't start the daemon if there's nothing to do
+ If there are no configuration files for networkd-dispatcher, then do not
+ start the (relatively heavyweight) process.
+Author: Steve Langasek <steve.langa...@ubuntu.com>
+Last-Update: 2022-07-08
+Forwarded: no
+
+Index: networkd-dispatcher-2.1/networkd-dispatcher.service
+===================================================================
+--- networkd-dispatcher-2.1.orig/networkd-dispatcher.service
++++ networkd-dispatcher-2.1/networkd-dispatcher.service
+@@ -1,5 +1,7 @@
+ [Unit]
+ Description=Dispatcher daemon for systemd-networkd
++ConditionPathExistsGlob=|/etc/networkd-dispatcher/*/*
++ConditionPathExistsGlob=|/usr/lib/networkd-dispatcher/*/*
+ 
+ [Service]
+ Type=notify
diff -Nru networkd-dispatcher-2.1/debian/patches/series 
networkd-dispatcher-2.1/debian/patches/series
--- networkd-dispatcher-2.1/debian/patches/series       2022-05-04 
06:29:24.000000000 -0700
+++ networkd-dispatcher-2.1/debian/patches/series       2022-07-08 
13:32:37.000000000 -0700
@@ -6,3 +6,4 @@
 CVE-2022-29800-1.patch
 CVE-2022-29800-2.patch
 CVE-2022-29799-regression.patch
+no-start-by-default.patch

Reply via email to