All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [v2 0/2] package: bootpc: add bootpc and bootp interface configuration
@ 2023-05-26 17:55 Colin Foster
  2023-05-26 17:55 ` [Buildroot] [v2 1/2] package/bootpc: new package Colin Foster
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Colin Foster @ 2023-05-26 17:55 UTC (permalink / raw)
  To: buildroot; +Cc: Yann E. MORIN, Thomas Petazzoni

Believe it or not, there are use cases for running BOOTPC instead of
DHCP or static IP addressing.

The /etc/network/interfaces configuration file allows for the
configuration option

```
iface eth0 inet bootp
```

However, this relies on two things. The first is the existence of the
bootpc application, which is added in patch 1.

That doesn't solve all the problems, however. `bootpc` only works with
interfaces that are up, which leads to a chicken-or-egg problem. Patch 2
utilizes an ancient technique to temporarily bring up an interface
before running the actual bootpc application.

The end result is an interface with the above configuration that
successfully gets an IP address and netmask from a BOOTP server.


---

v2:
  * Mostly check-package fixups and formatting.
  * Remove stale reference to buildroot overlay

---

Colin Foster (2):
  package/bootpc: new package
  bootpc: add dhcp-like configuration ability

 .checkpackageignore                           |  1 +
 package/Config.in                             |  1 +
 package/bootpc/0001-main-fix-build.patch      | 49 +++++++++++
 ...Makefile-remove-strip-from-the-build.patch | 33 +++++++
 package/bootpc/Config.in                      | 20 +++++
 package/bootpc/bootpc.hash                    |  3 +
 package/bootpc/bootpc.mk                      | 39 +++++++++
 package/bootpc/bootpc_dhcp_script             | 86 +++++++++++++++++++
 8 files changed, 232 insertions(+)
 create mode 100644 package/bootpc/0001-main-fix-build.patch
 create mode 100644 package/bootpc/0002-Makefile-remove-strip-from-the-build.patch
 create mode 100644 package/bootpc/Config.in
 create mode 100644 package/bootpc/bootpc.hash
 create mode 100644 package/bootpc/bootpc.mk
 create mode 100644 package/bootpc/bootpc_dhcp_script

-- 
2.25.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

* [Buildroot] [v2 1/2] package/bootpc: new package
  2023-05-26 17:55 [Buildroot] [v2 0/2] package: bootpc: add bootpc and bootp interface configuration Colin Foster
@ 2023-05-26 17:55 ` Colin Foster
  2023-05-26 17:55 ` [Buildroot] [v2 2/2] bootpc: add dhcp-like configuration ability Colin Foster
  2026-11-20 21:47 ` [Buildroot] [v2 0/2] package: bootpc: add bootpc and bootp interface configuration Angelo Compagnucci
  2 siblings, 0 replies; 4+ messages in thread
From: Colin Foster @ 2023-05-26 17:55 UTC (permalink / raw)
  To: buildroot; +Cc: Yann E. MORIN, Thomas Petazzoni

Add the ability to select, build, and run bootpc - a client program for
BOOTP requests.

Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
---

v2:
  * Fix all check-package warnings
  * Add patch messages referencing upstream status
  * Add hashes
  * Add license references

---
 package/Config.in                             |  1 +
 package/bootpc/0001-main-fix-build.patch      | 49 +++++++++++++++++++
 ...Makefile-remove-strip-from-the-build.patch | 33 +++++++++++++
 package/bootpc/Config.in                      |  4 ++
 package/bootpc/bootpc.hash                    |  3 ++
 package/bootpc/bootpc.mk                      | 21 ++++++++
 6 files changed, 111 insertions(+)
 create mode 100644 package/bootpc/0001-main-fix-build.patch
 create mode 100644 package/bootpc/0002-Makefile-remove-strip-from-the-build.patch
 create mode 100644 package/bootpc/Config.in
 create mode 100644 package/bootpc/bootpc.hash
 create mode 100644 package/bootpc/bootpc.mk

diff --git a/package/Config.in b/package/Config.in
index 420ebaa370..4581455c2a 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -2273,6 +2273,7 @@ endif
 	source "package/bmon/Config.in"
 	source "package/bmx7/Config.in"
 	source "package/boinc/Config.in"
