Commit Graph

3022 Commits

Author SHA1 Message Date
Denys Vlasenko
5d553bc558 more --help text tweaks
function                                             old     new   delta
packed_usage                                       33545   33581     +36

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-13 19:18:28 +01:00
Denys Vlasenko
11f1a2553e help text tweaks
function                                             old     new   delta
packed_usage                                       33547   33545      -2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-13 19:04:19 +01:00
Denys Vlasenko
6c5f4296dc traceroute: code shrink
function                                             old     new   delta
hexdump_if_verbose                                     -     255    +255
common_traceroute_main                              1668    1644     -24
hexdump                                              239       -    -239
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/1 up/down: 255/-263)           Total: -8 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-13 15:58:47 +01:00
Denys Vlasenko
623e55a396 traceroute: even with -v, don't show other ping processes reply's
function                                             old     new   delta
traceroute_init                                     1135    1151     +16
common_ping_main                                    1919    1935     +16
common_traceroute_main                              1715    1668     -47
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 32/-47)            Total: -15 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-13 15:53:06 +01:00
Denys Vlasenko
d067acb005 traceroute: simpler hexdump()
function                                             old     new   delta
hexdump                                              270     239     -31

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-13 15:10:07 +01:00
Denys Vlasenko
b4b1828076 traceroute: make "ipv4 or ipv6?" cheaper to find out
function                                             old     new   delta
traceroute_init                                     1131    1135      +4
hexdump                                              274     270      -4
common_traceroute_main                              1730    1715     -15
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 4/-19)             Total: -15 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-13 14:58:11 +01:00
Denys Vlasenko
8055173128 traceroute: don't set SO_DONTROUTE on recv socket, it only affects send
function                                             old     new   delta
traceroute_init                                     1147    1131     -16

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-13 14:18:05 +01:00
Denys Vlasenko
724c7df683 traceroute: untangle main loop
function                                             old     new   delta
common_traceroute_main                              1785    1730     -55

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-12 21:44:32 +01:00
Denys Vlasenko
e76f03b267 traceroute: commonalize verbose printing
function                                             old     new   delta
hexdump                                                -     274    +274
traceroute_init                                     1172    1147     -25
pr_type                                               79       -     -79
common_traceroute_main                              2091    1785    -306
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/2 up/down: 274/-410)         Total: -136 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-12 21:09:21 +01:00
Denys Vlasenko
df5c5394b0 traceroute: set IP_PKTINFO to see correct local IP of received pkt (fixes -v display)
Also, assorted code shrink:

function                                             old     new   delta
traceroute_init                                     1210    1172     -38
common_traceroute_main                              2141    2091     -50
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-88)             Total: -88 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-12 20:09:52 +01:00
Denys Vlasenko
cc55bbef75 traceroute: code shrink
Move init code to a separate function.

function                                             old     new   delta
traceroute_init                                        -    1203   +1203
common_traceroute_main                              3391    2141   -1250
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/1 up/down: 1203/-1250)        Total: -47 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-12 18:09:45 +01:00
Denys Vlasenko
70726640b3 traceroute: code shrink
Do not pass "from" and "to" addresses as parameters, keep them in globals

function                                             old     new   delta
common_traceroute_main                              3426    3391     -35

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-12 18:09:45 +01:00
Denys Vlasenko
d0dea17900 traceroute: code shrink
Do not byteswap ident (why we were doing it?)

