All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH iproute2-next] Makefile: use systemd-tmpfiles to create /var/lib/arpd
@ 2024-03-11 16:57 Max Gautier
  2024-03-11 19:40 ` Stephen Hemminger
  0 siblings, 1 reply; 9+ messages in thread
From: Max Gautier @ 2024-03-11 16:57 UTC (permalink / raw)
  To: netdev; +Cc: Max Gautier

Only apply on systemd systems (detected in the configure script).
The motivation is to build distributions packages without /var to go
towards stateless systems, see link below (TL;DR: provisionning anything
outside of /usr on boot).

The feature flag can be overridden on make invocation:
`make USE_TMPFILES_D=n DESTDIR=<install_loc> install`

Links: https://0pointer.net/blog/projects/stateless.html
---
 Makefile          |  8 +++++++-
 configure         | 14 ++++++++++++++
 etc/tmpfiles.conf |  1 +
 3 files changed, 22 insertions(+), 1 deletion(-)
 create mode 100644 etc/tmpfiles.conf

diff --git a/Makefile b/Makefile
index 8024d45e..8ce69a35 100644
--- a/Makefile
+++ b/Makefile
@@ -101,10 +101,16 @@ config.mk:
 		sh configure $(KERNEL_INCLUDE); \
 	fi
 
+ifeq ($(USE_TMPFILES_D),y)
+INSTALL_ARPDDIR := install -m 0644 -D etc/tmpfiles.conf $(DESTDIR)$(TMPFILESDIR)/iproute2-arpd.conf
+else
+INSTALL_ARPDDIR := install -m 0755 -d $(DESTDIR)$(ARPDDIR)
+endif
+
 install: all
 	install -m 0755 -d $(DESTDIR)$(SBINDIR)
 	install -m 0755 -d $(DESTDIR)$(CONF_USR_DIR)
-	install -m 0755 -d $(DESTDIR)$(ARPDDIR)
+	$(INSTALL_ARPDDIR)
 	install -m 0755 -d $(DESTDIR)$(HDRDIR)
 	@for i in $(SUBDIRS);  do $(MAKE) -C $$i install; done
 	install -m 0644 $(shell find etc/iproute2 -maxdepth 1 -type f) $(DESTDIR)$(CONF_USR_DIR)
diff --git a/configure b/configure
index 928048b3..2e974e75 100755
--- a/configure
+++ b/configure
@@ -432,6 +432,17 @@ check_cap()
 	fi
 }
 
+check_tmpfiles_d()
+{
+    if ${PKG_CONFIG} systemd --exists; then
+        echo "USE_TMPFILES_D ?= y" >>$CONFIG
+        echo "yes"
+        echo 'TMPFILESDIR ?=' "$(${PKG_CONFIG} systemd --variable=tmpfilesdir)" >> $CONFIG
+	else
+		echo "no"
+	fi
+}
+
 check_color()
 {
 	case "$COLOR" in
@@ -615,6 +626,9 @@ check_cap
 echo -n "color output: "
 check_color
 
+echo -n "systemd tmpfiles: "
+check_tmpfiles_d
+
 echo >> $CONFIG
 echo "%.o: %.c" >> $CONFIG
 echo '	$(QUIET_CC)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CPPFLAGS) -c -o $@ $<' >> $CONFIG
diff --git a/etc/tmpfiles.conf b/etc/tmpfiles.conf
new file mode 100644
index 00000000..39c6d13c
--- /dev/null
+++ b/etc/tmpfiles.conf
@@ -0,0 +1 @@
+d %S/arpd 0755
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH iproute2-next] Makefile: use systemd-tmpfiles to create /var/lib/arpd
  2024-03-11 16:57 [PATCH iproute2-next] Makefile: use systemd-tmpfiles to create /var/lib/arpd Max Gautier
@ 2024-03-11 19:40 ` Stephen Hemminger
  2024-03-11 22:28   ` Max Gautier
  0 siblings, 1 reply; 9+ messages in thread
From: Stephen Hemminger @ 2024-03-11 19:40 UTC (permalink / raw)
  To: Max Gautier; +Cc: netdev

On Mon, 11 Mar 2024 17:57:27 +0100
Max Gautier <mg@max.gautier.name> wrote:

> Only apply on systemd systems (detected in the configure script).
> The motivation is to build distributions packages without /var to go
> towards stateless systems, see link below (TL;DR: provisionning anything
> outside of /usr on boot).
> 
> The feature flag can be overridden on make invocation:
> `make USE_TMPFILES_D=n DESTDIR=<install_loc> install`
> 
> Links: https://0pointer.net/blog/projects/stateless.html

Why does arpd need such hand holding, it is rarely used, maybe should just not be built.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH iproute2-next] Makefile: use systemd-tmpfiles to create /var/lib/arpd
  2024-03-11 19:40 ` Stephen Hemminger
