Commit Graph

2924 Commits

Author SHA1 Message Date
Denys Vlasenko
04a0b7f080 bc: placate compiler warnings
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-06-08 12:58:16 +02:00
Denys Vlasenko
3e463e1cfd brctl: placate compiler warnings
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-06-08 12:35:06 +02:00
Denys Vlasenko
1230aec77a httpd: .js is "application/javascript", not "application/x-javascript"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-06-07 12:32:30 +02:00
Denys Vlasenko
5c317c0b8d httpd: add js to built in MIME types list
Firefox needs this to execute .js

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-06-07 09:32:03 +02:00
Vicente Jimenez Aguilar
09b25ecc51 httpd: add svg to built in MIME types list
Signed-off-by: Vicente Jimenez Aguilar <googuy@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-06-07 09:31:57 +02:00
Denys Vlasenko
45e3967c20 libbb: move netlink socket binding to the utility function
function                                             old     new   delta
create_and_bind_to_netlink                             -     134    +134
ifplugd_main                                        1117    1052     -65
uevent_main                                          399     306     -93
mdev_main                                            314     215     -99
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/3 up/down: 134/-257)         Total: -123 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-06-03 14:16:52 +02:00
Denys Vlasenko
6eb6e6a1e9 dhcp: downgrade "got raw socket fd" message to log3, make log2 default max
log3 messages are very much redundant

function                                             old     new   delta
change_listen_mode                                   322     302     -20

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-31 23:52:16 +02:00
Denys Vlasenko
65c34c52df dhcp: get rid of static data signal_pipe
function                                             old     new   delta
udhcp_sp_setup                                        65     110     +45
udhcp_sp_fd_set                                       60      59      -1
udhcpd_main                                         1442    1437      -5
udhcpc_main                                         2684    2679      -5
signal_pipe                                            8       -      -8
packed_usage                                       33292   33284      -8
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/4 up/down: 45/-27)             Total: 18 bytes
   text	   data	    bss	    dec	    hex	filename
 952746	    481	   7296	 960523	  ea80b	busybox_old
 952768	    481	   7288	 960537	  ea819	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-31 23:39:22 +02:00
Denys Vlasenko
91755cb16d udhcp: rename server_config to server_data
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-30 16:23:34 +02:00
Denys Vlasenko
bcb1fc3e6c udhcp: rename client_config to client_data, server_config to server_data
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-26 15:03:05 +02:00
Martin Lewis
818d9e02f2 udhcpc6: Fixed aliasing compilation error
Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-26 14:24:32 +02:00
Denys Vlasenko
a4ed2c45b9 dhcp: get rid of last global data
function                                             old     new   delta
udhcpc_main                                         2680    2684      +4
state                                                  1       -      -1
listen_mode                                            1       -      -1
sockfd                                                 4       -      -4
------------------------------------------------------------------------------
(add/remove: 0/3 grow/shrink: 1/0 up/down: 4/-6)               Total: -2 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-26 13:05:04 +02:00
Denys Vlasenko
1115e40c88 dhcp: tweak comments, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-23 15:24:03 +02:00
Denys Vlasenko
028c5aa18b ip: use rtnl_send_check() on flush commands, closes 6962
function                                             old     new   delta
rtnl_send_check                                        -     160    +160
xrtnl_wilddump_request                                64      66      +2
ipneigh_list_or_flush                                714     706      -8
rtnl_send                                             69       -     -69
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 1/1 up/down: 162/-77)            Total: 85 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-22 13:54:46 +02:00
Denys Vlasenko
84fc645605 *: slap on a few ALIGN1/2s where appropriate
The result of looking at "grep -F -B2 '*fill*' busybox_unstripped.map"

   text	   data	    bss	    dec	    hex	filename
 952537	    485	   7296	 960318	  ea73e	busybox_old
 952527	    485	   7296	 960308	  ea734	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-21 17:29:24 +02:00
Denys Vlasenko
831844c139 udhcpd: fix printing of static leases
function                                             old     new   delta
read_staticlease                                     299     282     -17

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-21 16:06:34 +02:00
Khem Raj
ee9e5f92b6 networking: cc is not a register
gcc accepts

  __asm__ ( "" : : : "%cc");

but cc is not a real register and clang does not like it.

networking/tls_pstm_montgomery_reduce.c:385:4: error: unknown register name '%cc' in asm
|                         INNERMUL;
|                         ^