function                                             old     new   delta
common_traceroute_main                              3544    3426    -118

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-12 18:09:45 +01:00
Denys Vlasenko
3978adc445 traceroute: fix traceroute6 -I (icmp mode)
function                                             old     new   delta
common_traceroute_main                              3530    3544     +14

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-12 18:09:45 +01:00
Denys Vlasenko
030fe31760 libbb: make msleep() result in only one syscall instead of looping
function                                             old     new   delta
msleep                                                45      52      +7

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-11 16:48:47 +01:00
Denys Vlasenko
e7d853b4eb wget: do not ftruncate if -O- is used, closes 13351
function                                             old     new   delta
wget_main                                           2558    2571     +13
retrieve_file_data                                   612     621      +9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 22/0)               Total: 22 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-08 19:06:28 +01:00
Denys Vlasenko
6cc4962b60 decrease padding: gcc-9.3.1 slaps 32-byte alignment on arrays willy-nilly
text	   data	    bss	    dec	    hex	filename
1021236	    559	   5052	1026847	  fab1f	busybox_old
1021120	    559	   5052	1026731	  faaab	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-30 14:58:02 +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
Denys Vlasenko
6a55b4e403 libbb: introduce and use msleep()
function                                             old     new   delta
msleep                                                 -      45     +45
watchdog_main                                        271     266      -5
common_traceroute_main                              3546    3530     -16
beep_main                                            277     248     -29
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/3 up/down: 45/-50)             Total: -5 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-29 12:40:25 +01:00
Denys Vlasenko
ec16c030bd libbb: introduce and use sleep1()
function                                             old     new   delta
sleep1                                                 -       9      +9
run_shutdown_and_kill_processes                       97      95      -2
restore_state_and_exit                               116     114      -2
reread_partition_table                                67      65      -2
flush_buffer_cache                                    80      78      -2
chat_main                                           1302    1300      -2
timeout_main                                         310     307      -3
telnet_main                                         1235    1232      -3
stop_handler                                          86      83      -3
process_action                                      1078    1075      -3
nbdclient_main                                      1185    1182      -3
init_main                                            789     786      -3
getty_main                                          1541    1538      -3
do_time                                              410     407      -3
runsv_main                                          1682    1677      -5
pause_and_low_level_reboot                            59      54      -5
inetd_main                                          1917    1911      -6
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/16 up/down: 9/-50)            Total: -41 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-29 11:37:34 +01:00
Denys Vlasenko
87bd558f3f libbb: bb_do_delay(3) -> pause_after_failed_login(), and stop looping there
function                                             old     new   delta
pause_after_failed_login                               -       9      +9
vlock_main                                           358     353      -5
sulogin_main                                         252     247      -5
su_main                                              484     479      -5
passwd_main                                          936     931      -5
login_main                                           967     962      -5
bb_do_delay                                           68       -     -68
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/5 up/down: 9/-93)             Total: -84 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-29 11:32:48 +01:00
Denys Vlasenko
885121e25d libbb: change decode_base32/64 API to return the end of _dst_, not _src_.
function                                             old     new   delta
decode_base64                                        173     178      +5
read_base64                                          222     220      -2
decode_base32                                        186     182      -4
handle_incoming_and_exit                            2263    2239     -24
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/3 up/down: 5/-30)             Total: -25 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-28 13:27:36 +01:00
Denys Vlasenko
170b8628fa libbb: smaller and faster decode_base64()
function                                             old     new   delta
decode_base64                                        195     180     -15

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-27 20:45:15 +01:00
Denys Vlasenko
4323ac861e libiproute: reuse string constants
text	   data	    bss	    dec	    hex	filename
1020826	    559	   5052	1026437	  fa985	busybox_old
1020815	    559	   5052	1026426	  fa97a	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-21 17:23:13 +01:00
Denys Vlasenko
2496616b0a avoid using strok - eliminates use of hidden global variable
function                                             old     new   delta
udhcp_str2optset                                     616     650     +34
setpriv_main                                         950     975     +25
switch_root_main                                     688     706     +18
parse                                                958     970     +12
getopt_main                                          622     628      +6
parse_resolvconf                                     302     306      +4
mpstat_main                                         1139    1142      +3
static.p                                               4       -      -4
cdcmd                                                717     702     -15
strtok                                               148       -    -148
------------------------------------------------------------------------------
(add/remove: 0/3 grow/shrink: 7/1 up/down: 102/-167)          Total: -65 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-10-06 02:36:47 +02:00
Xabier Oneca
535a509846 httpd: code shrink
Use decode_base64() from uuencode.c when uudecode/base64 applets are included.
That function is bigger than httpd's decodeBase64(), so we use the old one when
those applets are disabled. Bloat-o-meter when one of those is enabled:

function                                             old     new   delta
handle_incoming_and_exit                            2371    2265    -106

Signed-off-by: Xabier Oneca <xoneca@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-10-06 02:36:06 +02:00
Rui Salvaterra
eecd6f7a6c ip rule: add support for fwmark/fwmask for policy routing
This adds support for fwmark/fwmask in ip rule which is needed, for example, in
OpenWrt's mwan3. Masks are supported since Linux 2.6.19.

Fixes: https://bugs.busybox.net/show_bug.cgi?id=11621

