Commit Graph

370 Commits

Author SHA1 Message Date
Alexey Sheplyakov
30a09ca772 20210831-alt1
- Network boot: improved automatic interface selection (closes: #40616)
2021-09-02 12:04:57 +04:00
Alexey Sheplyakov
110ac7dff1 Network boot: ignore interfaces without a carrier
Also skip interfaces which can't be brought up for some reason
(i.e. missing firmware). Thus the system can boot automatically
when exactly one interface has a carrier.

Closes: #40616
2021-09-02 12:04:57 +04:00
Alexey Sheplyakov
dd58d27275 20210823-alt1 2021-08-23 16:15:59 +04:00
Alexey Sheplyakov
db44ebdc74 Avoid races between init mounting loopback device and udev probing it
LOOP_SET_FD, LOOP_SET_STATUS ioctls trigger a `change` event with
loopback device in question. udev handles those events with
(builtin) blkid command. Probing a device with blkid takes a while,
so init might try to mount the loopback device in question while
`blkid` is still running. As a result init and udev block each other.
Eventually (after 3 minutes or whatever udev event timeout is)
`blkid` gets killed and boot proceeds. However such long delays are
very annoying. Therefore run `udev_settle` after each loop related
ioctl to avoid the concurrent access to the same loopback device.

Closes: #40687
2021-08-19 20:00:34 +04:00
Egor Ignatov
095e17ab91
20210721-alt1
- mkmodpack: include leading directories for firmware files
  The kernel needs leading directories in the cpio archive when
  creating rootfs. Otherwise, the files will not be copied.
2021-07-21 18:56:21 +03:00
Egor Ignatov
7738617c4c
mkmodpack: include leading directories for firmware files
The kernel needs leading directories in the cpio archive when
creating rootfs. Otherwise, the files will not be copied.
2021-07-21 18:56:10 +03:00
Evgeny Sinelnikov
eee4e636d9 20210329-alt1
- Add support 'fuid' automatic mode option for method cdrom
- Fix potential memory overflow in welcome string
- Set PREFIX to "/" for nfs and cifs methods due its mounted to image root
2021-04-05 13:10:16 +04:00
Evgeny Sinelnikov
9e47dc484c network.c: set PREFIX to "/" for nfs and cifs methods due its mounted to image root 2021-04-05 13:05:51 +04:00
Evgeny Sinelnikov
bcc496411b Fix potential memory overflow in welcome string
stage1.c:354:41: warning: '%s' directive output may be truncated writing up to 127 bytes into a region of size 117 [-Wformat-truncation=]
  snprintf(buf, sizeof(buf), "Welcome to %s", version);
                                         ^~   ~~~~~~~
In file included from /usr/include/stdio.h:862,
                 from stage1.c:30:
/usr/include/bits/stdio2.h:64:10: note: '__builtin___snprintf_chk' output between 12 and 139 bytes into a destination of size 128
   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        __bos (__s), __fmt, __va_arg_pack ());
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2021-04-04 17:34:46 +04:00
Evgeny Sinelnikov
7a21d264c7 cdrom.c, tools.{h.c}: Add support 'fuid' automatic mode option for method cdrom
The installed system can have several devices with the same structure.
The automatic 'fuid' option can be used to detach one from the other to find the
partition where our stage2 image is stored, launched from stage1 (in this case
propagator). This option works automatically with the cdrom method:
- automatic=method:cdrom,fuid:PATH_TO_UNIQ_UID_FILENAME
2021-04-04 17:18:25 +04:00
Evgeny Sinelnikov
1a5eefb6f4 20210327-alt1
- cdrom.c: Try to mount multiple devices in automatic mode
2021-03-27 03:01:15 +04:00
Evgeny Sinelnikov
6beeb2ccca cdrom.c: Try to mount multiple devices in automatic mode 2021-03-27 02:59:28 +04:00
Anton Midyukov
c1feb23c6d 20210323-alt1
- disk.c, mount.c: Add support exfat
2021-03-23 12:25:53 +07:00
Anton Midyukov
ae2901d290 disk.c, mount.c: Add support exfat 2021-03-23 12:24:50 +07:00
Dmitriy Terekhin
b4c8144c03 20201216-alt1
- mkmodpack: warn about incorrect patterns
  Kernel modules may be needed to access rootfs.
  Such modules must be present in the initramfs.
  The mkmodpack script finds modules by given patterns.
  If the pattern is specified incorrectly, the module
  will not be found and booting will become impossible.
  Need to warn about module patterns that do not match with anything.
2020-12-18 20:45:04 +04:00
Dmitriy Terekhin
72805ad038 mkmodpack: warn about incorrect patterns
Kernel modules may be needed to access rootfs.
Such modules must be present in the initramfs.
The mkmodpack script finds modules by given patterns.
If the pattern is specified incorrectly, the module
will not be found and booting will become impossible.

Need to warn about module patterns
that do not match with anything.

