[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [OSSTEST PATCH 59/62] Debian: Fix /lib/udev/ifupdown-hotplug to not run if / is ro



Empirically, without this, on Debian stretch:

 1. udev starts before / is remounted rw
 2. udev spots eth0 and runs /lib/udev/ifupdown-hotplug
 3. ifupdown-hotplug runs ifup which runs isc-dhcp-client
 4. isc-dhcp-client talks to the dhcp server to get an address
 5. isc-dhcp-client tries to write the lease and run the hook
    scripts but something here fails with EROFS
 6. isc-dhcp-client sends DHCPDECLINE to the server
 7. GOTO 4

This loop continues for several seconds, until / is remounted rw.

None of this is appears in any of the guest's logs because syslog is
not running yet, and none of this stuff goes to the console either.
But it does appear in the dhcp *server* logs so that a conscientious
administrator will suffer consternation and concern.

It is not ever sensible to run /lib/udev/ifupdown-hotplug with /
mounted ro.  (Maybe it is not sensible to run udev so early.)
Skipping it is fine because the boot sequence contains an explicit
call to ifup which occurs *after* / is remounted, and that will
collect any interfaces which were skipped earlier.

In my osstest stretch series development tests I don't think I saw any
actual host install failures due to this situation.  The timeouts are
generous enough not to matter, and of course when we install Xen we
reconfigure the host networking to have a static IP address so then
the problem goes away.

In this patch we do this for the host.  We provide a function to
return the appropriate rune which we will use in a moment.

I have not yet reported this situation to the appropriate Debian
channels.  That's on my backlog.  But in any case I have limited the
workaround to stretch so we will revisit this for buster.

The approach to fixing this is somewhat awkward.

Firstly, since the bug is in /lib/udev/ifupdown-hotplug we want to
edit that script.  But we need to do it in the installer environment
as a late_command, because after first boot, via ssh, is too late.
The installer environment has no `patch'.  I didn't want to just
supply a whole new script.  So instead we use sed and mv.

Secondly, as for the contents of /lib/udev/ifupdown-hotplug: I wasn't
able to think of a convenient shell command which will tell us the
errno value from trying to write a file.  Plenty will print the
strerror but I balked at LC_MESSAGES=C and grep.  Perl, however, can
do this, and is always available on Debian.  So perl it is.

Thirdly, the code has a bad case of toothpicks (lots of \), because it
needs to pass through (i) perl (ii) the shell (iii) sed's regexp
syntax and/or i command.

Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 Osstest/Debian.pm | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/Osstest/Debian.pm b/Osstest/Debian.pm
index 9d7d1518..41aa28b0 100644
--- a/Osstest/Debian.pm
+++ b/Osstest/Debian.pm
@@ -48,6 +48,7 @@ BEGIN {
                       preseed_hook_cmds
                       di_installcmdline_core
                       di_vg_name
+                      debian_dhcp_rofs_fix
                       );
     %EXPORT_TAGS = ( );
 
@@ -931,6 +932,9 @@ END
 set -ex
 END
 
+    preseed_hook_command($ho, 'late_command', $sfx,
+                        debian_dhcp_rofs_fix($ho, '/target'));
+
     my $preseed = <<"END";
 d-i debian-installer/locale string en_GB
 d-i console-keymaps-at/keymap select gb
@@ -1563,4 +1567,22 @@ sub debian_guest_di_version ($) {
     return $gho->{DiVersion};
 }
 
+sub debian_dhcp_rofs_fix ($$) {
+    my ($ho, $rootdir) = @_;
+    # Works around bug where /lib/udev/ifupdown-hotplug runs while
+    # / is still ro.  In stretch, the isc dhcp client spins requesting
+    # an address and then sending a DHCPDECLINE (and then, usually,
+    # eventually works).
+    return '' unless $ho->{Suite} =~ m/stretch/;
+    my $script = "$rootdir/lib/udev/ifupdown-hotplug";
+    <<END.<<'ENDQ'.<<END
+set -ex
+sed -e <'$script' >'$script.new' \\
+END
+'/^if \[ -d \/run\/systemd\/system ]; then/ i perl -e '\''use POSIX; my 
$f="/var/lib/dhcp/rw-fs-check"; exit 0 if open T, ">", $f; die "quitting: $f: 
$!\\n" if $!==EROFS; warn "warning: $f: $!\\n"'\'' || exit 0'
+ENDQ
+mv '$script.new' '$script'
+END
+}
+
 1;
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.