Commit Graph

118 Commits

Author SHA1 Message Date
Denys Vlasenko
8cc3a744fb help text: use -P PORT form
function                                             old     new   delta
packed_usage                                       33502   33491     -11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-18 22:51:46 +01:00
Michal Kazior
b817699e6c udhcp: bind to device even for ucast packets
There are cases where binding to source IP and
destination IP is insufficient to guarantee sane
xmit netdev.

One case where this can fail is when
route-matching netdev carrier is down (cable
unplugged, wifi disconnected), or the netdev is
admin down. Then all the IP based bindings (bind()
+ connect()) will seemingly succeed but the actual
packet can go out through a default gw path.

Depending on the network this happens on
it can create issues or false alarms. It can
also leak some subnet info across networks that
shouldn't be routed.

As such better be safe than sorry and bind to a
netdev to be sure it's used for xmit.

function                                             old     new   delta
udhcp_send_kernel_packet                             293     336     +43
send_packet                                          182     188      +6
bcast_or_ucast                                        37      43      +6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 55/0)               Total: 55 bytes

Signed-off-by: Michal Kazior <michal@plume.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-15 21:44:21 +01:00
Denys Vlasenko
965b795b87 decrease paddign: gcc-9.3.1 slaps 32-byte alignment on arrays willy-nilly
text	   data	    bss	    dec	    hex	filename
1021988	    559	   5052	1027599	  fae0f	busybox_old
1021236	    559	   5052	1026847	  fab1f	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-30 13:03:03 +01:00
Norbert Lange
79bd7c3f7b acpid: only display -p if supported in usage
Signed-off-by: Norbert Lange <nolange79@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-29 14:11:03 +02:00
Norbert Lange
05faa6103b dhcpd: remove hardcoded pidfile path
Signed-off-by: Norbert Lange <nolange79@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-29 14:07:57 +02:00
Denys Vlasenko
020abc8856 udhcpd: mangle hostnames starting with dash ("-option")
function                                             old     new   delta
add_lease                                            316     328     +12

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-01-14 17:07:18 +01:00
James Byrne
6937487be7 libbb: reduce the overhead of single parameter bb_error_msg() calls
Back in 2007, commit 0c97c9d437 ("'simple' error message functions by
Loic Grenie") introduced bb_simple_perror_msg() to allow for a lower
overhead call to bb_perror_msg() when only a string was being printed
with no parameters. This saves space for some CPU architectures because
it avoids the overhead of a call to a variadic function. However there
has never been a simple version of bb_error_msg(), and since 2007 many
new calls to bb_perror_msg() have been added that only take a single
parameter and so could have been using bb_simple_perror_message().

This changeset introduces 'simple' versions of bb_info_msg(),
bb_error_msg(), bb_error_msg_and_die(), bb_herror_msg() and
bb_herror_msg_and_die(), and replaces all calls that only take a
single parameter, or use something like ("%s", arg), with calls to the
corresponding 'simple' version.

Since it is likely that single parameter calls to the variadic functions
may be accidentally reintroduced in the future a new debugging config
option WARN_SIMPLE_MSG has been introduced. This uses some macro magic
which will cause any such calls to generate a warning, but this is
turned off by default to avoid use of the unpleasant macros in normal
circumstances.

This is a large changeset due to the number of calls that have been
replaced. The only files that contain changes other than simple
substitution of function calls are libbb.h, libbb/herror_msg.c,
libbb/verror_msg.c and libbb/xfuncs_printf.c. In miscutils/devfsd.c,
networking/udhcp/common.h and util-linux/mdev.c additonal macros have
been added for logging so that single parameter and multiple parameter
logging variants exist.

The amount of space saved varies considerably by architecture, and was
found to be as follows (for 'defconfig' using GCC 7.4):

Arm:     -92 bytes
MIPS:    -52 bytes
PPC:   -1836 bytes
x86_64: -938 bytes

Note that for the MIPS architecture only an exception had to be made
disabling the 'simple' calls for 'udhcp' (in networking/udhcp/common.h)
because it made these files larger on MIPS.

Signed-off-by: James Byrne <james.byrne@origamienergy.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-07-02 11:35:03 +02:00
Denys Vlasenko
65c34c52df dhcp: get rid of static data signal_pipe
function                                             old     new   delta
udhcp_sp_setup                                        65     110     +45
udhcp_sp_fd_set                                       60      59      -1
udhcpd_main                                         1442    1437      -5
udhcpc_main                                         2684    2679      -5
signal_pipe                                            8       -      -8
packed_usage                                       33292   33284      -8
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/4 up/down: 45/-27)             Total: 18 bytes
   text	   data	    bss	    dec	    hex	filename
 952746	    481	   7296	 960523	  ea80b	busybox_old
 952768	    481	   7288	 960537	  ea819	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-31 23:39:22 +02:00
