Commit Graph

87 Commits

Author SHA1 Message Date
Denys Vlasenko
53b2fdcdba *: add NOINLINEs where code noticeably shrinks
function                                             old     new   delta
display                                               85    1463   +1378  -73 bytes
select_and_cluster                                     -    1088   +1088 -139 bytes
parse_reply                                            -     979    +979 -109 bytes
zbc_num_sqrt                                           -     632    +632 -191 bytes
show_bridge_port                                       -     585    +585  -56 bytes
sp_256_proj_point_add_8                                -     576    +576  -45 bytes
encode_then_append_var_plusminus                       -     554    +554 -118 bytes
read_mode_db                                           -     537    +537  -47 bytes
fbset_main                                          1331     747    -584
sp_256_ecc_mulmod_8                                 1157     536    -621
brctl_main                                          2189    1548    -641
expand_one_var                                      2544    1872    -672
zxc_vm_process                                      6412    5589    -823
send_queries                                        1813     725   -1088
recv_and_process_peer_pkt                           2245    1018   -1227
bb_dump_dump                                        1531      80   -1451
------------------------------------------------------------------------------
(add/remove: 7/0 grow/shrink: 1/8 up/down: 6329/-7107)       Total: -778 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-10-10 13:50:53 +02:00
Paul Spooren
327b9f8848 nslookup: mention QUERY_TYPE SRV
SRV lookups are supported since "6b4960155 nslookup: implement support
for SRV records" and should therefore be mentioned as a possible
QUERY_TYPE in the help message.

Signed-off-by: Paul Spooren <mail@aparcar.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-03 16:23:52 +02:00
Denys Vlasenko
49fd1d69ba nslookup: do not print "No answer" for NODATA replies, closes 13006
Only print when there was no answer at all.

function                                             old     new   delta
send_queries                                        1834    1813     -21

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-31 01:39:44 +01:00
Denys Vlasenko
b230ff9d8f *: use fopen helpers where appropriate
function                                             old     new   delta
finalize                                             348     343      -5
parse_resolvconf                                     306     299      -7
list_i2c_busses_and_exit                             495     483     -12
bootchartd_main                                     1091    1076     -15
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-39)             Total: -39 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-30 00:16:27 +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
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
Jo-Philipp Wich
6b4960155e nslookup: implement support for SRV records
Add support for querying and parsing SRV DNS records.

function                                             old     new   delta
send_queries                                        1711    1865    +154
qtypes                                                72      80      +8

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-27 17:07:35 +01:00
Jo-Philipp Wich
8c3b520d4f nslookup: handle replies without RRs
Under some circumstances, a DNS reply might contain no resource records,
e.g. when a valid domain is queried that does not have records of the
requested type.

Example with nslookup from BIND dnsutils:

    $ nslookup -q=SRV example.org
    Server:	10.11.12.13
    Address:	10.11.12.13#53

    Non-authoritative answer:
    *** Can't find example.org: No answer

Currently the busybox nslookup applet simply prints nothing after the
"Non-authoritative answer:" line in the same situation.

This change modifies nslookup to either print "Parse error" or "No answer"
diagnostics, depending on the parse_reply() return value.

function                                             old     new   delta
send_queries                                        1676    1711     +35

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-27 17:02:08 +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
6ca8e347fe nslookup: return exitcode 1 on resolution errors
function                                             old     new   delta
nslookup_main                                        757     760      +3
send_queries                                        1690    1677     -13

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-01-09 13:38:57 +01:00
Denys Vlasenko
b097a84d62 config: update size information
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-28 03:20:17 +01:00
Denys Vlasenko
9408978a43 nslookup: add support for search domains, closes 11161
function                                             old     new   delta
parse_resolvconf                                       -     311    +311
add_query_with_search                                  -     105    +105
nslookup_main                                        873     757    -116
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 0/1 up/down: 416/-116)          Total: 300 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-08-01 19:42:46 +02:00
Denys Vlasenko
2f7738e474 nslookup: placate "warning: unused variable i"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-06-27 14:44:35 +02:00
Denys Vlasenko
c72499584a nslookup: simplify make_ptr
function                                             old     new   delta
nslookup_main                                       2644    2611     -33

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-15 20:04:57 +02:00
Denys Vlasenko
71e4b3f482 nslookup: get rid of query::rlen field
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-15 19:51:42 +02:00
Denys Vlasenko
58e43a4c40 nslookup: move array of queries to "globals"
function                                             old     new   delta
add_query                                             95      89      -6
nslookup_main                                       2692    2641     -51
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-57)             Total: -57 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-15 14:10:45 +02:00
Denys Vlasenko
4b6091f92c nslookup: accept lowercase -type=soa, document query types
Usage: nslookup [-type=QUERY_TYPE] [-debug] HOST [DNS_SERVER]

    Query DNS about HOST

    QUERY_TYPE: soa,ns,a,aaaa,cname,mx,txt,ptr,any