@ 2024-03-11 22:28   ` Max Gautier
  2024-03-12  1:30     ` Stephen Hemminger
  0 siblings, 1 reply; 9+ messages in thread
From: Max Gautier @ 2024-03-11 22:28 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev

On Mon, Mar 11, 2024 at 12:40:03PM -0700, Stephen Hemminger wrote:
> On Mon, 11 Mar 2024 17:57:27 +0100
> Max Gautier <mg@max.gautier.name> wrote:
> 
> > Only apply on systemd systems (detected in the configure script).
> > The motivation is to build distributions packages without /var to go
> > towards stateless systems, see link below (TL;DR: provisionning anything
> > outside of /usr on boot).
> > 
> > The feature flag can be overridden on make invocation:
> > `make USE_TMPFILES_D=n DESTDIR=<install_loc> install`
> > 
> > Links: https://0pointer.net/blog/projects/stateless.html
> 
> Why does arpd need such hand holding, it is rarely used, maybe should just not be built.

The commit introducing the install of that directory is quite old

> commit e48f73d6a5e90d2f883e15ccedf4f53d26bb6e74
> Author: Olaf Rempel <razzor@kopf-tisch.de>
> Date:   Wed Nov 9 15:25:40 2005 +0100
> 
>     iproute2-2.6.14-051107: missing arpd directory
>     
>     arpd requires a directory (/var/lib/arpd/) to run.
>     see attached patch, which lets iproute create this directroy during install.

For the why, arpd.c, L.671:

dbase = dbopen(dbname, O_CREAT|O_RDWR, 0644, DB_HASH, NULL);
if (dbase == NULL) {
    perror("db_open");
    exit(-1);
}

You think arpd should create its directory itself if it does not exists
?

-- 
Max Gautier

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH iproute2-next] Makefile: use systemd-tmpfiles to create /var/lib/arpd
  2024-03-11 22:28   ` Max Gautier
@ 2024-03-12  1:30     ` Stephen Hemminger
  2024-03-12  8:22       ` Max Gautier
  0 siblings, 1 reply; 9+ messages in thread
From: Stephen Hemminger @ 2024-03-12  1:30 UTC (permalink / raw)
  To: Max Gautier; +Cc: netdev

On Mon, 11 Mar 2024 23:28:31 +0100
Max Gautier <mg@max.gautier.name> wrote:

> On Mon, Mar 11, 2024 at 12:40:03PM -0700, Stephen Hemminger wrote:
> > On Mon, 11 Mar 2024 17:57:27 +0100
> > Max Gautier <mg@max.gautier.name> wrote:
> >   
> > > Only apply on systemd systems (detected in the configure script).
> > > The motivation is to build distributions packages without /var to go
> > > towards stateless systems, see link below (TL;DR: provisionning anything
> > > outside of /usr on boot).
> > > 
> > > The feature flag can be overridden on make invocation:
> > > `make USE_TMPFILES_D=n DESTDIR=<install_loc> install`
> > > 
> > > Links: https://0pointer.net/blog/projects/stateless.html  
> > 
> > Why does arpd need such hand holding, it is rarely used, maybe should just not be built.  
> 
> The commit introducing the install of that directory is quite old

The problem is that build environment != runtime environment for embedded systems.
But arpd really is legacy/dead/rotting code at this point.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH iproute2-next] Makefile: use systemd-tmpfiles to create /var/lib/arpd
  2024-03-12  1:30     ` Stephen Hemminger
@ 2024-03-12  8:22       ` Max Gautier
  2024-03-12 21:24         ` Stephen Hemminger
  0 siblings, 1 reply; 9+ messages in thread
From: Max Gautier @ 2024-03-12  8:22 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev

On Mon, Mar 11, 2024 at 06:30:07PM -0700, Stephen Hemminger wrote:
> On Mon, 11 Mar 2024 23:28:31 +0100
> Max Gautier <mg@max.gautier.name> wrote:
> 
> > On Mon, Mar 11, 2024 at 12:40:03PM -0700, Stephen Hemminger wrote:
> > > On Mon, 11 Mar 2024 17:57:27 +0100
> > > Max Gautier <mg@max.gautier.name> wrote:
> > >   
> > > > Only apply on systemd systems (detected in the configure script).
> > > > The motivation is to build distributions packages without /var to go
> > > > towards stateless systems, see link below (TL;DR: provisionning anything
> > > > outside of /usr on boot).
> > > > 
> > > > The feature flag can be overridden on make invocation:
> > > > `make USE_TMPFILES_D=n DESTDIR=<install_loc> install`
> > > > 
> > > > Links: https://0pointer.net/blog/projects/stateless.html  
> > > 
> > > Why does arpd need such hand holding, it is rarely used, maybe should just not be built.  
> > 
> > The commit introducing the install of that directory is quite old
> 
> The problem is that build environment != runtime environment for embedded systems.

That's the same for anything detected by the configure script, right ?
Hence the override capability.

> But arpd really is legacy/dead/rotting code at this point.

Yeah I can see that, not touched since 2016 (mostly). You would rather
just drop it ?

-- 
Max Gautier

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH iproute2-next] Makefile: use systemd-tmpfiles to create /var/lib/arpd
  2024-03-12  8:22       ` Max Gautier
@ 2024-03-12 21:24         ` Stephen Hemminger
  2024-03-12 21:34           ` Max Gautier
  0 siblings, 1 reply; 9+ messages in thread
From: Stephen Hemminger @ 2024-03-12 21:24 UTC (permalink / raw)
  To: Max Gautier; +Cc: netdev

On Tue, 12 Mar 2024 09:22:20 +0100
Max Gautier <mg@max.gautier.name> wrote:

> On Mon, Mar 11, 2024 at 06:30:07PM -0700, Stephen Hemminger wrote:
> > On Mon, 11 Mar 2024 23:28:31 +0100
> > Max Gautier <mg@max.gautier.name> wrote:
> >   
> > > On Mon, Mar 11, 2024 at 12:40:03PM -0700, Stephen Hemminger wrote:  
> > > > On Mon, 11 Mar 2024 17:57:27 +0100
> > > > Max Gautier <mg@max.gautier.name> wrote:
> > > >     
> > > > > Only apply on systemd systems (detected in the configure script).
> > > > > The motivation is to build distributions packages without /var to go
> > > > > towards stateless systems, see link below (TL;DR: provisionning anything
> > > > > outside of /usr on boot).
> > > > > 
> > > > > The feature flag can be overridden on make invocation:
> > > > > `make USE_TMPFILES_D=n DESTDIR=<install_loc> install`
> > > > > 
> > > > > Links: https://0pointer.net/blog/projects/stateless.html    
> > > > 
> > > > Why does arpd need such hand holding, it is rarely used, maybe should just not be built.    
> > > 
> > > The commit introducing the install of that directory is quite old  
> > 
> > The problem is that build environment != runtime environment for embedded systems.  
> 
> That's the same for anything detected by the configure script, right ?
> Hence the override capability.

Configure is mostly about what packages are missing from the build.
It would be better if arpd was just smarter about where to put its
file.

> 
> > But arpd really is legacy/dead/rotting code at this point.  
> 
> Yeah I can see that, not touched since 2016 (mostly). You would rather
> just drop it ?
> 


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH iproute2-next] Makefile: use systemd-tmpfiles to create /var/lib/arpd
  2024-03-12 21:24         ` Stephen Hemminger
@ 2024-03-12 21:34           ` Max Gautier
  2024-03-12 22:19             ` Stephen Hemminger
  0 siblings, 1 reply; 9+ messages in thread
From: Max Gautier @ 2024-03-12 21:34 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev

On Tue, Mar 12, 2024 at 02:24:20PM -0700, Stephen Hemminger wrote:
> On Tue, 12 Mar 2024 09:22:20 +0100
> Max Gautier <mg@max.gautier.name> wrote:
> 
> > On Mon, Mar 11, 2024 at 06:30:07PM -0700, Stephen Hemminger wrote:
> > > On Mon, 11 Mar 2024 23:28:31 +0100
> > > Max Gautier <mg@max.gautier.name> wrote:
> > >   
> > > > On Mon, Mar 11, 2024 at 12:40:03PM -0700, Stephen Hemminger wrote:  
> > > > > On Mon, 11 Mar 2024 17:57:27 +0100
> > > > > Max Gautier <mg@max.gautier.name> wrote:
> > > > >     
> > > > > > Only apply on systemd systems (detected in the configure script).
> > > > > > The motivation is to build distributions packages without /var to go
> > > > > > towards stateless systems, see link below (TL;DR: provisionning anything
> > > > > > outside of /usr on boot).
> > > > > > 
> > > > > > The feature flag can be overridden on make invocation:
> > > > > > `make USE_TMPFILES_D=n DESTDIR=<install_loc> install`
> > > > > > 
> > > > > > Links: https://0pointer.net/blog/projects/stateless.html    
> > > > > 
> > > > > Why does arpd need such hand holding, it is rarely used, maybe should just not be built.    
> > > > 
> > > > The commit introducing the install of that directory is quite old  
> > > 
> > > The problem is that build environment != runtime environment for embedded systems.  
> > 
> > That's the same for anything detected by the configure script, right ?
> > Hence the override capability.
> 
> Configure is mostly about what packages are missing from the build.
> It would be better if arpd was just smarter about where to put its
> file.

What do you mean by smarter ? Trying to found an existing directory
rather than a fixed one ?

> 
> > 
> > > But arpd really is legacy/dead/rotting code at this point.  
> > 
> > Yeah I can see that, not touched since 2016 (mostly). You would rather
> > just drop it ?
> > 
> 

-- 
Max Gautier

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH iproute2-next] Makefile: use systemd-tmpfiles to create /var/lib/arpd
  2024-03-12 21:34           ` Max Gautier
@ 2024-03-12 22:19             ` Stephen Hemminger
  0 siblings, 0 replies; 9+ messages in thread
From: Stephen Hemminger @ 2024-03-12 22:19 UTC (permalink / raw)
  To: Max Gautier; +Cc: netdev

On Tue, 12 Mar 2024 22:34:59 +0100
Max Gautier <mg@max.gautier.name> wrote:

> On Tue, Mar 12, 2024 at 02:24:20PM -0700, Stephen Hemminger wrote:
> > On Tue, 12 Mar 2024 09:22:20 +0100
> > Max Gautier <mg@max.gautier.name> wrote:
> >   
> > > On Mon, Mar 11, 2024 at 06:30:07PM -0700, Stephen Hemminger wrote:  
> > > > On Mon, 11 Mar 2024 23:28:31 +0100
> > > > Max Gautier <mg@max.gautier.name> wrote:
> > > >     
> > > > > On Mon, Mar 11, 2024 at 12:40:03PM -0700, Stephen Hemminger wrote:    
> > > > > > On Mon, 11 Mar 2024 17:57:27 +0100
> > > > > > Max Gautier <mg@max.gautier.name> wrote:
> > > > > >       
> > > > > > > Only apply on systemd systems (detected in the configure script).
> > > > > > > The motivation is to build distributions packages without /var to go
> > > > > > > towards stateless systems, see link below (TL;DR: provisionning anything
> > > > > > > outside of /usr on boot).
> > > > > > > 
> > > > > > > The feature flag can be overridden on make invocation:
> > > > > > > `make USE_TMPFILES_D=n DESTDIR=<install_loc> install`
> > > > > > > 
> > > > > > > Links: https://0pointer.net/blog/projects/stateless.html      
> > > > > > 
> > > > > > Why does arpd need such hand holding, it is rarely used, maybe should just not be built.      
> > > > > 
> > > > > The commit introducing the install of that directory is quite old    
> > > > 
> > > > The problem is that build environment != runtime environment for embedded systems.    
> > > 
> > > That's the same for anything detected by the configure script, right ?
> > > Hence the override capability.  
> > 
> > Configure is mostly about what packages are missing from the build.
> > It would be better if arpd was just smarter about where to put its
> > file.  
> 
> What do you mean by smarter ? Trying to found an existing directory
> rather than a fixed one ?
> 

Isn't there some environment variable that systemd uses to tell a service
where to put its files? If that is present use that.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH iproute2-next] Makefile: use systemd-tmpfiles to create /var/lib/arpd
@ 2024-03-13  9:16 Max Gautier
  0 siblings, 0 replies; 9+ messages in thread
