From patchwork Fri Jan 16 13:08:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jeremy Rosen X-Patchwork-Id: 429840 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from hemlock.osuosl.org (hemlock.osuosl.org [140.211.166.133]) by ozlabs.org (Postfix) with ESMTP id E3A2C140277 for ; Sat, 17 Jan 2015 00:08:52 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id E5E3193127; Fri, 16 Jan 2015 13:08:51 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZDtn73L2S89o; Fri, 16 Jan 2015 13:08:51 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 1A36E9312F; Fri, 16 Jan 2015 13:08:51 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (whitealder.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 59E411C2826 for ; Fri, 16 Jan 2015 13:08:49 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 5333B8AC19 for ; Fri, 16 Jan 2015 13:08:49 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vTAnmj2vvRbs for ; Fri, 16 Jan 2015 13:08:48 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-we0-f174.google.com (mail-we0-f174.google.com [74.125.82.174]) by whitealder.osuosl.org (Postfix) with ESMTPS id 0E88B89543 for ; Fri, 16 Jan 2015 13:08:48 +0000 (UTC) Received: by mail-we0-f174.google.com with SMTP id k48so20157752wev.5 for ; Fri, 16 Jan 2015 05:08:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; bh=zlZJVc+NbxWIDKAmri2hrexrn+4Fhvr0W6J2SHngfbM=; b=tAGC1jAh++Ysbnq3x0lH6/C9Xvzp+Y7A1qplxDg6C7fO4N+AH/8Z2gA1wUteAHUoCn hxuYw7ThI3dH6e4Jz/sxP6svJQCZl6ed3s+TljzIUNOrIhvkx2utEvHgZiJAmvs4jyjf FufyIcMKVDhDyzk4FuWAI7yBY6jxn4QuYYpdh8QUON3aBO1kvIDtUH0ARe0BTaPadaSR t6ZKgmUQxALXC9aOI0cSwaui3tbNz6rPy96ygwMxttJNx8JS8RMOmJ9XEYZdQ9PR/Gvy VrJ4QXfuxG/4E5U196EQ5pra3M+ESwvyMhqzqBbWFL2q+cGBogcEvx2+Bk8NTB/UV8m1 jDXA== X-Received: by 10.194.2.75 with SMTP id 11mr29722345wjs.78.1421413726437; Fri, 16 Jan 2015 05:08:46 -0800 (PST) Received: from localhost.localdomain (247.37.0.109.rev.sfr.net. [109.0.37.247]) by mx.google.com with ESMTPSA id jr4sm6014337wjc.20.2015.01.16.05.08.45 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Jan 2015 05:08:45 -0800 (PST) From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Rosen?= To: buildroot@busybox.net Date: Fri, 16 Jan 2015 14:08:39 +0100 Message-Id: <1421413719-10383-1-git-send-email-jeremy.rosen@openwide.fr> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 Subject: [Buildroot] [PATCH v4] Allow a single DHCP configuration via the system configuration submenu X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" This patch allows the setup of simple a single interface to be automatically brought up and configured via DHCP on system startup. The interface name can be set via a configuration option. This patch does not support systemd-networkd, any complex network configuration should be done via overlay of /etc/network/interfaces or the relevant networkd configuration file Signed-off-by: Jérémy Rosen --- v4 : - changed condition to also depend on ifupdown or busybox suggestion by Gustavo Zacarias v3 : - move the condition from shell logic to make logic (reusing the code proposed by Thomas Petazzoni) v2 : - inline shell section instead of providing a script - add one Config.in option instead of two --- system/Config.in | 21 +++++++++++++++++++++ system/skeleton/etc/network/interfaces | 4 ---- system/system.mk | 25 +++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 4 deletions(-) delete mode 100644 system/skeleton/etc/network/interfaces diff --git a/system/Config.in b/system/Config.in index 4d7a4e3..71d8689 100644 --- a/system/Config.in +++ b/system/Config.in @@ -324,6 +324,27 @@ config BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW endif # BR2_ROOTFS_SKELETON_DEFAULT + +config BR2_SIMPLE_DHCP + string "Name of the physical network interface to run DHCP on" + default "" + depends on !BR2_PACKAGE_SYSTEMD_NETWORKD && (BR2_PACKAGE_BUSYBOX || BR2_PACKAGE_IFUPDOWN) + help + The name of the network interface to configure automatically. + A DHCP request will automatically happen on startup on the selected + interface. + + If left empty, no automatic DHCP requests will take place. + + For more complicated network setups use an overlay to overwrite + /etc/network/interfaces or add a networkd configuration file. + +comment "automatic network configuration via DHCP is not compatible with networkd" + depends on BR2_PACKAGE_SYSTEMD_NETWORKD + +comment "automatic network configuration via DHCP needs ifupdown or busybox" + depends on !(BR2_PACKAGE_BUSYBOX || BR2_PACKAGE_IFUPDOWN) + config BR2_TARGET_TZ_INFO bool "Install timezone info" # No timezone for musl; only for uClibc or (e)glibc. diff --git a/system/skeleton/etc/network/interfaces b/system/skeleton/etc/network/interfaces deleted file mode 100644 index 218b82c..0000000 --- a/system/skeleton/etc/network/interfaces +++ /dev/null @@ -1,4 +0,0 @@ -# Configure Loopback -auto lo -iface lo inet loopback - diff --git a/system/system.mk b/system/system.mk index e4a3160..96aa342 100644 --- a/system/system.mk +++ b/system/system.mk @@ -38,6 +38,31 @@ ifneq ($(TARGET_GENERIC_ROOT_PASSWD),) TARGETS += host-mkpasswd endif +define SET_NETWORK_LOCALHOST + echo "# interface file auto-generated by buildroot" > $(TARGET_DIR)/etc/network/interfaces + echo >> $(TARGET_DIR)/etc/network/interfaces + echo "auto lo" >> $(TARGET_DIR)/etc/network/interfaces + echo "iface lo inet loopback" >> $(TARGET_DIR)/etc/network/interfaces + echo >> $(TARGET_DIR)/etc/network/interfaces +endef + +NETWORK_DHCP_IFACE = $(call qstrip,$(BR2_SIMPLE_DHCP)) + +ifneq ($(NETWORK_DHCP_IFACE),) +define SET_NETWORK_DHCP + echo "auto $(NETWORK_DHCP_IFACE)" >> $(TARGET_DIR)/etc/network/interfaces + echo "iface $(NETWORK_DHCP_IFACE) inet dhcp" >> $(TARGET_DIR)/etc/network/interfaces +endef +endif + +define SET_NETWORK + mkdir -p $(TARGET_DIR)/etc/network/ + $(SET_NETWORK_LOCALHOST) + $(SET_NETWORK_DHCP) +endef + +TARGET_FINALIZE_HOOKS += SET_NETWORK + ifeq ($(BR2_ROOTFS_SKELETON_DEFAULT),y) define SYSTEM_ROOT_PASSWD