summaryrefslogtreecommitdiff
path: root/examples
AgeCommit message (Collapse)Author
2018-03-10udhcpd: fix "not dying on SIGTERM"Denys Vlasenko
Fixes: commit 52a515d18724bbb34e3ccbbb0218efcc4eccc0a8 "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>
2017-07-27tweak examples/var_service/*Denys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-15fix more instances of ": $((a++))" in shell scriptsDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-17Spelling fixes in comments, documentation, tests and examplesDenys Vlasenko
By klemens <ka7@github.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-06examples: make udhcpc script handle /32 netmasksDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-24remove "local" bashism from a few scriptsDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-03README_distro_proposal.txt: typo fixesTito Ragusa
Signed-off-by: Tito Ragusa <farmatito@tiscali.it> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-12-25Update to examples/var_service/README_distro_proposal.txtDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-12-09mdev.conf: rename hw_random to hwrngMike Frysinger
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-03README_distro_proposal.txt: writeup about runit adoptionDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-14examples: update var_service/README againDenys Vlasenko
Added "ps -AH e" example Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-14typo fixes in docDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-14examples: update var_service/README againDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-14examples: update var_service/READMEDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-03examples: add example of a DHCP serverDenys Vlasenko
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-09-26examples: wpa_supplicant.conf has a wrong field deleted in examplesDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-20examples/var_service/supplicant_if: new service exampleDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-07-30service/fw example: do not ruin $if[], use different nameDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-07-25var_service/fw: optionally flush all netdevs; optionally prefer one 0/0 routingDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-07-10examples: add a useful "see abridged log" script for ntpd service exampleDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-04unrpm: clean upMike Frysinger
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2016-04-04undeb: clean upMike Frysinger
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2015-10-24tweak zcip service exampleDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-24Tweak READMEDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-24update network service examplesDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-24New example of a service: examples/var_service/zcip_ifDenys Vlasenko
Zeroconf for IPv4 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-15better pinger service exampleDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-04-14build system: make CONFIG_EXTRA_LDFLAGS go to LDFLAGS, not EXTRA_LDFLAGSDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-03-31update example ntp.scriptDenys Vlasenko
Handle an interesting corner case when NTP server is reachable... but on a different IP now. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-02-07examples/mdev_fat.conf: document that newer mdev exposes pathDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-02-21Improve examples/var_service READMEsDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-01-13examples/udhcp: do not rewrite resolv.conf if no DNS servers. Closes 6788Denys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-04-02examples/mdev.conf.change_blockdev.sh: updateDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-03-30examples: add mdev example for Android phoneDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-03-29examples/inittab: fix a few incorrect statements about initDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-03-12udhcpc: use readlink rather than realpathMike Frysinger
The realpath utility requires all paths exist when canonicalizing symlinks. If /etc/resolv.conf points to a tmpfs, then it might not exist initially. Use `readlink -f` so that we follow all symlinks that are available. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-02-27mdev: improve $SEQ handling; improve debug loggingDenys Vlasenko
Sequential run of concurrent mdev's was too simplistic: they waited for /dev/mdev.seq to match. This could sometimes cause cumulative loss of time on the order of a second. Added SIGCHLD signaling from exiting mdev to all other mdev's. Added debugging required to see that code actually works as intended. Example of /dev/mdev.log (with "woken up" elevated from dbg lvl 3 to 2): mdev[1023]: first seq written ^^^^ seq, not pid mdev[1023]: 35.022395 ACTION:add SUBSYSTEM:module DEVNAME:(null) DEVPATH:/module/lib80211 mdev[1023]: rule matched, line -1 ^^^^^^^ means "default rule" mdev[1023]: 35.022676 exiting ^^^^^^^^^ second,usec timestamp mdev[1024]: 35.069691 ACTION:add SUBSYSTEM:vc DEVNAME:vcs9 DEVPATH:/devices/virtual/vc/vcs9 mdev[1024]: dev 7,9 mdev[1025]: 35.069889 waiting for '1024' mdev[1026]: 35.069946 waiting for '1024' mdev[1027]: 35.070151 waiting for '1024' mdev[1024]: rule matched, line -1 mdev[1024]: mknod vcs9 (7,9) 20660 0:0 mdev[1024]: 35.070346 exiting mdev[1025]: woken up mdev[1026]: woken up mdev[1025]: 35.071213 ACTION:add SUBSYSTEM:vc DEVNAME:vcsa9 DEVPATH:/devices/virtual/vc/vcsa9 ^^^^^^^^^ took only a millisecond to start running after prev mdev exited mdev[1025]: dev 7,137 mdev[1027]: woken up mdev[1025]: rule matched, line -1 mdev[1025]: mknod vcsa9 (7,137) 20660 0:0 mdev[1025]: 35.072109 exiting function old new delta mdev_main 849 1372 +523 curtime - 59 +59 dirAction 87 134 +47 static.ts - 8 +8 keywords 19 12 -7 make_device 2189 2119 -70 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-27udhcpc: tweak math shell style with the metric varMike Frysinger
Some shells (like dash) are lame and omit the POSIX increment/decrement feature (because it is listed as optional). Tweak the shell script to work in all POSIX variants. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-02-27udhcpc: support resolv.conf symlinksMike Frysinger
Often it is desirable to have /etc/ be on read-only storage (well, the whole rootfs) but have things like /etc/resolv.conf be symlinks to a writable location. Tweak the simple script to support that. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-05-18mdev: remove undocumented subsystem/devname matching hackDenys Vlasenko
It was colliding with matching of devnames with slashes. We need a more generic way to examine env.vars in rules anyway. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-05-18mdev: when found, print major,minor into mdev.logDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-05-18mdev: add support for $DEVNAME and /dev/mdev.log debug aidDenys Vlasenko
function old new delta make_device 1843 2083 +240 mdev_main 712 804 +92 packed_usage 29236 29251 +15 keywords 288 19 -269 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/1 up/down: 347/-269) Total: 78 bytes text data bss dec hex filename 887506 497 7584 895587 daa63 busybox_old 887982 497 7584 896063 dac3f busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-05-16examples/mdev_fat.conf: small additionDenys Vlasenko
I needed this to make Android's adb see my phone Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-12-16udhcp: finish support of classless static routesMichael McTernan
function old new delta udhcp_str2optset 415 532 +117 Signed-off-by: Michael McTernan <Michael.McTernan.2001@cs.bris.ac.uk> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-09depmod.pl: output correct dep format according to kernel versionSonic Zhang
All kernel version except for 2.4 has the same dep output format. (Possibly related to era of kernels 3.0+) Signed-off-by: Sonic Zhang <sonic.zhang@analog.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-09tweak comments in android build filesDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-08-09zcip.script: fix $ip environment variableThomas Petazzoni
The environment variable containing the IP address allocated by zcip is "ip" and not "IP". Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-07-19add defconfig files for Android, Cygwin and FreeBSDDaniel Fandrich
Also added an example script to show how to compile BusyBox against Android's bionic. Signed-off-by: Daniel Fandrich <dan@coneharvesters.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-04tweak examples/udhcp/udhcpd.confDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-04-26udhcp: add FEATURE_UDHCP_8021Q optionNigel Hathaway
function old new delta dhcp_option_strings 217 237 +20 dhcp_optflags 64 68 +4 Signed-off-by: Nigel Hathaway <Nigel.Hathaway@ubiquisys.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>