The pattern can match the name of a module built into
the kernel as given by modprobe.
However, modprobe can fix some incorrect patterns.
These patterns should also be reported.
2020-12-18 20:38:54 +04:00
Evgeny Sinelnikov
7fb55b0d80 20190829-alt1
- fix hangs until http socket not closed on server side (closes: #37150)
- tools.c: break reading cycle if we actually loaded program into memory
- url.c, network.c: disable keep-alive and close http socket after downloading
2019-09-03 17:31:04 +04:00
Evgeny Sinelnikov
d39b85ae32 tools.c: break reading cycle if we actually loaded program into memory 2019-09-03 17:31:03 +04:00
Evgeny Sinelnikov
111d828c45 network.c, url.c: disable keep-alive and close http socket after downloading
With default Connection: keep-alive and without closing read socket after
downloading stage2 propagator hangs until socket not closed on server side.
2019-09-03 17:30:52 +04:00
0d3ff4dabd 20190418-alt1
- compile with _FILE_OFFSET_BITS=64
2019-04-18 12:00:06 +03:00
Leonid Krivoshein
b4917948fe 20181117-alt1
- probing.c: added support for SD-cards when boot in LiveCD-mode
2018-11-17 22:53:22 +03:00
Evgeny Sinelnikov
a352e62521 20180822-alt1
- add support cifs install method
- replace HTTP request version from 1.0 to 1.1
- increase DHCP tries and timeouts for DISCOVER request
2018-08-22 20:11:28 +04:00
Evgeny Sinelnikov
59a9c4de30 add support of cifs network install method 2018-08-22 20:08:23 +04:00
Evgeny Sinelnikov
95bfcf8542 replace HTTP request version to 1.1 2018-08-22 20:08:23 +04:00
Evgeny Sinelnikov
8c1beeb584 DHCP: fixed timeout for DISCOVER request 2018-08-22 20:08:23 +04:00
Arseny Maslennikov
41bb05e67e 20180606-alt1
- dhcp.c: Remove temporary default route properly (altbug:#34347).
- dhcp.c: Provide DHCP vendor class identifier in requests (altbug:#34320).
  This behaviour can be reverted with a kernel command line parameter.
2018-06-09 18:32:06 +03:00
Arseny Maslennikov
6ce39ab483 dhcp.c: Remove temporary default route properly
DHCP is implemented in propagator in a rather lazy way:
to dynamically configure a network interface, say `eno1',
instead of slinging raw Ethernet frames around like everyone else,
it sets up a (temporary) default null route through that interface
and throws UDP messages with actual bootp payload.

`ip' utility describes such a route as `default dev eno1 scope link'

The idea behind this presumably was to avoid generating IP and UDP
headers manually while the null route is sufficient to send a couple of
link-wide (maybe broadcast) messages and generic enough to work anywhere.

To this date propagator didn't bother to remove that route,
so *in some networks* it had persisted even after the initramfs
(and propagator itself) was long gone, and in other networks did not,
having been luckily replaced by the default route to DHCP gateway.

In the cases where it did the real problem showed itself
after the real userspace (for example, in a live distro)
eventually tried to reconfigure the network (because why not?).
The pesky null route was most often left untouched by the DHCP client
(ALT live distros mostly use dhcpcd), managing to squeeze its way
up the routing table and effectively preventing the host
from network access beyond a router.

If the NFS root is behind a couple routers, any attempt to access
the file system gets stuck — the system keeps tirelessly looking for
the NFS host via ARP.
2018-06-09 18:27:06 +03:00
Arseny Maslennikov
dfa3713d0f dhcp.c: Provide an option to omit the vendor class
Some obsolete DHCP implementations in specialized network hardware
(Cisco, we're looking at you) discard DHCP messages from a client
attempting to reconfigure itself and providing a different vendor class
identifier the second time — much like a network-booting system.

To cope with that, propagator will not send a vendor class identifier
if `dhcp-send-vendor-id:off' is specified as part of its "automatic"
parameters on the kernel command line.
Feel free to use any boolean value: yes/no, true/false, on/off.
The default behaviour is "yes".
2018-06-09 18:27:00 +03:00
Arseny Maslennikov
41519b564d dhcp.c: Provide a DHCP vendor class identifier in requests 2018-06-06 23:40:28 +03:00
Arseny Maslennikov
2440a17fbe Remove unnecessary whitespace from C program text 2018-05-09 15:21:26 +03:00
Leonid Krivoshein
bb48084aa0 20180423-alt1
- New udev control logic imported from make-initrd scripts.
- Udev-trigger replaced to udev-settle() in hardware wait loops.
- All udev control code moved from init.c to new udev.c module.
- Lazy initialization mode support added for work in cooperate
  with make-initrd: this is experimental future, turned off by
  default, and also required patched make-initrd-propagator.
- disk.c, cdrom.c: 15 attempts with udev-settle() calls.
- network.c: bridge up algorithm reviewed, fixed memory leaks.
- network.c: 15 attempts to select and wait network interface;
- probing.c, probing.h, dhcp.c: small fixes, now black list used.
- modules_descr.h, stage1.c: deprecated header, unused code removed.
- dhcp.c: fix potentially destructive typo (closes: #34322),
  thanks to Arseny Maslennikov <arseny@altlinux.org>.
- Workaround race conditions during disks detection (closes: #30315).
- Workaround race conditions during bridging up network interfaces,
  see: https://bugzilla.altlinux.org/show_bug.cgi?id=34347 and
  https://lists.altlinux.org/pipermail/sysadmins/2018-April/date.html
  (about "No network Devices found" error message).
- Multiple small code improvements, fixes for avoid memory leaks
  and suppress compiler warnings.
2018-04-23 01:23:23 +03:00
Leonid Krivoshein
8c4366e9c6 network.c: protect from buffer overflow.
This change also suppress a compiler warning:

network.c:307:18: warning: '%d' directive writing between
1 and 11 bytes into a region of size 3 [-Wformat-overflow=]
2018-04-22 20:27:51 +03:00
Leonid Krivoshein
870d181ace mount.c: header added for suppress warning. 2018-04-22 20:14:14 +03:00
Leonid Krivoshein
d2866d5d21 dhcp.c: suppress warning in rfc951_sleep(). 2018-04-22 19:26:01 +03:00
Leonid Krivoshein
6afa449e2e dhcp.c: fix potentially destructive typo.
Thanks to Arseny Maslennikov <arseny@altlinux.org>.
See also: https://bugzilla.altlinux.org/show_bug.cgi?id=34322
2018-04-22 19:20:44 +03:00
Leonid Krivoshein
547debb59b newt-frontend.c: suppress incompatible pointer type warning. 2018-04-22 18:34:27 +03:00
Leonid Krivoshein
70bd62ff84 Makefile, init.c, init.h: multiple changes in code and algorithms.
- New udev control logic imported from make-initrd scripts;
- Udev-trigger replaced to udev-settle() in hardware wait loops;
- All udev control code moved from init.c to new udev.c module;
- Lazy initialization mode support added for work in cooperate
  with make-initrd: this is experimental future, turned off by
  default, and also required patched make-initrd-propagator;
- Small fixes for suppress compiler warnings;
2018-04-22 17:43:47 +03:00
Leonid Krivoshein
416b43d012 network.c: bridge up algorithm reviewed, fixed memory leaks.
+ network.c/interface_select():
  - "No network device found." message moved to intf_select_and_up();
  - This function now is only one attempt with udev-settle() call;
  - Fixed memory leaks;
+ network.c/intf_select_and_up():
  - "No network device found." error messege now here;
  - 15 attempts to select and wait network interface;
  - Recursion replaced to loop;
2018-04-22 17:19:55 +03:00
Leonid Krivoshein
28515312fd disk.c, cdrom.c: 15 attempts with udev-settle() calls. 2018-04-22 17:07:12 +03:00
Leonid Krivoshein
da2111e239 init.c, disk.c, cdrom.c, network.c: whitespace cleanup. 2018-04-22 17:06:01 +03:00
Leonid Krivoshein
485839e4cc probing.c, probing.h, dhcp.c: code fixes, use black list.
+ probing.h/free_net_devices():
  - New function declared;
+ probing.c/free_net_devices():
  - Reverse for get_net_devices() to avoid memory leaks;
+ probing.c/net_dev_black_list:
  - Wireless interfaces "wlan*" added to black list;
+ dhcp.c/perform_dhcp():
  - No more restrict by interface name;
2018-04-22 15:48:10 +03:00
Leonid Krivoshein
da664f7f9e tools.c, tools.h: correct argument type of get_from_env().
This change also suppress compiler warnings.
2018-04-22 15:35:37 +03:00
Leonid Krivoshein
a73ab0446a common.c: more strict address ariphmetic. 2018-04-22 15:31:04 +03:00
Leonid Krivoshein
08aefa7dde udev.c, udev.h: new source files added. 2018-04-22 15:25:16 +03:00
Leonid Krivoshein
5f0d958d1e stage1.c: unused code removed for suppress warning. 2018-04-22 15:17:43 +03:00
Leonid Krivoshein
c22c8f7c72 modules_descr.h: deprecated header removed. 2018-04-22 15:15:09 +03:00
Mikhail Efremov
190f7a826c 20171208-alt1
- probing.c: added support for MMC devices when boot in LiveCD-mode
  (by Leonid Krivoshein).
- cdrom.c: fixed implicit declaration of function opendir warning
  (by Leonid Krivoshein).
- disk.c: Workaround race conditions during disks detection
  (closes: #30315).
- cdrom.c, network.c, tools.c: Fix memory leaks.
- tools.c: Don't do useless comparisons during cmdline processing.
- Use ramdisk_size from kernel cmdline.
- Check that RAM size is enough for ramdisk.
2017-12-08 19:24:09 +03:00
Leonid Krivoshein
0cbc6e7994 probing.c: added support for MMC devices when boot in LiveCD-mode 2017-12-08 16:54:52 +03:00
Leonid Krivoshein
c4d274d21a cdrom.c: fixed implicit declaration of function opendir warning 2017-12-08 16:54:48 +03:00
Mikhail Efremov
a084159547 disk.c: Workaround race conditions during disks detection
https://bugzilla.altlinux.org/show_bug.cgi?id=30315.
2017-12-08 16:54:37 +03:00