+	source "package/bootpc/Config.in"
 	source "package/brcm-patchram-plus/Config.in"
 	source "package/bridge-utils/Config.in"
 	source "package/bwm-ng/Config.in"
diff --git a/package/bootpc/0001-main-fix-build.patch b/package/bootpc/0001-main-fix-build.patch
new file mode 100644
index 0000000000..5c0bc22d16
--- /dev/null
+++ b/package/bootpc/0001-main-fix-build.patch
@@ -0,0 +1,49 @@
+From e957c19edebf256d77c2d9ddaba76147208f978e Mon Sep 17 00:00:00 2001
+From: Colin Foster <colin.foster@in-advantage.com>
+Date: Mon, 20 Mar 2023 11:18:13 -0700
+Subject: [PATCH] main: fix build
+
+When buildroot attempts to compile bootpc, it comes across the following
+error:
+
+main.c:24:18: error: initializer element is not constant
+   24 | FILE * logfile = stderr ;
+      |                  ^~~~~~
+
+Fix this error by removing logfile entirely, and simply use stderr in
+all fprintf() calls.
+
+Upstream: N/A Has been sent to main developer, but project seems stale.
+Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
+---
+ main.c | 8 +++-----
+ 1 file changed, 3 insertions(+), 5 deletions(-)
+
+diff --git a/main.c b/main.c
+index 6774cf1..0aa3767 100644
+--- a/main.c
++++ b/main.c
+@@ -21,8 +21,6 @@
+ 
+ #include "bootpc.h"
+ 
+-FILE * logfile = stderr ;
+-
+ int main(int argc,
+ 	 char *argv[])
+ {
+@@ -159,8 +157,8 @@ void doLogMessage(char * s, ...) {
+     va_list args;
+ 
+     va_start(args, s);
+-    fprintf(logfile, "* ");
+-    vfprintf(logfile, s, args);
+-    fprintf(logfile, "\n");
++    fprintf(stderr, "* ");
++    vfprintf(stderr, s, args);
++    fprintf(stderr, "\n");
+     va_end(args);
+ }
+-- 
+2.25.1
+
diff --git a/package/bootpc/0002-Makefile-remove-strip-from-the-build.patch b/package/bootpc/0002-Makefile-remove-strip-from-the-build.patch
new file mode 100644
index 0000000000..43efc5dd80
--- /dev/null
+++ b/package/bootpc/0002-Makefile-remove-strip-from-the-build.patch
@@ -0,0 +1,33 @@
+From 93ea730f4a6b9c6c786bbdad98213ddccc668986 Mon Sep 17 00:00:00 2001
+From: Colin Foster <colin.foster@in-advantage.com>
+Date: Mon, 20 Mar 2023 11:35:12 -0700
+Subject: [PATCH] Makefile: remove strip from the build
+
+Stripping of binary symbols should be an optional step after a build,
+not forced during every build.
+
+Upstream: N/A Has been sent to main developer, but project seems stale.
+Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
+---
+ Makefile | 2 --
+ 1 file changed, 2 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index 4189648..54562ba 100644
+--- a/Makefile
++++ b/Makefile
+@@ -33,11 +33,9 @@ clean:
+ 
+ ${PROG}: ${OBJS}
+ 	${CC} -o ${PROG} ${CFLAGS} ${OBJS}
+-	strip ${PROG}
+ 
+ ${PROG}-static: ${OBJS}
+ 	${CC} -static -o ${PROG} ${CFLAGS} ${OBJS}
+-	strip ${PROG}
+ 
+ # Make up a distribution file from the bits we want people to see
+ distrib:  $(CFILES) $(CHEADS) $(MISC)
+-- 
+2.25.1
+
diff --git a/package/bootpc/Config.in b/package/bootpc/Config.in
new file mode 100644
index 0000000000..59c6a6e739
--- /dev/null
+++ b/package/bootpc/Config.in
@@ -0,0 +1,4 @@
+config BR2_PACKAGE_BOOTPC
+	bool "bootpc"
+	help
+	  Application to perform BOOTP
diff --git a/package/bootpc/bootpc.hash b/package/bootpc/bootpc.hash
new file mode 100644
index 0000000000..cfa7f49944
--- /dev/null
+++ b/package/bootpc/bootpc.hash
@@ -0,0 +1,3 @@
+sha256  b3ec94a1881f5dc4f7ad7832448bc5bd028bb413eac7032b481f2d8713910ba8  bootpc-80c0811dc69f9f3923661be4f9f9c09a44313f62-br1.tar.gz
+sha256  91df39d1816bfb17a4dda2d3d2c83b1f6f2d38d53e53e41e8f97ad5ac46a0cad  LICENCE
+sha256  a31e61b9fc2de25c229bb9f1baa3138ed5e66ece7d5e203c5847f46d867cc1dd  NOTICE
diff --git a/package/bootpc/bootpc.mk b/package/bootpc/bootpc.mk
new file mode 100644
index 0000000000..200ed24872
--- /dev/null
+++ b/package/bootpc/bootpc.mk
@@ -0,0 +1,21 @@
+################################################################################
+#
+# bootpc package
+#
+################################################################################
+
+BOOTPC_VERSION = 80c0811dc69f9f3923661be4f9f9c09a44313f62
+BOOTPC_SITE = https://salsa.debian.org/debian/bootpc.git
+BOOTPC_SITE_METHOD = git
+BOOTPC_LICENSE = GPL-2.0-or-later
+BOOTPC_LICENSE_FILES = LICENSE NOTICE
+
+define BOOTPC_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) -C $(@D) all
+endef
+
+define BOOTPC_INSTALL_TARGET_CMDS
+	$(INSTALL) -D -m 0755 $(@D)/bootpc $(TARGET_DIR)/sbin
+endef
+
+$(eval $(generic-package))
-- 
2.25.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

