Commit Graph

2385 Commits

Author SHA1 Message Date
Denys Vlasenko
5fa6d1a632 Aboriginal linux/musl build fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-05 11:15:43 +02:00
Denys Vlasenko
5b865deb3f ping: fix recently introduced build breakage for non-optimizing builds
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-08-25 16:26:31 +02:00
Alex Dowad
65c501a093 ifupdown: 'prio' should have been 'metric' in static_up and static_up6
When a static interface with explicit gateway and metric in /etc/network/interfaces
is enabled using 'ifup', and further, the BusyBox 'ip' applet is enabled, the
following error message appears at the console (and no default route is added):

ip: either "to" is duplicate, or "prio" is garbage

Tracing ifup reveals that it is attempting to run the following shell command:

ip route add default via <GW> dev <DEVICE> prio <METRIC>

'ip' does not understand the 'prio' argument, causing this error. With 'metric',
it works fine.

Signed-off-by: Alex Dowad <alexinbeijing@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-08-24 20:18:36 +02:00
Denys Vlasenko
c52cbea2bb libbb: add setsockopt_foo helpers
function                                             old     new   delta
setsockopt_int                                         -      23     +23
do_load                                              918     934     +16
setsockopt_SOL_SOCKET_int                              -      14     +14
setsockopt_keepalive                                   -      10     +10
setsockopt_SOL_SOCKET_1                                -      10     +10
buffer_fill_and_print                                169     178      +9
setsockopt_1                                           -       8      +8
nfsmount                                            3560    3566      +6
redirect                                            1277    1282      +5
tcpudpsvd_main                                      1782    1786      +4
d6_send_kernel_packet                                272     275      +3
i2cget_main                                          380     382      +2
ed_main                                             2544    2545      +1
scan_recursive                                       380     378      -2
nbdclient_main                                       492     490      -2
hash_find                                            235     233      -2
cmdputs                                              334     332      -2
parse_command                                       1443    1440      -3
static.two                                             4       -      -4
ntpd_main                                           1039    1035      -4
const_int_1                                            4       -      -4
const_IPTOS_LOWDELAY                                   4       -      -4
RCVBUF                                                 4       -      -4
ntp_init                                             474     469      -5
change_listen_mode                                   316     310      -6
uevent_main                                          416     409      -7
arping_main                                         1697    1690      -7
telnet_main                                         1612    1603      -9
socket_want_pktinfo                                   42      33      -9
setsockopt_reuseaddr                                  21      10     -11
setsockopt_broadcast                                  21      10     -11
httpd_main                                           772     757     -15
get_remote_transfer_fd                               109      94     -15
make_new_session                                     503     487     -16
ftpd_main                                           2177    2160     -17
read_bunzip                                         1896    1866     -30
common_traceroute_main                              4099    4058     -41
common_ping_main                                    1836    1783     -53
------------------------------------------------------------------------------
(add/remove: 5/4 grow/shrink: 8/21 up/down: 111/-283)        Total: -172 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-08-24 20:00:17 +02:00
Denys Vlasenko
2db782bc7b Merge setsockopt error messages
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-08-24 20:00:17 +02:00
Denys Vlasenko
729b70646c traceroute: fix help text
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-08-24 20:00:17 +02:00
Denys Vlasenko
fb52769f4a arping: make help text clearer
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-08-16 19:56:16 +02:00
Ron Yorston
72dcbe4df7 ipcalc: fix trivial usage message
Signed-off-by: Ron Yorston <rmy@frippery.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-08-15 21:15:27 +02:00
Denys Vlasenko
a83e3ae172 zcip: tweak comments and make unsigned division more obvious
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-08-04 15:06:38 +02:00
Denys Vlasenko
e347583835 zcip: another code shrink
function                                             old     new   delta
send_arp_request                                       -     185    +185
zcip_main                                           1273    1272      -1
pick_nip                                              40       -     -40
arp                                                  185       -    -185
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 0/1 up/down: 185/-226)          Total: -41 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-08-04 14:30:31 +02:00
Denys Vlasenko
99e30be38b zcip: code shrink
function                                             old     new   delta
zcip_main                                           1263    1230     -33

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-08-04 12:28:21 +02:00
Denys Vlasenko
16aa7a73c4 zcip: simplify code
function                                             old     new   delta
zcip_main                                           1411    1263    -148

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-08-04 03:27:56 +02:00
Arthur Gautier
c29021e2a5 udhcpc: dns labels can actually start with a number
While RFC1035 recommends a label not to start with a number, there is
actually no such limitation in dns. One may buy a domain name like
0x1.net and use it.