Denys Vlasenko
91755cb16d udhcp: rename server_config to server_data
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-30 16:23:34 +02:00
Denys Vlasenko
831844c139 udhcpd: fix printing of static leases
function                                             old     new   delta
read_staticlease                                     299     282     -17

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-21 16:06:34 +02:00
Denys Vlasenko
25393fb55e udhcpd: code shrink
function                                             old     new   delta
send_packet_verbose                                    -      35     +35
send_offer                                           443     423     -20
send_ACK                                             152     131     -21
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/2 up/down: 35/-41)             Total: -6 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-16 11:27:28 +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
8402969d48 udhcpd: code shrink - do not fetch requested IP twice
function                                             old     new   delta
send_offer                                           444     443      -1
udhcpd_main                                         1454    1442     -12
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-13)             Total: -13 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-15 13:08:48 +02:00
Denys Vlasenko
8c317f03f6 style fix, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-14 17:26:47 +02:00
Denys Vlasenko
15021f393d udhcpd: code shrink
function                                             old     new   delta
is_nip_reserved_as_static                              -      28     +28
get_static_nip_by_mac                                 43      47      +4
udhcpd_main                                         1459    1454      -5
send_offer                                           449     444      -5
read_leases                                          309     299     -10
is_nip_reserved                                       20       -     -20
packed_usage                                       33283   33243     -40
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 1/4 up/down: 32/-80)            Total: -48 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-10 15:55:12 +02:00
James Byrne
253c4e787a Optionally re-introduce bb_info_msg()
Between Busybox 1.24.2 and 1.25.0 the bb_info_msg() function was
eliminated and calls to it changed to be bb_error_msg(). The downside of
this is that daemons now log all messages to syslog at the LOG_ERR level
which makes it hard to filter errors from informational messages.

This change optionally re-introduces bb_info_msg(), controlled by a new
option FEATURE_SYSLOG_INFO, restores all the calls to bb_info_msg() that
were removed (only in applets that set logmode to LOGMODE_SYSLOG or
LOGMODE_BOTH), and also changes informational messages in ifplugd and
ntpd.

The code size change of this is as follows (using 'defconfig' on x86_64
with gcc 7.3.0-27ubuntu1~18.04)

function                                             old     new   delta
bb_info_msg                                            -     182    +182
bb_vinfo_msg                                           -      27     +27
static.log7                                          194     198      +4
log8                                                 190     191      +1
log5                                                 190     191      +1
crondlog                                              45       -     -45
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 3/0 up/down: 215/-45)           Total: 170 bytes

If you don't care about everything being logged at LOG_ERR level
then when FEATURE_SYSLOG_INFO is disabled Busybox actually gets smaller:

function                                             old     new   delta
static.log7                                          194     200      +6
log8                                                 190     193      +3
log5                                                 190     193      +3
syslog_level                                           1       -      -1
bb_verror_msg                                        583     581      -2
crondlog                                              45       -     -45
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 3/1 up/down: 12/-48)            Total: -36 bytes

Signed-off-by: James Byrne <james.byrne@origamienergy.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-30 10:51:27 +02:00
Denys Vlasenko
3d27d435db randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-27 18:03:20 +01:00
Denys Vlasenko
6d3b4bb24d udhcpc: check that 4-byte options are indeed 4-byte, closes 11506
function                                             old     new   delta
udhcp_get_option32                                     -      27     +27
udhcp_get_option                                     231     248     +17
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/0 up/down: 44/0)               Total: 44 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-17 18:07:18 +01:00
Denys Vlasenko
148788eb0e udhcpc: remove code which requires server ID to be on local network
This reverts "udhcpc: paranoia when using kernel UDP mode
for sending renew: server ID may be bogus".

