Commit Graph

213 Commits

Author SHA1 Message Date
Stefan Agner
62744efa47 examples/udhcp/simple.script: fix IPv6 support when using udhcpc
The udhcpc script calls ip addr flush .. which flushes addresses
of any address family, including IPv6. However, busybox udhcpc is
IPv4 only and should not influence IPv6 addressing. Hence use ip
addr flush with family constraint.

The script particularly broke IPv6 SLAAC: Typically when udhcpc
calls the script the kernel already assigned the IPv6 link-local
address. The flush removes the link-local IPv6 address again and
prohibits proper IPv6 operation such as SLAAC since neighbor
discovery protocol relies on IPv6 link-local addressing.

Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
[Taken from https://git.openembedded.org/openembedded-core/commit/meta/recipes-core/busybox/files/simple.script?id=b77541dbb2f442e51842f9d24c8745a6df2d1478]
Signed-off-by: Quentin Schulz <quentin.schulz@streamunlimited.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-21 03:02:02 +02:00
Denys Vlasenko
419d0294e9 Updated inittab example documentation
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-11-17 17:48:53 +01:00
Rolf Eike Beer
7f89ebe18f examples/udhcp/simple.script: print the filename actually changed
Signed-off-by: Rolf Eike Beer <eb@emlix.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-09-12 12:06:46 +02:00
Denys Vlasenko
81a708393d examples/udhcp/simple.script: up interface on deconfig event
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-09-05 14:58:30 +02:00
Denys Vlasenko
a51eec0b5a typo fix in comment
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-16 14:31:58 +02:00
Denys Vlasenko
a840884531 udhcpd: support per-client hostnames in static leases
function                                             old     new   delta
read_staticlease                                     222     299     +77
add_server_options                                    92     154     +62
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 139/0)             Total: 139 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-16 11:18:49 +02:00
Denys Vlasenko
1e9a4f56f5 examples/var_service: use "exec sleep 5" instead of "{ sleep 5; exit; }"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-21 14:30:19 +02:00
Rolf Eike Beer
7180d9ed86 examples/udhcp/simple.script: fix resolv.conf update if it is a dangling symlink
If /etc/resolv.conf is a symlink to a tmpfs and the actual file does not
already exist, "readlink -f" will not detect it as symlink. Explicitely check
for that condition before and touch the file, making the other code work as
intended.

Signed-off-by: Rolf Eike Beer <eb@emlix.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-13 16:58:00 +02:00
Denys Vlasenko
1e474d3d93 service examples: if iface do not exist, retry upping it
I've had a case of a machine where eth0 was appearing a bit later
after the boot, and appearing _downed_. ifplugd then fails to detect
"link up". Thus, depending on how service startup
("ip link set dev eth0 up") races with driver initialization,
ethernet randomly fails to initialize on boot.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-05 18:41:48 +02:00
Denys Vlasenko
5a387e26c2 dhcp service example: rewrite "private network to mask" as case statement
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-02-08 10:37:05 +01:00
Denys Vlasenko
2feaba1d8d dhcp service example: cater for servers hot giving subnet and/or router
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-02-05 17:48:24 +01:00
Denys Vlasenko
e17e8d4b7d service examples: do not respawn supplicant too often
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-02-02 19:06:19 +01:00
Denys Vlasenko
f7235cc89f service examples: ifplugd -M to prevents frequent respawning
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-01-18 14:17:02 +01:00
Denys Vlasenko
edb74f4019 Update examples/udhcp/udhcpd.conf
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-01-15 13:19:01 +01:00
Jiří Prchal
47839ae679 examples/udhcp/simple.script: add possibility to use modern "ip"
Script uses "ifconfig" only, not up-to-date so much.
This patch adds "ip" in condition if exists.