This commit remove this check and allow a user to use such domains.

Signed-off-by: Arthur Gautier <baloo@gandi.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-07-30 03:03:58 +02:00
Ron Yorston
d840c5d139 libbb: add a function to make a copy of a region of memory
Introduce a library routine to package the idiom:

    p = xmalloc(b, n);
    memcpy(p, b, n);

and use it where possible.  The example in traceroute used xzalloc
but it didn't need to.

function                                             old     new   delta
xmemdup                                                -      32     +32
last_main                                            834     826      -8
make_device                                         2321    2311     -10
common_traceroute_main                              3698    3685     -13
readtoken1                                          3182    3168     -14
procps_scan                                         1222    1206     -16
forkchild                                            655     638     -17
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/6 up/down: 32/-78)            Total: -46 bytes

Signed-off-by: Ron Yorston <rmy@frippery.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-07-19 23:05:20 +02:00
Maninder Singh
97f2f7ca7f Removes stray empty line from code
This patch removes stray empty line from busybox code
reported by script find_stray_empty_lines

Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
Signed-off-by: Akhilesh Kumar <akhilesh.k@samsung.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-07-13 03:25:46 +02:00
Denys Vlasenko
db31c637fa ipaddress: better formatting, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-07-01 18:36:06 +02:00
Michael Tokarev
6a7cd3d4ab ip addr: support change and replace commands
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-07-01 18:26:41 +02:00
Maninder Singh
97c6491b4e typo fixes
Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-05-25 13:46:36 +02:00
Denys Vlasenko
b878121e76 tc: fix print_rate
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-05-24 18:01:53 +02:00
Denys Vlasenko
9472e8a86f ftpd: change_identity() must be after chroot()
Otherwise chroot() doesn't work for non-root

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-03-31 21:46:26 +02:00
Vladislav Grishenko
4d15068d83 zcip: fix wrong comparison of source IP with our IP
Commit "zcip: fix link-local IP conflict detection" has introduced
wrong comparsion of source IP with our IP. This leads to a new IP
being picked unnecessarily on every incoming ARP packet.

Signed-off-by: Vladislav Grishenko <themiron@mail.ru>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-03-22 17:59:34 +01:00
Denys Vlasenko
6d8ea1d50e ifupdown: shrink a message
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-03-22 17:08:51 +01:00
Frank Bergmann
6ca03f2dd8 ifupdown: correct ifstate update during 'ifup -a'. Closes 6212
When 'if -a' runs into an failure on an interface all further
interfaces won't be correctly updated in ifstate. This patch
inserts a new variable that only tracks the current interfaces
failure so that the write to ifstate can rely on this and not
the one for the functions return value.

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

Signed-off-by: Frank Bergmann <frank.frajasalo@googlemail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-03-22 17:04:27 +01:00
Ron Yorston
8ec1ff350c Use chomp to remove newlines
function                                             old     new   delta
unix_do_one                                          548     540      -8
process_timer_stats                                  508     500      -8
process_irq_counts                                   532     524      -8
lpd_main                                             839     831      -8
hwclock_main                                         502     494      -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/6 up/down: 0/-50)             Total: -40 bytes

Signed-off-by: Ron Yorston <rmy@tigress.co.uk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-03-12 20:18:51 +01:00
Denys Vlasenko
8dff01d06a libbb: introduce and use is_prefixed_with()
function                                             old     new   delta
is_prefixed_with                                       -      18     +18
complete_username                                     78      77      -1
man_main                                             737     735      -2
fsck_device                                          429     427      -2
unpack_ar_archive                                     80      76      -4
strip_unsafe_prefix                                  105     101      -4
singlemount                                         1054    1050      -4
rtc_adjtime_is_utc                                    90      86      -4
resolve_mount_spec                                    88      84      -4
parse_one_line                                      1029    1025      -4
parse_conf                                          1460    1456      -4
may_wakeup                                            83      79      -4
loadkmap_main                                        219     215      -4
get_irqs_from_stat                                   103      99      -4
get_header_cpio                                      913     909      -4
findfs_main                                           79      75      -4
fbsplash_main                                       1230    1226      -4
load_crontab                                         776     771      -5
expand_vars_to_list                                 1151    1146      -5
date_main                                            881     876      -5
skip_dev_pfx                                          30      24      -6
make_device                                         2199    2193      -6
complete_cmd_dir_file                                773     767      -6
run_applet_and_exit                                  715     708      -7
uudecode_main                                        321     313      -8
pwdx_main                                            197     189      -8
execute                                              568     560      -8
i2cdetect_main                                      1186    1176     -10
procps_scan                                         1242    1230     -12
procps_read_smaps                                   1017    1005     -12
process_module                                       746     734     -12
patch_main                                          1903    1891     -12
nfsmount                                            3572    3560     -12
stack_machine                                        126     112     -14
process_timer_stats                                  449     435     -14
match_fstype                                         111      97     -14
do_ipaddr                                           1344    1330     -14
open_list_and_close                                  359     343     -16
get_header_tar                                      1795    1779     -16
prepend_new_eth_table                                340     323     -17
fsck_main                                           1811    1794     -17
find_iface_state                                      56      38     -18
dnsd_main                                           1321    1303     -18
base_device                                          179     158     -21
find_keyword                                         104      82     -22
handle_incoming_and_exit                            2785    2762     -23
parse_and_put_prompt                                 774     746     -28
modinfo                                              347     317     -30
find_action                                          204     171     -33
update_passwd                                       1470    1436     -34
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/49 up/down: 18/-540)         Total: -522 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-03-12 17:48:34 +01:00
Alexander Korolkov
748fb60f27 arping: fix iface name in error messages
arping: interface eth0 not found: No such device
                  ^^^^