* [Buildroot] [v2 2/2] bootpc: add dhcp-like configuration ability
  2023-05-26 17:55 [Buildroot] [v2 0/2] package: bootpc: add bootpc and bootp interface configuration Colin Foster
  2023-05-26 17:55 ` [Buildroot] [v2 1/2] package/bootpc: new package Colin Foster
@ 2023-05-26 17:55 ` Colin Foster
  2026-11-20 21:47 ` [Buildroot] [v2 0/2] package: bootpc: add bootpc and bootp interface configuration Angelo Compagnucci
  2 siblings, 0 replies; 4+ messages in thread
From: Colin Foster @ 2023-05-26 17:55 UTC (permalink / raw)
  To: buildroot; +Cc: Yann E. MORIN, Thomas Petazzoni

bootpc only works on interfaces that are up. If BOOTP is desired to get
an IP address to a running kernel, bootpc won't work.

This scenario was brought up as a bug in Debian forums [1] in 2007. The
response was to run the attached script to bring up the network without
an IP address. Sure enough, it still works!

Implement this bootpc script to allow IP configuration by way of
"iface eth0 inet bootp" in /etc/network/interfaces.

[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=436443

Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
---

v2:
  * check-package fixups
  * Ignore shellcheck issues in the bootpc_dhcp_script
  * Fix max line lengths
  * Fix stale OVERLAY reference
  * Note: pre-up and post-up were suggested instead of doing things in
    the bootpc_dhcp_script. If the script could be removed entirely, I
    feel that'd be the best course, but it seemingly needs to be there
    to apply the settings. Keeping things in the script leads to less
    user configuration, so that was chosen.

---
 .checkpackageignore               |  1 +
 package/bootpc/Config.in          | 16 ++++++
 package/bootpc/bootpc.mk          | 22 +++++++-
 package/bootpc/bootpc_dhcp_script | 86 +++++++++++++++++++++++++++++++
 4 files changed, 123 insertions(+), 2 deletions(-)
 create mode 100644 package/bootpc/bootpc_dhcp_script

diff --git a/.checkpackageignore b/.checkpackageignore
index 947f4606aa..15cfc6868b 100644
--- a/.checkpackageignore
+++ b/.checkpackageignore
@@ -243,6 +243,7 @@ package/bmx7/0002-Fix-linking-error.patch Upstream
 package/bmx7/0003-Reorder-includes-to-avoid-ethhdr-collision.patch Upstream
 package/boinc/S99boinc-client Indent Shellcheck Variables
 package/bootgen/0001-Fix-build-on-machines-with-modern-flex.patch Upstream
+package/bootpc/bootpc_dhcp_script Shellcheck
 package/botan/0001-Add-superh-alias-needed-by-Debian.patch Upstream
 package/botan/0002-src-build-data-arch-superh.txt-add-sh4-eb-aeb.patch Upstream
 package/brickd/S70brickd Indent Shellcheck Variables
diff --git a/package/bootpc/Config.in b/package/bootpc/Config.in
index 59c6a6e739..1a77181c35 100644
--- a/package/bootpc/Config.in
+++ b/package/bootpc/Config.in
@@ -2,3 +2,19 @@ config BR2_PACKAGE_BOOTPC
 	bool "bootpc"
 	help
 	  Application to perform BOOTP
+
+if BR2_PACKAGE_BOOTPC
+
+config BR2_PACKAGE_BOOTPC_FULL_CONFIG
+	bool "bootpc interface configuration script"
+	help
+	  BOOTP can be used to fully configure a network interface in a
+	  similar manner to DHCP. bootpc requires the network interface
+	  to be configured before this can happen.
+
+	  Replace the bootpc binary with a script that allows an
+	  unconfigured network interface to work as a BOOTP client. The
+	  setting can be applied with "iface eth0 inet bootp" in
+	  /etc/network/interfaces.
+
+endif
diff --git a/package/bootpc/bootpc.mk b/package/bootpc/bootpc.mk
index 200ed24872..e3d41350d9 100644
--- a/package/bootpc/bootpc.mk
+++ b/package/bootpc/bootpc.mk
@@ -10,12 +10,30 @@ BOOTPC_SITE_METHOD = git
 BOOTPC_LICENSE = GPL-2.0-or-later
 BOOTPC_LICENSE_FILES = LICENSE NOTICE
 
+ifeq ($(BR2_PACKAGE_BOOTPC_FULL_CONFIG),y)
+BOOTPC_TARGET_BIN_NAME = bootpc-bin
+else
+BOOTPC_TARGET_BIN_NAME = bootpc
+endif
+
 define BOOTPC_BUILD_CMDS
-	$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) -C $(@D) all
+	$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) \
+		-C $(@D) \
+		PROG=$(BOOTPC_TARGET_BIN_NAME) \
+		all
+endef
+
+ifeq ($(BR2_PACKAGE_BOOTPC_FULL_CONFIG),y)
+define BOOTPC_INSTALL_CONFIG_SCRIPT
+	$(INSTALL) -m 0755 \
+		package/bootpc/bootpc_dhcp_script \
+		$(TARGET_DIR)/sbin/bootpc
 endef
+endif
 
 define BOOTPC_INSTALL_TARGET_CMDS
-	$(INSTALL) -D -m 0755 $(@D)/bootpc $(TARGET_DIR)/sbin
+	$(INSTALL) -D -m 0755 $(@D)/$(BOOTPC_TARGET_BIN_NAME) $(TARGET_DIR)/sbin
+	$(BOOTPC_INSTALL_CONFIG_SCRIPT)
 endef
 
 $(eval $(generic-package))
diff --git a/package/bootpc/bootpc_dhcp_script b/package/bootpc/bootpc_dhcp_script
new file mode 100644
index 0000000000..239ef5ec03
--- /dev/null
+++ b/package/bootpc/bootpc_dhcp_script
@@ -0,0 +1,86 @@
+#!/bin/sh
+#
+# script to initialize a network interface using bootp
+#
+# Copyright (C) 2008 by Fuji Xerox Co., Ltd. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# written by Kohei Tanaka <Kohei.Tanaka@fujixerox.co.jp>
+
+INTERFACE=eth0
+
+# load configuration file
+[ -f /etc/default/bootpc ] && . /etc/default/bootpc
+
+# to get the interface looping over arguments
+while [ $# -ne 0 ]
+do
+	case $1 in
+	--dev)	INTERFACE=$2
+		break;;
+	*)	shift
+		continue;;
+	esac
+done
+
+# up the interface for sending broadcast packet
+ifconfig $INTERFACE up 0.0.0.0
+route add default dev $INTERFACE
+
+TMPFILE=`mktemp /tmp/bootpc.XXXXXX`
+
+/sbin/bootpc-bin --dev $INTERFACE --returniffail --serverbcast > $TMPFILE
+RET=$?
+route del default
+ifconfig $INTERFACE down
+if [ $RET -ne 0 ]
+then
+	rm -rf $TMPFILE
+	exit 1
+fi
+
+. $TMPFILE
+rm -rf $TMPFILE
+
+[ -z "$IPADDR" ] && exit 1
+
+OPT_NETMASK=""
+OPT_BROADCAST=""
+if [ -n "$NETMASK" ]
+then
+	OPT_NETMASK="netmask $NETMASK"
+fi
+if [ -n "$BROADCAST" ]
+then
+	OPT_BROADCAST="broadcast $BROADCAST"
+fi
+ifconfig $INTERFACE $IPADDR $OPT_NETMASK $OPT_BROADCAST
+
+# already added a route to the network.  just add default gateway.
+for i in $GATEWAYS
+do
+	route add default gw $i
+done
+
+[ x"$SETDNS" == xno ] && exit 0
+if [ -n "$DOMAIN" ] || [ -n "$DNSSRVS" ]
+then
+	mv -f /etc/resolv.conf /etc/resolv.conf.old
+	if [ -n "$DOMAIN" ]
+	then
+		echo "search $DOMAIN" >> /etc/resolv.conf
+	fi
+	for i in $DNSSRVS
+	do
+		echo "nameserver $i" >> /etc/resolv.conf
+	done
+fi
-- 
2.25.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

* Re: [Buildroot] [v2 0/2] package: bootpc: add bootpc and bootp interface configuration
  2023-05-26 17:55 [Buildroot] [v2 0/2] package: bootpc: add bootpc and bootp interface configuration Colin Foster
  2023-05-26 17:55 ` [Buildroot] [v2 1/2] package/bootpc: new package Colin Foster
  2023-05-26 17:55 ` [Buildroot] [v2 2/2] bootpc: add dhcp-like configuration ability Colin Foster
@ 2026-11-20 21:47 ` Angelo Compagnucci
  2 siblings, 0 replies; 4+ messages in thread
