Commit Graph

42 Commits

Author SHA1 Message Date
Ron Yorston
cad3fc743a libbb: introduce and use fputs_stdout
function                                             old     new   delta
fputs_stdout                                           -      12     +12
zxc_vm_process                                      7237    7230      -7
yes_main                                              85      78      -7
write_block                                          380     373      -7
wrapf                                                305     298      -7
strings_main                                         437     430      -7
show_bridge                                          353     346      -7
rev_main                                             384     377      -7
put_prompt_custom                                     58      51      -7
put_cur_glyph_and_inc_cursor                         168     161      -7
print_numbered_lines                                 152     145      -7
print_named_ascii                                    130     123      -7
print_name                                           135     128      -7
print_login_issue                                    386     379      -7
print_ascii                                          208     201      -7
powertop_main                                       1249    1242      -7
od_main                                             1789    1782      -7
logread_main                                         518     511      -7
head_main                                            804     797      -7
display_process_list                                1319    1312      -7
cut_main                                            1002     995      -7
bb_dump_dump                                        1550    1543      -7
bb_ask_noecho                                        393     386      -7
baseNUM_main                                         702     695      -7
expand_main                                          755     745     -10
dumpleases_main                                      497     487     -10
write1                                                12       -     -12
putcsi                                                37      23     -14
print_login_prompt                                    55      41     -14
paste_main                                           525     511     -14
cat_main                                             440     426     -14
print_it                                             245     230     -15
print_addrinfo                                      1188    1171     -17
print_rule                                           770     750     -20
print_linkinfo                                       842     822     -20
httpd_main                                           791     771     -20
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/34 up/down: 12/-341)         Total: -329 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-02-03 20:52:40 +01: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
68ae54243c ip: fix crash in "ip neigh show"
parse_rtattr() was using tb[] array without initializing it.

Based on patch by Balaji Punnuru <balaji_punnuru@cable.comcast.com>

function                                             old     new   delta
parse_rtattr                                          85     107     +22
print_route                                         1630    1617     -13
print_linkinfo                                       807     794     -13
iproute_get                                          835     822     -13
print_rule                                           680     665     -15
ll_remember_index                                    263     248     -15
print_addrinfo                                      1223    1197     -26
ipaddr_list_or_flush                                1253    1223     -30
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/7 up/down: 22/-125)          Total: -103 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-02-08 08:42:37 +01:00
Eugene Rudoy
ecce3a1999 iproute/iprule: support toolchains without RTA_TABLE routing attribute
iproute.c: In function 'print_route':
 iproute.c:85:9: error: 'RTA_TABLE' undeclared (first use in this function)
 iproute.c:85:9: note: each undeclared identifier is reported only once for each function it appears in
 iproute.c: In function 'iproute_modify':
 iproute.c:467:36: error: 'RTA_TABLE' undeclared (first use in this function)

Fix it by partially #ifdef'ing the code added in b42107f215

Signed-off-by: Eugene Rudoy <gene.devel@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-10-27 19:25:08 +02:00
Denys Vlasenko
a02a4e9830 whitespace and comment format fixes, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-10-05 15:19:25 +02:00
Stefan Tomanek
192dce4b84 ip rule: add suppress_{prefixlength,ifgroup} options
function                                             old     new   delta
iprule_modify                                        816     887     +71
print_rule                                           610     680     +70
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 141/0)             Total: 141 bytes

Signed-off-by: Stefan Tomanek <stefan.tomanek@wertarbyte.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-06-13 19:06:09 +02:00
Lukasz Nowak
b42107f215 libiproute: handle table ids larger than 255
Linux kernel, starting from 2.6.19 allows ip table ids to have 32-bit values.
In order to preserve compatibility, the old 8-bit field: rtm_table is still
in use when table id is lower than 256.

Add support for the 32-bit table id (RTA_TABLE attribute) in:
- ip route print
- ip route modify
- ip rule print
- ip rule modify

Add printing of table ids to ip route.

Changes are compatible with the mainline iproute2 utilities.

