Commit Graph

209 Commits

Author SHA1 Message Date
Denys Vlasenko
ca466f385a *: slap on a few ALIGN* where appropriate
The result of looking at "grep -F -B2 '*fill*' busybox_unstripped.map"

function                                             old     new   delta
.rodata                                           108586  108460    -126
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-126)           Total: -126 bytes
   text	   data	    bss	    dec	    hex	filename
 970412	   4219	   1848	 976479	  ee65f	busybox_old
 970286	   4219	   1848	 976353	  ee5e1	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-02-06 19:53:10 +01:00
Denys Vlasenko
a2f18d950a help text tweaks
function                                             old     new   delta
packed_usage                                       33570   33502     -68

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-18 04:12:51 +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
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
405095d84b ifupdown: close memory leak
function                                             old     new   delta
execute_all                                           80      91     +11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-28 17:55:27 +02: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
Brandon Maier
14454b3071 ifupdown: support "source-directory" stanza
Support the "source-directory" stanza from ifupdown[1]. source-directory
will include all files in the named directory. Similar to the Busybox
version of the "source" stanza, this version of source-directory does
not currently support shell wildcards.

We only check that the stanza starts with "source-dir" as ifupdown does[2].

[1] https://manpages.debian.org/stretch/ifupdown/interfaces.5.en.html#INCLUDING_OTHER_FILES
[2] https://salsa.debian.org/debian/ifupdown/blob/0.8.33/config.c#L498

function                                             old     new   delta
read_interfaces                                     1150    1241     +91

Signed-off-by: Brandon Maier <brandon.maier@rockwellcollins.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-09-30 13:23:05 +02:00
Kaarle Ritvanen
123fdda0a4 ifupdown: do not fail if interface disappears during ifdown
Interface may not exist because it got deleted by an ifdown hook script
earlier. This may happen when a virtual interface, such as VLAN, has multiple
iface blocks defined.

function                                             old     new   delta
static_down6                                          14      40     +26
static_down                                           54      70     +16
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 42/0)               Total: 42 bytes

Signed-off-by: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-28 00:02:52 +02:00
Denys Vlasenko
ebe6d9d875 whitespace and comment format fixes, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-10-05 14:40:24 +02:00
Denys Vlasenko
0c4dbd481a regularize format of source file headers, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-09-18 16:28:43 +02:00
Denys Vlasenko
68b653b66b config: trim/improve item names and help texts, take 2
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-27 10:53:09 +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
205d48e948 *: add comment about APPLET_ODDNAME format
It confused me more than once

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-29 14:57:33 +01:00
Denys Vlasenko
f560422fa0 Big cleanup in config help and description
Redundant help texts (one which only repeats the description)
are deleted.

Descriptions and help texts are trimmed.

Some config options are moved, even across menus.

No config option _names_ are changed.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-10 14:58:54 +01:00
Denys Vlasenko
100aea8486 Remove FEATURE_IFUPDOWN_IP_BUILTIN and FEATURE_IFUPDOWN_IFCONFIG_BUILTIN
They merely enable ip or ifconfig/route. There is already a way to do this
on the same menuconfig page.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-12-23 15:20:16 +01:00
Denys Vlasenko
a8c696bf09 Make ifup and ifdown individually selectable.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-14 18:31:07 +01:00
Denys Vlasenko
3720a61daf ifupdown: rewrite state file atomically
By user's request.
Decided to not use fcntl(F_SETLKW) in lieu of problems with locking
on networked filesystems. The existence of /var/run/ifstate.new
is treated as a write lock. rename() provides atomicity.

function                                             old     new   delta
ifupdown_main                                       1019    1122    +103

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-09 23:04:16 +02:00
Denys Vlasenko
bcf47eaa1f ifupdown: improve help text, add comment about run-parts error msg
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-25 02:05:24 +02:00
Denys Vlasenko
92d98f0612 ifupdown: when flushing addresses with "ip", add label %label%
User report:

or our board we setup eth0:0 on a 10.10.10.x/29 netwrok.

The problem is ip addr flush dev eth0:0 removes all ip addresses from
eth0.  You can see this if you run
ip -stat -stat addr flush dev eth0:0

2: eth0    inet 172.27.105.10/22 brd 172.27.107.255 scope global eth0
       valid_lft forever preferred_lft forever