This is because error template is formed before parsing command line arguments,
so it always uses default interface name "eth0".

Signed-off-by: Alexander Korolkov <alexander.korolkov@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-03-12 13:05:33 +01:00
Denys Vlasenko
3c31b092ac ntpd: tweak help text
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-03-05 14:04:44 +01:00
Denys Vlasenko
2ec4f44225 inetd: fix order of array index check and array access
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-03-03 13:10:30 +01:00
Denys Vlasenko
3aef814c0b ntpd: chnage help text about -l to say that it doesn't disable client code
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-03-02 20:59:13 +01:00
Bernhard Reutner-Fischer
d7bfee1edb wget: fix --header to not append duplicate headers
function                                             old     new   delta
wget_main                                           2551    2715    +164
wget_user_headers                                      -      62     +62
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/0 up/down: 226/0)             Total: 226 bytes

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-02-18 20:41:02 +01:00
Denys Vlasenko
54e9585e10 trivial code shrink
function                                             old     new   delta
rdate_main                                           246     251      +5
show_entry                                           291     287      -4
daytime_stream                                        44      39      -5
packed_usage                                       30176   30168      -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/3 up/down: 5/-17)             Total: -12 bytes
   text	   data	    bss	    dec	    hex	filename
 929453	    932	  17684	 948069	  e7765	busybox_old
 929411	    932	  17684	 948027	  e773b	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-02-18 13:47:46 +01:00
Denys Vlasenko
a75dcd4353 route: fix bogus read error when route table is empty
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-02-04 10:40:10 +01:00
Denys Vlasenko
09020b1aa8 route: improve -A inet6
Upstream route command shows non-up routes, it shows reject and nonexthop flags.
And we had "ref" and "use" values mixed up...

function                                             old     new   delta
flagvals                                              32      44     +12
flagchars                                              9      12      +3
INET_setroute                                        767     768      +1
INET6_setroute                                       495     496      +1
set_flags                                             43      39      -4
flags_ipvx                                            16       8      -8
route_main                                           632     623      -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/3 up/down: 17/-21)             Total: -4 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-02-03 19:32:44 +01:00
Denys Vlasenko
a977778893 ifconfig: fix double free fatal error in INET_sprint
Based on the patch by Zheng Junling <zhengjunling@huawei.com>
and Chen Gang <cg.chen@huawei.com>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-02-03 12:11:30 +01:00
Martin Kaiser
1cbe93cf4e telnetd: we only need CONFIG_UNIX98_PTYS from the Linux kernel
(re-sending this as it got ignored completey and the format of the
previous mail was probably not correct - please let me know if there's
anything else I can do to get this trivial fix applied)

for telnetd to work, we only need CONFIG_UNIX98_PTYS to be enabled
in the Linux kernel - DEVPTS_FS has been obsolete for some time

Signed-off-by: Martin Kaiser <lists@kaiser.cx>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-30 17:12:38 +01:00
Denys Vlasenko
ff3f3accc6 ntpd: get rid of G.initial_poll_complete
This speeds up syncing - now happens only just
two replies from a peer. Especially useful for "ntpd -q".
Shouldn't have ill effects: if we chose a bad peer,
we will discover it later and switch to another one.

The code is even smaller this way.

