Skip to contentSkip to conversation

Configure wired network interface with dhcp for systemd

PATCH In review [email protected] 3 participants 6 messages May 21, 2019 – May 23, 2019

lore
Share & tools
lore
#0 lore raw

v2 cover Configure wired network interface with dhcp for systemd

From: Kai Kang <[email protected]>

v2:
Refer to https://github.com/YoeDistro/meta-yoe/tree/master/recipes-core/systemd

* add section 'DHCP' in dhcp.network which could solve got 2 ips when connman is installed
* not install the configure file for qemu

Kai Kang (1):
systemd-conf: configure wired network with dhcp

 meta/recipes-core/systemd/systemd-conf/dhcp.network | 9 +++++++++
 meta/recipes-core/systemd/systemd-conf_242.bb       | 5 +++++
 2 files changed, 14 insertions(+)
 create mode 100644 meta/recipes-core/systemd/systemd-conf/dhcp.network
Signature · 1 line
2.20.0
#1 lore raw

PATCH v2 1/1 systemd-conf: configure wired network with dhcp

From: Kai Kang <[email protected]>

Add a configure file for systemd.networkd to configure wired network interfaces with dhcp. It works with common network interfaces such eth0 and eno1.

Refer to
https://github.com/YoeDistro/meta-yoe/tree/master/recipes-core/systemd