The % syntax nominally goes before a register, in this case cc,
like "memory" isn't a true register it's just a way of specifying that
the condition code registers for the target are clobbered

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-17 22:56:47 +02:00
Denys Vlasenko
25393fb55e udhcpd: code shrink
function                                             old     new   delta
send_packet_verbose                                    -      35     +35
send_offer                                           443     423     -20
send_ACK                                             152     131     -21
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/2 up/down: 35/-41)             Total: -6 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-16 11:27:28 +02:00
Denys Vlasenko
a840884531 udhcpd: support per-client hostnames in static leases
function                                             old     new   delta
read_staticlease                                     222     299     +77
add_server_options                                    92     154     +62
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 139/0)             Total: 139 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-16 11:18:49 +02:00
Denys Vlasenko
abe248b208 udhcpc6: unbreak
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-15 14:20:32 +02:00
Denys Vlasenko
8402969d48 udhcpd: code shrink - do not fetch requested IP twice
function                                             old     new   delta
send_offer                                           444     443      -1
udhcpd_main                                         1454    1442     -12
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-13)             Total: -13 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-15 13:08:48 +02:00
Denys Vlasenko
8c317f03f6 style fix, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-14 17:26:47 +02:00
Denys Vlasenko
15021f393d udhcpd: code shrink
function                                             old     new   delta
is_nip_reserved_as_static                              -      28     +28
get_static_nip_by_mac                                 43      47      +4
udhcpd_main                                         1459    1454      -5
send_offer                                           449     444      -5
read_leases                                          309     299     -10
is_nip_reserved                                       20       -     -20
packed_usage                                       33283   33243     -40
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 1/4 up/down: 32/-80)            Total: -48 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-10 15:55:12 +02:00
James Byrne
253c4e787a Optionally re-introduce bb_info_msg()
Between Busybox 1.24.2 and 1.25.0 the bb_info_msg() function was
eliminated and calls to it changed to be bb_error_msg(). The downside of
this is that daemons now log all messages to syslog at the LOG_ERR level
which makes it hard to filter errors from informational messages.

This change optionally re-introduces bb_info_msg(), controlled by a new
option FEATURE_SYSLOG_INFO, restores all the calls to bb_info_msg() that
were removed (only in applets that set logmode to LOGMODE_SYSLOG or
LOGMODE_BOTH), and also changes informational messages in ifplugd and
ntpd.

The code size change of this is as follows (using 'defconfig' on x86_64
with gcc 7.3.0-27ubuntu1~18.04)

function                                             old     new   delta
bb_info_msg                                            -     182    +182
bb_vinfo_msg                                           -      27     +27
static.log7                                          194     198      +4
log8                                                 190     191      +1
log5                                                 190     191      +1
crondlog                                              45       -     -45
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 3/0 up/down: 215/-45)           Total: 170 bytes

If you don't care about everything being logged at LOG_ERR level
then when FEATURE_SYSLOG_INFO is disabled Busybox actually gets smaller:

function                                             old     new   delta
static.log7                                          194     200      +6
log8                                                 190     193      +3
log5                                                 190     193      +3
syslog_level                                           1       -      -1
bb_verror_msg                                        583     581      -2
crondlog                                              45       -     -45
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 3/1 up/down: 12/-48)            Total: -36 bytes

Signed-off-by: James Byrne <james.byrne@origamienergy.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-30 10:51:27 +02:00
Denys Vlasenko
13f4204561 ip: fix comment placement
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-29 00:34:07 +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
e49a572b52 httpd: do disable header reading timeout even if proxying
function                                             old     new   delta
handle_incoming_and_exit                            2362    2369      +7

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-19 14:24:57 +02:00
Denys Vlasenko
1c356948f1 httpd: use full size of iobuf[] when piping CGI data
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-19 14:19:41 +02:00
Denys Vlasenko
af6012a1a7 httpd: do not set alarm() timeout if we read cached header
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-19 14:03:37 +02:00
Denys Vlasenko
bca888a73e httpd: deindent code block, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-19 14:02:51 +02:00
Denys Vlasenko
ad29ba73ee httpd: require "HTTP/xyz" at the end of request line
function                                             old     new   delta
handle_incoming_and_exit                            2379    2362     -17
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-17)             Total: -17 bytes
   text	   data	    bss	    dec	    hex	filename
 981787	    485	   7296	 989568	  f1980	busybox_old
 981779	    485	   7296	 989560	  f1978	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-19 13:59:58 +02:00
Alexander Vickberg
049670fbbe httpd: pass authorization header to CGI if not Basic
Pass the Authorization header to CGI if not of type Basic. This will
make it possible for CGI to verify authorization headers of type
Bearer <token>.

function                                             old     new   delta
handle_incoming_and_exit                            2370    2379      +9

Signed-off-by: Alexander Vickberg <wickbergster@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-18 10:06:39 +02:00
Alexander Vickberg
210b52476c httpd: When sending gzipped content use content-length header
Today for gzipped content httpd is using a header with name
Transfer-Length. However I can't find a header with that name in the
standards. Instead use Content-Length.

function                                             old     new   delta
.rodata                                           157940  157936      -4
send_headers                                         980     939     -41
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-45)             Total: -45 bytes