From: Angelo Compagnucci @ 2026-11-20 21:47 UTC (permalink / raw)
  To: buildroot; +Cc: Colin Foster, Yann E. MORIN, Thomas Petazzoni

Hi Colin,

On 26/05/23 19:55, Colin Foster wrote:
> Believe it or not, there are use cases for running BOOTPC instead of
> DHCP or static IP addressing.

I think this series can be dropped.

bootpc is legacy software: its code has not changed since 1999, and it
no longer builds with GCC 14 (implicit declaration of strlen()). BOOTP
itself was replaced by DHCP, which uses the same packets and adds
leases and more options.

A BOOTP client is still useful when the server only speaks BOOTP, and
Buildroot can already do that with DHCP tools:

- dhcpcd is also a BOOTP client: add "bootp" to /etc/dhcpcd.conf (or
  run "dhcpcd --bootp"). It brings the interface up and configures it,
  so no wrapper script is needed.
- With CONFIG_FEATURE_IFUPDOWN_EXTERNAL_DHCP in busybox,
  "iface eth0 inet dhcp" in /etc/network/interfaces runs dhcpcd.
- At boot, the kernel can use BOOTP with CONFIG_IP_PNP_BOOTP and
  ip=...:bootp on its command line.
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

end of thread, other threads:[~2026-11-20 21:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-26 17:55 [Buildroot] [v2 0/2] package: bootpc: add bootpc and bootp interface configuration Colin Foster
2023-05-26 17:55 ` [Buildroot] [v2 1/2] package/bootpc: new package Colin Foster
2023-05-26 17:55 ` [Buildroot] [v2 2/2] bootpc: add dhcp-like configuration ability Colin Foster
2026-11-20 21:47 ` [Buildroot] [v2 0/2] package: bootpc: add bootpc and bootp interface configuration Angelo Compagnucci

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.