Users complain that they do have servers behind routers
(with DHCP relays).

function                                             old     new   delta
send_packet                                          168     166      -2
bcast_or_ucast                                        25      23      -2
udhcp_send_kernel_packet                             301     295      -6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-10)             Total: -10 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-06-21 17:38:14 +02:00
Denys Vlasenko
6027597fd1 udhcpc6: set -x options in request
Last foru commits:

function                                             old     new   delta
option_to_env                                        621     791    +170
.rodata                                           168351  168505    +154
attach_option                                        431     506     +75
add_d6_client_options                                112     167     +55
d6_option_strings                                     30      84     +54
udhcp_str2optset                                     644     660     +16
d6_optflags                                           12      20      +8
udhcpc6_main                                        2590    2596      +6
udhcpc_main                                         2648    2651      +3
read_optset                                           15      18      +3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 10/0 up/down: 544/0)            Total: 544 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-05-14 11:11:08 +02:00
Denys Vlasenko
3d306bffc5 udhcpd: clamp down huge auto_times to ~2M seconds, better EINTR poll handling
EINTR _should_ only happen on two signals we trap, and safe_poll
_should_ work here just fine, but there were kernel bugs where spurious EINTRs
happen (e.g. on ptrace attach). Be safe.

function                                             old     new   delta
udhcpd_main                                         1437    1468     +31

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-11 11:39:05 +01: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
2bd5b4e9a0 udhcp: do not setlinebuf(stdout), we don't print to stdout anymore
Since bb_info_msg() was eliminated type of buffering on stdout is not important

function                                             old     new   delta
udhcpd_main                                         1463    1451     -12
udhcpc_main                                         2735    2723     -12
setlinebuf                                            19       -     -19
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 0/2 up/down: 0/-43)             Total: -43 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-07 16:32:30 +01:00
Denys Vlasenko
06076494da udhcpd: use ptr_to_globals for its lone global data (g_leases)
function                                             old     new   delta
udhcpd_main                                         1461    1463      +2
add_lease                                            320     318      -2
g_leases                                               4       -      -4
write_leases                                         223     214      -9
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/2 up/down: 2/-15)             Total: -13 bytes
   text	   data	    bss	    dec	    hex	filename
 933232	    481	   6856	 940569	  e5a19	busybox_old
 933223	    481	   6852	 940556	  e5a0c	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-01 10:41:14 +01:00
Denys Vlasenko
6f97b30a90 use %m printf specifier where appropriate
function                                             old     new   delta
out                                                   85      75     -10
udhcpd_main                                         1472    1461     -11
open_stdio_to_tty                                     98      85     -13
init_exec                                            245     232     -13
udhcpc_main                                         2763    2749     -14
do_cmd                                              4771    4755     -16
status_line_bold_errno                                32      14     -18
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/7 up/down: 0/-95)             Total: -95 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-09-29 18:17:25 +02:00
Denys Vlasenko
a6a3ad3273 udhcpc: paranoia when using kernel UDP mode for sending renew: server ID may be bogus
With new code, we request that target IP (server ID) must be directly reachable.
If it's not, this happens:

udhcpc: waiting 2000 seconds
udhcpc: entering listen mode: kernel
udhcpc: opening listen socket on *:68 wlan0
udhcpc: entering renew state
udhcpc: sending renew to 1.1.1.1
udhcpc: send: Network is unreachable
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1.1.1.1 needs routing, this is fishy!
udhcpc: entering rebinding state
udhcpc: entering listen mode: raw
udhcpc: created raw socket
udhcpc: sending renew to 0.0.0.0
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ going to use broadcast

which is the desired behavior. Before the patch, packet to 1.1.1.1 was routed
over eth0 (!) and maybe even into Internet (!!!).