These changes are required for compatibility with ConnMan, which by default
uses table ids greater than 255.

function                                             old     new   delta
print_route                                         1588    1637     +49
do_iproute                                          2187    2222     +35
do_iprule                                            955     987     +32
print_rule                                           617     630     +13
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/0 up/down: 129/0)             Total: 129 bytes

Signed-off-by: Lukasz Nowak <lnowak@tycoint.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-12-18 18:56:49 +01:00
Denys Vlasenko
4548293799 libiproute: eliminate some redundant zero stores
function                                             old     new   delta
do_iprule                                            974     955     -19
rtnl_dump_request                                    173     146     -27
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-46)             Total: -46 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-08-14 02:08:56 +02:00
Denys Vlasenko
926d801fa5 libiproute: make rt_addr_n2a() and format_host() return auto strings
function                                             old     new   delta
rt_addr_n2a                                           56      53      -3
print_addrinfo                                      1227    1178     -49
print_neigh                                          933     881     -52
print_rule                                           689     617     -72
print_tunnel                                         640     560     -80
print_route                                         1727    1588    -139
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/6 up/down: 0/-395)           Total: -395 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-14 13:56:42 +02:00
Denys Vlasenko
0f296a3a56 libiproute: rename invarg(a,b) to invarg_1_to_2(a,b)
invarg(a,b) - "invalid argument", but how a and b enter the message?

invarg_1_to_2(a,b) is somewhat easier to read: "invalid argument 'a' to 'b'"

Audit of usage revealed a number of bad uses, with too long messages.

   text	   data	    bss	    dec	    hex	filename
 938848	    932	  17448	 957228	  e9b2c	busybox_old
 938788	    932	  17448	 957168	  e9af0	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-14 13:21:01 +02:00
