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
1diff --git a/debian/changelog b/debian/changelog
2index a32dfcf..dea3cd6 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,10 @@
6+initramfs-tools (0.133ubuntu6) UNRELEASED; urgency=medium
7+
8+ * Add support for creating VLANs via vlan=eth0.1:eth0 on kernel
9+ commandline, and as VLAN= conf.d snippet. LP: #1382054
10+
11+ -- Dimitri John Ledkov <xnox@ubuntu.com> Sat, 08 Jun 2019 00:13:30 +0100
12+
13 initramfs-tools (0.133ubuntu5) eoan; urgency=medium
14
15 * Correctly serialize previously absent static ip configuration
16diff --git a/init b/init
17index 5174092..426342b 100755
18--- a/init
19+++ b/init
20@@ -55,6 +55,7 @@ export ROOTFLAGS=
21 export ROOTFSTYPE=
22 export IP=
23 export IP6=
24+export VLAN=
25 export DEVICE=
26 export BOOT=
27 export BOOTIF=
28@@ -148,6 +149,9 @@ for x in $(cat /proc/cmdline); do
29 ip6=*)
30 IP6="${x#ip6=}"
31 ;;
32+ vlan=*)
33+ VLAN="${x#vlan=}"
34+ ;;
35 boot=*)
36 BOOT=${x#boot=}
37 ;;
38@@ -340,6 +344,7 @@ unset ROOTDELAY
39 unset ROOT
40 unset IP
41 unset IP6
42+unset VLAN
43 unset BOOT
44 unset BOOTIF
45 unset DEVICE
46diff --git a/initramfs-tools.7 b/initramfs-tools.7
47index 521ec20..65a25da 100644
48--- a/initramfs-tools.7
49+++ b/initramfs-tools.7
50@@ -84,6 +84,12 @@ NFS server than the DHCP server. See Documentation/filesystems/nfsroot.txt
51 in any recent Linux source for details. Optional parameter for NFS root.
52
53 .TP
54+\fB\fI vlan
55+tells to create a VLAN tagged device. Allows one to configure one or
56+multiple VLAN tagged devices using the "vlan=$name.$id:$parent"
57+syntax. E.g. "vlan=eth0.1:eth0" Optional parameter for NFS root.
58+
59+.TP
60 \fB\fI BOOTIF
61 is a mac address in pxelinux format with leading "01-" and "-" as separations.
62 pxelinux passes mac address of network card used to PXE boot on with this
63diff --git a/initramfs.conf.5 b/initramfs.conf.5
64index 96e641c..4817519 100644
65--- a/initramfs.conf.5
66+++ b/initramfs.conf.5
67@@ -111,6 +111,11 @@ Specifies the default network interface to use, like eth0. The \fIip\fP or
68 \fIBOOTIF\fP bootargs may override this.
69
70 .TP
71+\fB VLAN
72+Specifies the VLAN tag id to setup, e.g. VLAN=eth0.1:eth0. The \fIvlan\fP
73+bootarg may override this.
74+
75+.TP
76 \fB ROOT
77 Allows optional root bootarg hardcoding, when no root bootarg can be passed.
78 A root bootarg overrides that special setting.
79diff --git a/scripts/functions b/scripts/functions
80index 4b2a332..1273e29 100644
81--- a/scripts/functions
82+++ b/scripts/functions
83@@ -312,8 +312,12 @@ configure_networking()
84
85 _handle_device_vs_ip
86
87+ for v in $VLAN; do
88+ VLAN_LINK="$VLAN_LINK ${v##*:}"
89+ done
90+
91 # activate non-autoconfigured s390x devices
92- for dev in $DEVICE $DEVICE6 $IP6; do
93+ for dev in $DEVICE $DEVICE6 $IP6 $VLAN_LINK; do
94 case ${dev} in
95 enc*)
96 zdev=${dev#enc}
97@@ -322,6 +326,13 @@ configure_networking()
98 esac
99 done
100
101+ for v in $VLAN; do
102+ vlink=${v##*:}
103+ vname=${v%:*}
104+ vid=${vname#*.}
105+ ip link add name "$vname" link "$vlink" type vlan id "$vid"
106+ done
107+
108 wait_for_udev 10
109
110 # support ip options see linux sources
111@@ -519,8 +530,12 @@ _declare_ip_info() {
112 _render_netplan() {
113 # write a netplan stanza for the given device.
114 local name="$1" mac="$2" dhcp4="$3" dhcp6="$4" addrs="$5" \
115- gateway4="$6" gateway6="$7" ns_addrs="$8" ns_search="$9"
116+ gateway4="$6" gateway6="$7" ns_addrs="$8" ns_search="$9" \
117+ vlink="${10}" vname="${11}" vid="${12}"
118 local n found=""
119+ if [ -n "$vlink" ]; then
120+ name=$vlink
121+ fi
122 echo "network:"
123 echo " version: 2"
124 echo " renderer: networkd"
125@@ -531,6 +546,12 @@ _render_netplan() {
126 echo " macaddress: \"$mac\""
127 echo " set-name: $name"
128 fi
129+ if [ -n "$vname" ]; then
130+ echo " vlans:"
131+ echo " $vname:"
132+ echo " id: $vid"
133+ echo " link: $name"
134+ fi
135 if [ -n "$dhcp4" ]; then
136 echo " dhcp4: $dhcp4"
137 echo " dhcp-identifier: mac"
138@@ -618,6 +639,17 @@ netinfo_to_netplan() {
139 fi
140
141 {
142+ for v in $VLAN; do
143+ vlink=${v##*:}
144+ vname=${v%:*}
145+ vid=${vname#*.}
146+ if [ "$name" = "$vname" ]; then
147+ echo "vlink=$vlink"
148+ echo "vname=$vname"
149+ echo "vid=$vid"
150+ break
151+ fi
152+ done
153 if [ -n "$DEVICE" ]; then
154 # shellcheck disable=SC2153
155 _declare_ip_info 4 "$PROTO" "$IPV4ADDR" "$IPV4NETMASK" "$IPV4GATEWAY"
156@@ -637,9 +669,11 @@ netinfo_to_netplan() {
157 for name in $devices; do
158 local macaddress="" dhcp4="" dhcp6="" addresses=""
159 local gateway4="" gateway6="" ns_addresses="" ns_search=""
160+ local vlink="" vname="" vid=""
161 . "$tmpd/$name"
162 _render_netplan "$name" "$macaddress" "$dhcp4" "$dhcp6" "$addresses" \
163 "$gateway4" "$gateway6" "$ns_addresses" "$ns_search" \
164+ "$vlink" "$vname" "$vid" \
165 > "${out_d}/$name.yaml"
166 done
167 rm -Rf "$tmpd"
168diff --git a/tests/test_netinfo.d/vlan/expected-resolv.conf b/tests/test_netinfo.d/vlan/expected-resolv.conf
169new file mode 100644
170index 0000000..c5d1458
171--- /dev/null
172+++ b/tests/test_netinfo.d/vlan/expected-resolv.conf
173@@ -0,0 +1,3 @@
174+nameserver 192.168.122.1
175+nameserver 2001:67c:1562:8010::2:1
176+search foo.com example.com ubuntu.com
177diff --git a/tests/test_netinfo.d/vlan/net-example1.1.conf b/tests/test_netinfo.d/vlan/net-example1.1.conf
178new file mode 100644
179index 0000000..ef7008b
180--- /dev/null
181+++ b/tests/test_netinfo.d/vlan/net-example1.1.conf
182@@ -0,0 +1,22 @@
183+# VLAN actually comes from vlan= kernel cmdline...
184+# ... but this file is sourced, so pretend it was
185+# parsed out kernel cmdline
186+VLAN=example1.1:example1
187+# end of hack
188+DEVICE='example1.1'
189+PROTO='dhcp'
190+IPV4ADDR='192.168.122.89'
191+IPV4BROADCAST='192.168.122.255'
192+IPV4NETMASK='255.255.255.0'
193+IPV4GATEWAY='192.168.122.1'
194+IPV4DNS0='192.168.122.1'
195+IPV4DNS1='0.0.0.0'
196+HOSTNAME='foohost'
197+DNSDOMAIN=''
198+NISDOMAIN=''
199+ROOTSERVER='192.168.122.1'
200+ROOTPATH=''
201+filename=''
202+UPTIME='21'
203+DHCPLEASETIME='3600'
204+DOMAINSEARCH='foo.com'
205diff --git a/tests/test_netinfo.d/vlan/net6-example1.1.conf b/tests/test_netinfo.d/vlan/net6-example1.1.conf
206new file mode 100644
207index 0000000..c7d3cda
208--- /dev/null
209+++ b/tests/test_netinfo.d/vlan/net6-example1.1.conf
210@@ -0,0 +1,15 @@
211+# VLAN actually comes from vlan= kernel cmdline...
212+# ... but this file is sourced, so pretend it was
213+# parsed out kernel cmdline
214+VLAN=example1.1:example1
215+# end of hack
216+DEVICE6=example1.1
217+HOSTNAME=
218+DNSDOMAIN=
219+IPV6PROTO=dhcp6
220+IPV6ADDR=2001:67c:1562:8010:0:1::
221+IPV6NETMASK=64
222+IPV6DNS0=2001:67c:1562:8010::2:1
223+IPV6DOMAINSEARCH="example.com ubuntu.com"
224+HOSTNAME=
225+DNSDOMAIN=
226diff --git a/tests/test_netinfo.d/vlan/netplan/example1.1.yaml b/tests/test_netinfo.d/vlan/netplan/example1.1.yaml
227new file mode 100644
228index 0000000..7a570fb
229--- /dev/null
230+++ b/tests/test_netinfo.d/vlan/netplan/example1.1.yaml
231@@ -0,0 +1,16 @@
232+network:
233+ version: 2
234+ renderer: networkd
235+ ethernets:
236+ example1:
237+ vlans:
238+ example1.1:
239+ id: 1
240+ link: example1
241+ dhcp4: true
242+ dhcp-identifier: mac
243+ dhcp6: true
244+ critical: true
245+ nameservers:
246+ addresses: ["192.168.122.1", "2001:67c:1562:8010::2:1"]
247+ search: ["foo.com", "example.com", "ubuntu.com"]

Subscribers

People subscribed via source and target branches