Signed-off-by: Rui Salvaterra <rsalvaterra@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-10-03 22:08:39 +02:00
Denys Vlasenko
a90a54aead udhcp: remove struct packing attribute, eliminates gcc-9.x
"error: taking address of packed member of 'struct ip_udp_dhcp_packet'
may result in an unaligned pointer value" here:

	udhcp_dump_packet(&packet.data);

and in other places.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-10-01 23:49:16 +02:00
Denys Vlasenko
689d0650ab libbb: shrink recursive_action() by reducing memory pressure
function                                             old     new   delta
recursive_action1                                      -     316    +316
file_action_grep                                     161     164      +3
add_to_prg_cache_if_socket                           202     205      +3
depmod_main                                          509     511      +2
writeFileToTarball                                   488     489      +1
parse_module                                         281     282      +1
fileAction                                           207     208      +1
act                                                  189     190      +1
add_to_dirlist                                        65      64      -1
writeTarFile                                         196     194      -2
uuidcache_init                                        47      45      -2
uuidcache_check_device                               109     107      -2
true_action                                            8       6      -2
run_parts_main                                       310     308      -2
netstat_main                                         534     532      -2
lsusb_main                                            29      27      -2
lspci_main                                            45      43      -2
initial_scan                                         138     136      -2
grep_main                                            845     843      -2
find_main                                            482     480      -2
config_file_action                                   437     435      -2
chmod_main                                           142     140      -2
dirAction                                             14      10      -4
diff_main                                           1544    1540      -4
chown_main                                           154     148      -6
skip_dir                                             136     129      -7
dir_act                                              191     184      -7
recursive_action                                     453      69    -384
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 7/20 up/down: 328/-439)        Total: -111 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-10-01 21:52:16 +02:00
Denys Vlasenko
4a0eb0370c gcc-9.x warning fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-10-01 03:07:22 +02:00
Denys Vlasenko
afb5d8b2db ntpd: fix the case where two replies received at once and first one causes a step
function                                             old     new   delta
recv_and_process_peer_pkt                           2476    2486     +10

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-09-29 14:19:17 +02:00
Sergey Ponomarev
a949399d17 httpd: Make Deny/Allow by IP config support optional
When disabled:

function                                             old     new   delta
if_ip_denied_send_HTTP_FORBIDDEN_and_exit             52       -     -52
handle_incoming_and_exit                            2201    2097    -104
scan_ip                                              170       -    -170
parse_conf                                          1365    1065    -300
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 0/2 up/down: 0/-626)           Total: -626 bytes

Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-08-16 14:58:31 +02:00
Sergey Ponomarev
4864a68596 httpd: Support caching via ETag header
If server responds with ETag then next time client can resend it via If-None-Match header.
Then httpd will check if file wasn't modified and if not return 304 Not Modified status code.
The ETag value is constructed from file's last modification date in unix epoch and it's size:
"hex(last_mod)-hex(file_size)" e.g. "5e132e20-417" (with quotes).
That means that it's not completely reliable as hash functions but fair enough.
The same form of ETag is used by Nginx so load balancing of static content is safe.

function                                             old     new   delta
handle_incoming_and_exit                            2135    2201     +66
http_response                                         88      96      +8
send_headers                                         676     683      +7
parse_conf                                          1362    1365      +3
http_response_type                                    22      24      +2
send_file_and_exit                                   847     841      -6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/1 up/down: 86/-6)              Total: 80 bytes

Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-08-15 23:54:48 +02:00
Sergey Ponomarev
b6efac31d8 httpd: Don't add Last-Modified header to response
The Last-Modified header is used for caching.
The client (browser) will send back the received date to server via If-Modified-Since request header.
But both headers MUST be an RFC 1123 formatted string.
And the formatting consumes resources on request parsing and response generation.
Instead we can use ETag header.
This simplifies logic and the only downside is that in JavaScript the document.lastModified will return null.

Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-08-15 23:23:45 +02:00
Sergey Ponomarev
68f75bb9ce httpd: Don't add Date header to response
RFC 2616 sec. 14.18 says that server MUST send Date header.
But in fact the header make sense only for Cache-Control and can be omitted.
In the same time the Date eats power, CPU and network resources which are critical for embedded systems.

Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-08-15 23:04:49 +02:00
Sergey Ponomarev
b414cdf5b4 httpd: Update to HTTP/1.1
HTTP v1.1 was released in 1999 year and it's time to update BB HTTPD.
Browsers may behave badly with HTTP/1.0
E.g. Chrome does not send the If-None-Match header with ETag.

Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-08-15 22:51:14 +02:00
Ron Yorston
5c69ad0ecd build system: drop PLATFORM_LINUX
PLATFORM_LINUX is a hidden configuration option which is disabled by
default and enabled at over a hundred locations for features that are
deemed to be Linux specific.