function                                             old     new   delta
udhcpc_main                                         2752    2763     +11
udhcp_send_kernel_packet                             295     301      +6
send_renew                                            82      84      +2
send_packet                                          166     168      +2
bcast_or_ucast                                        23      25      +2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/0 up/down: 23/0)               Total: 23 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-09-29 16:02:11 +02:00
Denys Vlasenko
22542eca18 getopt32: remove opt_complementary
function                                             old     new   delta
vgetopt32                                           1318    1392     +74
runsvdir_main                                        703     713     +10
bb_make_directory                                    423     425      +2
collect_cpu                                          546     545      -1
opt_chars                                              3       -      -3
opt_complementary                                      4       -      -4
tftpd_main                                           567     562      -5
ntp_init                                             476     471      -5
zcip_main                                           1266    1256     -10
xxd_main                                             428     418     -10
whois_main                                           140     130     -10
who_main                                             463     453     -10
which_main                                           212     202     -10
wget_main                                           2535    2525     -10
watchdog_main                                        291     281     -10
watch_main                                           222     212     -10
vlock_main                                           399     389     -10
uuencode_main                                        332     322     -10
uudecode_main                                        316     306     -10
unlink_main                                           45      35     -10
udhcpd_main                                         1482    1472     -10
udhcpc_main                                         2762    2752     -10
tune2fs_main                                         290     280     -10
tunctl_main                                          366     356     -10
truncate_main                                        218     208     -10
tr_main                                              518     508     -10
time_main                                           1134    1124     -10
tftp_main                                            286     276     -10
telnetd_main                                        1873    1863     -10
tcpudpsvd_main                                      1785    1775     -10
taskset_main                                         521     511     -10
tar_main                                            1009     999     -10
tail_main                                           1644    1634     -10
syslogd_main                                        1967    1957     -10
switch_root_main                                     368     358     -10
svlogd_main                                         1454    1444     -10
sv                                                  1296    1286     -10
stat_main                                            104      94     -10
start_stop_daemon_main                              1028    1018     -10
split_main                                           542     532     -10
sort_main                                            796     786     -10
slattach_main                                        624     614     -10
shuf_main                                            504     494     -10
setsid_main                                           96      86     -10
setserial_main                                      1132    1122     -10
setfont_main                                         388     378     -10
setconsole_main                                       78      68     -10
sendmail_main                                       1209    1199     -10
sed_main                                             677     667     -10
script_main                                         1077    1067     -10
run_parts_main                                       325     315     -10
rtcwake_main                                         454     444     -10
rm_main                                              175     165     -10
reformime_main                                       119     109     -10
readlink_main                                        123     113     -10
rdate_main                                           246     236     -10
pwdx_main                                            189     179     -10
pstree_main                                          317     307     -10
pscan_main                                           663     653     -10
popmaildir_main                                      818     808     -10
pmap_main                                             80      70     -10
nc_main                                             1042    1032     -10
mv_main                                              558     548     -10
mountpoint_main                                      477     467     -10
mount_main                                          1264    1254     -10
modprobe_main                                        768     758     -10
modinfo_main                                         333     323     -10
mktemp_main                                          200     190     -10
mkswap_main                                          324     314     -10
mkfs_vfat_main                                      1489    1479     -10
microcom_main                                        715     705     -10
md5_sha1_sum_main                                    521     511     -10
man_main                                             867     857     -10
makedevs_main                                       1052    1042     -10
ls_main                                              563     553     -10
losetup_main                                         432     422     -10
loadfont_main                                         89      79     -10
ln_main                                              524     514     -10
link_main                                             75      65     -10
ipcalc_main                                          544     534     -10
iostat_main                                         2397    2387     -10
install_main                                         768     758     -10
id_main                                              480     470     -10
i2cset_main                                         1239    1229     -10
i2cget_main                                          380     370     -10
i2cdump_main                                        1482    1472     -10
i2cdetect_main                                       682     672     -10
hwclock_main                                         406     396     -10
httpd_main                                           741     731     -10
grep_main                                            837     827     -10
getty_main                                          1559    1549     -10
fuser_main                                           297     287     -10
ftpgetput_main                                       345     335     -10
ftpd_main                                           2232    2222     -10
fstrim_main                                          251     241     -10
fsfreeze_main                                         77      67     -10
fsck_minix_main                                     2921    2911     -10
flock_main                                           314     304     -10
flashcp_main                                         740     730     -10
flash_eraseall_main                                  833     823     -10
fdformat_main                                        532     522     -10
expand_main                                          680     670     -10
eject_main                                           335     325     -10
dumpleases_main                                      630     620     -10
du_main                                              314     304     -10
dos2unix_main                                        441     431     -10
diff_main                                           1350    1340     -10
df_main                                             1064    1054     -10
date_main                                           1095    1085     -10
cut_main                                             961     951     -10
cryptpw_main                                         228     218     -10
crontab_main                                         575     565     -10
crond_main                                          1149    1139     -10
cp_main                                              370     360     -10
common_traceroute_main                              3834    3824     -10
common_ping_main                                    1767    1757     -10
comm_main                                            239     229     -10
cmp_main                                             655     645     -10
chrt_main                                            379     369     -10
chpst_main                                           704     694     -10
chpasswd_main                                        308     298     -10
chown_main                                           171     161     -10
chmod_main                                           158     148     -10
cat_main                                             428     418     -10
bzip2_main                                           120     110     -10
blkdiscard_main                                      264     254     -10
base64_main                                          221     211     -10
arping_main                                         1665    1655     -10
ar_main                                              556     546     -10
adjtimex_main                                        406     396     -10
adduser_main                                         882     872     -10
addgroup_main                                        411     401     -10
acpid_main                                          1198    1188     -10
optstring                                             11       -     -11
opt_string                                            18       -     -18
OPT_STR                                               25       -     -25
ubi_tools_main                                      1288    1258     -30
ls_options                                            31       -     -31
------------------------------------------------------------------------------
(add/remove: 0/6 grow/shrink: 3/129 up/down: 86/-1383)      Total: -1297 bytes
   text	   data	    bss	    dec	    hex	filename
 915428	    485	   6876	 922789	  e14a5	busybox_old
 914629	    485	   6872	 921986	  e1182	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-08 21:55:02 +02:00