Suggested by Miroslav Lichvar <mlichvar@redhat.com>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-29 16:31:36 +01: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
Denys Vlasenko
64b744997e ftpd: prevent zombies. closes 7832
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-26 15:45:48 +01:00
Denys Vlasenko
da9212667c libbb: code shrink by factoring out common update_utmp_DEAD_PROCESS
function                                             old     new   delta
update_utmp_DEAD_PROCESS                               -      17     +17
telnetd_main                                        1685    1674     -11
mark_terminated                                       56      45     -11
handle_sigchld                                        74      63     -11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-05 15:37:58 +01:00
Denys Vlasenko
08b90a9d10 deleting unused ntpd_simple.c
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-05 15:12:37 +01:00
Adam Tkac
4bf88d9094 ntpd: relicense ntpd applet to ISC-style license
OpenNTPd is licensed under ISC-style license so it's good idea to keep
ntpd applet under same license to avoid mess, instead of having
our changes to be under GPL.

Names of original code's authors are added.

Signed-off-by: Adam Tkac <vonsch@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-04 17:46:08 +01:00
John Schroeder
8074a6ca4d udhcpd: account for script delay in lease
Prevent nasty surprises if script runs longer than lease time / 2.

Signed-off-by: John Schroeder <jschroed@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-12-25 21:12:51 +01:00
Denys Vlasenko
28634924f0 udhcpc: account for script run time
Based on the following user report:

I ran into an issue where I was seeing a long delay in the scripts called
in udhcp_run_script. I was using an old version of OpenWrt (kamikaze)
and a satellite modem. An NTP script was being called and the modem
would sometimes take a long time to respond to the DNS lookup when
it was offline.

This delay started affecting my lease time. The lease that I would
get from my satellite modem before it was online would be short:
only 60 seconds. The delay with NTP and the modem would typically
be about 18 seconds. This would cause the first DHCP renew request
from dhcpc to be a little late. Under certain circumstances,
I could even see the first DHCP renew to occur after the lease
had expired!

function                                             old     new   delta
udhcpc_main                                         2816    2837     +21

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-12-21 16:10:22 +01:00
Bartosz Golaszewski
8d75d794ea libbb: use sendfile() to copy data between file descriptors
Busybox already uses sendfile in httpd. This patch proposes to use it
globally to copy data between file descriptors.

It speeds up the copying on slow systems a lot - below are the times needed
to copy a 450Mb file with and without this option enabled on a BeagleBone
Black:

sendfile:
user    0m0.000s
sys     0m8.170s

read/write 4k:
user    0m0.470s
sys     0m16.300s

function                                             old     new   delta
bb_full_fd_action                                    394     474     +80

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-11-27 23:31:58 +01:00
Denys Vlasenko
298fabaefc udhcpd: if a lease from lease file coincides with a static one, ignore it
function                                             old     new   delta
read_leases                                          269     328     +59

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-11-25 18:49:14 +01:00
Michael Tokarev
1a1143907c iproute: support onelink route option and print route flags
function                                             old     new   delta
print_route                                         1797    1865     +68
do_iproute                                          2097    2112     +15
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 83/0)               Total: 83 bytes

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-11-17 19:35:41 +01:00
Michel Stam
d3fabf89d7 zcip: Add environment variable for overriding log functionality
function                                             old     new   delta
bb_logenv_override                                     -      70     +70
packed_usage                                       29969   30033     +64
zcip_main                                           1426    1431      +5
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 2/0 up/down: 139/0)             Total: 139 bytes

Signed-off-by: Michel Stam <m.stam@fugro.nl>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-11-04 12:19:04 +01:00
Michel Stam
fdd957bdc9 zcip: allow our own class B range to be used for ZeroConf
169.254 may already be used by a local network. This patch allows
specifying your own IP range.

Our particular use case is a mesh network, in which the nodes partaking
were using an IP range specifically assigned for the meshing purpose.
As the LAN side of the mesh node could use 169.254, this default range
was not an option.

function                                             old     new   delta
zcip_main                                           1342    1426     +84
pick_nip                                               -      40     +40
packed_usage                                       29974   29969      -5
pick                                                  34       -     -34
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 1/1 up/down: 124/-39)            Total: 85 bytes

Signed-off-by: Michel Stam <m.stam@fugro.nl>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-10-30 13:43:09 +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
Miroslav Lichvar
760d035699 ntpd: calculate offset to jitter ratio before updating jitter
The offset to jitter ratio is now calculated before updating
jitter to make the test more sensitive.

function                                             old     new   delta
ntp_init                                             460     474     +14
update_local_clock                                   752     764     +12
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 26/0)               Total: 26 bytes

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-10-05 03:11:53 +02:00