Denys Vlasenko
3d8d5e8ad4 libiproute: use itoa() where appropriate
function                                             old     new   delta
rtnl_rtprot_a2n                                       31      88     +57
print_tunnel                                         647     640      -7
print_route                                         1865    1858      -7
print_linkinfo                                       820     812      -8
print_addrinfo                                      1241    1227     -14
rtnl_rttable_n2a                                      53      38     -15
rtnl_rtscope_n2a                                      53      38     -15
rtnl_rtrealm_n2a                                      53      38     -15
rtnl_dsfield_n2a                                      61      38     -23
rtnl_rtntype_n2a                                     118      89     -29
print_rule                                           724     689     -35
ipaddr_list_or_flush                                1293    1253     -40
rtnl_rtprot_n2a                                       53       -     -53
rtnl_rtprot_initialize                                63       -     -63
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 1/11 up/down: 57/-324)         Total: -267 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-08 13:02:28 +02:00
Denys Vlasenko
9b58fe9c0b ip: code shrink
function                                             old     new   delta
do_ipaddr                                             78      81      +3
do_iprule                                            140     139      -1
do_iptunnel                                          283     278      -5
iprule_modify                                        851     841     -10
ipaddr_modify                                       1293    1236     -57
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/4 up/down: 3/-73)             Total: -70 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-07-15 05:15:46 +02:00
Denys Vlasenko
60cb48ca50 whitespace cleanup. no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-14 15:57:44 +01:00
Denys Vlasenko
fb132e4737 whitespace cleanup
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-10-29 11:46:52 +02:00
Denys Vlasenko
2e9b5510d6 libiproute: code shrink by adding FAST_FUNC
function                                             old     new   delta
ipaddr_list_or_flush                                1282    1293     +11
ip_parse_common_args                                 153     151      -2
ip_main                                               53      50      -3
ip_do                                                 19      15      -4
do_iptunnel                                          985     980      -5
do_iprule                                            982     977      -5
do_iplink                                           1637    1631      -6
do_iproute                                          2105    2098      -7
do_ipaddr                                           1406    1398      -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/8 up/down: 11/-40)            Total: -29 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-24 23:27:38 +02:00
Bernhard Reutner-Fischer
1b3549875c ip rule: unify parsing args
function                                             old     new   delta
do_iprule                                             83     134     +51
print_rule                                           736     726     -10
iprule_list                                           73       -     -73
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/1 up/down: 51/-83)            Total: -32 bytes

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2010-05-25 18:48:33 +02:00
Denys Vlasenko
6b9f163353 *: style fixes. no code changes (verified with objdump)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-28 02:24:24 +01:00
Denys Vlasenko
a355da0775 *: make 2 more "int argc"'s unused; more saved if !DESKTOP
function                                             old     new   delta
sync_main                                             18      20      +2
tty_main                                              90      87      -3
iprule_list                                           83      79      -4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-04 13:16:08 +01:00
Denys Vlasenko
8131eea3dc *: introduce and use ffulsh_all()
function                                             old     new   delta
buffer_fill_and_print                                179     196     +17
fflush_all                                             -       9      +9
spawn                                                 87      92      +5
rtcwake_main                                         455     453      -2
...
alarm_intr                                            93      84      -9
readcmd                                             1072    1062     -10
bb_ask                                               345     333     -12
more_main                                            845     832     -13
flush_stdout_stderr                                   42      23     -19
xfflush_stdout                                        27       -     -27
flush_stderr                                          30       -     -30
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 2/50 up/down: 31/-397)         Total: -366 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-02 14:19:51 +01:00
Denys Vlasenko
d31575a3ae libiproute/*: code shrink
function                                             old     new   delta
ll_addr_a2n                                          181     178      -3
rtnl_rtntype_a2n                                     198     194      -4
ipaddr_modify                                       1309    1305      -4
print_addrinfo                                      1303    1298      -5
do_iplink                                           1137    1132      -5
print_route                                         1609    1603      -6
parse_args                                          1440    1434      -6
iproute_list_or_flush                               1261    1254      -7
rtnl_rttable_a2n                                      39      31      -8
rtnl_rtscope_a2n                                      39      31      -8
rtnl_rtrealm_a2n                                      39      31      -8
rtnl_rtprot_a2n                                       39      31      -8
rtnl_dsfield_a2n                                      39      31      -8
ll_type_n2a                                           78      70      -8
get_rt_realms                                        115     107      -8
print_tunnel                                         656     647      -9
rtnl_rttable_n2a                                      63      53     -10
rtnl_rtscope_n2a                                      63      53     -10
rtnl_rtrealm_n2a                                      63      53     -10
rtnl_rtntype_n2a                                     128     118     -10
rtnl_dsfield_n2a                                      71      61     -10
print_linkinfo                                       815     805     -10
ipaddr_list_or_flush                                1246    1235     -11
iproute_modify                                      1048    1036     -12
iprule_modify                                        866     851     -15
print_rule                                           765     738     -27
ll_addr_n2a                                          182     150     -32
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/27 up/down: 0/-262)          Total: -262 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-13 17:58:24 +02:00
Denys Vlasenko
d5f1b1bbe0 *: add FAST_FUNC to function ptrs where it makes sense
function                                             old     new   delta
evalcommand                                         1195    1209     +14
testcmd                                                -      10     +10
printfcmd                                              -      10     +10
echocmd                                                -      10     +10
func_exec                                            270     276      +6
echo_dg                                              104     109      +5
store_nlmsg                                           85      89      +4
pseudo_exec_argv                                     195     198      +3
dotcmd                                               287     290      +3
machtime_stream                                       29      31      +2
discard_stream                                        24      26      +2
argstr                                              1299    1301      +2
killcmd                                              108     109      +1
evalfor                                              226     227      +1
daytime_stream                                        43      44      +1
run_list                                            2544    2543      -1
lookupvar                                             62      61      -1
ipaddr_modify                                       1310    1309      -1
...
parse_stream                                        2254    2245      -9
evalpipe                                             356     347      -9
collect_if                                           210     197     -13
read_opt                                             869     851     -18
handle_dollar                                        681     658     -23
print_addrinfo                                      1342    1303     -39
iterate_on_dir                                       156      59     -97
print_route                                         1709    1609    -100
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 12/130 up/down: 74/-767)       Total: -693 bytes
   text    data     bss     dec     hex filename
 841748     467    7872  850087   cf8a7 busybox_old
 841061     467    7872  849400   cf5f8 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-05 12:06:05 +02:00
Denis Vlasenko
76140a77c9 networking/libiproute/*: code shrink by optimizing numeric conversions
and other misc stuff

function                                             old     new   delta
print_tunnel                                         660     656      -4
format_host                                            5       -      -5
get_unsigned                                          70      54     -16
get_u32                                               70      54     -16
do_iplink                                           1173    1151     -22
get_prefix                                           417     393     -24
print_rule                                           800     771     -29
print_addrinfo                                      1374    1342     -32
print_route                                         1745    1709     -36
iprule_modify                                        905     866     -39
iproute_modify                                      1105    1048     -57
get_integer                                           70       -     -70
parse_args                                          1684    1440    -244
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 0/11 up/down: 0/-594)          Total: -594 bytes
   text    data     bss     dec     hex filename
 817378     476    7892  825746   c9992 busybox_old
 816784     476    7892  825152   c9740 busybox_unstripped
2009-03-05 09:21:57 +00:00
Bernhard Reutner-Fischer
6c4dadefb6 - update my name. No obj-code changes ;) 2008-09-25 12:13:34 +00:00
Denis Vlasenko
a60f84ebf0 *: rename ATTRIBUTE_XXX to just XXX. 2008-07-05 09:18:54 +00:00
Bernhard Reutner-Fischer
9de4622055 - make the first arg of the filter function passed to rtnl_dump_filter constant
to match normal iproute. No obj-code changes.
2008-06-12 15:54:49 +00:00
Denis Vlasenko
bedfabd500 libiproute: use stdout directly instead of passing it as a parameter
function                                             old     new   delta
iprule_list                                           86      82      -4
print_rule                                           860     791     -69
ipaddr_list_or_flush                                2484    2384    -100
print_addrinfo                                      1498    1292    -206
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-379)           Total: -379 bytes
2008-06-05 05:00:24 +00:00
Bernhard Reutner-Fischer
f470196a41 - fix conflicting decls of syslog related facilitynames and prioritynames tables 2008-01-27 12:50:12 +00:00
Denis Vlasenko
186c2b3d0e iproute: fix a bug where "ip r flush table main" was rejected,
add "ip r flush cache" (however I'm unsure it is really valid syntax)
Add a few comments and stop mixing params and params' keywords.
2007-11-26 18:29:52 +00:00
Denis Vlasenko
ed6a49c657 ip: stop propagating argc; optimize ip_parse_common_args
function                                             old     new   delta
find_pair                                            167     187     +20
static.families                                        -      17     +17
die_must_be_on_off                                     -      11     +11
...
on_off                                                33      22     -11
do_ipaddr                                            103      90     -13
do_iptunnel                                         1001     986     -15
iproute_list_or_flush                               1237    1217     -20
static.ip_common_commands                             43      22     -21
do_iproute                                          2217    2193     -24
parse_args                                          1444    1414     -30
ip_do                                                 47      16     -31
do_iprule                                            994     963     -31
ip_main                                              153     113     -40
ipaddr_modify                                       1357    1305     -52
ipaddr_list_or_flush                                2543    2490     -53
ip_parse_common_args                                 294     159    -135
------------------------------------------------------------------------------
(add/remove: 4/1 grow/shrink: 4/24 up/down: 85/-563)         Total: -478 bytes
   text    data     bss     dec     hex filename
 775561     966    9236  785763   bfd63 busybox_old
 775073     962    9236  785271   bfb77 busybox_unstripped
2007-11-18 22:56:25 +00:00
Denis Vlasenko
605b20e277 replace printf with fputs where appropriate 2007-09-30 16:22:36 +00:00
Denis Vlasenko
6ca409e0e4 trylink: produce even more info about final link stage
trylink: explain how to modify link and drastically decrease amount
  of padding (unfortunately, needs hand editing ATM).
*: add ALIGN1 / ALIGN2 to global strings and arrays of bytes and shorts

size saving: 0.5k
2007-08-12 20:58:27 +00:00
Denis Vlasenko
990d0f63ee Replace index_in_[sub]str_array with index_in_[sub]strings,
which scans thru "abc\0def\0123\0\0" type strings. Saves 250 bytes.

   text    data     bss     dec     hex filename
 781266    1328   11844  794438   c1f46 busybox_old
 781010    1328   11844  794182   c1e46 busybox_unstripped
2007-07-24 15:54:42 +00:00
Bernhard Reutner-Fischer
cd0e80ce90 - move iprule and ipaddress from matches() to index_in_str_array
text    data     bss     dec     hex filename
   2544       0       0    2544     9f0 networking/libiproute/iprule.o.oorig
   2356       0       0    2356     934 networking/libiproute/iprule.o
   6481       0       0    6481    1951 networking/libiproute/ipaddress.o.oorig
   6464       0       0    6464    1940 networking/libiproute/ipaddress.o
2007-06-20 14:53:49 +00:00
Denis Vlasenko
9a7d38fe24 delete tons of extra #includes 2007-05-31 22:42:12 +00:00
Bernhard Reutner-Fischer
b290889f02 - add xsendto and use where appropriate; shrink iplink; sanitize libiproute a bit.
-916 byte
2007-04-12 11:34:39 +00:00
Denis Vlasenko
540a2a1f3b libiproute: audit callgraph, shortcut error paths into die() functions.
Kill a few statics, made other globals smaller:
oneline is smallint, _SL_ is char

function                                             old     new   delta
print_tunnel                                         693     731     +38
print_route                                         1775    1777      +2
print_addrinfo                                      1495    1497      +2
ipaddr_list_or_flush                                2826    2828      +2
oneline                                                4       1      -3
_SL_                                                   4       1      -3
ipaddr_modify                                       1476    1472      -4
parse_address                                        124     119      -5
ip_parse_common_args                                 429     423      -6
on_off                                                53      46      -7
do_del_ioctl                                         113     106      -7
do_add_ioctl                                         120     113      -7
do_show                                              864     856      -8
iprule_list                                          157     148      -9
do_iptunnel                                          310     299     -11
do_add                                               143     126     -17
get_ctl_fd                                            95      76     -19
set_address                                          108      84     -24
ip_main                                              351     323     -28
static.ifr                                            32       -     -32
parse_args                                          1992    1949     -43
iproute_list_or_flush                               1673    1582     -91
do_iplink                                           1583    1485     -98
filter                                               280       -    -280
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 4/18 up/down: 44/-702)         Total: -658 bytes
2007-04-07 01:14:45 +00:00
Bernhard Reutner-Fischer
2806b2368c - reinstate static for the command string arrray to be gentle to gcc-3.x 2007-01-28 11:14:26 +00:00
Bernhard Reutner-Fischer
4d9a358ec1 - use uint32_t as suggested by vda.
- minor size- and readability tweaks while at it:
   text	   data	    bss	    dec	    hex	filename
   2631	      0	      0	   2631	    a47	networking/libiproute/iprule.o.orig
   2596	      0	      0	   2596	    a24	networking/libiproute/iprule.o
2007-01-28 00:20:46 +00:00
Bernhard Reutner-Fischer
425997223c - rtnl_rttable_a2n wants an unsigned int32 2007-01-23 01:27:17 +00:00
Bernhard Reutner-Fischer
620e57b421 - forgot to include ip_common.h 2007-01-22 17:42:37 +00:00
Denis Vlasenko
98ee06d3d4 stop using __u32 etc. uint32_t is there for a reason 2006-12-31 18:57:37 +00:00
Bernhard Reutner-Fischer
921f5df25f - add 'ip rule' support. First take..
text    data     bss     dec     hex filename
   2999       0       0    2999     bb7 networking/libiproute/iprule.o
2006-11-21 15:36:08 +00:00