Signed-off-by: Jiří Prchal <jiri.prchal@aksignal.cz>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-10-30 12:05:03 +01:00
Denys Vlasenko
871bd2abac examples/var_service: add /var/run flag file to ntp.script
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-07-26 13:45:33 +02:00
Denys Vlasenko
14339191af examples/var_service/: use standard logger script, viewer and pager scripts
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-07-03 23:23:09 +02:00
Denys Vlasenko
aa75a7da7f examples/var_service/: use "svc" for service commands, other tweaks
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-07-03 17:02:50 +02:00
Denys Vlasenko
e56e091d65 examples: update /var/service/getty for Unicode ttys
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-06-23 13:55:13 +02:00
Denys Vlasenko
a40a661d97 tweak /var/service example
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-05-20 22:43:42 +02:00
Denys Vlasenko
c21dfaf836 examples/shutdown-1.0: an example of reboot which does not signal init
For one, my inits know nothing about the concept of "shutting down the system".

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-20 15:12:52 +02:00
Denys Vlasenko
816d8d7a66 setlogcons: open /dev/ttyN for "setlogcons N", not /dev/tty1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-16 21:48:32 +02:00
Denys Vlasenko
266f6f1973 udhcp: support string user options, closes 10946
function                                             old     new   delta
udhcp_str2optset                                     536     628     +92
packed_usage                                       32757   32760      +3
udhcpc_main                                         2708    2692     -16
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 95/-16)             Total: 79 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-13 13:27:52 +02:00
Denys Vlasenko
df65dc89b4 examples/var_service: new example: dnsmasq service
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-30 20:49:16 +02:00
Denys Vlasenko
0d79d7709d svok: new applet (daemontools compat)
function                                             old     new   delta
svok_main                                              -     127    +127
packed_usage                                       32705   32757     +52
applet_names                                        2756    2761      +5
applet_main                                         1588    1592      +4
bb_banner                                             46      47      +1
sv                                                  1286    1284      -2
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 4/1 up/down: 189/-2)            Total: 187 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-30 20:02:33 +02:00
Denys Vlasenko
d892f7137f ifplugd service example: always run up/down script on startup
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-30 11:14:46 +02:00
Denys Vlasenko
3293bc1469 udhcpd: fix "not dying on SIGTERM"
Fixes:
	commit 52a515d187
	"udhcp: use poll() instead of select()"
	Feb 16 2017

udhcp_sp_read() is meant to check whether signal pipe indeed has some data to read.
In the above commit, it was changed as follows:

-	if (!FD_ISSET(signal_pipe.rd, rfds))
+	if (!pfds[0].revents)
		return 0;

The problem is, the check was working for select() purely by accident.
Caught signal interrupts select()/poll() syscalls, they return with EINTR
(regardless of SA_RESTART flag in sigaction). _Then_ signal handler is invoked.
IOW: they can't see any changes to fd state caused by signal haldler
(in our case, signal handler makes signal pipe ready to be read).

For select(), it means that rfds[] bit array is unmodified, bit of signal
pipe's read fd is still set, and the above check "works": it thinks select()
says there is data to read.

This accident does not work for poll(): .revents stays clear, and we do not
try reading signal pipe as we should. In udhcpd, we fall through and block
in socket read. Further SIGTERM signals simply cause socket read to be
interrupted and then restarted (since SIGTERM handler has SA_RESTART=1).

Fixing this as follows: remove the check altogether. Set signal pipe read fd
to nonblocking mode. Always read it in udhcp_sp_read().
If read fails, assume it's EAGAIN and return 0 ("no signal seen").

udhcpd avoids reading signal pipe on every recvd packet by looping if EINTR
(using safe_poll()) - thus ensuring we have correct .revents for all fds -
and calling udhcp_sp_read() only if pfds[0].revents!=0.

udhcpc performs much fewer reads (typically it sleeps >99.999% of the time),
there is no need to optimize it: can call udhcp_sp_read() after each poll
unconditionally.

To robustify socket reads, unconditionally set pfds[1].revents=0
in udhcp_sp_fd_set() (which is before poll), and check it before reading
network socket in udhcpd.

