Merge ~xnox/ubuntu/+source/initramfs-tools:ubuntu/devel into ubuntu/+source/initramfs-tools:ubuntu/devel

Proposed by Dimitri John Ledkov
Status: Merged
Merge reported by: Dimitri John Ledkov
Merged at revision: d2389c9ddc9f8bd52d4a019f7c954aa68edc7cd6
Proposed branch: ~xnox/ubuntu/+source/initramfs-tools:ubuntu/devel
Merge into: ubuntu/+source/initramfs-tools:ubuntu/devel
Diff against target: 247 lines (+115/-2)
9 files modified
debian/changelog (+7/-0)
init (+5/-0)
initramfs-tools.7 (+6/-0)
initramfs.conf.5 (+5/-0)
scripts/functions (+36/-2)
tests/test_netinfo.d/vlan/expected-resolv.conf (+3/-0)
tests/test_netinfo.d/vlan/net-example1.1.conf (+22/-0)
tests/test_netinfo.d/vlan/net6-example1.1.conf (+15/-0)
tests/test_netinfo.d/vlan/netplan/example1.1.yaml (+16/-0)
Reviewer Review Type Date Requested Status
Mathieu Trudel-Lapierre (community) Needs Fixing
git-ubuntu developers Pending
Review via email: mp+368566@code.launchpad.net

Commit message

Correctly serialize previously absent static ip configuration (declared as protocol 'none' by ipconfig) into runtime netplan yaml. LP: #1832042

Description of the change

Correctly serialize previously absent static ip configuration (declared as protocol 'none' by ipconfig) into runtime netplan yaml. LP: #1832042

To post a comment you must log in.
Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

Also let's close the original bug from Alkis (I'll find it)

review: Needs Fixing
Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

> Also let's close the original bug from Alkis (I'll find it)

OKay, it was comments on a different bug and there didn't end up being a separate bug report about this issue in initramfs-tools.

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

Ack. I was thinking to just use "none" as well. Happy to do that.

On Fri, 7 Jun 2019, 20:40 Mathieu Trudel-Lapierre, <email address hidden>
wrote:

> Review: Needs Fixing
>
> Also let's close the original bug from Alkis (I'll find it)
>
> Diff comments:
>
> > diff --git a/scripts/functions b/scripts/functions
> > index 511d482..42635bb 100644
> > --- a/scripts/functions
> > +++ b/scripts/functions
> > @@ -501,7 +501,7 @@ _declare_ip_info() {
> > dhcp|dhcp4|dhcp6)
> > echo "dhcp${version}=true"
> > ;;
> > - static)
> > + static|off|none)
>
> I think this should just be "none". ipconfig does not generate "off" or
> "static", just "none". It's not the same as $IP; $PROTO comes straight from
> sourcing the ipconfig output.
>
> > if [ -n "$address" ]; then
> > netprefix=$netmask
> > if [ "$version" = "4" ]; then
>
>
> --
>
> https://code.launchpad.net/~xnox/ubuntu/+source/initramfs-tools/+git/initramfs-tools/+merge/368566
> You are the owner of ~xnox/ubuntu/+source/initramfs-tools:ubuntu/devel.
>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/debian/changelog b/debian/changelog
index a32dfcf..dea3cd6 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
1initramfs-tools (0.133ubuntu6) UNRELEASED; urgency=medium
2
3 * Add support for creating VLANs via vlan=eth0.1:eth0 on kernel
4 commandline, and as VLAN= conf.d snippet. LP: #1382054
5
6 -- Dimitri John Ledkov <xnox@ubuntu.com> Sat, 08 Jun 2019 00:13:30 +0100
7
1initramfs-tools (0.133ubuntu5) eoan; urgency=medium8initramfs-tools (0.133ubuntu5) eoan; urgency=medium
29
3 * Correctly serialize previously absent static ip configuration10 * Correctly serialize previously absent static ip configuration
diff --git a/init b/init
index 5174092..426342b 100755
--- a/init
+++ b/init
@@ -55,6 +55,7 @@ export ROOTFLAGS=
55export ROOTFSTYPE=55export ROOTFSTYPE=
56export IP=56export IP=
57export IP6=57export IP6=
58export VLAN=
58export DEVICE=59export DEVICE=
59export BOOT=60export BOOT=
60export BOOTIF=61export BOOTIF=
@@ -148,6 +149,9 @@ for x in $(cat /proc/cmdline); do
148 ip6=*)149 ip6=*)
149 IP6="${x#ip6=}"150 IP6="${x#ip6=}"
150 ;;151 ;;
152 vlan=*)
153 VLAN="${x#vlan=}"
154 ;;
151 boot=*)155 boot=*)
152 BOOT=${x#boot=}156 BOOT=${x#boot=}
153 ;;157 ;;
@@ -340,6 +344,7 @@ unset ROOTDELAY
340unset ROOT344unset ROOT
341unset IP345unset IP
342unset IP6346unset IP6
347unset VLAN
343unset BOOT348unset BOOT
344unset BOOTIF349unset BOOTIF
345unset DEVICE350unset DEVICE
diff --git a/initramfs-tools.7 b/initramfs-tools.7
index 521ec20..65a25da 100644
--- a/initramfs-tools.7
+++ b/initramfs-tools.7
@@ -84,6 +84,12 @@ NFS server than the DHCP server. See Documentation/filesystems/nfsroot.txt
84in any recent Linux source for details. Optional parameter for NFS root.84in any recent Linux source for details. Optional parameter for NFS root.
8585
86.TP86.TP
87\fB\fI vlan
88tells to create a VLAN tagged device. Allows one to configure one or
89multiple VLAN tagged devices using the "vlan=$name.$id:$parent"
90syntax. E.g. "vlan=eth0.1:eth0" Optional parameter for NFS root.
91
92.TP
87\fB\fI BOOTIF93\fB\fI BOOTIF
88is a mac address in pxelinux format with leading "01-" and "-" as separations.94is a mac address in pxelinux format with leading "01-" and "-" as separations.
89pxelinux passes mac address of network card used to PXE boot on with this95pxelinux passes mac address of network card used to PXE boot on with this
diff --git a/initramfs.conf.5 b/initramfs.conf.5
index 96e641c..4817519 100644
--- a/initramfs.conf.5
+++ b/initramfs.conf.5
@@ -111,6 +111,11 @@ Specifies the default network interface to use, like eth0. The \fIip\fP or
111\fIBOOTIF\fP bootargs may override this.111\fIBOOTIF\fP bootargs may override this.
112112
113.TP113.TP
114\fB VLAN
115Specifies the VLAN tag id to setup, e.g. VLAN=eth0.1:eth0. The \fIvlan\fP
116bootarg may override this.
117
118.TP
114\fB ROOT119\fB ROOT
115Allows optional root bootarg hardcoding, when no root bootarg can be passed.120Allows optional root bootarg hardcoding, when no root bootarg can be passed.
116A root bootarg overrides that special setting.121A root bootarg overrides that special setting.
diff --git a/scripts/functions b/scripts/functions
index 4b2a332..1273e29 100644
--- a/scripts/functions
+++ b/scripts/functions
@@ -312,8 +312,12 @@ configure_networking()
312312
313 _handle_device_vs_ip313 _handle_device_vs_ip
314314
315 for v in $VLAN; do
316 VLAN_LINK="$VLAN_LINK ${v##*:}"
317 done
318
315 # activate non-autoconfigured s390x devices319 # activate non-autoconfigured s390x devices
316 for dev in $DEVICE $DEVICE6 $IP6; do320 for dev in $DEVICE $DEVICE6 $IP6 $VLAN_LINK; do
317 case ${dev} in321 case ${dev} in
318 enc*)322 enc*)
319 zdev=${dev#enc}323 zdev=${dev#enc}
@@ -322,6 +326,13 @@ configure_networking()
322 esac326 esac
323 done327 done
324328
329 for v in $VLAN; do
330 vlink=${v##*:}
331 vname=${v%:*}
332 vid=${vname#*.}
333 ip link add name "$vname" link "$vlink" type vlan id "$vid"
334 done
335
325 wait_for_udev 10336 wait_for_udev 10
326337
327 # support ip options see linux sources338 # support ip options see linux sources
@@ -519,8 +530,12 @@ _declare_ip_info() {
519_render_netplan() {530_render_netplan() {
520 # write a netplan stanza for the given device.531 # write a netplan stanza for the given device.
521 local name="$1" mac="$2" dhcp4="$3" dhcp6="$4" addrs="$5" \532 local name="$1" mac="$2" dhcp4="$3" dhcp6="$4" addrs="$5" \
522 gateway4="$6" gateway6="$7" ns_addrs="$8" ns_search="$9"533 gateway4="$6" gateway6="$7" ns_addrs="$8" ns_search="$9" \
534 vlink="${10}" vname="${11}" vid="${12}"
523 local n found=""535 local n found=""
536 if [ -n "$vlink" ]; then
537 name=$vlink
538 fi
524 echo "network:"539 echo "network:"
525 echo " version: 2"540 echo " version: 2"
526 echo " renderer: networkd"541 echo " renderer: networkd"
@@ -531,6 +546,12 @@ _render_netplan() {
531 echo " macaddress: \"$mac\""546 echo " macaddress: \"$mac\""
532 echo " set-name: $name"547 echo " set-name: $name"
533 fi548 fi
549 if [ -n "$vname" ]; then
550 echo " vlans:"
551 echo " $vname:"
552 echo " id: $vid"
553 echo " link: $name"
554 fi
534 if [ -n "$dhcp4" ]; then555 if [ -n "$dhcp4" ]; then
535 echo " dhcp4: $dhcp4"556 echo " dhcp4: $dhcp4"
536 echo " dhcp-identifier: mac"557 echo " dhcp-identifier: mac"
@@ -618,6 +639,17 @@ netinfo_to_netplan() {
618 fi639 fi
619640
620 {641 {
642 for v in $VLAN; do
643 vlink=${v##*:}
644 vname=${v%:*}
645 vid=${vname#*.}
646 if [ "$name" = "$vname" ]; then
647 echo "vlink=$vlink"
648 echo "vname=$vname"
649 echo "vid=$vid"
650 break
651 fi
652 done
621 if [ -n "$DEVICE" ]; then653 if [ -n "$DEVICE" ]; then
622 # shellcheck disable=SC2153654 # shellcheck disable=SC2153
623 _declare_ip_info 4 "$PROTO" "$IPV4ADDR" "$IPV4NETMASK" "$IPV4GATEWAY"655 _declare_ip_info 4 "$PROTO" "$IPV4ADDR" "$IPV4NETMASK" "$IPV4GATEWAY"
@@ -637,9 +669,11 @@ netinfo_to_netplan() {
637 for name in $devices; do669 for name in $devices; do
638 local macaddress="" dhcp4="" dhcp6="" addresses=""670 local macaddress="" dhcp4="" dhcp6="" addresses=""
639 local gateway4="" gateway6="" ns_addresses="" ns_search=""671 local gateway4="" gateway6="" ns_addresses="" ns_search=""
672 local vlink="" vname="" vid=""
640 . "$tmpd/$name"673 . "$tmpd/$name"
641 _render_netplan "$name" "$macaddress" "$dhcp4" "$dhcp6" "$addresses" \674 _render_netplan "$name" "$macaddress" "$dhcp4" "$dhcp6" "$addresses" \
642 "$gateway4" "$gateway6" "$ns_addresses" "$ns_search" \675 "$gateway4" "$gateway6" "$ns_addresses" "$ns_search" \
676 "$vlink" "$vname" "$vid" \
643 > "${out_d}/$name.yaml"677 > "${out_d}/$name.yaml"
644 done678 done
645 rm -Rf "$tmpd"679 rm -Rf "$tmpd"
diff --git a/tests/test_netinfo.d/vlan/expected-resolv.conf b/tests/test_netinfo.d/vlan/expected-resolv.conf
646new file mode 100644680new file mode 100644
index 0000000..c5d1458
--- /dev/null
+++ b/tests/test_netinfo.d/vlan/expected-resolv.conf
@@ -0,0 +1,3 @@
1nameserver 192.168.122.1
2nameserver 2001:67c:1562:8010::2:1
3search foo.com example.com ubuntu.com
diff --git a/tests/test_netinfo.d/vlan/net-example1.1.conf b/tests/test_netinfo.d/vlan/net-example1.1.conf
0new file mode 1006444new file mode 100644
index 0000000..ef7008b
--- /dev/null
+++ b/tests/test_netinfo.d/vlan/net-example1.1.conf
@@ -0,0 +1,22 @@
1# VLAN actually comes from vlan= kernel cmdline...
2# ... but this file is sourced, so pretend it was
3# parsed out kernel cmdline
4VLAN=example1.1:example1
5# end of hack
6DEVICE='example1.1'
7PROTO='dhcp'
8IPV4ADDR='192.168.122.89'
9IPV4BROADCAST='192.168.122.255'
10IPV4NETMASK='255.255.255.0'
11IPV4GATEWAY='192.168.122.1'
12IPV4DNS0='192.168.122.1'
13IPV4DNS1='0.0.0.0'
14HOSTNAME='foohost'
15DNSDOMAIN=''
16NISDOMAIN=''
17ROOTSERVER='192.168.122.1'
18ROOTPATH=''
19filename=''
20UPTIME='21'
21DHCPLEASETIME='3600'
22DOMAINSEARCH='foo.com'
diff --git a/tests/test_netinfo.d/vlan/net6-example1.1.conf b/tests/test_netinfo.d/vlan/net6-example1.1.conf
0new file mode 10064423new file mode 100644
index 0000000..c7d3cda
--- /dev/null
+++ b/tests/test_netinfo.d/vlan/net6-example1.1.conf
@@ -0,0 +1,15 @@
1# VLAN actually comes from vlan= kernel cmdline...
2# ... but this file is sourced, so pretend it was
3# parsed out kernel cmdline
4VLAN=example1.1:example1
5# end of hack
6DEVICE6=example1.1
7HOSTNAME=
8DNSDOMAIN=
9IPV6PROTO=dhcp6
10IPV6ADDR=2001:67c:1562:8010:0:1::
11IPV6NETMASK=64
12IPV6DNS0=2001:67c:1562:8010::2:1
13IPV6DOMAINSEARCH="example.com ubuntu.com"
14HOSTNAME=
15DNSDOMAIN=
diff --git a/tests/test_netinfo.d/vlan/netplan/example1.1.yaml b/tests/test_netinfo.d/vlan/netplan/example1.1.yaml
0new file mode 10064416new file mode 100644
index 0000000..7a570fb
--- /dev/null
+++ b/tests/test_netinfo.d/vlan/netplan/example1.1.yaml
@@ -0,0 +1,16 @@
1network:
2 version: 2
3 renderer: networkd
4 ethernets:
5 example1:
6 vlans:
7 example1.1:
8 id: 1
9 link: example1
10 dhcp4: true
11 dhcp-identifier: mac
12 dhcp6: true
13 critical: true
14 nameservers:
15 addresses: ["192.168.122.1", "2001:67c:1562:8010::2:1"]
16 search: ["foo.com", "example.com", "ubuntu.com"]

Subscribers

People subscribed via source and target branches