From patchwork Thu Jan 8 09:36:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jeremy Rosen X-Patchwork-Id: 426550 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 E59D8140119 for ; Thu, 8 Jan 2015 20:37:08 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 2E33E8B35E; Thu, 8 Jan 2015 09:37:07 +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 gP3oarAImD6U; Thu, 8 Jan 2015 09:37:06 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id D7BC78B33C; Thu, 8 Jan 2015 09:37:05 +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 077481C2994 for ; Thu, 8 Jan 2015 09:37:04 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 029768C3D2 for ; Thu, 8 Jan 2015 09:37:04 +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 nX-tWSD3HA2O for ; Thu, 8 Jan 2015 09:37:03 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wi0-f179.google.com (mail-wi0-f179.google.com [209.85.212.179]) by whitealder.osuosl.org (Postfix) with ESMTPS id A41198C39A for ; Thu, 8 Jan 2015 09:37:02 +0000 (UTC) Received: by mail-wi0-f179.google.com with SMTP id ex7so2030474wid.0 for ; Thu, 08 Jan 2015 01:37:01 -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=gD9XLE2+AyzHHX+dhoUx9oyPmlqz7a0ioqOb8FFzztc=; b=OacpoIiUItctxCEtoLxfUFY+ougtnEwcY2WHHlAWrSZ4QaAMJAfbfxFV4O0ojGfJ1u /eX6UT831wh4ppzKG63inWSkSDgvtqVNSg/KRybeEuoXTTB+e01SvuvJiphKPHlFg69A DS/K8QGI8aRC9q0hTmiYXKsR9c3mZCQW2WvZDKliDdq/NsEuHC5z0wg2F2Opi97qWO+k eId2/DmvZnQylixGxkHO0c8Qp/EXcoszX6jhFuZlvSbDFNavzFtcH/hS8MpFWDkezwnU ToRdNfiOs3NNGBM5fwMiZm3nYSpwqS+psc3LNg1+V0rsfdqet07NbubL2hfr/kHwkxNi Ysow== X-Received: by 10.180.107.70 with SMTP id ha6mr57635881wib.71.1420709821078; Thu, 08 Jan 2015 01:37:01 -0800 (PST) Received: from pcrosen.daviel.openwide.fr. ([193.56.60.161]) by mx.google.com with ESMTPSA id h8sm5800700wiy.17.2015.01.08.01.37.00 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 08 Jan 2015 01:37:00 -0800 (PST) From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Rosen?= To: buildroot@busybox.net Date: Thu, 8 Jan 2015 10:36:45 +0100 Message-Id: <1420709805-13040-1-git-send-email-jeremy.rosen@openwide.fr> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 Subject: [Buildroot] [PATCH v3] 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 Reviewed-by: Karoly Kasza Tested-by: Gustavo Zacarias Acked-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 | 18 ++++++++++++++++++ system/skeleton/etc/network/interfaces | 4 ---- system/system.mk | 25 +++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 4 deletions(-) delete mode 100644 system/skeleton/etc/network/interfaces diff --git a/system/Config.in b/system/Config.in index a3b7aff..71ba7ab 100644 --- a/system/Config.in +++ b/system/Config.in @@ -324,6 +324,24 @@ 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 + 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 + 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