function                                             old     new   delta
packed_usage                                       32189   32258     +69

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-15 12:58:15 +02:00
Denys Vlasenko
6cdc3195a6 nslookup: change -stats to -debug (it's a bug in bind that it accepts -s)
function                                             old     new   delta
packed_usage                                       32211   32189     -22
nslookup_main                                       2754    2692     -62
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-84)             Total: -84 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-15 12:50:28 +02:00
Denys Vlasenko
d4461ef9fb nslookup: rework option parsing
function                                             old     new   delta
nslookup_main                                       2715    2754     +39
packed_usage                                       32179   32211     +32
add_ns                                                65      66      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 72/0)               Total: 72 bytes
   text	   data	    bss	    dec	    hex	filename
 926262	    555	   5740	 932557	  e3acd	busybox_old
 926239	    555	   5740	 932534	  e3ab6	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-15 12:01:46 +02:00
Denys Vlasenko
a980109c6a nslookup: smaller qtypes[] array
function                                             old     new   delta
nslookup_main                                       2708    2715      +7
qtypes                                                80      72      -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 7/-8)               Total: -1 bytes
   text	   data	    bss	    dec	    hex	filename
 926277	    555	   5740	 932572	  e3adc	busybox_old
 926262	    555	   5740	 932557	  e3acd	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-15 10:52:11 +02:00
Denys Vlasenko
2cf75b3c81 nslookup: process replies immediately, do not store them
function                                             old     new   delta
nslookup_main                                       1837    2708    +871
parse_reply                                          852       -    -852
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/0 up/down: 871/-852)           Total: 19 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-15 10:46:44 +02:00
Denys Vlasenko
4e73c0f659 nslookup: fix output corruption for "nslookup 1.2.3.4"
function                                             old     new   delta
nslookup_main                                       1832    1837      +5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-14 23:18:34 +02:00
Denys Vlasenko
cf950cd3ea nslookup: more closely resemble output format of bind-utils-9.11.3
function                                             old     new   delta
nslookup_main                                       1880    1832     -48
parse_reply                                         1022     852    -170
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-218)           Total: -218 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-14 23:08:23 +02:00
Denys Vlasenko
71e016d806 nslookup: shrink send_queries()
function                                             old     new   delta
rcodes                                                68      64      -4
nslookup_main                                       2007    1880    -127
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-131)           Total: -131 bytes
   text	   data	    bss	    dec	    hex	filename
 926735	    555	   5740	 933030	  e3ca6	busybox_old
 926525	    555	   5740	 932820	  e3bd4	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-14 22:53:39 +02:00
Denys Vlasenko
db93b21ec9 nslookup: use xmalloc_sockaddr2dotted() instead of homegrown function
function                                             old     new   delta
nslookup_main                                       2091    2007     -84

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-14 18:11:35 +02:00
Denys Vlasenko
55bc8e8826 nslookup: usee bbox network functions instead of opne-coded mess
function                                             old     new   delta
nslookup_main                                       2363    2091    -272
add_ns                                               663      65    -598
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-870)           Total: -870 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-14 17:55:54 +02:00
Denys Vlasenko
0dd3be8c09 nslookup: add openwrt / lede version
Needs work on size reduction

function                                             old     new   delta
nslookup_main                                        114    2363   +2249
parse_reply                                            -    1022   +1022
add_ns                                                 -     663    +663
ns_parserr                                             -     486    +486
ns_initparse                                           -     184    +184
ns_skiprr                                              -     117    +117
add_query                                              -      95     +95
qtypes                                                 -      80     +80
rcodes                                                 -      68     +68
dn_skipname                                            -      58     +58
ns_name_uncompress                                     -      56     +56
ns_get16                                               -      13     +13
v4_mapped                                              -      12     +12
ns_get32                                               -       9      +9
res_init                                               3       -      -3
__res_state                                            6       -      -6
xmalloc_sockaddr2hostonly_noport                      10       -     -10
gai_strerror                                          47       -     -47
set_default_dns                                       95       -     -95
print_host                                           199       -    -199
static.res                                           512       -    -512
------------------------------------------------------------------------------
(add/remove: 15/10 grow/shrink: 1/0 up/down: 5112/-872)      Total: 4240 bytes
   text	   data	    bss	    dec	    hex	filename
 921944	    555	   6252	 928751	  e2bef	busybox_old
 927375	    555	   5740	 933670	  e3f26	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-14 14:05:45 +02:00