2: eth0    inet 10.10.10.9/29 scope global eth0:0
       valid_lft forever preferred_lft forever
2: eth0    inet6 fe80::a2f6:fdff:fe18:2b13/64 scope link
       valid_lft forever preferred_lft forever

*** Round 1, deleting 3 addresses ***
*** Flush is complete after 1 round ***

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-20 17:31:11 +02:00
Denys Vlasenko
47cfbf32fd *: add most of the required setup_common_bufsiz() calls
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-21 18:18:48 +02:00
Denys Vlasenko
e6a2f4cc5a libbb: make bb_common_bufsiz1 1 kbyte, add capability to use bss tail for it
The config item is FEATURE_USE_BSS_TAIL. When it is off (default):

function                                             old     new   delta
read_config                                          210     228     +18
doCommands                                          2279    2294     +15
ipneigh_list_or_flush                                763     772      +9
ipaddr_list_or_flush                                1256    1261      +5
display_process_list                                1301    1306      +5
conspy_main                                         1378    1383      +5
do_lzo_compress                                      352     355      +3
do_lzo_decompress                                    565     567      +2
push                                                  46      44      -2
inetd_main                                          2136    2134      -2
uevent_main                                          421     418      -3
addLines                                              97      92      -5
bb_common_bufsiz1                                   8193    1024   -7169
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 8/5 up/down: 62/-7181)        Total: -7119 bytes
   text	   data	    bss	    dec	    hex	filename
 829850	   4086	   9080	 843016	  cdd08	busybox_old
 829901	   4086	   1904	 835891	  cc133	busybox_unstripped

FEATURE_USE_BSS_TAIL=y:

read_config                                          210     228     +18
doCommands                                          2279    2294     +15
ipneigh_list_or_flush                                763     772      +9
ipaddr_list_or_flush                                1256    1261      +5
display_process_list                                1301    1306      +5
conspy_main                                         1378    1383      +5
do_lzo_compress                                      352     355      +3
do_lzo_decompress                                    565     567      +2
inetd_main                                          2136    2134      -2
bb_common_bufsiz1                                   8193       -   -8193
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 8/1 up/down: 62/-8195)        Total: -8133 bytes
   text	   data	    bss	    dec	    hex	filename
 829850	   4086	   9080	 843016	  cdd08	busybox_old
 829911	   4086	    880	 834877	  cbd3d	busybox_unstripped

FIXME: setup_common_bufsiz() calls are missing.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-21 17:39:11 +02:00
Denys Vlasenko
35e063e1b9 ifupdowm: fix "warning: unused variable 'iface_list'"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-03-03 02:19:16 +01:00
Nicolas Cavallari
e5aba88712 ifupdown: allow duplicate interface definitions
This patch allow to have multiple interface definitions, much like
Debian's ifupdown.  More specifically, it removes the check for a
duplicate definition, so the impact on binary size should be fairly
minimal.

This configuration:

iface eth0 inet static
        address 192.168.0.15
        netmask 255.255.0.0
        gateway 192.168.0.1

iface eth0 inet static
        address 10.0.0.1
        netmask 255.255.255.0

Will add two addresses to eth0 if ip is used.  If ifconfig is used,
the standards methods will likely not stack, but the administrator may
still use the manual method.  The DHCP method may work depending on the
DHCP client in use.

This is a fairly advanced feature for power users who knows what they
are doing.  There are not many other network configuration systems that
allows multiple addresses on an interface.

Signed-off-by: Nicolas Cavallari <nicolas.cavallari@green-communications.fr>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-03-01 18:59:08 +01:00
Natanael Copa
1062391365 ifupdown: use -x hostname:NAME with udhcpc
The -H NAME is deprecated in udhcpc. See commit
2017d48c0d

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-31 14:19:06 +01:00
Timo Teräs
028524317d ifupdown: pass interface device name for ipv6 route commands
IPv6 routes need the device argument for link-local routes, or they
cannot be used at all. E.g. "gateway fe80::def" seems to be used in
some places, but kernel refuses to insert the route unless device
name is explicitly specified in the route addition.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-26 17:06:12 +01: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
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
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
Denys Vlasenko
e765b5ac34 libbb: rename execable -> executable. No code changes
English speakers complained that it sounded awfully broken.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-05-02 17:15:58 +02:00
Kaarle Ritvanen
fe8390e0fe ifupdown: support 'link' address family
Does not configure anything. L2 configuration hook scripts should do
their job on receiving ADDRFAM=link. Configuration will be done only
once, irrespective of L3 protocols used.

