Skip to contentSkip to conversation

skeleton: /etc/network/interface.d/* support

PATCH Superseded Matt Weber 3 participants 7 messages Aug 16, 2016 – Oct 25, 2016

lore
Share & tools
lore

Matt Weber

author
#0 lore raw

PATCH v2 1/1 skeleton: /etc/network/interface.d/* support

---

v1 -> v2
- interfaces.d is only supported with full ifupdown package

---
 package/skeleton/skeleton.mk                    | 10 ++++++++++
 system/device_table.txt                         |  1 +
 system/skeleton/etc/network/interfaces.d/.empty |  0
 3 files changed, 11 insertions(+)
 create mode 100644 system/skeleton/etc/network/interfaces.d/.empty
package/skeleton/skeleton.mk +10 -0
index 1000161..39e2cbb 100644
@@ -170,9 +170,19 @@ define SKELETON_SET_NETWORK_DHCP
 endef
 endif
 
+ifeq ($(BR2_PACKAGE_IFUPDOWN),y)
+define SKELETON_SET_NETWORK_SUPPORT_INTERFACES_D
+	( \
+		echo ;                                               \
+		echo "source interfaces.d/*";                        \
+	) >> $(TARGET_DIR)/etc/network/interfaces
+endef
+endif
+
 define SKELETON_SET_NETWORK
 	mkdir -p $(TARGET_DIR)/etc/network/
 	$(SKELETON_SET_NETWORK_LOCALHOST)
+	$(SKELETON_SET_NETWORK_SUPPORT_INTERFACES_D)
 	$(SKELETON_SET_NETWORK_DHCP)
 endef
 
system/device_table.txt +1 -0
index dc1af51..69b1d46 100644
@@ -17,5 +17,6 @@
 /etc/network/if-pre-up.d		d	755	0	0	-	-	-	-	-
 /etc/network/if-down.d			d	755	0	0	-	-	-	-	-
 /etc/network/if-post-down.d		d	755	0	0	-	-	-	-	-
+/etc/network/interfaces.d		d	755	0	0	-	-	-	-	-
 # uncomment this to allow starting x as non-root
 #/usr/X11R6/bin/Xfbdev		     	f	4755	0	0	-	-	-	-	-
system/skeleton/etc/network/interfaces.d/.empty new file +0 -0
new file mode 100644
index 0000000..e69de29
Signature · 1 line
1.9.1
#1 lore raw

PATCH v2 1/1 skeleton: /etc/network/interface.d/* support

Hello,

system/skeleton/etc/network/interfaces.d/.empty

Quoted 38 lines · Matt Weber
package/skeleton/skeleton.mk +10 -0
index 1000161..39e2cbb 100644
@@ -170,9 +170,19 @@ define SKELETON_SET_NETWORK_DHCP
 endef
 endif
 
+ifeq ($(BR2_PACKAGE_IFUPDOWN),y)
+define SKELETON_SET_NETWORK_SUPPORT_INTERFACES_D
+	( \
+		echo ;                                               \
+		echo "source interfaces.d/*";                        \
+	) >> $(TARGET_DIR)/etc/network/interfaces
+endef
+endif
+
 define SKELETON_SET_NETWORK
 	mkdir -p $(TARGET_DIR)/etc/network/
 	$(SKELETON_SET_NETWORK_LOCALHOST)
+	$(SKELETON_SET_NETWORK_SUPPORT_INTERFACES_D)
 	$(SKELETON_SET_NETWORK_DHCP)
 endef
 
system/device_table.txt +1 -0
index dc1af51..69b1d46 100644
@@ -17,5 +17,6 @@
 /etc/network/if-pre-up.d		d	755	0	0	-	-	-	-	-
 /etc/network/if-down.d			d	755	0	0	-	-	-	-	-
 /etc/network/if-post-down.d		d	755	0	0	-	-	-	-	-
+/etc/network/interfaces.d		d	755	0	0	-	-	-	-	-
 # uncomment this to allow starting x as non-root
 #/usr/X11R6/bin/Xfbdev		     	f	4755	0	0	-	-	-	-	-
system/skeleton/etc/network/interfaces.d/.empty new file +0 -0
new file mode 100644
index 0000000..e69de29

Sorry for the late answer. I believe none of this should go in the main skeleton, as it is really specific to ifupdown. What about instead adding the following in ifupdown.mk:

ifeq ($(BR2_ROOTFS_SKELETON_DEFAULT),y)
define IFUPDOWN_TUNE_ETC_NETWORK_INTERFACES

	mkdir -p $(TARGET_DIR)/etc/network/interfaces.d
	echo "source interfaces.d/*" >> $(TARGET_DIR)/etc/network/interfaces

endef
IFUPDOWN_TARGET_FINALIZE_HOOKS += IFUPDOWN_TUNE_ETC_NETWORK_INTERFACES endif

define IFUPDOWN_PERMISSIONS
/etc/network/interfaces.d d 755 0 0 - - - - -
endef

This should do exactly the same thing, but is isolated in the ifupdown package.

Could you look into this?

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#2 lore raw

PATCH v2 1/1 skeleton: /etc/network/interface.d/* support

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

Hi,

Quoted 2 lines

Sorry for the late answer. I believe none of this should go in the main skeleton, as it is really specific to ifupdown.

Indeed. From what I can see, the busybox applet doesn't support wildcards in the source lines (and doesn't support source-directory).

What is the reason to use source with a wildcard instead of source-directory? From the man page:

source interfaces.d/machine-dependent

source-directory interfaces.d

It does say though:

Currently, "source-directory" isn't supported by network-manager and guessnet.

By default, on a freshly installed Debian system, the interfaces file includes a line to source files in the /etc/network/interfaces.d directory.

From the postinst script:

if [ ! -f /etc/network/interfaces ] ; then
if [ -z "$2" ]; then
echo "Creating /etc/network/interfaces."
echo "# interfaces(5) file used by ifup(8) and ifdown(8)" > /etc/network/interfaces echo "# Include files from /etc/network/interfaces.d:" >> /etc/network/interfaces echo "source-directory /etc/network/interfaces.d" >> /etc/network/interfaces

Quoted 8 lines

adding the following in ifupdown.mk:

ifeq ($(BR2_ROOTFS_SKELETON_DEFAULT),y)
define IFUPDOWN_TUNE_ETC_NETWORK_INTERFACES

	mkdir -p $(TARGET_DIR)/etc/network/interfaces.d
	echo "source interfaces.d/*" >> $(TARGET_DIR)/etc/network/interfaces

endef
IFUPDOWN_TARGET_FINALIZE_HOOKS += IFUPDOWN_TUNE_ETC_NETWORK_INTERFACES

We afaik provide no explicit guarantees on the ordering of the various _TARGET_FINALIZE hooks, but it afaik will run in (package-)alphabetical order, E.G. before the finalize hooks of skeleton so this doesn't work :/

Signature · 1 line
Bye, Peter Korsgaard
#3 lore raw

PATCH v2 1/1 skeleton: /etc/network/interface.d/* support

Hello,

Quoted 2 lines · Peter Korsgaard

We afaik provide no explicit guarantees on the ordering of the various _TARGET_FINALIZE hooks

Correct.

Quoted 3 lines

, but it afaik will run in (package-)alphabetical
order, E.G. before the finalize hooks of skeleton so this doesn't work :/

Hum, my thinking was that it did not matter if the "source" line is before or after the lo definition. However, the skeleton package completely overwrites the file, so indeed, it doesn't work.

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#4 lore raw

PATCH v2 1/1 skeleton: /etc/network/interface.d/* support

Thomas/ Peter

Quoted 10 lines · Thomas Petazzoni

Hello,

Quoted 2 lines · Peter Korsgaard

We afaik provide no explicit guarantees on the ordering of the various _TARGET_FINALIZE hooks

Correct.

Quoted 7 lines
Quoted 3 lines

, but it afaik will run in (package-)alphabetical
order, E.G. before the finalize hooks of skeleton so this doesn't work :/

Hum, my thinking was that it did not matter if the "source" line is before or after the lo definition. However, the skeleton package completely overwrites the file, so indeed, it doesn't work.

So leave it as is in the skeleton.mk?

Signature · 8 lines
Matthew L Weber / Pr Software Engineer
Airborne Information Systems / Security Systems and Software / Secure Platforms
MS 131-100, C Ave NE, Cedar Rapids, IA, 52498, USA
www.rockwellcollins.com

Note: Any Export License Required Information and License Restricted
Third Party Intellectual Property (TPIP) content must be encrypted and
sent to matthew.weber at corp.rockwellcollins.com.
#5 lore raw

PATCH v2 1/1 skeleton: /etc/network/interface.d/* support

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Matthew" == Matthew Weber <[email protected]> writes:

Hi,

Quoted 9 lines
Quoted 9 lines
Quoted 2 lines

We afaik provide no explicit guarantees on the ordering of the various _TARGET_FINALIZE hooks

Correct.

Quoted 3 lines

, but it afaik will run in (package-)alphabetical
order, E.G. before the finalize hooks of skeleton so this doesn't work :/

Quoted 5 lines
Quoted 3 lines

Hum, my thinking was that it did not matter if the "source" line is before or after the lo definition. However, the skeleton package completely overwrites the file, so indeed, it doesn't work.

So leave it as is in the skeleton.mk?

I think that is the only place we can add it, yes.

With that said, there's afaik no packages using interface.d, so if this is just for project customization then you might as well handle it there (E.G. you might already have a custom interfaces or appending the line to it in your post-build is easy).

Signature · 2 lines
Venlig hilsen,
Peter Korsgaard 
#6 lore raw

PATCH v2 1/1 skeleton: /etc/network/interface.d/* support

Peter,

Quoted 17 lines · Peter Korsgaard
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Matthew" == Matthew Weber <[email protected]> writes:

Hi,

Quoted 12 lines
Quoted 12 lines
Quoted 2 lines

We afaik provide no explicit guarantees on the ordering of the various _TARGET_FINALIZE hooks

Correct.

Quoted 3 lines

, but it afaik will run in (package-)alphabetical
order, E.G. before the finalize hooks of skeleton so this doesn't work :/

Hum, my thinking was that it did not matter if the "source" line is before or after the lo definition. However, the skeleton package completely overwrites the file, so indeed, it doesn't work.

Quoted 8 lines
Quoted 1 line

So leave it as is in the skeleton.mk?

I think that is the only place we can add it, yes.

With that said, there's afaik no packages using interface.d, so if this is just for project customization then you might as well handle it there (E.G. you might already have a custom interfaces or appending the line to it in your post-build is easy).

Agree, but in this case we thought it might make sense to include by default, so that we encourage the practice of using that style of interface configuration which follows the behavior/intent of larger Linux distros. Especially since the user intentionally enables ifupdown for more advanced use cases.

I'm good either way.

Signature · 8 lines
Matthew L Weber / Pr Software Engineer
Airborne Information Systems / Security Systems and Software / Secure Platforms
MS 131-100, C Ave NE, Cedar Rapids, IA, 52498, USA
www.rockwellcollins.com

Note: Any Export License Required Information and License Restricted
Third Party Intellectual Property (TPIP) content must be encrypted and
sent to matthew.weber at corp.rockwellcollins.com.