Denys Vlasenko
ba4fbca8a8 udhcpc6: make -O OPT work
Patch is based on work by tiggerswelt.net.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-06-28 19:18:17 +02:00
Denys Vlasenko
52a515d187 udhcp: use poll() instead of select()
function                                             old     new   delta
udhcp_sp_read                                         65      46     -19
udhcp_sp_fd_set                                       79      54     -25
udhcpd_main                                         1530    1482     -48
udhcpc_main                                         2780    2730     -50
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-142)           Total: -142 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-02-16 23:25:44 +01:00
Denys Vlasenko
f7683cdf83 Convert all udhcp applets to "new style" applet definitions
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-23 18:54:59 +01:00
Denys Vlasenko
a85740c8af dhcp: merge leases.c and static_leases.c into dhcpd.c
function                                             old     new   delta
send_offer                                           292     461    +169
udhcpd_main                                         1531    1588     +57
read_leases                                          330     332      +2
add_lease                                            314     312      -2
find_lease_by_mac                                     68       -     -68
find_free_or_expired_nip                             174       -    -174
------------------------------------------------------------------------------
(add/remove: 0/4 grow/shrink: 3/1 up/down: 228/-244)          Total: -16 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-04 00:56:58 +02:00
Denys Vlasenko
d2ae66cb3e dhcp: merge most of static_leases.c into dhcpd.c
function                                             old     new   delta
read_staticlease                                     121     222    +101
add_static_lease                                      48       -     -48
log_static_leases                                     68       -     -68
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 1/0 up/down: 101/-116)          Total: -15 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-04 00:56:58 +02:00
Denys Vlasenko
2bf2931d52 dhcp: merge files.c into dhcpd.c
Added NOINLINE to two function, since my version of gcc would actualy increase
code size otherwise.

