Commit Graph

478 Commits

Author SHA1 Message Date
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
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
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
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
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
Jeremy Kerr
b8ffd11e65 udhcp: add PXELINUX path prefix option (code 210) definition
Like d3092c99, this change adds support for the DHCP "path-prefix"
option, as defined in RFC 5071. We use the string identifer
"pxepathprefix".

Adding this option makes string parsing in the hook scripts simpler.

function                                             old     new   delta
dhcp_option_strings                                  255     269     +14
dhcp_optflags                                         72      74      +2

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-07-16 14:21:42 +02:00
Denys Vlasenko
85090c162b udhcpc: make hostname sanitization optional. Closes 3979
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-06-16 00:17:00 +02:00
Denys Vlasenko
e2318bbad7 udhcpc: ignore NAKs from "wrong" servers. Closes 4267
function                                             old     new   delta
udhcpc_main                                         2716    2814     +98

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-02-27 18:15:50 +01:00
Denys Vlasenko
ffc3a93d0d udhcpc: fix BPF filter. Hopefully fixes the root cause of 4598 and 6746
Use a *signed* large positive value in BPF filter to indicate success.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-02-19 14:17:11 +01:00
Denys Vlasenko
744ee5db1c udhcpc: in comments, explain the kind of raw socket we create
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-02-07 17:38:52 +01:00
Denys Vlasenko
e4785ca653 udhcpc: don't use BPF filter, users report problems (bugs 4598, 6746)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-02-03 18:03:42 +01:00
Jeremy Kerr
d3092c99ae udhcp: add PXELINUX config file option (code 209) definition
This change adds a definition for DHCP option 209. RFC 5071 defines code
209 as a configuration file for a PXE bootloader; this change uses
the string "pxeconffile" as its text identifier.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-11-12 11:18:26 +01:00
Denys Vlasenko
8d3efaf35e udhcpc: allow zero server-id. Closes 6614.
function                                             old     new   delta
bcast_or_ucast                                         -      47     +47
udhcp_send_kernel_packet                             271     295     +24
udhcpc_main                                         2696    2705      +9
udhcp_send_raw_packet                                456     459      +3
send_release                                          90      76     -14
send_renew                                           105      77     -28
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/2 up/down: 83/-42)             Total: 41 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-11-03 19:20:54 +01:00
Johannes Stezenbach
2d576e2a22 udhcpc: make DHCP packets to have at least 300 DHCP bytes
Commit b8b72f02 removed all padding from DHCP packets
to fix operation with buggy servers which can't handle
maximum sized packets.  But it introduced a regression
with buggy routers which drop DHCP packets smaller
than 300 bytes (i.e. 342 byte ethernet packets).
Add back some padding to work around.

function                                             old     new   delta
udhcp_send_kernel_packet                             268     292     +24
udhcp_send_raw_packet                                462     473     +11
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 35/0)               Total: 35 bytes

Signed-off-by: Johannes Stezenbach <js@sig21.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-10-28 23:27:37 +01:00
Denys Vlasenko
9ae6d79307 udhcpc: tweak help text more
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-08-08 12:45:45 +02:00
Denys Vlasenko
456687fff1 udhcpc: tweak help text
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-08-08 12:33:18 +02:00
Denys Vlasenko
aadb485bd0 udhcpc: tweak help text
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-08-05 02:21:36 +02:00
Denys Vlasenko
b443a3780d udhcp: code shrink
function                                             old     new   delta
attach_option                                        416     413      -3
allocate_tempopt_if_needed                            74       -     -74

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-05-17 15:19:47 +02:00
Denys Vlasenko
c133fa66f3 udhcpc: fix a problem with binary-encoded options #2
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-05-17 15:13:38 +02:00
Denys Vlasenko
7b5d5c1bdb udhcpd: also add -I ADDR to help text
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-03-14 02:18:52 +01:00
Denys Vlasenko
e3f5b73ad0 udhcpd: add -I LOCAL_ADDR option
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-03-13 22:27:37 +01:00
Denys Vlasenko
04ac6e03c3 udhcpc6: fix port numbers used if !FEATURE_UDHCP_PORT
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-28 15:25:35 +01: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
Felix Fietkau
1c7a58dfb8 udhcpc[6]: allow discover_retries == 0 (infinite)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-27 16:22:24 +02:00
Alexey Froloff
3c62bbae94 ushcpc: gracefully handle packets with CHECKSUM_PARTIAL
function                                             old     new   delta
udhcp_recv_raw_packet                                415     579    +164
change_listen_mode                                   317     370     +53
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 217/0)             Total: 217 bytes

