diff mbox

[v3,11/13] package/dhcp: systemd: support IPv6 lease file

Message ID 1445734779-7212-11-git-send-email-benoit.thebaudeau.dev@gmail.com
State Changes Requested
Headers show

Commit Message

Benoît Thébaudeau Oct. 25, 2015, 12:59 a.m. UTC
The IPv6 lease file has a different name.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>

---
Changes v2 -> v3: new patch.
---
 package/dhcp/dhcp.mk | 2 ++
 1 file changed, 2 insertions(+)

Comments

Maxime Hadjinlian Nov. 4, 2015, 10:21 a.m. UTC | #1
Hi Benoit, all

On Sun, Oct 25, 2015 at 2:59 AM, Benoît Thébaudeau <
benoit.thebaudeau.dev@gmail.com> wrote:

> The IPv6 lease file has a different name.
>
> Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
>
> ---
> Changes v2 -> v3: new patch.
> ---
>  package/dhcp/dhcp.mk | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/package/dhcp/dhcp.mk b/package/dhcp/dhcp.mk
> index c05e694..3aa1577 100644
> --- a/package/dhcp/dhcp.mk
> +++ b/package/dhcp/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@gmail.com>

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 ?

> --
> 2.1.4
>
>
Benoît Thébaudeau Nov. 4, 2015, 10:36 a.m. UTC | #2
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@gmail.com <mailto:benoit.thebaudeau.dev@gmail.com>> wrote:
> 
>     The IPv6 lease file has a different name.
> 
>     Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com <mailto:benoit.thebaudeau.dev@gmail.com>>
> 
>     ---
>     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
> 
> Reviewed-by: "Maxime Hadjinlian" <maxime.hadjinlian@gmail.com <mailto:maxime.hadjinlian@gmail.com>>
> 
> 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
Maxime Hadjinlian Nov. 4, 2015, 10:53 a.m. UTC | #3
On Wed, Nov 4, 2015 at 11:36 AM, Benoît Thébaudeau <benoit@wsystem.com>
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@gmail.com <mailto:benoit.thebaudeau.dev@gmail.com>>
> wrote:
> >
> >     The IPv6 lease file has a different name.
> >
> >     Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com
> <mailto:benoit.thebaudeau.dev@gmail.com>>
> >
> >     ---
> >     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
> >
> > Reviewed-by: "Maxime Hadjinlian" <maxime.hadjinlian@gmail.com <mailto:
> maxime.hadjinlian@gmail.com>>
> >
> > 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
> 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.

>
> "$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.

>
> Best regards,
> Benoît
>
Benoît Thébaudeau Nov. 4, 2015, 11:15 a.m. UTC | #4
On 04/11/2015 11:53, Maxime Hadjinlian wrote:
> 
> 
> On Wed, Nov 4, 2015 at 11:36 AM, Benoît Thébaudeau <benoit@wsystem.com <mailto:benoit@wsystem.com>> 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@gmail.com <mailto:benoit.thebaudeau.dev@gmail.com> <mailto:benoit.thebaudeau.dev@gmail.com <mailto:benoit.thebaudeau.dev@gmail.com>>> wrote:
>     >
>     >     The IPv6 lease file has a different name.
>     >
>     >     Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com <mailto:benoit.thebaudeau.dev@gmail.com> <mailto:benoit.thebaudeau.dev@gmail.com <mailto:benoit.thebaudeau.dev@gmail.com>>>
>     >
>     >     ---
>     >     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@gmail.com <mailto:maxime.hadjinlian@gmail.com> <mailto:maxime.hadjinlian@gmail.com <mailto:maxime.hadjinlian@gmail.com>>>
>     >
>     > 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.

>     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?

>     "$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
Maxime Hadjinlian Nov. 4, 2015, 11:31 a.m. UTC | #5
[-SNIP-]

>
> >     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?
>
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@.service and when you enable it, you create a symlink called
dhcpd@4.service, and the '4' is passed as argument to the template and you
can use it however you want it to.

>
> >     "$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.
>
Maybe that would be a good thing, I don't have a clear opinion on this, do
other want to weigh in ?

>
> Best regards,
> Benoît
>
Benoît Thébaudeau Nov. 9, 2015, 10:49 a.m. UTC | #6
Hi Maxime, all,

On 04/11/2015 12:31, Maxime Hadjinlian wrote:
>>>     > 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.

>     >     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?
> 
> 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@.service and when you enable it, you create a symlink called dhcpd@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
Maxime Hadjinlian Nov. 12, 2015, 10:42 a.m. UTC | #7
Hi Benoit, all

On Mon, Nov 9, 2015 at 11:49 AM, Benoît Thébaudeau <benoit@wsystem.com>
wrote:

> Hi Maxime, all,
>
> On 04/11/2015 12:31, Maxime Hadjinlian wrote:
> >>>     > 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.
>
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 :).

>
> >     >     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?
> >
> > 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@.service and when you enable it, you create a symlink called
> dhcpd@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.
>
> In my humble opinion, I would go for the Kconfig options as I find this
easier for the end user and to maintain.

> Best regards,
> Benoît
>
Benoît Thébaudeau Nov. 15, 2015, 5:55 p.m. UTC | #8
Hi Maxime, all,

On Thu, Nov 12, 2015 at 11:42 AM, Maxime Hadjinlian
<maxime.hadjinlian@gmail.com> wrote:
> On Mon, Nov 9, 2015 at 11:49 AM, Benoît Thébaudeau <benoit@wsystem.com>
> wrote:
>> On 04/11/2015 12:31, Maxime Hadjinlian wrote:
>> >     >     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?
>> >
>> > 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@.service and when you enable it, you create a symlink called
>> > dhcpd@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.
>>
> In my humble opinion, I would go for the Kconfig options 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?
diff mbox

Patch

diff --git a/package/dhcp/dhcp.mk b/package/dhcp/dhcp.mk
index c05e694..3aa1577 100644
--- a/package/dhcp/dhcp.mk
+++ b/package/dhcp/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