I see no size changes.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-04 00:56:58 +02:00
Denys Vlasenko
df70a43af2 udhcp: add setup_common_bufsiz() as needed
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-21 18:54:36 +02:00
Denys Vlasenko
16efe19128 dhcpd: string reuse
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-03-30 18:44:52 +02:00
Denys Vlasenko
8f2e99c813 udhcp: get rid of bb_info_msg()
function                                             old     new   delta
udhcpd_main                                         1501    1531     +30
d6_recv_raw_packet                                   251     264     +13
perform_d6_release                                   188     198     +10
udhcpc6_main                                        2443    2449      +6
udhcp_recv_raw_packet                                582     588      +6
udhcp_recv_kernel_packet                             132     138      +6
send_d6_renew                                        140     146      +6
d6_recv_kernel_packet                                118     124      +6
send_renew                                            77      82      +5
send_discover                                         85      90      +5
send_decline                                          84      89      +5
send_d6_select                                        97     102      +5
send_d6_discover                                     174     179      +5
perform_release                                      167     172      +5
count_lines                                           72      74      +2
udhcpc_main                                         2836    2837      +1
bb_info_msg                                          125       -    -125
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 17/4 up/down: 117/-180)         Total: -63 bytes
   text	   data	    bss	    dec	    hex	filename
 924935	    906	  17160	 943001	  e6399	busybox_old
 924736	    906	  17160	 942802	  e62d2	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-03-30 18:41:23 +02:00
Denys Vlasenko
936c401077 dhcpd: fix an improper widening conversion
We wanted to detect when tv_sec = unsigned1 - unsigned2
underflows by looking at tv_sec's sign. But if tv_sec
is long and it is wider than unsigned, we get unsigned -> long
conversion which is in this case never negative.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-27 21:59:40 +01:00
Michel Stam
9f41271f3c udhcpd: add option for tweaking arpping
Some clients have a very short timeout for sending the DHCP
DISCOVER, shorter than the arpping timeout of 2000 milliseconds
that udhcpd uses by default.

This patch allows tweaking the timeout, or disabling of arpping
altogether, at the risk of handing out addresses which are
already in use.

function                                             old     new   delta
udhcpd_main                                         1460    1501     +41
udhcpc_main                                         2814    2851     +37
packed_usage                                       29957   29974     +17
arpping                                              477     493     +16
find_free_or_expired_nip                             161     174     +13
send_offer                                           285     292      +7
nobody_responds_to_arp                                85      89      +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 7/0 up/down: 135/0)             Total: 135 bytes

Signed-off-by: Michel Stam <m.stam@fugro.nl>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-10-30 11:59:04 +01:00
Denys Vlasenko
7b5d5c1bdb udhcpd: also add -I ADDR to help text
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-03-14 02:18:52 +01:00
Denys Vlasenko
e3f5b73ad0 udhcpd: add -I LOCAL_ADDR option
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-03-13 22:27:37 +01:00
Denys Vlasenko
71045cc819 dhcpd: write lease file on exit
function                                             old     new   delta
udhcpd_main                                         1431    1403     -28

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-07-24 17:21:26 +02:00
Leonid Lisovskiy
6c9c0a1dc9 udhcp: IF_UDHCP_VERBOSE() macro - improve code readability
Signed-off-by: Leonid Lisovskiy <lly.dev@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-10-18 00:35:47 +02:00
Pere Orga
5bc8c005a8 move remaining help text from include/usage.src.h
Signed-off-by: Pere Orga <gotrunks@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-04-11 03:29:49 +02:00
Denys Vlasenko
713d241852 dhcpd: reply with NAK to clients in INIT-REBOOT state w/o existing lease
We were not responding to them at all.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-11-28 21:51:44 +01:00
Denys Vlasenko
fa5e295600 dhcpd: smaller code: do not look for REQUESTED_IP twice
text    data     bss     dec     hex filename
 883235     936   17192  901363   dc0f3 busybox_old
 883219     936   17192  901347   dc0e3 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-11-28 01:10:51 +01:00
Denys Vlasenko
e4dcba1c10 *: whitespace fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-10-28 18:57:19 +02:00
Denys Vlasenko
0bb35e19a7 udhcpd: reduce stack usage by ~700 bytes. +28 bytes code size
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-10-21 12:33:10 +02:00
Mike Frysinger
6db1373295 udhcpd: fix daemonize crash on nommu systems
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2010-06-04 13:24:50 -04:00
Denys Vlasenko
f8fcc184b6 udhcpd: note missing sanity checks on INFORM message handling
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-04-04 22:36:34 +02:00
Denys Vlasenko
406bd14416 udhcpd: fix -v/-P mixup
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-03-27 23:24:57 +01:00