package/dhcp: fix SysV init scripts option passing
PATCH v3 1/13 package/dhcp: fix SysV init scripts option passing
From: Beno?t Th?baudeau <[email protected]>
The SysV init scripts have configuration variables like INTERFACES whose contents have to be passed to the daemon. These variables are initialized as empty strings, but some of them are not allowed to be empty and there was no means of filling them apart from creating a root FS overlay to overwrite these scripts.
This commit adds support for files under /etc/default/ to set these configuration variables. Such light files can now be added to the root FS skeleton or overlays without having to duplicate most of the SysV init scripts.
---
Changes v2 -> v3: none.
Changes v1 -> v2:
- Rebase.
--- package/dhcp/S80dhcp-relay | 4 ++++ package/dhcp/S80dhcp-server | 4 ++++ 2 files changed, 8 insertions(+)
package/dhcp/S80dhcp-relay +4 -0
@@ -13,6 +13,10 @@ INTERFACES="" # Additional options that are passed to the DHCP relay daemon? OPTIONS="" +# Read configuration variable file if it is present +CFG_FILE="/etc/default/dhcrelay" +[ -r "${CFG_FILE}" ] && . "${CFG_FILE}" + # Sanity checks test -f /usr/sbin/dhcrelay || exit 0 test -n "$INTERFACES" || exit 0
package/dhcp/S80dhcp-server +4 -0
@@ -7,6 +7,10 @@ # Separate multiple interfaces with spaces, e.g. "eth0 eth1". INTERFACES="" +# Read configuration variable file if it is present +CFG_FILE="/etc/default/dhcpd" +[ -r "${CFG_FILE}" ] && . "${CFG_FILE}" + # Sanity checks test -f /usr/sbin/dhcpd || exit 0 test -f /etc/dhcp/dhcpd.conf || exit 0
Signature · 1 line
2.1.4
PATCH v3 2/13 package/dhcp: systemd: rename environment file
Use the same EnvironmentFile name as the SysV init script for consistency. The filenames under /etc/default/ are usually just the package/daemon/service/feature name without any extension, so remove the ".conf" extension from EnvironmentFile.
---
Changes v2 -> v3: new patch.
--- package/dhcp/dhcpd.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
package/dhcp/dhcpd.service +1 -1
@@ -7,7 +7,7 @@ Type=forking PIDFile=/run/dhcpd.pid ExecStart=/usr/sbin/dhcpd -q -pf /run/dhcpd.pid $INTERFACES KillSignal=SIGINT -EnvironmentFile=/etc/default/dhcpd.conf +EnvironmentFile=/etc/default/dhcpd [Install] WantedBy=multi-user.target
Signature · 1 line
2.1.4
PATCH v3 2/13 package/dhcp: systemd: rename environment file
Hi Benoit, all
Quoted 18 lines · Beno?t Th?baudeau
Use the same EnvironmentFile name as the SysV init script for consistency. The filenames under
/etc/default/are usually just the package/daemon/service/feature name without any extension, so remove the ".conf" extension from EnvironmentFile.Signed-off-by Beno?t Th?baudeau <[email protected]>---
Changes v2 -> v3: new patch.--- package/dhcp/dhcpd.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)package/dhcp/dhcpd.service +0
-0
package/dhcp/dhcpd.service Type=forking · line 11
Quoted 6 lines
package/dhcp/dhcpd.service +1
-1@@ -7,7 +7,7 @@ Type=forking PIDFile=/run/dhcpd.pid ExecStart=/usr/sbin/dhcpd -q -pf /run/dhcpd.pid $INTERFACES KillSignal=SIGINT -EnvironmentFile=/etc/default/dhcpd.conf +EnvironmentFile=/etc/default/dhcpd
Maybe this should be:
EnvironmentFile-=/etc/default/dhcpd
Notice the '-' before the '=', in case the file doesn't exists, it won't print a warning or error the whole service.
When I build dhcp, I did not find a /etc/default folder in my target directory, am I missing something there ?
Quoted 7 lines
package/dhcp/dhcpd.service +0
-1[Install] WantedBy=multi-user.target --2.1.4
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20151104/2651351d/attachment.html>
PATCH v3 2/13 package/dhcp: systemd: rename environment file
Quoted 32 lines · Maxime Hadjinlian
Hi Benoit, all
Quoted 18 lines · Beno?t Th?baudeau
Use the same EnvironmentFile name as the SysV init script for consistency. The filenames under
/etc/default/are usually just the package/daemon/service/feature name without any extension, so remove the ".conf" extension from EnvironmentFile.Signed-off-by Beno?t Th?baudeau <[email protected]>---
Changes v2 -> v3: new patch.--- package/dhcp/dhcpd.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)package/dhcp/dhcpd.service +0
-0package/dhcp/dhcpd.service Type=forking · line 11
Quoted 6 lines
package/dhcp/dhcpd.service +1
-1@@ -7,7 +7,7 @@ Type=forking PIDFile=/run/dhcpd.pid ExecStart=/usr/sbin/dhcpd -q -pf /run/dhcpd.pid $INTERFACES KillSignal=SIGINT -EnvironmentFile=/etc/default/dhcpd.conf +EnvironmentFile=/etc/default/dhcpdMaybe this should be:
EnvironmentFile-=/etc/default/dhcpd
Quoted 17 lines
Notice the '-' before the '=', in case the file doesn't exists, it won't print a warning or error the whole service.
My mistake, the '-' should be *AFTER* the '='.
When I build dhcp, I did not find a
/etc/defaultfolder in my target directory, am I missing something there ?Quoted 7 lines
package/dhcp/dhcpd.service +0
-1[Install] WantedBy=multi-user.target --2.1.4
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20151104/1452c283/attachment.html>
PATCH v3 2/13 package/dhcp: systemd: rename environment file
Hi Maxime, all,
Quoted 32 lines · Maxime Hadjinlian
On Wed, Nov 4, 2015 at 10:52 AM, Maxime Hadjinlian <maxime.hadjinlian at gmail.com <mailto:[email protected]>> wrote:
Hi Benoit, all
On Sun, Oct 25, 2015 at 2:59 AM, Beno?t Th?baudeau <benoit.thebaudeau.dev at gmail.com <mailto:[email protected]>> wrote:
Use the same EnvironmentFile name as the SysV init script for consistency. The filenames under
/etc/default/are usually just the package/daemon/service/feature name without any extension, so remove the ".conf" extension from EnvironmentFile.Signed-off-by Beno?t Th?baudeau <benoit.thebaudeau.dev at gmail.com <mailto:[email protected]>>---
Changes v2 -> v3: new patch.
---
package/dhcp/dhcpd.service | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)diff --git a/package/dhcp/dhcpd.service b/package/dhcp/dhcpd.service index 7b265cb..5989506 100644
--- a/package/dhcp/dhcpd.service
+++ b/package/dhcp/dhcpd.service
@@ -7,7 +7,7 @@ Type=forking
PIDFile=/run/dhcpd.pid
ExecStart=/usr/sbin/dhcpd -q -pf/run/dhcpd.pid$INTERFACES KillSignal=SIGINT
-EnvironmentFile=/etc/default/dhcpd.conf +EnvironmentFile=/etc/default/dhcpd
Quoted 6 lines
Maybe this should be:
EnvironmentFile-=/etc/default/dhcpdNotice the '-' before the '=', in case the file doesn't exists, it won't print a warning or error the whole service.
My mistake, the '-' should be *AFTER* the '='.
See 06/13.
Quoted 1 line
When I build dhcp, I did not find a
/etc/defaultfolder in my target directory, am I missing something there ?
You might have this question about 13/13 which requires a file in /etc/default, but not here because of 06/13. But a default file provided by Buildroot would not make sense for 13/13 since the file contents would be application-specific though required. In this case, it is up to users to add a rootfs overlay with such files.
Quoted 4 lines
[Install]
WantedBy=multi-user.target
--
2.1.4Best regards,
Beno?t
PATCH v3 2/13 package/dhcp: systemd: rename environment file
Quoted 45 lines · Beno?t Th?baudeau
Hi Maxime, all,
Quoted 3 lines · Maxime Hadjinlian
On Wed, Nov 4, 2015 at 10:52 AM, Maxime Hadjinlian <
Quoted 4 lines · maxime.hadjinlian at gmail.com
Hi Benoit, all
On Sun, Oct 25, 2015 at 2:59 AM, Beno?t Th?baudeau <
benoit.thebaudeau.dev at gmail.com <mailto:[email protected]>>
Quoted 3 lines · wrote:
Use the same EnvironmentFile name as the SysV init script for consistency. The filenames under
/etc/default/are usually justthe
Quoted 1 line
package/daemon/service/feature name without any extension, so
remove the
Quoted 3 lines
".conf" extension from EnvironmentFile.
Signed-off-by Beno?t Th?baudeau <benoit.thebaudeau.dev at gmail.com <mailto:[email protected]>>
Quoted 8 lines
--- Changes v2 -> v3: new patch. --- package/dhcp/dhcpd.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/dhcp/dhcpd.serviceb/package/dhcp/dhcpd.service
Quoted 13 lines
index 7b265cb..5989506 100644
--- a/package/dhcp/dhcpd.service
+++ b/package/dhcp/dhcpd.service
@@ -7,7 +7,7 @@ Type=forking
PIDFile=/run/dhcpd.pid
ExecStart=/usr/sbin/dhcpd -q -pf/run/dhcpd.pid$INTERFACES KillSignal=SIGINT
-EnvironmentFile=/etc/default/dhcpd.conf +EnvironmentFile=/etc/default/dhcpdMaybe this should be:
EnvironmentFile-=/etc/default/dhcpd
Quoted 7 lines
Quoted 1 line
Notice the '-' before the '=', in case the file doesn't exists, it
won't print a warning or error the whole service.
Quoted 2 lines
My mistake, the '-' should be *AFTER* the '='.
See 06/13.
Ah yes, should they be squashed ?
Quoted 4 lines
Quoted 2 lines
When I build dhcp, I did not find a
/etc/defaultfolder in my targetdirectory, am I missing something there ?
Quoted 10 lines
You might have this question about 13/13 which requires a file in
/etc/default,
but not here because of 06/13. But a default file provided by Buildroot would
not make sense for 13/13 since the file contents would be application-specific
though required. In this case, it is up to users to add a rootfs overlay with
such files.
Ok, that's fair enough.
Quoted 9 lines
Quoted 5 lines
[Install] WantedBy=multi-user.target -- 2.1.4Best regards,
Beno?t
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20151104/5f236a75/attachment.html>
PATCH v3 2/13 package/dhcp: systemd: rename environment file
Quoted 48 lines · Maxime Hadjinlian
On Wed, Nov 4, 2015 at 11:01 AM, Beno?t Th?baudeau <benoit at wsystem.com <mailto:[email protected]>> wrote:
Hi Maxime, all, On 04/11/2015 10:54, Maxime Hadjinlian wrote: > > > On Wed, Nov 4, 2015 at 10:52 AM, Maxime Hadjinlian <maxime.hadjinlian at gmail.com <mailto:[email protected]> <mailto:maxime.hadjinlian at gmail.com <mailto:[email protected]>>> wrote: > > Hi Benoit, all > > On Sun, Oct 25, 2015 at 2:59 AM, Beno?t Th?baudeau <benoit.thebaudeau.dev at gmail.com <mailto:[email protected]> <mailto:benoit.thebaudeau.dev at gmail.com <mailto:[email protected]>>> wrote: > > Use the same EnvironmentFile name as the SysV init script for > consistency. The filenames under /etc/default/ are usually just the > package/daemon/service/feature name without any extension, so remove the > ".conf" extension from EnvironmentFile. > > Signed-off-by: Beno?t Th?baudeau <benoit.thebaudeau.dev at gmail.com <mailto:[email protected]> <mailto:benoit.thebaudeau.dev at gmail.com <mailto:[email protected]>>> > > --- > Changes v2 -> v3: new patch. > --- > package/dhcp/dhcpd.service | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/package/dhcp/dhcpd.service b/package/dhcp/dhcpd.service > index 7b265cb..5989506 100644 > --- a/package/dhcp/dhcpd.service > +++ b/package/dhcp/dhcpd.service > @@ -7,7 +7,7 @@ Type=forking > PIDFile=/run/dhcpd.pid > ExecStart=/usr/sbin/dhcpd -q -pf /run/dhcpd.pid $INTERFACES > KillSignal=SIGINT > -EnvironmentFile=/etc/default/dhcpd.conf > +EnvironmentFile=/etc/default/dhcpd > > Maybe this should be: > EnvironmentFile-=/etc/default/dhcpd > > Notice the '-' before the '=', in case the file doesn't exists, it won't print a warning or error the whole service. > > My mistake, the '-' should be *AFTER* the '='. See 06/13.
Quoted 1 line
Ah yes, should they be squashed ?
No: these patches have different purposes.
Quoted 15 lines
Quoted 1 line
When I build dhcp, I did not find a
/etc/defaultfolder in my target directory, am I missing something there ?You might have this question about 13/13 which requires a file in
/etc/default, but not here because of 06/13. But a default file provided by Buildroot would not make sense for 13/13 since the file contents would be application-specific though required. In this case, it is up to users to add a rootfs overlay with such files.Ok, that's fair enough.
Quoted 4 lines
[Install] WantedBy=multi-user.target -- 2.1.4
Best regards,
Beno?t
PATCH v3 2/13 package/dhcp: systemd: rename environment file
[-SNIP-]
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
Maybe this should be:
EnvironmentFile-=/etc/default/dhcpdNotice the '-' before the '=', in case the file doesn't
exists, it won't print a warning or error the whole service.
Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
My mistake, the '-' should be *AFTER* the '='.
See 06/13.Ah yes, should they be squashed ?
No: these patches have different purposes.
Yes, on that bombshell
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20151104/07dd322d/attachment.html>
PATCH v3 2/13 package/dhcp: systemd: rename environment file
In reply to Maxime HadjinlianMaxime, Beno?t, Gabe,
Quoted 5 lines · Maxime Hadjinlian
Quoted 5 lines
package/dhcp/dhcpd.service +0
-0@@ -7,7 +7,7 @@ Type=forking
Quoted 8 lines
package/dhcp/dhcpd.service Type=forking · line 11
Quoted 6 lines
package/dhcp/dhcpd.service +1
-1PIDFile=/run/dhcpd.pid ExecStart=/usr/sbin/dhcpd -q -pf /run/dhcpd.pid $INTERFACES KillSignal=SIGINT -EnvironmentFile=/etc/default/dhcpd.conf +EnvironmentFile=/etc/default/dhcpdMaybe this should be:
EnvironmentFile-=/etc/default/dhcpd
On the dropbear package, Gabe Evans said it may not be such a good idea to do this EnvironmentFile thing.
Can we settle on a common decision ?
(From my PoV, using this EnvironmentFile looked good as it would be a common mechanism between the systemd and Busybox/sysvinit cases to tune the configuration of services. But Gabe seemed to disagree.)
Could systemd people in Buildroot decide what to do ? :-)
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH v3 2/13 package/dhcp: systemd: rename environment file
Thomas, Gabe, Maxime, all,
Quoted 16 lines · Thomas Petazzoni
Quoted 5 lines · Maxime Hadjinlian
Quoted 5 lines
package/dhcp/dhcpd.service +0
-0@@ -7,7 +7,7 @@ Type=forkingQuoted 8 lines
package/dhcp/dhcpd.service Type=forking · line 11
Quoted 6 lines
package/dhcp/dhcpd.service +1
-1PIDFile=/run/dhcpd.pid ExecStart=/usr/sbin/dhcpd -q -pf /run/dhcpd.pid $INTERFACES KillSignal=SIGINT -EnvironmentFile=/etc/default/dhcpd.conf +EnvironmentFile=/etc/default/dhcpdMaybe this should be:
EnvironmentFile-=/etc/default/dhcpd
Quoted 2 lines
On the dropbear package, Gabe Evans said it may not be such a good idea to do this EnvironmentFile thing.
Why? What was the rationale? What would be the alternatives?
Quoted 7 lines
Can we settle on a common decision ?
(From my PoV, using this EnvironmentFile looked good as it would be a common mechanism between the systemd and Busybox/sysvinit cases to tune the configuration of services. But Gabe seemed to disagree.)
Could systemd people in Buildroot decide what to do ? :-)
Beno?t
PATCH v3 2/13 package/dhcp: systemd: rename environment file
In reply to Thomas PetazzoniHi Thomas, all
Quoted 18 lines · Thomas Petazzoni
Maxime, Beno?t, Gabe,
Quoted 5 lines · Maxime Hadjinlian
Quoted 5 lines
package/dhcp/dhcpd.service +0
-0@@ -7,7 +7,7 @@ Type=forkingQuoted 8 lines
package/dhcp/dhcpd.service Type=forking · line 11
Quoted 6 lines
package/dhcp/dhcpd.service +1
-1PIDFile=/run/dhcpd.pid ExecStart=/usr/sbin/dhcpd -q -pf /run/dhcpd.pid $INTERFACES KillSignal=SIGINT -EnvironmentFile=/etc/default/dhcpd.conf +EnvironmentFile=/etc/default/dhcpdMaybe this should be:
EnvironmentFile-=/etc/default/dhcpd
Quoted 9 lines
On the dropbear package, Gabe Evans said it may not be such a good idea to do this EnvironmentFile thing.
Can we settle on a common decision ?
(From my PoV, using this EnvironmentFile looked good as it would be a common mechanism between the systemd and Busybox/sysvinit cases to tune the configuration of services. But Gabe seemed to disagree.)
I still have to read that thread, I'll get to it in a few minutes. The mechanism in itself is good, adding the '-' simply makes the file optional. For me, a program must be able to start without options, or they are not options but mandatory parameters (which is a bit contradictory)
Quoted 9 lines
Could systemd people in Buildroot decide what to do ? :-)
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20151104/e0fc767a/attachment.html>
PATCH v3 2/13 package/dhcp: systemd: rename environment file
In reply to Thomas PetazzoniHi Thomas, all,
Quoted 27 lines · Thomas Petazzoni
Maxime, Beno?t, Gabe,
Quoted 5 lines · Maxime Hadjinlian
Quoted 5 lines
package/dhcp/dhcpd.service +0
-0@@ -7,7 +7,7 @@ Type=forkingQuoted 8 lines
package/dhcp/dhcpd.service Type=forking · line 11
Quoted 6 lines
package/dhcp/dhcpd.service +1
-1PIDFile=/run/dhcpd.pid ExecStart=/usr/sbin/dhcpd -q -pf /run/dhcpd.pid $INTERFACES KillSignal=SIGINT -EnvironmentFile=/etc/default/dhcpd.conf +EnvironmentFile=/etc/default/dhcpdMaybe this should be:
EnvironmentFile-=/etc/default/dhcpdOn the dropbear package, Gabe Evans said it may not be such a good idea to do this EnvironmentFile thing.
Can we settle on a common decision ?
(From my PoV, using this EnvironmentFile looked good as it would be a common mechanism between the systemd and Busybox/sysvinit cases to tune the configuration of services. But Gabe seemed to disagree.)
Quoted 7 lines
Could systemd people in Buildroot decide what to do ? :-)
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
Maxime cleared everything up for me. I'm okay with this as long as the environment file is optional with:
'EnvironmentFile=-/etc/default/dhcpd'. Under the rationale of sharing configuration between Busybox/SysVinit it makes the most sense.
Thanks,
Gabe
Signature · 2 lines
Gabe Evans | Co-Founder & CTO hashrabbit.co ? angel.co/hashrabbit ? github.com/gevans
PATCH v3 2/13 package/dhcp: systemd: rename environment file
In reply to Benoît ThébaudeauDear Beno?t Th?baudeau,
Quoted 6 lines · Beno?t Th?baudeau
Use the same EnvironmentFile name as the SysV init script for consistency. The filenames under
/etc/default/are usually just the package/daemon/service/feature name without any extension, so remove the ".conf" extension from EnvironmentFile.Signed-off-by Beno?t Th?baudeau <[email protected]>
I already did this change in a commit that also adjusted S80dhcp-server:
https://git.busybox.net/buildroot/commit/?id=6f81baaf47e3f47b131ec2b1c6c5f7d062a48d84
Thanks,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH v3 3/13 package/dhcp/S80dhcp-server: support extra options
In reply to Benoît ThébaudeauFrom: Beno?t Th?baudeau <[email protected]>
Add an OPTIONS configuration variable in order to make it possible to pass custom extra options to dhcpd.
---
Changes v2 -> v3: none.
Changes v1 -> v2:
- Rebase.
--- package/dhcp/S80dhcp-server | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
package/dhcp/S80dhcp-server +4 -1
@@ -7,6 +7,9 @@ # Separate multiple interfaces with spaces, e.g. "eth0 eth1". INTERFACES="" +# Additional options that are passed to the DHCP server daemon? +OPTIONS="" + # Read configuration variable file if it is present CFG_FILE="/etc/default/dhcpd" [ -r "${CFG_FILE}" ] && . "${CFG_FILE}"
@@ -21,7 +24,7 @@ case "$1" in printf "Starting DHCP server: " test -d /var/lib/dhcp/ || mkdir -p /var/lib/dhcp/ test -f /var/lib/dhcp/dhcpd.leases || touch /var/lib/dhcp/dhcpd.leases - start-stop-daemon -S -x /usr/sbin/dhcpd -- -q $INTERFACES + start-stop-daemon -S -x /usr/sbin/dhcpd -- -q $OPTIONS $INTERFACES [ $? = 0 ] && echo "OK" || echo "FAIL" ;; stop)
Signature · 1 line
2.1.4
Thomas Petazzoni
AppliedPATCH v3 3/13 package/dhcp/S80dhcp-server: support extra options
Dear Beno?t Th?baudeau,
Quoted 9 lines · Beno?t Th?baudeau
From: Beno?t Th?baudeau <[email protected]>
Add an OPTIONS configuration variable in order to make it possible to pass custom extra options to dhcpd.
Signed-off-by Beno?t Th?baudeau <[email protected]>---
Changes v2 -> v3: none.
Applied, thanks.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH v3 4/13 package/dhcp: systemd: support extra options
In reply to Benoît ThébaudeauAdd an OPTIONS configuration variable in order to make it possible to pass custom extra options to dhcpd. This keeps the systemd support consistent with the SysV init script.
---
Changes v2 -> v3: new patch.
--- package/dhcp/dhcpd.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
package/dhcp/dhcpd.service +1 -1
@@ -5,7 +5,7 @@ After=network.target [Service] Type=forking PIDFile=/run/dhcpd.pid -ExecStart=/usr/sbin/dhcpd -q -pf /run/dhcpd.pid $INTERFACES +ExecStart=/usr/sbin/dhcpd -q -pf /run/dhcpd.pid $OPTIONS $INTERFACES KillSignal=SIGINT EnvironmentFile=/etc/default/dhcpd
Signature · 1 line
2.1.4
PATCH v3 4/13 package/dhcp: systemd: support extra options
Quoted 17 lines · Beno?t Th?baudeau
Add an OPTIONS configuration variable in order to make it possible to pass custom extra options to dhcpd. This keeps the systemd support consistent with the SysV init script.
Signed-off-by Beno?t Th?baudeau <[email protected]>---
Changes v2 -> v3: new patch.--- package/dhcp/dhcpd.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)package/dhcp/dhcpd.service +0
-0
package/dhcp/dhcpd.service After=network.target · line 11
Quoted 8 lines
package/dhcp/dhcpd.service +1
-1@@ -5,7 +5,7 @@ After=network.target [Service] Type=forking PIDFile=/run/dhcpd.pid -ExecStart=/usr/sbin/dhcpd -q -pf /run/dhcpd.pid $INTERFACES +ExecStart=/usr/sbin/dhcpd -q -pf /run/dhcpd.pid $OPTIONS $INTERFACES KillSignal=SIGINT EnvironmentFile=/etc/default/dhcpd
Quoted 5 lines
--
2.1.4
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20151104/104b6aa5/attachment.html>
Thomas Petazzoni
AppliedPATCH v3 4/13 package/dhcp: systemd: support extra options
In reply to Benoît ThébaudeauDear Beno?t Th?baudeau,
Quoted 11 lines · Beno?t Th?baudeau
Add an OPTIONS configuration variable in order to make it possible to pass custom extra options to dhcpd. This keeps the systemd support consistent with the SysV init script.
Signed-off-by Beno?t Th?baudeau <[email protected]>---
Changes v2 -> v3: new patch.--- package/dhcp/dhcpd.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied, thanks.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH v3 5/13 package/dhcp/S80dhcp-server: allow empty INTERFACES
In reply to Benoît ThébaudeauFrom: Beno?t Th?baudeau <[email protected]>
The dhcpd daemon does not require network interface names to be specified on the command line.
From dhcpd(8):
"The names of the network interfaces on which dhcpd should listen for broadcasts may be specified on the command line. This should be done on systems where dhcpd is unable to identify non-broadcast interfaces, but should not be required on other systems. If no interface names are specified on the command line dhcpd will identify all network interfaces which are up, eliminating non-broadcast interfaces if possible, and listen for DHCP broadcasts on each interface."
dhcpd exits with "Not configured to listen on any interfaces!" only if no requested (those in INTERFACES, or all if empty) non-broadcast interfaces matching the subnet declarations in dhcpd.conf are up.
---
Changes v2 -> v3: none.
Changes v1 -> v2:
- Rebase.
--- package/dhcp/S80dhcp-server | 1 - 1 file changed, 1 deletion(-)
package/dhcp/S80dhcp-server +0 -1
@@ -17,7 +17,6 @@ CFG_FILE="/etc/default/dhcpd" # Sanity checks test -f /usr/sbin/dhcpd || exit 0 test -f /etc/dhcp/dhcpd.conf || exit 0 -test -n "$INTERFACES" || exit 0 case "$1" in start)
Signature · 1 line
2.1.4
Thomas Petazzoni
AppliedPATCH v3 5/13 package/dhcp/S80dhcp-server: allow empty INTERFACES
Dear Beno?t Th?baudeau,
Quoted 14 lines · Beno?t Th?baudeau
From: Beno?t Th?baudeau <[email protected]>
The dhcpd daemon does not require network interface names to be specified on the command line.
Quoted 1 line
From dhcpd(8):
"The names of the network interfaces on which dhcpd should listen for broadcasts may be specified on the command line. This should be done on systems where dhcpd is unable to identify non-broadcast interfaces, but should not be required on other systems. If no interface names are specified on the command line dhcpd will identify all network interfaces which are up, eliminating non-broadcast interfaces if possible, and listen for DHCP broadcasts on each interface."
Quoted 8 lines
dhcpd exits with "Not configured to listen on any interfaces!" only if no requested (those in INTERFACES, or all if empty) non-broadcast interfaces matching the subnet declarations in dhcpd.conf are up.
Signed-off-by Beno?t Th?baudeau <[email protected]>---
Changes v2 -> v3: none.
Applied, thanks.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH v3 6/13 package/dhcp: systemd: allow missing environment file
In reply to Benoît ThébaudeauThe dhcpd daemon does not require network interface names to be specified on the command line.
From dhcpd(8):
"The names of the network interfaces on which dhcpd should listen for broadcasts may be specified on the command line. This should be done on systems where dhcpd is unable to identify non-broadcast interfaces, but should not be required on other systems. If no interface names are specified on the command line dhcpd will identify all network interfaces which are up, eliminating non-broadcast interfaces if possible, and listen for DHCP broadcasts on each interface."
dhcpd exits with "Not configured to listen on any interfaces!" only if no requested (those in INTERFACES, or all if empty) non-broadcast interfaces matching the subnet declarations in dhcpd.conf are up.
Also, no extra options are required on the command line, which means that the EnvironmentFile file does not have to be present, so make it optional.
---
Changes v2 -> v3: new patch.
--- package/dhcp/dhcpd.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
package/dhcp/dhcpd.service +1 -1
@@ -7,7 +7,7 @@ Type=forking PIDFile=/run/dhcpd.pid ExecStart=/usr/sbin/dhcpd -q -pf /run/dhcpd.pid $OPTIONS $INTERFACES KillSignal=SIGINT -EnvironmentFile=/etc/default/dhcpd +EnvironmentFile=-/etc/default/dhcpd [Install] WantedBy=multi-user.target
Signature · 1 line
2.1.4
PATCH v3 6/13 package/dhcp: systemd: allow missing environment file
Quoted 34 lines · Beno?t Th?baudeau
The dhcpd daemon does not require network interface names to be specified on the command line.
Quoted 1 line
From dhcpd(8):
"The names of the network interfaces on which dhcpd should listen for broadcasts may be specified on the command line. This should be done on systems where dhcpd is unable to identify non-broadcast interfaces, but should not be required on other systems. If no interface names are specified on the command line dhcpd will identify all network interfaces which are up, eliminating non-broadcast interfaces if possible, and listen for DHCP broadcasts on each interface."
dhcpd exits with "Not configured to listen on any interfaces!" only if no requested (those in INTERFACES, or all if empty) non-broadcast interfaces matching the subnet declarations in dhcpd.conf are up.
Also, no extra options are required on the command line, which means that the EnvironmentFile file does not have to be present, so make it optional.
Signed-off-by Beno?t Th?baudeau <[email protected]>---
Changes v2 -> v3: new patch.--- package/dhcp/dhcpd.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)package/dhcp/dhcpd.service +0
-0
package/dhcp/dhcpd.service Type=forking · line 13
Quoted 8 lines
package/dhcp/dhcpd.service +1
-1@@ -7,7 +7,7 @@ Type=forking PIDFile=/run/dhcpd.pid ExecStart=/usr/sbin/dhcpd -q -pf /run/dhcpd.pid $OPTIONS $INTERFACES KillSignal=SIGINT -EnvironmentFile=/etc/default/dhcpd +EnvironmentFile=-/etc/default/dhcpd [Install] WantedBy=multi-user.target
Quoted 4 lines
--
2.1.4
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20151104/c3ae58c8/attachment.html>
PATCH v3 6/13 package/dhcp: systemd: allow missing environment file
In reply to Benoît ThébaudeauDear Beno?t Th?baudeau,
package/dhcp/dhcpd.service Type=forking · line 13
Quoted 13 lines · Beno?t Th?baudeau
package/dhcp/dhcpd.service +1
-1@@ -7,7 +7,7 @@ Type=forking PIDFile=/run/dhcpd.pid ExecStart=/usr/sbin/dhcpd -q -pf /run/dhcpd.pid $OPTIONS $INTERFACES KillSignal=SIGINT -EnvironmentFile=/etc/default/dhcpd +EnvironmentFile=-/etc/default/dhcpd [Install] WantedBy=multi-user.target
A similar change had already been done in commit21aa707a126155533748998f4fae328b1c63d1d6.
Thanks,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH v3 7/13 package/dhcp: fix SysV init scripts output text
In reply to Benoît ThébaudeauFrom: Beno?t Th?baudeau <[email protected]>
Fix various messages displayed by these scripts:
- remove extra "dhcpd3" for S80dhcp-server stop,
- make start-stop-daemon quiet in order to avoid extra messages like "stopped /usr/sbin/dhcpd (pid 174)" being output between the command description and its result,
- fix the script names in the usage strings.
---
Changes v2 -> v3: none.
Changes v1 -> v2:
- Rebase.
- Use 'printf' instead of 'echo -n' following
0f75b2635ee564fbbdb9ea631cf39fa8731d6d6c.
--- package/dhcp/S80dhcp-relay | 6 +++--- package/dhcp/S80dhcp-server | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-)
package/dhcp/S80dhcp-relay +3 -3
@@ -33,12 +33,12 @@ DHCRELAYPID=/var/run/dhcrelay.pid case "$1" in start) printf "Starting DHCP relay: " - start-stop-daemon -S -x /usr/sbin/dhcrelay -- -q $OPTIONS $IFCMD $SERVERS + start-stop-daemon -S -q -x /usr/sbin/dhcrelay -- -q $OPTIONS $IFCMD $SERVERS [ $? = 0 ] && echo "OK" || echo "FAIL" ;; stop) printf "Stopping DHCP relay: " - start-stop-daemon -K -x /usr/sbin/dhcrelay + start-stop-daemon -K -q -x /usr/sbin/dhcrelay [ $? = 0 ] && echo "OK" || echo "FAIL" ;; restart | force-reload)
@@ -47,7 +47,7 @@ case "$1" in $0 start ;; *) - echo "Usage: /etc/init.d/dhcp-relay {start|stop|restart|force-reload}" + echo "Usage: $0 {start|stop|restart|force-reload}" exit 1 esac
package/dhcp/S80dhcp-server +4 -4
@@ -23,12 +23,12 @@ case "$1" in printf "Starting DHCP server: " test -d /var/lib/dhcp/ || mkdir -p /var/lib/dhcp/ test -f /var/lib/dhcp/dhcpd.leases || touch /var/lib/dhcp/dhcpd.leases - start-stop-daemon -S -x /usr/sbin/dhcpd -- -q $OPTIONS $INTERFACES + start-stop-daemon -S -q -x /usr/sbin/dhcpd -- -q $OPTIONS $INTERFACES [ $? = 0 ] && echo "OK" || echo "FAIL" ;; stop) - printf "Stopping DHCP server: dhcpd3" - start-stop-daemon -K -x /usr/sbin/dhcpd + printf "Stopping DHCP server: " + start-stop-daemon -K -q -x /usr/sbin/dhcpd [ $? = 0 ] && echo "OK" || echo "FAIL" ;; restart | force-reload)
@@ -40,7 +40,7 @@ case "$1" in fi ;; *) - echo "Usage: /etc/init.d/dhcp-server {start|stop|restart|force-reload}" + echo "Usage: $0 {start|stop|restart|force-reload}" exit 1 esac
Signature · 1 line
2.1.4
PATCH v3 7/13 package/dhcp: fix SysV init scripts output text
Dear Beno?t Th?baudeau,
Quoted 4 lines · Beno?t Th?baudeau
From: Beno?t Th?baudeau <[email protected]>
Fix various messages displayed by these scripts:
- remove extra "dhcpd3" forS80dhcp-server stop,
I had already done this change in a previous commit.
Quoted 6 lines
- make start-stop-daemon quiet in order to avoid extra messages like "stopped
/usr/sbin/dhcpd(pid 174)" being output between the command description and its result,
- fix the script names in the usage strings.Signed-off-by Beno?t Th?baudeau <[email protected]>
So, I've applied your patch, after adjusting it to not do the dhcpd3 removal.
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH v3 8/13 package/dhcp: remove sleep from SysV init scripts restart
In reply to Benoît ThébaudeauFrom: Beno?t Th?baudeau <[email protected]>
No sleep is required for the restart and force-reload operations to succeed.
---
Changes v2 -> v3: none.
Changes v1 -> v2:
- Rebase.
--- package/dhcp/S80dhcp-relay | 1 - package/dhcp/S80dhcp-server | 1 - 2 files changed, 2 deletions(-)
package/dhcp/S80dhcp-relay +0 -1
@@ -43,7 +43,6 @@ case "$1" in ;; restart | force-reload) $0 stop - sleep 2 $0 start ;; *)
package/dhcp/S80dhcp-server +0 -1
@@ -33,7 +33,6 @@ case "$1" in ;; restart | force-reload) $0 stop - sleep 2 $0 start if [ "$?" != "0" ]; then exit 1
Signature · 1 line
2.1.4
Thomas Petazzoni
AppliedPATCH v3 8/13 package/dhcp: remove sleep from SysV init scripts restart
Dear Beno?t Th?baudeau,
Quoted 9 lines · Beno?t Th?baudeau
From: Beno?t Th?baudeau <[email protected]>
No sleep is required for the restart and force-reload operations to succeed.
Signed-off-by Beno?t Th?baudeau <[email protected]>---
Changes v2 -> v3: none.
Applied, thanks.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH v3 9/13 package/dhcp: SysV init scripts: remove PID files after stop
In reply to Benoît ThébaudeauFrom: Beno?t Th?baudeau <[email protected]>
These daemons do not remove their PID files, so do it manually in the scripts.
---
Changes v2 -> v3: none.
Changes v1 -> v2:
- Rebase.
--- package/dhcp/S80dhcp-relay | 12 ++++++++++-- package/dhcp/S80dhcp-server | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-)
package/dhcp/S80dhcp-relay +10 -2
@@ -17,6 +17,9 @@ OPTIONS="" CFG_FILE="/etc/default/dhcrelay" [ -r "${CFG_FILE}" ] && . "${CFG_FILE}" +# PID files generated by the daemon +PID_FILES="/var/run/dhcrelay.pid /var/run/dhcrelay6.pid" + # Sanity checks test -f /usr/sbin/dhcrelay || exit 0 test -n "$INTERFACES" || exit 0
@@ -38,8 +41,13 @@ case "$1" in ;; stop) printf "Stopping DHCP relay: " - start-stop-daemon -K -q -x /usr/sbin/dhcrelay - [ $? = 0 ] && echo "OK" || echo "FAIL" + if start-stop-daemon -K -q -x /usr/sbin/dhcrelay; then + # This daemon does not remove its PID file when it exits. + rm -f ${PID_FILES} + echo "OK" + else + echo "FAIL" + fi ;; restart | force-reload) $0 stop
package/dhcp/S80dhcp-server +10 -2
@@ -14,6 +14,9 @@ OPTIONS="" CFG_FILE="/etc/default/dhcpd" [ -r "${CFG_FILE}" ] && . "${CFG_FILE}" +# PID files generated by the daemon +PID_FILES="/var/run/dhcpd.pid /var/run/dhcpd6.pid" + # Sanity checks test -f /usr/sbin/dhcpd || exit 0 test -f /etc/dhcp/dhcpd.conf || exit 0
@@ -28,8 +31,13 @@ case "$1" in ;; stop) printf "Stopping DHCP server: " - start-stop-daemon -K -q -x /usr/sbin/dhcpd - [ $? = 0 ] && echo "OK" || echo "FAIL" + if start-stop-daemon -K -q -x /usr/sbin/dhcpd; then + # This daemon does not remove its PID file when it exits. + rm -f ${PID_FILES} + echo "OK" + else + echo "FAIL" + fi ;; restart | force-reload) $0 stop
Signature · 1 line
2.1.4
PATCH v3 9/13 package/dhcp: SysV init scripts: remove PID files after stop
Beno?t,
Quoted 6 lines · Beno?t Th?baudeau
From: Beno?t Th?baudeau <[email protected]>
These daemons do not remove their PID files, so do it manually in the scripts.
Signed-off-by Beno?t Th?baudeau <[email protected]>
I think this is not the right way of handling this and the IPv6 problem.
What I would suggest is that the S80dhcp-server script should start two DHCP servers: one with -4 and one with -6. To avoid IPv6 failures, you can test if /proc/net/if_inet6 exists.
Then, I was hoping you could use the --remove-pidfile option of start-stop-daemon, but it unfortunately doesn't exist in the Busybox implementation of start-stop-daemon.
That being said, I still believe starting two daemons is the best solution. I don't think a Config.in option should be added for that. Just always start both, with as I propose an exception to not start the IPv6 daemon if /proc/net/if_inet6 does not exist.
Could you rework your patches 9 to 13 with this goal in mind ?
Thanks a lot!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH v3 9/13 package/dhcp: SysV init scripts: remove PID files after stop
Thomas,
Quoted 6 lines · Thomas Petazzoni
Quoted 5 lines · Beno?t Th?baudeau
From: Beno?t Th?baudeau <[email protected]>
These daemons do not remove their PID files, so do it manually in the scripts.
Quoted 8 lines
Quoted 1 line
Signed-off-by Beno?t Th?baudeau <[email protected]>I think this is not the right way of handling this and the IPv6 problem.
What I would suggest is that the S80dhcp-server script should start two DHCP servers: one with -4 and one with -6. To avoid IPv6 failures, you can test if
/proc/net/if_inet6exists.
OK, I'll do that.
Quoted 3 lines
Then, I was hoping you could use the --remove-pidfile option of start-stop-daemon, but it unfortunately doesn't exist in the Busybox implementation of start-stop-daemon.
Indeed. I also went that way first. So what are you eventually suggesting to change for 09/13 since there is apparently no other solution for SysV? Even with two daemons started, the PID files will have to be removed with rm for SysV, so 09/13 would only have to be split. This is already handled for systemd.
Quoted 8 lines
That being said, I still believe starting two daemons is the best solution. I don't think a Config.in option should be added for that. Just always start both, with as I propose an exception to not start the IPv6 daemon if
/proc/net/if_inet6does not exist.Could you rework your patches 9 to 13 with this goal in mind ?
Thanks a lot!
Will do.
Beno?t
PATCH v3 10/13 package/dhcp/S80dhcp-server: support IPv6 lease file
In reply to Benoît ThébaudeauFrom: Beno?t Th?baudeau <[email protected]>
The IPv6 lease file has a different name.
---
Changes v2 -> v3: none.
Changes v1 -> v2:
- Rebase.
--- package/dhcp/S80dhcp-server | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
package/dhcp/S80dhcp-server +4 -1
@@ -25,7 +25,10 @@ case "$1" in start) printf "Starting DHCP server: " test -d /var/lib/dhcp/ || mkdir -p /var/lib/dhcp/ - test -f /var/lib/dhcp/dhcpd.leases || touch /var/lib/dhcp/dhcpd.leases + for lease_file in /var/lib/dhcp/dhcpd.leases \ + /var/lib/dhcp/dhcpd6.leases; do + test -f "${lease_file}" || touch "${lease_file}" + done start-stop-daemon -S -q -x /usr/sbin/dhcpd -- -q $OPTIONS $INTERFACES [ $? = 0 ] && echo "OK" || echo "FAIL" ;;
Signature · 1 line
2.1.4
PATCH v3 11/13 package/dhcp: systemd: support IPv6 lease file
In reply to Benoît ThébaudeauThe IPv6 lease file has a different name.
---
Changes v2 -> v3: new patch.
--- package/dhcp/dhcp.mk | 2 ++ 1 file changed, 2 insertions(+)
package/dhcp/dhcp.mk +2 -0
@@ -83,6 +83,8 @@ define DHCP_INSTALL_INIT_SYSTEMD $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf echo "f /var/lib/dhcp/dhcpd.leases - - - - -" >> \ $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf + echo "f /var/lib/dhcp/dhcpd6.leases - - - - -" >> \ + $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf endef endif
Signature · 1 line
2.1.4
PATCH v3 11/13 package/dhcp: systemd: support IPv6 lease file
Hi Benoit, all
Quoted 23 lines · Beno?t Th?baudeau
The IPv6 lease file has a different name.
Signed-off-by Beno?t Th?baudeau <[email protected]>---
Changes v2 -> v3: new patch.--- package/dhcp/dhcp.mk | 2 ++ 1 file changed, 2 insertions(+)package/dhcp/dhcp.mk +2
-0@@ -83,6 +83,8 @@ define DHCP_INSTALL_INIT_SYSTEMD $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf echo "f /var/lib/dhcp/dhcpd.leases - - - - -" >> \ $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf + echo "f /var/lib/dhcp/dhcpd6.leases - - - - -" >> \ + $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf endef endif
Quoted 1 line
Reviewed-by "Maxime Hadjinlian" <[email protected]>
A question though, from the manual page of dhcpd, by default it starts as an IPv6 server should we have, two services one with '-4' and one with '-6' ? And it's left to the user to specify it in the "$OPTIONS" ? Maybe this should be mentioned somewhere ?
Quoted 4 lines
--
2.1.4
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20151104/9be81378/attachment.html>
PATCH v3 11/13 package/dhcp: systemd: support IPv6 lease file
Maxime, all,
Quoted 27 lines · Maxime Hadjinlian
Hi Benoit, all
On Sun, Oct 25, 2015 at 2:59 AM, Beno?t Th?baudeau <benoit.thebaudeau.dev at gmail.com <mailto:[email protected]>> wrote:
The IPv6 lease file has a different name. Signed-off-by: Beno?t Th?baudeau <benoit.thebaudeau.dev at gmail.com <mailto:[email protected]>> --- Changes v2 -> v3: new patch. --- package/dhcp/dhcp.mk <http://dhcp.mk> | 2 ++ 1 file changed, 2 insertions(+) diff --git a/package/dhcp/dhcp.mk <http://dhcp.mk> b/package/dhcp/dhcp.mk <http://dhcp.mk> index c05e694..3aa1577 100644 --- a/package/dhcp/dhcp.mk <http://dhcp.mk> +++ b/package/dhcp/dhcp.mk <http://dhcp.mk> @@ -83,6 +83,8 @@ define DHCP_INSTALL_INIT_SYSTEMD $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf echo "f /var/lib/dhcp/dhcpd.leases - - - - -" >> \ $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf + echo "f /var/lib/dhcp/dhcpd6.leases - - - - -" >> \ + $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf endef endif
Quoted 3 lines
Reviewed-by "Maxime Hadjinlian" <maxime.hadjinlian at gmail.com <mailto:[email protected]>>A question though, from the manual page of dhcpd, by default it starts as an IPv6 server should we have, two services one with '-4' and one with '-6' ? And it's left to the user to specify it in the "$OPTIONS" ? Maybe this should be mentioned somewhere ?
'-4' is the default, not '-6'. A single instance of dhcpd cannot be run with both '-4' and '-6'. I don't know if it's possible (or desirable) to safely run simultaneously two instances of dhcpd, one with '-4' and the other one with '-6'.
"$OPTIONS" is designed exactly for such things. Users should read the man page of dhcpd to know what may fit in there.
Best regards,
Beno?t
PATCH v3 11/13 package/dhcp: systemd: support IPv6 lease file
Quoted 35 lines · Beno?t Th?baudeau
Maxime, all,
Quoted 3 lines · Maxime Hadjinlian
Hi Benoit, all
On Sun, Oct 25, 2015 at 2:59 AM, Beno?t Th?baudeau <
benoit.thebaudeau.dev at gmail.com <mailto:[email protected]>>
Quoted 4 lines · wrote:
The IPv6 lease file has a different name.
Signed-off-by Beno?t Th?baudeau <[email protected]<mailto:[email protected]>>
Quoted 8 lines
--- Changes v2 -> v3: new patch. --- package/dhcp/dhcp.mk <http://dhcp.mk> | 2 ++ 1 file changed, 2 insertions(+) diff --git a/package/dhcp/dhcp.mk <http://dhcp.mk> b/package/dhcp/dhcp.mk <http://dhcp.mk>
Quoted 12 lines
index c05e694..3aa1577 100644 --- a/package/dhcp/dhcp.mk <http://dhcp.mk> +++ b/package/dhcp/dhcp.mk <http://dhcp.mk> @@ -83,6 +83,8 @@ define DHCP_INSTALL_INIT_SYSTEMD $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf echo "f /var/lib/dhcp/dhcpd.leases - - - - -" >> \ $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf + echo "f /var/lib/dhcp/dhcpd6.leases - - - - -" >> \ + $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf endef endifQuoted 1 line
Reviewed-by "Maxime Hadjinlian" <[email protected] <mailto:
Quoted 8 lines
maxime.hadjinlian at gmail.com>>
Quoted 2 lines
A question though, from the manual page of dhcpd, by default it starts
as an IPv6 server should we have, two services one with '-4' and one with '-6' ? And it's left to the user to specify it in the "$OPTIONS" ? Maybe this should be mentioned somewhere ?
'-4' is the default, not '-6'.
If I look at ./server/dhcpd.8 in the sources of dhcp-4.1-ESVR12, it clearly states:
-6 Run as a DHCPv6 server. This is the default and cannot be combined with -4.
A single instance of dhcpd cannot be run with
Quoted 5 lines
both '-4' and '-6'. I don't know if it's possible (or desirable) to safely run
simultaneously two instances of dhcpd, one with '-4' and the other one with '-6'.
Well it could be useful if you are trying to build a network appliance and you want to support both stack. So you would want to start two processes with different options. Maybe that's something that should be left to the users to figure out.
Quoted 5 lines
"$OPTIONS" is designed exactly for such things. Users should read the man page
of dhcpd to know what may fit in there.
I understood what was "$OPTIONS" about, I just worry that it's a bit "hidden" for the users, but maybe they should know what they are doing.
Quoted 4 lines
Best regards,
Beno?t
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20151104/e8920b7b/attachment.html>
PATCH v3 11/13 package/dhcp: systemd: support IPv6 lease file
Quoted 40 lines · Maxime Hadjinlian
On Wed, Nov 4, 2015 at 11:36 AM, Beno?t Th?baudeau <benoit at wsystem.com <mailto:[email protected]>> wrote:
Maxime, all, On 04/11/2015 11:21, Maxime Hadjinlian wrote: > Hi Benoit, all > > On Sun, Oct 25, 2015 at 2:59 AM, Beno?t Th?baudeau <benoit.thebaudeau.dev at gmail.com <mailto:[email protected]> <mailto:benoit.thebaudeau.dev at gmail.com <mailto:[email protected]>>> wrote: > > The IPv6 lease file has a different name. > > Signed-off-by: Beno?t Th?baudeau <benoit.thebaudeau.dev at gmail.com <mailto:[email protected]> <mailto:benoit.thebaudeau.dev at gmail.com <mailto:[email protected]>>> > > --- > Changes v2 -> v3: new patch. > --- > package/dhcp/dhcp.mk <http://dhcp.mk> <http://dhcp.mk> | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/package/dhcp/dhcp.mk <http://dhcp.mk> <http://dhcp.mk> b/package/dhcp/dhcp.mk <http://dhcp.mk> <http://dhcp.mk> > index c05e694..3aa1577 100644 > --- a/package/dhcp/dhcp.mk <http://dhcp.mk> <http://dhcp.mk> > +++ b/package/dhcp/dhcp.mk <http://dhcp.mk> <http://dhcp.mk> > @@ -83,6 +83,8 @@ define DHCP_INSTALL_INIT_SYSTEMD > $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf > echo "f /var/lib/dhcp/dhcpd.leases - - - - -" >> \ > $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf > + echo "f /var/lib/dhcp/dhcpd6.leases - - - - -" >> \ > + $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf > endef > endif > > Reviewed-by: "Maxime Hadjinlian" <maxime.hadjinlian at gmail.com <mailto:[email protected]> <mailto:maxime.hadjinlian at gmail.com <mailto:[email protected]>>> > > A question though, from the manual page of dhcpd, by default it starts as an IPv6 server should we have, two services one with '-4' and one with '-6' ? And it's left to the user to specify it in the "$OPTIONS" ? Maybe this should be mentioned somewhere ? '-4' is the default, not '-6'.
Quoted 3 lines
If I look at ./server/dhcpd.8 in the sources of dhcp-4.1-ESVR12, it clearly states:
-6 Run as a DHCPv6 server. This is the default and cannot be combined with -4.
My bad: I had looked at the man page of another version.
Quoted 6 lines
A single instance of dhcpd cannot be run with
both '-4' and '-6'. I don't know if it's possible (or desirable) to safely run simultaneously two instances of dhcpd, one with '-4' and the other one with '-6'.Well it could be useful if you are trying to build a network appliance and you want to support both stack. So you would want to start two processes with different options. Maybe that's something that should be left to the users to figure out.
Yes, but should everything be duplicated in Buildroot just for this purpose? For SysV, it's easy not to duplicate things, but how would you do that with systemd? How do distributions handle this?
Quoted 4 lines
"$OPTIONS" is designed exactly for such things. Users should read the man page of dhcpd to know what may fit in there.
I understood what was "$OPTIONS" about, I just worry that it's a bit "hidden" for the users, but maybe they should know what they are doing.
It's not possible to document everything, but there are comments about the meaning of these variables in the SysV init scripts, so I can add such comments to the .service files too.
Best regards,
Beno?t
PATCH v3 11/13 package/dhcp: systemd: support IPv6 lease file
[-SNIP-]
Quoted 13 lines
Quoted 3 lines
A single instance of dhcpd cannot be run with
both '-4' and '-6'. I don't know if it's possible (or desirable) tosafely run
Quoted 1 line
simultaneously two instances of dhcpd, one with '-4' and the other
one with
Quoted 3 lines
'-6'.Well it could be useful if you are trying to build a network appliance
and you want to support both stack. So you would want to start two processes with different options. Maybe that's something that should be left to the users to figure out.
Quoted 6 lines
Yes, but should everything be duplicated in Buildroot just for this purpose? For
SysV, it's easy not to duplicate things, but how would you do that with systemd?
How do distributions handle this?
I only looked at Arch Linux, they duplicate the service file. It's also possible to use the template mechanisms in systemd, to have something like dhcpd at .service and when you enable it, you create a symlink called dhcpd at 4.service, and the '4' is passed as argument to the template and you can use it however you want it to.
Quoted 5 lines
Quoted 2 lines
"$OPTIONS" is designed exactly for such things. Users should read
the man page
Quoted 2 lines
of dhcpd to know what may fit in there.
Quoted 8 lines
Quoted 1 line
I understood what was "$OPTIONS" about, I just worry that it's a bit
"hidden" for the users, but maybe they should know what they are doing.
It's not possible to document everything, but there are comments about the meaning of these variables in the SysV init scripts, so I can add such comments
to the .service files too.
Maybe that would be a good thing, I don't have a clear opinion on this, do other want to weigh in ?
Quoted 4 lines
Best regards,
Beno?t
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20151104/d07e34d5/attachment.html>
PATCH v3 11/13 package/dhcp: systemd: support IPv6 lease file
Hi Maxime, all,
Quoted 9 lines · Maxime Hadjinlian
Quoted 9 lines
Quoted 7 lines
Quoted 1 line
A question though, from the manual page of dhcpd, by default it starts as an IPv6 server should we have, two services one with '-4' and one with '-6' ? And it's left to the user to specify it in the "$OPTIONS" ? Maybe this should be mentioned somewhere ?
'-4' is the default, not '-6'.If I look at ./server/dhcpd.8 in the sources of dhcp-4.1-ESVR12, it clearly states:
-6 Run as a DHCPv6 server. This is the default and cannot be combined with -4.
My bad: I had looked at the man page of another version.
Actually, this dhcpd.8 is wrong. Looking at common/discover.c:
int local_family = AF_INET;
So IPv4 really is the default, and this is confirmed by the behavior.
This documentation issue is fixed in 4.3.3. A version bump would be great, all the more the EoL date of 4.1-ESV-R12 is Dec. 2015. I'll see if I can quickly add that to my series.
Quoted 5 lines
Quoted 5 lines
A single instance of dhcpd cannot be run with
both '-4' and '-6'. I don't know if it's possible (or desirable) to safely run simultaneously two instances of dhcpd, one with '-4' and the other one with '-6'.
Quoted 7 lines
Quoted 1 line
Well it could be useful if you are trying to build a network appliance and you want to support both stack. So you would want to start two processes with different options. Maybe that's something that should be left to the users to figure out.
Yes, but should everything be duplicated in Buildroot just for this purpose? For SysV, it's easy not to duplicate things, but how would you do that with systemd? How do distributions handle this?
I only looked at Arch Linux, they duplicate the service file. It's also possible to use the template mechanisms in systemd, to have something like dhcpd at .service and when you enable it, you create a symlink called dhcpd at 4.service, and the '4' is passed as argument to the template and you can use it however you want it to.
Ubuntu duplicates the service files too. And all the service files come from the same package.
How do we want to handle that in Buildroot?
1/ Always start IPv4 and IPv6 instances like Ubuntu does. This is wasting
resources if one of them is actually unused.
2/ Add a Kconfig choice - common to all the selected DHCP daemons - between
"only IPv4", "only IPv6", and "IPv4 + IPv6".
3/ Use /etc/default/dhcpd and the like. We could detect the presence of
/etc/default/dhcpd vs. /etc/default/dhcpd6, or of some variables in them, or of /etc/dhcp/dhcpd.conf vs. /etc/dhcp/dhcpd6.conf. Something like that seems to be easier to use, but less obvious for users unless well documented.
Best regards,
Beno?t
PATCH v3 11/13 package/dhcp: systemd: support IPv6 lease file
Hi Benoit, all
Quoted 21 lines · Beno?t Th?baudeau
Hi Maxime, all,
Quoted 1 line · Maxime Hadjinlian
Quoted 1 line
Quoted 1 line
Quoted 1 line
A question though, from the manual page of dhcpd, by default it
starts as an IPv6 server should we have, two services one with '-4' and one with '-6' ? And it's left to the user to specify it in the "$OPTIONS" ? Maybe this should be mentioned somewhere ?
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
'-4' is the default, not '-6'.If I look at ./server/dhcpd.8 in the sources of dhcp-4.1-ESVR12, it
clearly states:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
-6 Run as a DHCPv6 server. This is the default and cannot be combined
with -4.
Quoted 2 lines
Quoted 2 lines
My bad: I had looked at the man page of another version.
Actually, this dhcpd.8 is wrong. Looking at
common/discover.c:int local_family = AF_INET;
Quoted 8 lines
So IPv4 really is the default, and this is confirmed by the behavior.
This documentation issue is fixed in 4.3.3. A version bump would be great, all
the more the EoL date of 4.1-ESV-R12 is Dec. 2015. I'll see if I can quickly add
that to my series.
Ah, that explains everything. Indeed, a bump would be nice if you could squeeze it, otherwise I'm sure it'll be done pretty quickly, DHCP is a pretty used package after all :).
Quoted 41 lines
Quoted 3 lines
Quoted 3 lines
A single instance of dhcpd cannot be run with both '-4' and '-6'. I don't know if it's possible (or
desirable) to safely run
Quoted 1 line
Quoted 1 line
simultaneously two instances of dhcpd, one with '-4' and the
other one with
Quoted 3 lines
Quoted 3 lines
'-6'.Well it could be useful if you are trying to build a network
appliance and you want to support both stack. So you would want to start two processes with different options. Maybe that's something that should be left to the users to figure out.
Quoted 2 lines
Yes, but should everything be duplicated in Buildroot just for this
purpose? For
Quoted 1 line
SysV, it's easy not to duplicate things, but how would you do that
with systemd?
Quoted 3 lines
How do distributions handle this?
I only looked at Arch Linux, they duplicate the service file. It's also
possible to use the template mechanisms in systemd, to have something like dhcpd at .service and when you enable it, you create a symlink called dhcpd at 4.service, and the '4' is passed as argument to the template and you can use it however you want it to.
Ubuntu duplicates the service files too. And all the service files come from the
same package.How do we want to handle that in Buildroot?
1/ Always start IPv4 and IPv6 instances like Ubuntu does. This is wasting
resources if one of them is actually unused.
2/ Add aKconfigchoice - common to all the selected DHCP daemons - between
"only IPv4", "only IPv6", and "IPv4 + IPv6".
3/ Use/etc/default/dhcpdand the like. We could detect the presence of
/etc/default/dhcpdvs./etc/default/dhcpd6, or of some variables in
them, or
of/etc/dhcp/dhcpd.confvs./etc/dhcp/dhcpd6.conf. Something like that
seems
to be easier to use, but less obvious for users unless well documented.
Quoted 1 line
In my humble opinion, I would go for the
Kconfigoptions as I find this
easier for the end user and to maintain.
Quoted 3 lines
Best regards,
Beno?t
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20151112/3f60a172/attachment.html>
PATCH v3 11/13 package/dhcp: systemd: support IPv6 lease file
Hi Maxime, all,
Quoted 44 lines · Maxime Hadjinlian
Quoted 29 lines · Beno?t Th?baudeau
Quoted 18 lines · Maxime Hadjinlian
Quoted 2 lines
A single instance of dhcpd cannot be run with both '-4' and '-6'. I don't know if it's possible (or
desirable) to safely run
Quoted 1 line
simultaneously two instances of dhcpd, one with '-4' and the
other one with
Quoted 3 lines
'-6'.Well it could be useful if you are trying to build a network
appliance and you want to support both stack. So you would want to start two processes with different options. Maybe that's something that should be left to the users to figure out.
Yes, but should everything be duplicated in Buildroot just for this
purpose? For
SysV, it's easy not to duplicate things, but how would you do that
with systemd?
How do distributions handle this?Quoted 5 lines
I only looked at Arch Linux, they duplicate the service file. It's also possible to use the template mechanisms in systemd, to have something like dhcpd at .service and when you enable it, you create a symlink called dhcpd at 4.service, and the '4' is passed as argument to the template and you can use it however you want it to.
Ubuntu duplicates the service files too. And all the service files come from the
same package.Quoted 13 lines
How do we want to handle that in Buildroot?
1/ Always start IPv4 and IPv6 instances like Ubuntu does. This is wasting
resources if one of them is actually unused.
2/ Add aKconfigchoice - common to all the selected DHCP daemons - between
"only IPv4", "only IPv6", and "IPv4 + IPv6".
3/ Use/etc/default/dhcpdand the like. We could detect the presence of
/etc/default/dhcpdvs./etc/default/dhcpd6, or of some variables in
them, or
of/etc/dhcp/dhcpd.confvs./etc/dhcp/dhcpd6.conf. Something like that
seems
to be easier to use, but less obvious for users unless well documented.
Quoted 2 lines
In my humble opinion, I would go for the
Kconfigoptions as I find this easier for the end user and to maintain.
Actually, I've just noticed that, while it installs both IPv4 and IPv6 startup mechanisms, Ubuntu uses ConditionPathExists with /etc/dhcp/dhcpd.conf and /etc/dhcp/dhcpd6.conf to skip the dhcpd service if its required configuration file is not present, just like what is currently done by Buildroot's S80dhcp-server. In Buildroot, that would mean having to tweak the rootfs overlay and/or the post-build script to choose what to run. This would have to be done anyway with Kconfig options in order not to keep the default dhcpd.conf, which is not very useful, so it may be more flexible not to have Kconfig options. Thomas?
PATCH v3 12/13 package/dhcp: SysV init scripts: refactor using functions
In reply to Benoît ThébaudeauFrom: Beno?t Th?baudeau <[email protected]>
Refactor these scripts using start()/stop() functions rather than having these scripts invoke themselves.
By the way, clean up these scripts.
---
Changes v2 -> v3: none.
Changes v1 -> v2:
- Rebase.
- Use 'printf' instead of 'echo -n' following
0f75b2635ee564fbbdb9ea631cf39fa8731d6d6c.
--- package/dhcp/S80dhcp-relay | 63 +++++++++++++++++++++----------------- package/dhcp/S80dhcp-server | 74 +++++++++++++++++++++++++-------------------- 2 files changed, 76 insertions(+), 61 deletions(-)
package/dhcp/S80dhcp-relay +35 -28
@@ -1,61 +1,68 @@ #!/bin/sh -# -# $Id: dhcp3-relay,v 1.1 2004/04/16 15:41:08 ml Exp $ -# -# What servers should the DHCP relay forward requests to? -# e.g: SERVERS="192.168.0.1" -SERVERS="" +NAME="dhcrelay" +DESC="DHCP relay" +DAEMON="/usr/sbin/${NAME}" -# On what interfaces should the DHCP relay (dhrelay) serve DHCP requests? +# On what interfaces should the DHCP relay serve DHCP requests? INTERFACES="" +# What servers should the DHCP relay forward requests to? +# E.g: SERVERS="192.168.0.1" +SERVERS="" + # Additional options that are passed to the DHCP relay daemon? OPTIONS="" # Read configuration variable file if it is present -CFG_FILE="/etc/default/dhcrelay" +CFG_FILE="/etc/default/${NAME}" [ -r "${CFG_FILE}" ] && . "${CFG_FILE}" # PID files generated by the daemon -PID_FILES="/var/run/dhcrelay.pid /var/run/dhcrelay6.pid" +PID_FILES="/var/run/${NAME}.pid /var/run/${NAME}6.pid" # Sanity checks -test -f /usr/sbin/dhcrelay || exit 0 +test -f "${DAEMON}" || exit 0 test -n "$INTERFACES" || exit 0 test -n "$SERVERS" || exit 0 -# Build command line for interfaces (will be passed to dhrelay below.) +# Build command line for interfaces (will be passed to dhcrelay below). IFCMD="" for I in $INTERFACES; do IFCMD=${IFCMD}"-i "${I}" " done -DHCRELAYPID=/var/run/dhcrelay.pid +start() +{ + printf "Starting ${DESC}: " + start-stop-daemon -S -q -x "${DAEMON}" -- -q $OPTIONS $IFCMD $SERVERS && + echo "OK" || echo "FAIL" +} + +stop() +{ + printf "Stopping ${DESC}: " + if start-stop-daemon -K -q -x "${DAEMON}"; then + # This daemon does not remove its PID file when it exits. + rm -f ${PID_FILES} + echo "OK" + else + echo "FAIL" + fi +} case "$1" in start) - printf "Starting DHCP relay: " - start-stop-daemon -S -q -x /usr/sbin/dhcrelay -- -q $OPTIONS $IFCMD $SERVERS - [ $? = 0 ] && echo "OK" || echo "FAIL" + start ;; stop) - printf "Stopping DHCP relay: " - if start-stop-daemon -K -q -x /usr/sbin/dhcrelay; then - # This daemon does not remove its PID file when it exits. - rm -f ${PID_FILES} - echo "OK" - else - echo "FAIL" - fi + stop ;; - restart | force-reload) - $0 stop - $0 start + restart|force-reload) + stop + start ;; *) echo "Usage: $0 {start|stop|restart|force-reload}" exit 1 esac - -exit 0
package/dhcp/S80dhcp-server +41 -33
98 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v3 13/13 package/dhcp: systemd: add dhcrelay service file
In reply to Benoît ThébaudeauAdd a systemd service file to start dhcrelay.
The network interfaces to listen on must be set via the variable IFCMD in /etc/default/dhcrelay, e.g.:
IFCMD="-i eth0 -i eth1"
The "upstream" servers to pass the queries along to must be set via the variable SERVERS in the same file, e.g.:
SERVERS="server0 server1"
Extra command line options can be set via the variable OPTIONS in the same file.
---
Changes v2 -> v3: new patch.
--- package/dhcp/dhcp.mk | 45 ++++++++++++++++++++++++++++--------------- package/dhcp/dhcrelay.service | 13 +++++++++++++ 2 files changed, 42 insertions(+), 16 deletions(-) create mode 100644 package/dhcp/dhcrelay.service
package/dhcp/dhcp.mk +29 -16
@@ -37,6 +37,23 @@ define DHCP_INSTALL_SERVER $(INSTALL) -m 0644 -D package/dhcp/dhcpd.conf \ $(TARGET_DIR)/etc/dhcp/dhcpd.conf endef + +define DHCP_INSTALL_SERVER_INIT_SYSTEMD + $(INSTALL) -D -m 644 package/dhcp/dhcpd.service \ + $(TARGET_DIR)/usr/lib/systemd/system/dhcpd.service + + mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants + + ln -sf ../../../../usr/lib/systemd/system/dhcpd.service \ + $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/dhcpd.service + + echo "d /var/lib/dhcp 0755 - - - -" > \ + $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf + echo "f /var/lib/dhcp/dhcpd.leases - - - - -" >> \ + $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf + echo "f /var/lib/dhcp/dhcpd6.leases - - - - -" >> \ + $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf +endef endif ifeq ($(BR2_PACKAGE_DHCP_RELAY),y)
@@ -46,6 +63,16 @@ define DHCP_INSTALL_RELAY $(INSTALL) -m 0755 -D $(DHCP_DIR)/relay/dhcrelay \ $(TARGET_DIR)/usr/sbin/dhcrelay endef + +define DHCP_INSTALL_RELAY_INIT_SYSTEMD + $(INSTALL) -D -m 644 package/dhcp/dhcrelay.service \ + $(TARGET_DIR)/usr/lib/systemd/system/dhcrelay.service + + mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants + + ln -sf ../../../../usr/lib/systemd/system/dhcrelay.service \ + $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/dhcrelay.service +endef endif ifeq ($(BR2_PACKAGE_DHCP_CLIENT),y)
@@ -69,24 +96,10 @@ define DHCP_INSTALL_INIT_SYSV $(TARGET_DIR)/etc/init.d/S80dhcp-relay endef -ifeq ($(BR2_PACKAGE_DHCP_SERVER),y) define DHCP_INSTALL_INIT_SYSTEMD - $(INSTALL) -D -m 644 package/dhcp/dhcpd.service \ - $(TARGET_DIR)/usr/lib/systemd/system/dhcpd.service - - mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants - - ln -sf ../../../../usr/lib/systemd/system/dhcpd.service \ - $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/dhcpd.service - - echo "d /var/lib/dhcp 0755 - - - -" > \ - $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf - echo "f /var/lib/dhcp/dhcpd.leases - - - - -" >> \ - $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf - echo "f /var/lib/dhcp/dhcpd6.leases - - - - -" >> \ - $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf + $(DHCP_INSTALL_SERVER_INIT_SYSTEMD) + $(DHCP_INSTALL_RELAY_INIT_SYSTEMD) endef -endif define DHCP_INSTALL_TARGET_CMDS $(DHCP_INSTALL_RELAY)
package/dhcp/dhcrelay.service new file +13 -0
@@ -0,0 +1,13 @@ +[Unit] +Description=DHCP relay +After=network.target + +[Service] +Type=forking +PIDFile=/run/dhcrelay.pid +ExecStart=/usr/sbin/dhcrelay -q -pf /run/dhcrelay.pid $OPTIONS $IFCMD $SERVERS +KillSignal=SIGINT +EnvironmentFile=/etc/default/dhcrelay + +[Install] +WantedBy=multi-user.target
Signature · 1 line
2.1.4
PATCH v3 13/13 package/dhcp: systemd: add dhcrelay service file
Hi Benoit, all
Quoted 115 lines · Beno?t Th?baudeau
Add a systemd service file to start dhcrelay.
The network interfaces to listen on must be set via the variable IFCMD in
/etc/default/dhcrelay, e.g.:IFCMD="-i eth0 -i eth1"The "upstream" servers to pass the queries along to must be set via the variable SERVERS in the same file, e.g.:
SERVERS="server0 server1"
Extra command line options can be set via the variable OPTIONS in the same file.
Signed-off-by Beno?t Th?baudeau <[email protected]>---
Changes v2 -> v3: new patch.--- package/dhcp/dhcp.mk | 45 ++++++++++++++++++++++++++++--------------- package/dhcp/dhcrelay.service | 13 +++++++++++++ 2 files changed, 42 insertions(+), 16 deletions(-) create mode 100644 package/dhcp/dhcrelay.servicepackage/dhcp/dhcp.mk +17
-0@@ -37,6 +37,23 @@ define DHCP_INSTALL_SERVER $(INSTALL) -m 0644 -D package/dhcp/dhcpd.conf \ $(TARGET_DIR)/etc/dhcp/dhcpd.conf endef + +define DHCP_INSTALL_SERVER_INIT_SYSTEMD + $(INSTALL) -D -m 644 package/dhcp/dhcpd.service \ + $(TARGET_DIR)/usr/lib/systemd/system/dhcpd.service + + mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants + + ln -sf ../../../../usr/lib/systemd/system/dhcpd.service \ + $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/dhcpd.service + + echo "d /var/lib/dhcp 0755 - - - -" > \ + $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf + echo "f /var/lib/dhcp/dhcpd.leases - - - - -" >> \ + $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf + echo "f /var/lib/dhcp/dhcpd6.leases - - - - -" >> \ + $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf +endef endififeq ($(BR2_PACKAGE_DHCP_RELAY),y)
package/dhcp/dhcp.mk +10
-0@@ -46,6 +63,16 @@ define DHCP_INSTALL_RELAY $(INSTALL) -m 0755 -D $(DHCP_DIR)/relay/dhcrelay \ $(TARGET_DIR)/usr/sbin/dhcrelay endef + +define DHCP_INSTALL_RELAY_INIT_SYSTEMD + $(INSTALL) -D -m 644 package/dhcp/dhcrelay.service \ + $(TARGET_DIR)/usr/lib/systemd/system/dhcrelay.service + + mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants + + ln -sf ../../../../usr/lib/systemd/system/dhcrelay.service \ + $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/dhcrelay.service +endef endififeq ($(BR2_PACKAGE_DHCP_CLIENT),y)
package/dhcp/dhcp.mk +2
-16@@ -69,24 +96,10 @@ define DHCP_INSTALL_INIT_SYSV $(TARGET_DIR)/etc/init.d/S80dhcp-relay endef -ifeq ($(BR2_PACKAGE_DHCP_SERVER),y) define DHCP_INSTALL_INIT_SYSTEMD - $(INSTALL) -D -m 644 package/dhcp/dhcpd.service \ - $(TARGET_DIR)/usr/lib/systemd/system/dhcpd.service - - mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants - - ln -sf ../../../../usr/lib/systemd/system/dhcpd.service \ - $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/dhcpd.service - - echo "d /var/lib/dhcp 0755 - - - -" > \ - $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf - echo "f /var/lib/dhcp/dhcpd.leases - - - - -" >> \ - $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf - echo "f /var/lib/dhcp/dhcpd6.leases - - - - -" >> \ - $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf + $(DHCP_INSTALL_SERVER_INIT_SYSTEMD) + $(DHCP_INSTALL_RELAY_INIT_SYSTEMD) endef -endif define DHCP_INSTALL_TARGET_CMDS$(DHCP_INSTALL_RELAY)package/dhcp/dhcrelay.service new file +8
-0@@ -0,0 +1,13 @@ +[Unit] +Description=DHCP relay +After=network.target + +[Service] +Type=forking +PIDFile=/run/dhcrelay.pid +ExecStart=/usr/sbin/dhcrelay -q -pf /run/dhcrelay.pid $OPTIONS $IFCMD
Quoted 2 lines
$SERVERS
Why don't we want /var/run/dhcrelay.pid which is the default ?
Quoted 2 lines
+KillSignal=SIGINT
I did not try to run it, but it doesn't react to SIGTERM ? I did not see anything in the code to prevent it but I only looked at it pretty quickly.
Quoted 2 lines
+EnvironmentFile=/etc/default/dhcrelay
Should be 'EnvironmentFile=-/etc/default/dhcrelay'
Quoted 7 lines
package/dhcp/dhcrelay.service new file +3
-1+ +[Install] +WantedBy=multi-user.target --2.1.4
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20151104/23c97039/attachment.html>
PATCH v3 13/13 package/dhcp: systemd: add dhcrelay service file
Hi Maxime, all,
Quoted 114 lines · Maxime Hadjinlian
On Sun, Oct 25, 2015 at 2:59 AM, Beno?t Th?baudeau <benoit.thebaudeau.dev at gmail.com <mailto:[email protected]>> wrote:
Add a systemd service file to start dhcrelay. The network interfaces to listen on must be set via the variable IFCMD in /etc/default/dhcrelay, e.g.: IFCMD="-i eth0 -i eth1" The "upstream" servers to pass the queries along to must be set via the variable SERVERS in the same file, e.g.: SERVERS="server0 server1" Extra command line options can be set via the variable OPTIONS in the same file. Signed-off-by: Beno?t Th?baudeau <benoit.thebaudeau.dev at gmail.com <mailto:[email protected]>> --- Changes v2 -> v3: new patch. --- package/dhcp/dhcp.mk <http://dhcp.mk> | 45 ++++++++++++++++++++++++++++--------------- package/dhcp/dhcrelay.service | 13 +++++++++++++ 2 files changed, 42 insertions(+), 16 deletions(-) create mode 100644 package/dhcp/dhcrelay.service diff --git a/package/dhcp/dhcp.mk <http://dhcp.mk> b/package/dhcp/dhcp.mk <http://dhcp.mk> index 3aa1577..4ba302b 100644 --- a/package/dhcp/dhcp.mk <http://dhcp.mk> +++ b/package/dhcp/dhcp.mk <http://dhcp.mk> @@ -37,6 +37,23 @@ define DHCP_INSTALL_SERVER $(INSTALL) -m 0644 -D package/dhcp/dhcpd.conf \ $(TARGET_DIR)/etc/dhcp/dhcpd.conf endef + +define DHCP_INSTALL_SERVER_INIT_SYSTEMD + $(INSTALL) -D -m 644 package/dhcp/dhcpd.service \ + $(TARGET_DIR)/usr/lib/systemd/system/dhcpd.service + + mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants + + ln -sf ../../../../usr/lib/systemd/system/dhcpd.service \ + $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/dhcpd.service + + echo "d /var/lib/dhcp 0755 - - - -" > \ + $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf + echo "f /var/lib/dhcp/dhcpd.leases - - - - -" >> \ + $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf + echo "f /var/lib/dhcp/dhcpd6.leases - - - - -" >> \ + $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf +endef endif ifeq ($(BR2_PACKAGE_DHCP_RELAY),y) @@ -46,6 +63,16 @@ define DHCP_INSTALL_RELAY $(INSTALL) -m 0755 -D $(DHCP_DIR)/relay/dhcrelay \ $(TARGET_DIR)/usr/sbin/dhcrelay endef + +define DHCP_INSTALL_RELAY_INIT_SYSTEMD + $(INSTALL) -D -m 644 package/dhcp/dhcrelay.service \ + $(TARGET_DIR)/usr/lib/systemd/system/dhcrelay.service + + mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants + + ln -sf ../../../../usr/lib/systemd/system/dhcrelay.service \ + $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/dhcrelay.service +endef endif ifeq ($(BR2_PACKAGE_DHCP_CLIENT),y) @@ -69,24 +96,10 @@ define DHCP_INSTALL_INIT_SYSV $(TARGET_DIR)/etc/init.d/S80dhcp-relay endef -ifeq ($(BR2_PACKAGE_DHCP_SERVER),y) define DHCP_INSTALL_INIT_SYSTEMD - $(INSTALL) -D -m 644 package/dhcp/dhcpd.service \ - $(TARGET_DIR)/usr/lib/systemd/system/dhcpd.service - - mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants - - ln -sf ../../../../usr/lib/systemd/system/dhcpd.service \ - $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/dhcpd.service - - echo "d /var/lib/dhcp 0755 - - - -" > \ - $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf - echo "f /var/lib/dhcp/dhcpd.leases - - - - -" >> \ - $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf - echo "f /var/lib/dhcp/dhcpd6.leases - - - - -" >> \ - $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf + $(DHCP_INSTALL_SERVER_INIT_SYSTEMD) + $(DHCP_INSTALL_RELAY_INIT_SYSTEMD) endef -endif define DHCP_INSTALL_TARGET_CMDS $(DHCP_INSTALL_RELAY) diff --git a/package/dhcp/dhcrelay.service b/package/dhcp/dhcrelay.service new file mode 100644 index 0000000..5a1410e --- /dev/null +++ b/package/dhcp/dhcrelay.service @@ -0,0 +1,13 @@ +[Unit] +Description=DHCP relay +After=network.target + +[Service] +Type=forking +PIDFile=/run/dhcrelay.pid +ExecStart=/usr/sbin/dhcrelay -q -pf /run/dhcrelay.pid $OPTIONS $IFCMD $SERVERS
Quoted 1 line
Why don't we want
/var/run/dhcrelay.pidwhich is the default ?
I did that to be consistent with what had been done for dhcpd.service.
/run is the new norm, but Buildroot configures the dhcp package to use /var/run as the default, and the SysV init scripts stick to that.
I don't know Buildroot's rules about that if any. Maybe dhcp.mk should just be updated to use /run. Thomas?
Quoted 3 lines
+KillSignal=SIGINT
I did not try to run it, but it doesn't react to SIGTERM ? I did not see anything in the code to prevent it but I only looked at it pretty quickly.
It's also from dhcpd.service. I've searched around and I've not found a good reason for it, but there must be one. I'll try and dig more.
Quoted 3 lines
+EnvironmentFile=/etc/default/dhcrelay
Should be 'EnvironmentFile=-/etc/default/dhcrelay'
This is on purpose. This file is required because IFCMD and SERVERS are required too.
Quoted 5 lines
+
+[Install]
+WantedBy=multi-user.target
--
2.1.4Best regards,
Beno?t
PATCH v3 13/13 package/dhcp: systemd: add dhcrelay service file
Quoted 4 lines · Beno?t Th?baudeau
Hi Maxime, all,
Quoted 1 line · Maxime Hadjinlian
On Sun, Oct 25, 2015 at 2:59 AM, Beno?t Th?baudeau <benoit.thebaudeau.dev at gmail.com <mailto:[email protected]>> wrote:
[snip]
Quoted 11 lines
Quoted 3 lines
+ExecStart=/usr/sbin/dhcrelay -q -pf
/run/dhcrelay.pid$OPTIONS $IFCMD $SERVERSWhy don't we want
/var/run/dhcrelay.pidwhich is the default ?I did that to be consistent with what had been done for dhcpd.service.
/run is the new norm, but Buildroot configures the dhcp package to use
/var/runas the default, and the SysV init scripts stick to that.I don't know Buildroot's rules about that if any. Maybe dhcp.mk should just be updated to use /run. Thomas?
Since /var/run is currently a symlink to /run, it would be good to update
dhcp.mk as you propose. Or perhaps even remove those configures since I think they're the default anyway.
Regards,
Arnout
Quoted 29 lines
Quoted 4 lines
+KillSignal=SIGINT
I did not try to run it, but it doesn't react to SIGTERM ? I did not see anything in the code to prevent it but I only looked at it pretty quickly.
It's also from dhcpd.service. I've searched around and I've not found a good reason for it, but there must be one. I'll try and dig more.
Quoted 3 lines
+EnvironmentFile=/etc/default/dhcrelay
Should be 'EnvironmentFile=-/etc/default/dhcrelay'
This is on purpose. This file is required because IFCMD and SERVERS are required too.
Quoted 5 lines
+ +[Install] +WantedBy=multi-user.target -- 2.1.4Best regards,
Beno?t_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
PATCH v3 13/13 package/dhcp: systemd: add dhcrelay service file
In reply to Benoît ThébaudeauHi Maxime, all,
Quoted 2 lines · Beno?t Th?baudeau
Quoted 1 line · Maxime Hadjinlian
On Sun, Oct 25, 2015 at 2:59 AM, Beno?t Th?baudeau <benoit.thebaudeau.dev at gmail.com <mailto:[email protected]>> wrote:
[...]
Quoted 14 lines
Quoted 14 lines
diff --git a/package/dhcp/dhcrelay.service b/package/dhcp/dhcrelay.service new file mode 100644 index 0000000..5a1410e --- /dev/null +++ b/package/dhcp/dhcrelay.service @@ -0,0 +1,13 @@ +[Unit] +Description=DHCP relay +After=network.target + +[Service] +Type=forking +PIDFile=/run/dhcrelay.pid +ExecStart=/usr/sbin/dhcrelay -q -pf /run/dhcrelay.pid $OPTIONS $IFCMD $SERVERS
[...]
Quoted 6 lines
Quoted 3 lines
+KillSignal=SIGINT
I did not try to run it, but it doesn't react to SIGTERM ? I did not see anything in the code to prevent it but I only looked at it pretty quickly.
It's also from dhcpd.service. I've searched around and I've not found a good reason for it, but there must be one. I'll try and dig more.
There is a reference to it in this very old thread:
http://www.gossamer-threads.com/lists/gentoo/dev/31150
Here too:
https://kb.isc.org/article/AA-01043/0/Recommendations-for-restarting-a-DHCP-failover-pair.html
But this has been implemented in 4.2.0 according to:
https://kb.isc.org/article/AA-01297
But includes/site.h advises against using this feature.
This SIGINT seems to have been copied from Arch Linux for dhcpd.service. This originates from the following commit, which wants to make a difference between reload and stop, but without giving any reason:
https://projects.archlinux.org/svntogit/packages.git/commit/trunk?h=packages/dhcp&id=f60fc1997126ce5f104335d8f09a317300ce8323
Then this commit removed the reload thing:
https://projects.archlinux.org/svntogit/packages.git/commit/trunk?h=packages/dhcp&id=4d45b1bb254995199386eb2c1c8ab703c738d9d6
Looking at the sources, neither 4.1-ESV-R12 nor 4.3.3 seem to make any difference between SIGTERM and SIGINT. Also, contrary to Arch Linux, Ubuntu does not use SIGINT at all for dhcpd or dhcrelay, and it's not because of something in its patches. So I would be in favor of not using SIGINT in Buildroot too.
Quoted 1 line
Quoted 1 line
+EnvironmentFile=/etc/default/dhcrelay
[...]
Quoted 3 lines
Quoted 3 lines
+ +[Install] +WantedBy=multi-user.target
[...]
Best regards,
Beno?t
PATCH v3 1/13 package/dhcp: fix SysV init scripts option passing
In reply to Benoît ThébaudeauDear Beno?t Th?baudeau,
Quoted 13 lines · Beno?t Th?baudeau
From: Beno?t Th?baudeau <[email protected]>
The SysV init scripts have configuration variables like INTERFACES whose contents have to be passed to the daemon. These variables are initialized as empty strings, but some of them are not allowed to be empty and there was no means of filling them apart from creating a root FS overlay to overwrite these scripts.
This commit adds support for files under
/etc/default/to set these configuration variables. Such light files can now be added to the root FS skeleton or overlays without having to duplicate most of the SysV init scripts.
Quoted 4 lines
Signed-off-by Beno?t Th?baudeau <[email protected]>---
Changes v2 -> v3: none.
I've applied, after adjusting the commit title and explanation, since the change is now only needed for S80dhcp-relay, as S80dhcp-server had already been modified to read /etc/default/dhcpd by a previous commit.
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com