Denys Vlasenko
72089cf6b4 config: deindent all help texts
Those two spaces after tab have no effect, and always a nuisance when editing.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-21 09:50:55 +02:00
Denys Vlasenko
ae178cee3d Update remaining menuconfig items with approximate applet sizes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-19 14:32:54 +02:00
Denys Vlasenko
47367e1d50 Convert all networking/* applets to "new style" applet definitions
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-23 09:05:14 +01:00
Denys Vlasenko
d66eb9042d nslookup: set default DNS server again. Hopefully helps with 675
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-06-27 01:09:51 +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
Vitaly Magerya
7f4b769c42 don't call freeaddinfo(NULL)
Signed-off-by: Vitaly Magerya <vmagerya@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-03-22 20:14:26 +01:00
Denys Vlasenko
0ef64bdb40 *: make GNU licensing statement forms more regular
This change retains "or later" state! No licensing _changes_ here,
only form is adjusted (article, space between "GPL" and "v2" and so on).

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-08-16 20:14:46 +02:00
Denis Vlasenko
249d948e39 nslookup: glibc + IPv6 address of DNS server don't mix (yet) 2008-11-17 15:36:36 +00:00
Denis Vlasenko
3f5f246466 nslookup: allow usage of IPv6 addresses or hostnames
for DNS server name; allow for port specification.
 Tested to work: "nslookup google.com [::1]:5353"
2008-11-16 19:02:26 +00:00
Denis Vlasenko
391ffa19d1 nslookup: tiny shrink (-5 bytes); add comment about res_init
inet_common: cosmetics, no code changes
2008-11-04 21:44:28 +00:00
Denis Vlasenko
9b49a5ed85 add -fvisibility=hidden to CC flags, mark XXX_main functions
EXTERNALLY_VISIBLE. 5% size reduction of libbusybox.so
2007-10-11 10:05:36 +00:00
Denis Vlasenko
feb7ae7f01 printf("%s\n") -> puts() 2007-10-01 12:05:12 +00:00
Denis Vlasenko
4daad9004d introduce bb_putchar(). saves ~1800 on uclibc (less on glibc). 2007-09-27 10:20:47 +00:00
Denis Vlasenko
a27a11bb2c introduce and use xdup2(int, int)
stop checking whether setsockopt_reuseaddr(int fd) was successful (it always is)
remove second parameter (sockllen) from xmalloc_sockaddr2xxxxx functions

sockaddr2str                                         142     156     +14
collect_blk                                          467     474      +7
xdup2                                                 28      33      +5
singlemount                                         4456    4454      -2
print_host                                           214     212      -2
nslookup_main                                        139     137      -2
ftpgetput_main                                       414     412      -2
udhcpd_main                                         1258    1255      -3
udhcpc_main                                         2405    2402      -3
traceroute_main                                     4125    4122      -3
nc_main                                             1072    1069      -3
buffer_fill_and_print                                 76      73      -3
xmalloc_sockaddr2hostonly_noport                      18      14      -4
xmalloc_sockaddr2host_noport                          18      14      -4
xmalloc_sockaddr2host                                 15      11      -4
xmalloc_sockaddr2dotted_noport                        18      14      -4
xmalloc_sockaddr2dotted                               18      14      -4
wget_main                                           2618    2614      -4
ping_main                                            393     389      -4
ip_port_str                                          120     115      -5
dhcprelay_main                                      1146    1141      -5
dnsd_main                                           1531    1525      -6
passwd_main                                         1110    1102      -8
udhcp_kernel_packet                                  206     197      -9
udhcp_listen_socket                                  154     144     -10
getty_main                                          2576    2566     -10
setup                                                655     640     -15
xmove_fd                                              51      34     -17
dolisten                                             759     742     -17
tcpudpsvd_main                                      1866    1836     -30
startservice                                         339     299     -40
2007-08-18 14:16:39 +00:00
Denis Vlasenko
b6adbf1be2 usage.c: remove reference to busybox.h
*: s/include "busybox.h"/include "libbb.h"
2007-05-26 19:00:18 +00:00
Denis Vlasenko
51742f4bb0 style fixes. No code changes 2007-04-12 00:32:05 +00:00
Denis Vlasenko
42823d597a add x to IPv6 functions which can die 2007-02-04 02:39:08 +00:00
Denis Vlasenko
06af216528 suppress warnings about easch <applet>_main() having
no preceding prototype
2007-02-03 17:28:39 +00:00
Denis Vlasenko
5de9e9ce0b clean up commented out old code 2007-01-22 22:46:04 +00:00
Denis Vlasenko
448f0241e0 nslookup: full circle. Here we started IPv6 work. Use "new API"
and thus save a few bytes.
2007-01-22 22:43:05 +00:00
Bernhard Reutner-Fischer
bb8c7c041c - sed -i -e "/\$Id:/d;" 2007-01-22 17:04:53 +00:00
Denis Vlasenko
f7996f3b70 Trailing whitespace removal over entire tree 2007-01-11 17:20:00 +00:00
Denis Vlasenko
067e3f031a wget: fix error message.
Bad:
wget http://127.0.0.1:81/fgdg/Makefile
Connecting to 127.0.0.1[127.0.0.1]:81
: HTTP/1.0 404 Not Foundror 404 Not Found
Good:
wget http://127.0.0.1:81/fgdg/Makefile
Connecting to 127.0.0.1[127.0.0.1]:81
get: server returned error: HTTP/1.0 404 Not Found

nslookup: fix my mistake
applets: make Bernhard Fischer <rep.nop@aon.at> happy :)
2006-11-10 23:25:53 +00:00