The only effect of PLATFORM_LINUX is to control compilation of
libbb/match_fstype.c.  This file is only needed by mount and umount.

Remove all references to PLATFORM_LINUX and compile match_fstype.c
if mount or umount is enabled.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-08-13 17:12:56 +02:00
Martin Lewis
9914d8b861 udhcpc: add support for long options
Duplicate options are currently overridden (only the last option is kept).
This leads to unexpected behavior when using long options.

The patch adds support for long options in compliance with RFC 3396.

Fixes #13136.

function                                             old     new   delta
udhcp_run_script                                     601     725    +124
optitem_unset_env_and_free                             -      38     +38
putenvp                                               46      59     +13
static.xmalloc_optname_optval                        718     717      -1
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/1 up/down: 175/-1)            Total: 174 bytes

Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-08-13 16:48:07 +02:00
Christian Eggers
8a485b0a36 ip address: Add support for "valid_lft" and "preferred_lft" options
Signed-off-by: Christian Eggers <ceggers@arri.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-07-31 18:48:50 +02:00
Christian Eggers
31d34f3bd8 ip: Add support for "noprefixroute" option
The "noprefixroute" option suppresses automatic generation of a routing
table entry based on the interface's ip address.

The ifa_flags field has only 8 bit. If higher bits are set,
rta_tb[IFA_FLAGS] has to be used instead.

Signed-off-by: Christian Eggers <ceggers@arri.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-07-31 18:45:36 +02:00
Sergey Ponomarev
a088da4476 httpd_indexcgi.c: use CSS for odd/even rows
Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-07-31 18:14:54 +02:00
Sergey Ponomarev
197ae0f9ae httpd_indexcgi.c: minimize style CSS
Remove new lines \n and some semicolons ;. This minimize page style size from 655 to 604

Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-07-31 17:53:48 +02:00
Denys Vlasenko
9a2d899273 ntpd: fix refid reported in server mode, closes 13056
function                                             old     new   delta
resolve_peer_hostname                                129     196     +67
recv_and_process_peer_pkt                           2475    2476      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 68/0)               Total: 68 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-07-20 00:04:33 +02:00
Denys Vlasenko
06a407c628 networking: support ftp PASV responses not ending with ')'
Patch by Baruch Burstein <bmburstein@gmail.com>

function                                             old     new   delta
parse_pasv_epsv                                      153     181     +28

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-07-19 20:59:35 +02:00
Martin Lewis
4468c569f7 domain_codec: optimize dname_dec and convert_dname
dname_dec: now iterates over the packet only once.
convert_dname: remove redundant checks and code shrink.

While testing I've noticed that some of the tests didn't compile
properly, so I fixed them.

function                                             old     new   delta
dname_dec                                            286     267     -19
dname_enc                                            166     143     -23
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-42)             Total: -42 bytes

Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-07-12 21:19:13 +02:00
Martin Lewis
1f86ecb729 udhcpc: fix a TODO in fill_envp using option scanner
fill_envp now iterates over the packet only once instead of a few hundred times
using the new option scanner.

function                                             old     new   delta
udhcp_scan_options                                     -     189    +189
putenvp                                                -      46     +46
init_scan_state                                        -      22     +22
udhcp_get_option                                     227     104    -123
udhcp_run_script                                     835     601    -234
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 0/2 up/down: 257/-357)         Total: -100 bytes

Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-29 15:26:09 +02:00
Martin Lewis
acdc8eed89 udhcp: add option scanner
Added an option scanner to udhcp to enable iteration over packet options.

Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-29 14:57:02 +02:00
Scott Court
fc2ce04a38 wget: fix openssl options for cert verification
function                                             old     new   delta
is_ip_address                                          -      54     +54
spawn_https_helper_openssl                           461     486     +25
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/0 up/down: 79/0)               Total: 79 bytes

Signed-off-by: Scott Court <z5t1@z5t1.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-29 14:32:09 +02: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