From: Max Gautier @ 2024-03-13  9:16 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev

On Tue, Mar 12, 2024 at 03:19:19PM -0700, Stephen Hemminger wrote:
> On Tue, 12 Mar 2024 22:34:59 +0100
> Max Gautier <mg@max.gautier.name> wrote:
> 
> > On Tue, Mar 12, 2024 at 02:24:20PM -0700, Stephen Hemminger wrote:
> > > On Tue, 12 Mar 2024 09:22:20 +0100
> > > Max Gautier <mg@max.gautier.name> wrote:
> > >   
> > > > On Mon, Mar 11, 2024 at 06:30:07PM -0700, Stephen Hemminger wrote:  
> > > > > On Mon, 11 Mar 2024 23:28:31 +0100
> > > > > Max Gautier <mg@max.gautier.name> wrote:
> > > > >     
> > > > > > On Mon, Mar 11, 2024 at 12:40:03PM -0700, Stephen Hemminger wrote:    
> > > > > > > On Mon, 11 Mar 2024 17:57:27 +0100
> > > > > > > Max Gautier <mg@max.gautier.name> wrote:
> > > > > > >       
> > > > > > > > Only apply on systemd systems (detected in the configure script).
> > > > > > > > The motivation is to build distributions packages without /var to go
> > > > > > > > towards stateless systems, see link below (TL;DR: provisionning anything
> > > > > > > > outside of /usr on boot).
> > > > > > > > 
> > > > > > > > The feature flag can be overridden on make invocation:
> > > > > > > > `make USE_TMPFILES_D=n DESTDIR=<install_loc> install`
> > > > > > > > 
> > > > > > > > Links: https://0pointer.net/blog/projects/stateless.html      
> > > > > > > 
> > > > > > > Why does arpd need such hand holding, it is rarely used, maybe should just not be built.      
> > > > > > 
> > > > > > The commit introducing the install of that directory is quite old    
> > > > > 
> > > > > The problem is that build environment != runtime environment for embedded systems.    
> > > > 
> > > > That's the same for anything detected by the configure script, right ?
> > > > Hence the override capability.  
> > > 
> > > Configure is mostly about what packages are missing from the build.
> > > It would be better if arpd was just smarter about where to put its
> > > file.  
> > 
> > What do you mean by smarter ? Trying to found an existing directory
> > rather than a fixed one ?
> > 
> 
> Isn't there some environment variable that systemd uses to tell a service
> where to put its files? If that is present use that.

Yeah there is StateDirectory that could be used for this (set
STATE_DIRECTORY in the process). I would have done that, but there is no
systemd service file for arpd, and I don't know which options
combination should be preferred for the arpd invocation in the potential
service file.

On another note, I see in the examples sections of the man page the
following:

> arpd -b /var/tmp/arpd.db
>       Start  arpd to collect gratuitous ARP, but not messing with ker‐
>       nel functionality.
> 
> killall arpd ; arpd -l -b /var/tmp/arpd.db
>       Look at result after some time.
> 
> arpd -b /var/tmp/arpd.db -a 1 eth0 eth1
>       Enable kernel helper, leaving leading role to kernel.
> 
> arpd -b /var/tmp/arpd.db -a 3 -k eth0 eth1
>       Completely replace kernel  resolution  on  interfaces  eth0  and
>       eth1. In this case the kernel still does unicast probing to val‐
>       idate  entries, but all the broadcast activity is suppressed and
>       made under authority of arpd.

Looks like all examples use /var/tmp/arpd.db. Maybe that means that
should be the default instead ?

(forgot to cc the list)

-- 
Max Gautier

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-03-13  9:19 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-11 16:57 [PATCH iproute2-next] Makefile: use systemd-tmpfiles to create /var/lib/arpd Max Gautier
2024-03-11 19:40 ` Stephen Hemminger
2024-03-11 22:28   ` Max Gautier
2024-03-12  1:30     ` Stephen Hemminger
2024-03-12  8:22       ` Max Gautier
2024-03-12 21:24         ` Stephen Hemminger
2024-03-12 21:34           ` Max Gautier
2024-03-12 22:19             ` Stephen Hemminger
2024-03-13  9:16 Max Gautier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.