Using the 'link' family in the interfaces file conforms to the Debian
implementation:

http://sources.debian.net/src/ifupdown/0.7.47.1/link.defn

function                                             old     new   delta
link_methods                                           -      12     +12
addr_link                                              -      12     +12
link_up_down                                           -       6      +6
static.addr_fams                                      12      16      +4
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 1/0 up/down: 34/0)               Total: 34 bytes

Signed-off-by: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-02-03 15:56:20 +01:00
Denys Vlasenko
fb03663619 ifupdown: support "source" stanza in /etc/network/interfaces
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-28 19:01:28 +01:00
Denys Vlasenko
3f21044f20 ifupdown: code shrink
function                                             old     new   delta
execute                                              571     548     -23

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-11-09 17:16:40 +01:00
Denys Vlasenko
a803bfa0f0 ifupdown: remove unused errno assignments
function                                             old     new   delta
execute                                              607     571     -36

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-11-05 14:18:36 +01:00
Denys Vlasenko
11181335f9 ifupdown: simple code shrink
function                                             old     new   delta
execute                                              631     607     -24

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-11-05 13:22:56 +01:00
Denys Vlasenko
a0fd4a789c style fixes, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-02 14:29:14 +02:00
Andreas Oberritter
3a9365e273 ifupdown: improve compatibility with Debian
Set environment variable 'PHASE'.
Treat post-up and pre-down as aliases for up and down.
Uses the same logic as ifupdown.nw from ifupdown-0.6.16.
Makes it possible to execute Debian's ifupdown script for
wpa-supplicant.

Signed-off-by: Andreas Oberritter <obi@opendreambox.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-04-23 22:08:39 +02:00
Natanael Copa
cfcb1dac83 ifupdown: support metric for static default gw
This is useful when you have multiple ISPs with failover. It allows
setting the priority of the static gateway and makes it possible
to specify multiple static gateways.

The ubuntu ifupdown supports it.

function                                             old     new   delta
.rodata                                           116725  116797     +72
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 72/0)               Total: 72 bytes
   text    data     bss     dec     hex filename
 953343    7313    8984  969640   ecba8 busybox_old
 953415    7313    8984  969712   ecbf0 busybox_unstripped

Signed-off-by: Natanael Copa <natanael.copa@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-02-19 17:25:55 +01:00
Denys Vlasenko
d6f5000c13 *: style fixes. no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-12-15 12:39:25 +01:00
Lauri Hintsala
454fe29a80 ifupdown: remove interface from state_list if iface_up fails
Fix the issue where interface is set to the configured state even if
configuration has failed. Add error check to state setting logic.

Signed-off-by: Lauri Hintsala <lauri.hintsala@bluegiga.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-12-15 12:33:39 +01:00
Denys Vlasenko
9c28fb8d28 ifupdown: code shrink
function                                             old     new   delta
keywords_up_down                                       -      43     +43
set_environ                                          371     259    -112
ifupdown_main                                       2194    2073    -121
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/2 up/down: 43/-233)          Total: -190 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-10-19 02:37:08 +02:00
Peter Korsgaard
dd82443b92 ifupdown: support post-up / pre-down hooks
function                                             old     new   delta
set_environ                                          330     371     +41
ifupdown_main                                       2156    2194     +38
iface_up                                              97     113     +16
iface_down                                            97     113     +16
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/0 up/down: 111/0)             Total: 111 bytes

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-10-19 02:35:54 +02:00
Denys Vlasenko
66426760be *: remove "Options:" string from help texts
function                                             old     new   delta
packed_usage                                       28706   28623     -83

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-06-05 03:58:28 +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
681efe20d3 use user's shell instead of hardwired "/bin/sh" (android needs this)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-03-08 21:00:36 +01:00
Alexey Fomenko
1df0af7670 don't leak malloced variables in the loop; remove double alloc
Signed-off-by: Alexey Fomenko <ext-alexey.fomenko@nokia.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-03-02 04:13:21 +01:00
Denys Vlasenko
66cb7bed33 ifupdown: add manual method for IPv6. Closes bug 2497.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-10-29 02:42:20 +02: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
2ab3acb274 ifupdown: %client%, not %clientid%
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-03 16:58:37 +02:00