Signed-off-by: Alexey Froloff <raorn@raorn.name>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-17 16:02:44 +02:00
Denys Vlasenko
6567edd10b udhcp[cd]: fix binding to network aliases. Closes 5432, 5438
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-08-10 00:27:22 +02:00
Denys Vlasenko
293c94564c udhcpc: make -O <numeric_opt> work. Closes 5402
function                                             old     new   delta
udhcpc_main                                         2642    2685     +43
udhcp_recv_raw_packet                                414     415      +1
d6_recv_raw_packet                                   248     249      +1
udhcpc6_main                                        2430    2413     -17
add_client_options                                   239     213     -26
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/2 up/down: 45/-43)              Total: 2 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-07-27 13:25:07 +02:00
Denys Vlasenko
5cfb818181 Add yet another missing ALIGN2 on a global declaration.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-07-26 12:58:41 +02:00
Denys Vlasenko
71045cc819 dhcpd: write lease file on exit
function                                             old     new   delta
udhcpd_main                                         1431    1403     -28

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-07-24 17:21:26 +02:00
Michael Tokarev
32f774cd34 *: declare strings with ALIGN1, as appropriate
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-07-24 15:56:37 +02:00
Denys Vlasenko
085b293338 udhcpc[6]: show select timeout in log
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-02 23:53:53 +02:00
Mike Frysinger
3da46c8163 udhcpc6: depend on ipv6
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-05-02 21:45:35 -04:00
Denys Vlasenko
d2266d43bf udhcpc: fix improper size calculation for OPTION_STRING_HOST
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-04-22 03:37:01 +02:00
Denys Vlasenko
8cab66730a fix build breakage found by randconfig
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-04-20 14:48:00 +02:00
Denys Vlasenko
6500d123d0 udhcp: make arpping code resistant to time jumps
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-04-17 17:10:31 +02:00
Michael McTernan
ee0f444f11 udhcp: finish support of classless static routes (now the correct patch!)
Signed-off-by: Michael McTernan <Michael.McTernan.2001@cs.bris.ac.uk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-12-16 17:10:09 +01:00
Denys Vlasenko
7280d2017d udhcpc: sanitize hostnames in incoming packets. Closes 3979.
The following options are replaced with string "bad" if they
contain malformed hostname:
HOST_NAME, DOMAIN_NAME, NIS_DOMAIN, TFTP_SERVER_NAME

function                                             old     new   delta
xmalloc_optname_optval                               850     888     +38
attach_option                                        440     443      +3
len_of_option_as_string                               13      14      +1
dhcp_option_lengths                                   13      14      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/0 up/down: 43/0)               Total: 43 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-12-08 16:41:05 +01:00
Denys Vlasenko
860491c525 udhcpc: shrink code by setting xid more economically
function                                             old     new   delta
send_decline                                          90      82      -8
udhcpc_main                                         2649    2640      -9

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-11-18 02:09:13 +01:00
Denys Vlasenko
a092a89d8f udhcpc6: rudimentary code to export data to script; fix IAADDR parsing
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-11-16 20:17:12 +01:00
Denys Vlasenko
7e21f0491c udhcpc[6]: tweak help text, remove -B from udhcpc6 and "--version" from both
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-11-08 11:39:41 +01:00
Denys Vlasenko
2b6a6b90cc udhcpc6: set hop limit to 1 in emitted raw packets
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-11-07 18:22:06 +01:00
Denys Vlasenko
68c5b28156 udhcpc6: fix endianness
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-11-07 16:21:24 +01:00
Denys Vlasenko
9ba75048c0 udhcpc6: new applet. Not yet functional.
It builds. It sends Solicit packets. Not sure these packets are well-formed.
I have no server to test it against.

function                                             old     new   delta
udhcpc6_main                                           -    2426   +2426
d6_send_raw_packet                                     -     428    +428
d6_send_kernel_packet                                  -     274    +274
d6_recv_raw_packet                                     -     248    +248
send_d6_discover                                       -     177    +177
packed_usage                                       28795   28966    +171
d6_run_script                                          -     156    +156
send_d6_renew                                          -     140    +140
send_d6_release                                        -     126    +126
d6_recv_kernel_packet                                  -     116    +116
send_d6_select                                         -      95     +95
perform_d6_release                                     -      78     +78
d6_find_option                                         -      74     +74
init_d6_packet                                         -      54     +54
d6_copy_option                                         -      48     +48
d6_mcast_from_client_config_ifindex                    -      42     +42
d6_dump_packet                                         -      24     +24
static.FF02__1_2                                       -      16     +16
d6_store_blob                                          -      13     +13
applet_names                                        2432    2440      +8
applet_main                                         1412    1416      +4
applet_nameofs                                       706     708      +2
add_d6_client_options                                  -       1      +1
------------------------------------------------------------------------------
(add/remove: 21/0 grow/shrink: 4/0 up/down: 4721/0)          Total: 4721 bytes
   text	   data	    bss	    dec	    hex	filename
 879080	    493	   7584	 887157	  d8975	busybox_old
 884585	    497	   7584	 892666	  d9efa	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-11-07 15:55:39 +01:00
Denys Vlasenko
50089fc61c udhcpc: trim help text, rename badly-named variable
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-11-07 15:44:46 +01:00
Denys Vlasenko
0fd4347ced udhcpc: code shrink
function                                             old     new   delta
udhcpc_main                                         2646    2649      +3
udhcp_run_script                                     816     802     -14

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-11-07 00:54:27 +01:00
Denys Vlasenko
3b46fcb95d udhcpc: remove workaround for bugs in Win98 dhcp server ("MSFT 98" vendor string)
Stats for last three commits:

function                                             old     new   delta
udhcpc_main                                         2635    2646     +11
udhcp_recv_raw_packet                                425     414     -11
udhcp_recv_kernel_packet                             210     134     -76
packed_usage                                       28940   28857     -83
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/3 up/down: 11/-170)          Total: -159 bytes
   text    data     bss     dec     hex filename
 879524     493    7584  887601   d8b31 busybox_old
 879340     493    7584  887417   d8a79 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-11-05 01:26:18 +01:00
Denys Vlasenko
d38ca03946 udhcpc: reuse string constant; remove unneeded memset(0)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-11-05 01:25:03 +01:00
Denys Vlasenko
2017d48c0d udhcpc: deprecate --hostname NAME
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-11-05 01:24:14 +01:00