Signed-off-by: Alexander Vickberg <wickbergster@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-17 11:34:49 +02:00
Denys Vlasenko
2efa726b22 httpd: extract query string only after proxying check
function                                             old     new   delta
handle_incoming_and_exit                            2398    2370     -28

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-16 13:35:56 +02:00
Denys Vlasenko
62ba9e5ac3 httpd: make rmt_ip variable local
function                                             old     new   delta
handle_incoming_and_exit                            2385    2398     +13
if_ip_denied_send_HTTP_FORBIDDEN_and_exit             51      54      +3
get_line                                             110     106      -4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 16/-4)              Total: 12 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-16 13:18:12 +02:00
Denys Vlasenko
44f5b6a1cb httpd: check denied IPs even before reading 1st query line
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-16 12:59:20 +02:00
Denys Vlasenko
c69f648457 httpd: do not decode URL and headers if proxying - send all verbatim
function                                             old     new   delta
handle_incoming_and_exit                            2566    2385    -181

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-16 12:45:26 +02:00
Denys Vlasenko
cf695976c7 httpd: remove duplicate "decode URL escape sequences" code
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-16 11:58:28 +02:00
Denys Vlasenko
fba665a888 httpd: put all headers into environment as HTTP_UPPERCASED_HEADER=val
Set up environment variables before running the CGI script.
The variables will be named HTTP_<filtered_name> where the <filtered_name>
is the header name capitalized and all characters not matching
[a-z] | [A-Z] | [0-9] replaced with '_'.

function                                             old     new   delta
http_response                                         80      88      +8
http_response_type                                    20      22      +2
send_headers                                         718     715      -3
parse_conf                                          1481    1478      -3
get_line                                             128     110     -18
cgi_io_loop_and_exit                                 599     569     -30
send_cgi_and_exit                                    882     738    -144
handle_incoming_and_exit                            2793    2592    -201
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/6 up/down: 10/-399)          Total: -389 bytes
   text	   data	    bss	    dec	    hex	filename
 982178	    485	   7296	 989959	  f1b07	busybox_old
 981675	    485	   7296	 989456	  f1910	busybox_unstripped

Signed-off-by: Alexander Vickberg <wickbergster@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-16 11:37:02 +02:00
Denys Vlasenko
d0ae4103dd httpd: fix handling of EOF in get_line()
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-16 11:07:37 +02:00
Denys Vlasenko
ff36bec49b httpd: add missing {}
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-16 10:14:50 +02:00
Denys Vlasenko
bae8f7eaf2 httpd: do not percent-decode URI if proxying
The proxying is documented as follows:

P:/url:[http://]hostname[:port]/new/path

Howeverm urlcopy is not a true copy anymore when it is fdprint'ed
to proxy_fd, this is because percent_decode_in_place() is called
after the copy is created.

This breaks reverse proxying all URIs containing percent
encoded spaces, e.g. - because a decoded URI will be printed out
to proxy_fd instead of the original.

The fix keeps the logic in place to canonicalize the uri first,
before reverse proxying (one could argue that the uri
should be proxied completely unaltered, except for the prefix
rewrite).

function                                             old     new   delta
handle_incoming_and_exit                            2752    2792     +40

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-16 10:07:33 +02:00
Denys Vlasenko
02d650e159 httpd: fix proxy headers passing - full_write() instead of write()
function                                             old     new   delta
handle_incoming_and_exit                            2763    2752     -11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-14 20:46:57 +02:00
Denys Vlasenko
51792e126b httpd: if remote IP is denied, send FORBIDDEN reply earlier
While at it, fix sighup_handler to not clobber errno.

function                                             old     new   delta
send_HTTP_FORBIDDEN_and_exit_if_denied_ip              -      47     +47
sighup_handler                                        15      30     +15
handle_incoming_and_exit                            2791    2763     -28
checkPermIP                                           48       -     -48
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 1/1 up/down: 62/-76)            Total: -14 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-14 19:57:13 +02:00
Denys Vlasenko
60bf77f7e7 udhcpc6: code shrink
function                                             old     new   delta
d6_read_interface                                    593     582     -11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-14 17:01:10 +02:00
Denys Vlasenko
0d75e8b797 udhcpc6: add a few comments, no code changes.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-13 19:43:15 +02:00
Denys Vlasenko
cc45cbcca4 udhcpc6: make it enabled in defconfig
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-13 17:32:40 +02:00
Antoine Girard-Vallée
0e7bd69bb5 udhcp: add 100 and 101 dhcp options for ipv4
Support for the IEEE timezone string and timezone database strings (100
and 101 options respectively) is added for ipv4, conforming to RFC-4833.

The two options are passed to hook scripts in the variables tzstr and
tzdbstr.

function                                             old     new   delta
dhcp_option_strings                                  280     294     +14
dhcp_optflags                                         76      80      +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 18/0)               Total: 18 bytes

Signed-off-by: Antoine Girard-Vallée <antoine.girard-vallee@savoirfairelinux.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-13 16:27:26 +02:00
Denys Vlasenko
2945822f86 brctl: add TODO: "showmacs BR"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-13 15:48:31 +02:00
Denys Vlasenko
9435608804 brctl: simplify str_to_jiffies()
function                                             old     new   delta
write_uint                                             -      96     +96
brctl_main                                           721     678     -43
write_ulong                                           96       -     -96
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/1 up/down: 96/-139)           Total: -43 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-13 14:17:55 +02:00