[YOCTO #13057]

---
 meta/recipes-core/systemd/systemd-conf/dhcp.network | 9 +++++++++
 meta/recipes-core/systemd/systemd-conf_242.bb       | 5 +++++
 2 files changed, 14 insertions(+)
 create mode 100644 meta/recipes-core/systemd/systemd-conf/dhcp.network
meta/recipes-core/systemd/systemd-conf/dhcp.network new file +9 -0
new file mode 100644
index 0000000000..253aee9382
@@ -0,0 +1,9 @@
+[Match]
+Name=en* eth*
+
+[Network]
+DHCP=yes
+
+[DHCP]
+RouteMetric=10
+ClientIdentifier=mac
meta/recipes-core/systemd/systemd-conf_242.bb +5 -0
index 96beea53a7..105ee3ceed 100644
@@ -10,12 +10,16 @@ SRC_URI = "\
     file://logind.conf \
     file://system.conf \
     file://system.conf-qemuall \
+    file://dhcp.network \
 "
 
 do_install() {
 	install -D -m0644 ${WORKDIR}/journald.conf ${D}${systemd_unitdir}/journald.conf.d/00-${PN}.conf
 	install -D -m0644 ${WORKDIR}/logind.conf ${D}${systemd_unitdir}/logind.conf.d/00-${PN}.conf
 	install -D -m0644 ${WORKDIR}/system.conf ${D}${systemd_unitdir}/system.conf.d/00-${PN}.conf
+	if ${@bb.utils.contains('OVERRIDES', 'qemuall', 'false', 'true', d)}; then
+		install -D -m0644 ${WORKDIR}/dhcp.network ${D}${systemd_unitdir}/network/80-dhcp.network
+	fi
 }
 
 # Based on change from YP bug 8141, OE commit 5196d7bacaef1076c361adaa2867be31759c1b52
@@ -29,4 +33,5 @@ FILES_${PN} = "\
     ${systemd_unitdir}/journald.conf.d/ \
     ${systemd_unitdir}/logind.conf.d/ \
     ${systemd_unitdir}/system.conf.d/ \
+    ${systemd_unitdir}/network/ \
 "
Signature · 1 line
2.20.0
#2 lore raw

Re: [PATCH v2 1/1] systemd-conf: configure wired network with dhcp

Quoted 12 lines · On Tue, 2019-05-21 at 05:22 -0400, [email protected] wrote:

From: Kai Kang <[email protected]>

Add a configure file for systemd.networkd to configure wired network interfaces with dhcp. It works with common network interfaces such eth0
and eno1.

Refer to
https://github.com/YoeDistro/meta-yoe/tree/master/recipes-core/systemd

[YOCTO #13057]

Quoted 7 lines
---
 meta/recipes-core/systemd/systemd-conf/dhcp.network | 9 +++++++++
 meta/recipes-core/systemd/systemd-conf_242.bb       | 5 +++++
 2 files changed, 14 insertions(+)
 create mode 100644 meta/recipes-core/systemd/systemd-

conf/dhcp.network

This seems to result in the failures in:

https://autobuilder.yoctoproject.org/typhoon/#/builders/72/builds/617

Cheers,

Richard

author
#3 lore raw

Re: [PATCH v2 1/1] systemd-conf: configure wired network with dhcp

Quoted 20 lines · Richard Purdie
Quoted 12 lines · On Tue, 2019-05-21 at 05:22 -0400, [email protected] wrote:

From: Kai Kang <[email protected]>

Add a configure file for systemd.networkd to configure wired network interfaces with dhcp. It works with common network interfaces such eth0
and eno1.

Refer to
https://github.com/YoeDistro/meta-yoe/tree/master/recipes-core/systemd

[YOCTO #13057]

Quoted 7 lines
---
  meta/recipes-core/systemd/systemd-conf/dhcp.network | 9 +++++++++
  meta/recipes-core/systemd/systemd-conf_242.bb       | 5 +++++
  2 files changed, 14 insertions(+)

create mode 100644 meta/recipes-core/systemd/systemd-
conf/dhcp.network

Quoted 3 lines

This seems to result in the failures in:

https://autobuilder.yoctoproject.org/typhoon/#/builders/72/builds/617

Sorry, there was something wrong during my verify build and test. v3 will be sent.

Regards,
Kai

Quoted 6 lines

Cheers,

Richard

Signature · 1 line
Kai Kang
#4 lore raw

Re: [PATCH v2 1/1] systemd-conf: configure wired network with dhcp

In reply to [email protected]

just copy paste from meta-yoe, that has been long working.

Quoted 25 lines · On Tue, May 21, 2019 at 2:23 AM <[email protected]> wrote:

From: Kai Kang <[email protected]>

Add a configure file for systemd.networkd to configure wired network interfaces with dhcp. It works with common network interfaces such eth0 and eno1.

Refer to
https://github.com/YoeDistro/meta-yoe/tree/master/recipes-core/systemd

[YOCTO #13057]

---
 meta/recipes-core/systemd/systemd-conf/dhcp.network | 9 +++++++++
 meta/recipes-core/systemd/systemd-conf_242.bb       | 5 +++++
 2 files changed, 14 insertions(+)
 create mode 100644 meta/recipes-core/systemd/systemd-conf/dhcp.network
meta/recipes-core/systemd/systemd-conf/dhcp.network new file +0 -0
new file mode 100644
index 0000000000..253aee9382

meta/recipes-core/systemd/systemd-conf/dhcp.network line 2

Quoted 2 lines
meta/recipes-core/systemd/systemd-conf/dhcp.network new file +2 -0
@@ -0,0 +1,9 @@
+[Match]
+Name=en* eth*

I think this is better put
Name=en*
Name=eth*

Quoted 12 lines
meta/recipes-core/systemd/systemd-conf/dhcp.network new file +7 -0
+
+[Network]
+DHCP=yes
+
+[DHCP]
+RouteMetric=10
+ClientIdentifier=mac
meta/recipes-core/systemd/systemd-conf_242.bb +0 -0
index 96beea53a7..105ee3ceed 100644

meta/recipes-core/systemd/systemd-conf_242.bb SRC_URI = "\ · line 13

Quoted 4 lines
meta/recipes-core/systemd/systemd-conf_242.bb +1 -0
@@ -10,12 +10,16 @@ SRC_URI = "\
     file://logind.conf \
     file://system.conf \
     file://system.conf-qemuall \
+    file://dhcp.network \

better to call it wired or something

Quoted 21 lines
meta/recipes-core/systemd/systemd-conf_242.bb +4 -1
 "
 
 do_install() {
        install -D -m0644 ${WORKDIR}/journald.conf ${D}${systemd_unitdir}/journald.conf.d/00-${PN}.conf
        install -D -m0644 ${WORKDIR}/logind.conf ${D}${systemd_unitdir}/logind.conf.d/00-${PN}.conf
        install -D -m0644 ${WORKDIR}/system.conf ${D}${systemd_unitdir}/system.conf.d/00-${PN}.conf
+       if ${@bb.utils.contains('OVERRIDES', 'qemuall', 'false', 'true', d)}; then
+               install -D -m0644 ${WORKDIR}/dhcp.network ${D}${systemd_unitdir}/network/80-dhcp.network
+       fi
 }
 
 # Based on change from YP bug 8141, OE commit 5196d7bacaef1076c361adaa2867be31759c1b52
@@ -29,4 +33,5 @@ FILES_${PN} = "\
     ${systemd_unitdir}/journald.conf.d/ \
     ${systemd_unitdir}/logind.conf.d/ \
     ${systemd_unitdir}/system.conf.d/ \
+    ${systemd_unitdir}/network/ \
 "
--

2.20.0

author
#5 lore raw

Re: [PATCH v2 1/1] systemd-conf: configure wired network with dhcp

Quoted 21 lines · Khem Raj

just copy paste from meta-yoe, that has been long working.

Quoted 18 lines · On Tue, May 21, 2019 at 2:23 AM <[email protected]> wrote:

From: Kai Kang <[email protected]>

Add a configure file for systemd.networkd to configure wired network interfaces with dhcp. It works with common network interfaces such eth0 and eno1.

Refer to
https://github.com/YoeDistro/meta-yoe/tree/master/recipes-core/systemd

[YOCTO #13057]

---
  meta/recipes-core/systemd/systemd-conf/dhcp.network | 9 +++++++++
  meta/recipes-core/systemd/systemd-conf_242.bb       | 5 +++++
  2 files changed, 14 insertions(+)

create mode 100644 meta/recipes-core/systemd/systemd-conf/dhcp.network

Quoted 11 lines

meta/recipes-core/systemd/systemd-conf/dhcp.network line 2

Quoted 8 lines
meta/recipes-core/systemd/systemd-conf/dhcp.network new file +2 -0
new file mode 100644
index 0000000000..253aee9382
@@ -0,0 +1,9 @@
+[Match]
+Name=en* eth*

I think this is better put
Name=en*
Name=eth*

Accodring to systemd.network(5),

       Name=
           A whitespace-separated list of shell-style globs matching the device name, as exposed by the udev property "INTERFACE".

It also says:

       A network file is said to match a device if each of the entries in the "[Match]" section matches, or if the section is empty.

So I perfer to use put them in one line "Name=en* eth*".

Also check systemd source code,

neil@pek-kkang-d1:/mnt/sda4/git/systemd

$ find . -name *.network -exec grep -H -c ^Name= {} \; | grep -v 1$
neil@pek-kkang-d1:/mnt/sda4/git/systemd
$ find . -name *.network -exec grep -H 'Name=\S\+\s\S' {} \;
./test/test-network/conf/25-tunnel-remote-any.network:Name=*tun97 ip6tnl97
./test/test-network/conf/bond-slave.network:Name=dummy98 test1
./test/test-network/conf/25-tunnel.network:Name=*tun99 *tap99 ip6tnl99 erspan99
./test/test-network/conf/25-tunnel-local-any.network:Name=*tun98 *tap98 ip6tnl98 erspan98
Quoted 9 lines
Quoted 9 lines
meta/recipes-core/systemd/systemd-conf/dhcp.network new file +7 -0
+
+[Network]
+DHCP=yes
+
+[DHCP]
+RouteMetric=10
+ClientIdentifier=mac
meta/recipes-core/systemd/systemd-conf_242.bb +0 -0
index 96beea53a7..105ee3ceed 100644
Quoted 8 lines

meta/recipes-core/systemd/systemd-conf_242.bb SRC_URI = "\ · line 13

Quoted 7 lines
meta/recipes-core/systemd/systemd-conf_242.bb +1 -0
@@ -10,12 +10,16 @@ SRC_URI = "\
      file://logind.conf \
      file://system.conf \
      file://system.conf-qemuall \
+    file://dhcp.network \

better to call it wired or something

OK. Will install as 80-wired.network.

Regards,
Kai

Quoted 22 lines
Quoted 22 lines
meta/recipes-core/systemd/systemd-conf_242.bb +4 -1
  "
 
  do_install() {
         install -D -m0644 ${WORKDIR}/journald.conf ${D}${systemd_unitdir}/journald.conf.d/00-${PN}.conf
         install -D -m0644 ${WORKDIR}/logind.conf ${D}${systemd_unitdir}/logind.conf.d/00-${PN}.conf
         install -D -m0644 ${WORKDIR}/system.conf ${D}${systemd_unitdir}/system.conf.d/00-${PN}.conf
+       if ${@bb.utils.contains('OVERRIDES', 'qemuall', 'false', 'true', d)}; then
+               install -D -m0644 ${WORKDIR}/dhcp.network ${D}${systemd_unitdir}/network/80-dhcp.network
+       fi
  }
 
  # Based on change from YP bug 8141, OE commit 5196d7bacaef1076c361adaa2867be31759c1b52
@@ -29,4 +33,5 @@ FILES_${PN} = "\
      ${systemd_unitdir}/journald.conf.d/ \
      ${systemd_unitdir}/logind.conf.d/ \
      ${systemd_unitdir}/system.conf.d/ \
+    ${systemd_unitdir}/network/ \
  "
--

2.20.0

Signature · 1 line
Kai Kang