TODO:
This might still fail: if pfds[1].revents=POLLIN, socket read may still block.
There are rare cases when select/poll indicates that data can be read,
but then actual read still blocks (one such case is UDP packets with
wrong checksum). General advise is, if you use a poll/select loop,
keep all your fds nonblocking.
Maybe we should also do that to our network sockets?

function                                             old     new   delta
udhcp_sp_setup                                        55      65     +10
udhcp_sp_fd_set                                       54      60      +6
udhcp_sp_read                                         46      36     -10
udhcpd_main                                         1451    1437     -14
udhcpc_main                                         2723    2708     -15
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/3 up/down: 16/-39)            Total: -23 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-10 19:34:39 +01:00
Denys Vlasenko
2e01eec4d3 tweak examples/var_service/*
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-27 12:53:20 +02:00
Denys Vlasenko
08dfafc437 fix more instances of ": $((a++))" in shell scripts
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-15 19:20:45 +02:00
Denys Vlasenko
10ad622dc2 Spelling fixes in comments, documentation, tests and examples
By klemens <ka7@github.com>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-17 16:13:32 +02:00
Denys Vlasenko
9c192e7f94 examples: make udhcpc script handle /32 netmasks
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-06 00:53:43 +02:00
Denys Vlasenko
bca4ea8b68 remove "local" bashism from a few scripts
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-24 20:52:42 +01:00
Tito Ragusa
d3720828ea README_distro_proposal.txt: typo fixes
Signed-off-by: Tito Ragusa <farmatito@tiscali.it>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-03 12:25:18 +01:00
Denys Vlasenko
96f1d6b70c Update to examples/var_service/README_distro_proposal.txt
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-12-25 20:41:00 +01:00
Mike Frysinger
2098c3511c mdev.conf: rename hw_random to hwrng
The kernel broke the name years ago, but didn't notice until it was much
too late.  Rename the node to match expectations of userland software,
and what the kernel itself documents in its Kconfig help:
	This provides a device that's usually called /dev/hwrng, ...

URL: https://marc.info/?l=linux-crypto-vger&m=144249767024990&w=2
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2016-12-09 16:12:15 -05:00
Denys Vlasenko
fdb4421e00 README_distro_proposal.txt: writeup about runit adoption
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-12-03 14:06:55 +01:00
Denys Vlasenko
6bbb48fadf examples: update var_service/README again
Added "ps -AH e" example

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-14 19:02:11 +02:00
Denys Vlasenko
e43000f2d4 typo fixes in doc
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-14 18:48:05 +02:00
Denys Vlasenko
93ff2b4b5f examples: update var_service/README again
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-14 18:38:08 +02:00
Denys Vlasenko
ee2d19445b examples: update var_service/README
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-14 18:22:50 +02:00
Denys Vlasenko
095ddf7669 examples: add example of a DHCP server
As usual, by multiplying directories - "dhcpd_eth0", "dhcpd_wlan1"
you can run many servers on different interfaces.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-03 23:43:44 +02:00
Denys Vlasenko
dea3bdbefe examples: wpa_supplicant.conf has a wrong field deleted in examples
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-26 20:47:17 +02:00
Denys Vlasenko
d8330ca4a4 examples/var_service/supplicant_if: new service example
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-20 18:09:00 +02:00
Denys Vlasenko
6b5abc9596 service/fw example: do not ruin $if[], use different name
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-07-30 22:29:10 +02:00
Denys Vlasenko
3191ec7cce var_service/fw: optionally flush all netdevs; optionally prefer one 0/0 routing
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-07-25 16:28:57 +02:00
Denys Vlasenko
f6348e50ef examples: add a useful "see abridged log" script for ntpd service example
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-07-10 20:15:28 +02:00
Mike Frysinger
d7d4750e1e unrpm: clean up
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2016-04-04 01:39:17 -04:00
Mike Frysinger
ee22fe8793 undeb: clean up
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2016-04-04 01:35:34 -04:00
Denys Vlasenko
bf1866c183 tweak zcip service example
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-24 18:57:32 +02:00
Denys Vlasenko
1a1cfedbef Tweak README
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-24 14:58:58 +02:00