<feed xmlns='http://www.w3.org/2005/Atom'>
<title>busybox-w32/networking/udhcp/common.c, branch cron_changes</title>
<subtitle>A mirror of https://github.com/rmyorston/busybox-w32.git
</subtitle>
<id>https://git.lua4.win/busybox-w32/atom?h=cron_changes</id>
<link rel='self' href='https://git.lua4.win/busybox-w32/atom?h=cron_changes'/>
<link rel='alternate' type='text/html' href='https://git.lua4.win/busybox-w32/'/>
<updated>2023-06-12T11:22:47+00:00</updated>
<entry>
<title>udhcpd: optional BOOTP support</title>
<updated>2023-06-12T11:22:47+00:00</updated>
<author>
<name>Denys Vlasenko</name>
<email>vda.linux@googlemail.com</email>
</author>
<published>2023-06-12T11:12:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/busybox-w32/commit/?id=8f0e4c42c630126daafd834175b86d2b28f5b798'/>
<id>urn:sha1:8f0e4c42c630126daafd834175b86d2b28f5b798</id>
<content type='text'>
from Adam Goldman &lt;adamg@pobox.com&gt;

This patch makes udhcpd respond correctly to queries from BOOTP clients.

It contains the following changes:

The end field, or DHCP_END option, is required in DHCP requests but
optional in BOOTP requests. However, we still send an end
field in all replies, because some BOOTP clients expect one in replies
even if they didn't send one in the request.

Requests without a DHCP_MESSAGE_TYPE are recognized as BOOTP requests
and handled appropriately, instead of being discarded. We still require
an RFC 1048 options field, but we allow it to be empty.

Since a BOOTP client will keep using the assigned IP forever, we only
send a BOOTP reply if a static lease exists for that client.

BOOTP replies shouldn't contain DHCP_* options, so we omit them if there
was no DHCP_MESSAGE_TYPE in the request. Options other than DHCP_*
options are still sent.

The options field of a BOOTP reply must be exactly 64 bytes. If we
construct a reply with more than 64 bytes of options, we give up and log
an error instead of sending it. udhcp_send_raw_packet already pads the
options field to 64 bytes if it is too short.

This implementation has been tested against an HP PA-RISC client.

function                                             old     new   delta
.rodata                                           105247  105321     +74
udhcpd_main                                         1520    1591     +71
send_offer                                           419     470     +51
init_packet                                           81      97     +16
udhcp_init_header                                     75      88     +13
udhcp_scan_options                                   192     203     +11
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 6/0 up/down: 236/0)             Total: 236 bytes

Signed-off-by: Denys Vlasenko &lt;vda.linux@googlemail.com&gt;
</content>
</entry>
<entry>
<title>*: slap on a few ALIGN* where appropriate</title>
<updated>2022-02-06T18:53:10+00:00</updated>
<author>
<name>Denys Vlasenko</name>
<email>vda.linux@googlemail.com</email>
</author>
<published>2022-02-06T18:53:10+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/busybox-w32/commit/?id=ca466f385ac985a8b3491daa9f326dc480cdee70'/>
<id>urn:sha1:ca466f385ac985a8b3491daa9f326dc480cdee70</id>
<content type='text'>
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 &lt;vda.linux@googlemail.com&gt;
</content>
</entry>
<entry>
<title>udhcpc6: fix udhcp_find_option to actually find DHCP6 options</title>
<updated>2021-12-12T16:13:54+00:00</updated>
<author>
<name>Denys Vlasenko</name>
<email>vda.linux@googlemail.com</email>
</author>
<published>2021-12-12T16:13:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/busybox-w32/commit/?id=e67b80f4739c4075b51b0a575701b73928fe0bf1'/>
<id>urn:sha1:e67b80f4739c4075b51b0a575701b73928fe0bf1</id>
<content type='text'>
udhcp_insert_new_option treats code for IPv6 as follows:

new-&gt;data[D6_OPT_CODE] = code &gt;&gt; 8;
new-&gt;data[D6_OPT_CODE + 1] = code &amp; 0xff;

udhcp_find_option tests the code as follows:

while (opt_list &amp;&amp; opt_list-&gt;data[OPT_CODE] &lt; code)
...
if (opt_list &amp;&amp; opt_list-&gt;data[OPT_CODE] == code)

So yes, OPT_CODE and D6_OPT_CODE are both 0, but the D6_OPT_CLIENTID =
1 value means that the 1 is in the seconds byte, and udhcp_find_option
is only looking at the first byte,  So the send_d6_release can never
find it the created option.

function                                             old     new   delta
udhcp_find_option                                     28      53     +25
attach_option                                        276     284      +8
udhcpc6_main                                        2602    2607      +5
perform_d6_release                                   262     267      +5
udhcpd_main                                         1518    1520      +2
udhcpc_main                                         2542    2544      +2
add_serverid_and_clientid_options                     46      48      +2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 7/0 up/down: 49/0)               Total: 49 bytes

Signed-off-by: Denys Vlasenko &lt;vda.linux@googlemail.com&gt;
</content>
</entry>
<entry>
<title>udhcp: convert log1s() macro to function</title>
<updated>2021-06-03T09:12:20+00:00</updated>
<author>
<name>Denys Vlasenko</name>
<email>vda.linux@googlemail.com</email>
</author>
<published>2021-06-03T09:12:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/busybox-w32/commit/?id=774020c224653590110b30ea461d0ead34a6d875'/>
<id>urn:sha1:774020c224653590110b30ea461d0ead34a6d875</id>
<content type='text'>
function                                             old     new   delta
log1s                                                  -      15     +15
udhcp_recv_kernel_packet                             134     125      -9
d6_recv_kernel_packet                                118     109      -9
change_listen_mode                                   280     271      -9
send_packet                                          162     141     -21
udhcpc_main                                         2625    2598     -27
udhcpc6_main                                        2655    2628     -27
d6_recv_raw_packet                                   255     216     -39
udhcp_recv_raw_packet                                562     484     -78
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/8 up/down: 15/-219)          Total: -204 bytes

Signed-off-by: Denys Vlasenko &lt;vda.linux@googlemail.com&gt;
</content>
</entry>
<entry>
<title>udhcpc: get rid of client_data.fqdn field</title>
<updated>2021-06-02T13:51:50+00:00</updated>
<author>
<name>Denys Vlasenko</name>
<email>vda.linux@googlemail.com</email>
</author>
<published>2021-06-02T13:51:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/busybox-w32/commit/?id=949e9621d10faada3bb55a4aa206df44e7d39ae8'/>
<id>urn:sha1:949e9621d10faada3bb55a4aa206df44e7d39ae8</id>
<content type='text'>
function                                             old     new   delta
attach_option                                        253     276     +23
udhcpc_main                                         2582    2588      +6
udhcpc6_main                                        2579    2571      -8
add_client_options                                   175     158     -17
udhcp_insert_new_option                              169     138     -31
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/3 up/down: 29/-56)            Total: -27 bytes

Signed-off-by: Denys Vlasenko &lt;vda.linux@googlemail.com&gt;
</content>
</entry>
<entry>
<title>udhcpc: remove deprecated -H/-h HOSTNAME options (9 years), deprecate -V VENDOR</title>
<updated>2021-06-02T13:07:46+00:00</updated>
<author>
<name>Denys Vlasenko</name>
<email>vda.linux@googlemail.com</email>
</author>
<published>2021-06-02T13:07:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/busybox-w32/commit/?id=698cdef538f51bb85b68d591b1e42eb6b04d891c'/>
<id>urn:sha1:698cdef538f51bb85b68d591b1e42eb6b04d891c</id>
<content type='text'>
function                                             old     new   delta
udhcpc_main                                         2563    2582     +19
dhcp_option_strings                                  294     301      +7
dhcp_optflags                                         80      82      +2
.rodata                                           103250  103248      -2
udhcpc_longopts                                      252     241     -11
add_client_options                                   209     175     -34
alloc_dhcp_option                                     59       -     -59
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 3/3 up/down: 28/-106)           Total: -78 bytes

Signed-off-by: Denys Vlasenko &lt;vda.linux@googlemail.com&gt;
</content>
</entry>
<entry>
<title>udhcpc: include client-id option in DECLINEs, even if it's a custom -x 61:HEX option</title>
<updated>2021-06-02T12:07:26+00:00</updated>
<author>
<name>Denys Vlasenko</name>
<email>vda.linux@googlemail.com</email>
</author>
<published>2021-06-02T11:50:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/busybox-w32/commit/?id=265fcddd08f22c99a2a419a1537c18f4d6d43e9f'/>
<id>urn:sha1:265fcddd08f22c99a2a419a1537c18f4d6d43e9f</id>
<content type='text'>
client_data.vendorclass, .hostname and .fqdn probably need the same treatment:
just insert them into the list of -x opts, get rid of

        if (client_data.vendorclass)
                udhcp_add_binary_option(packet, client_data.vendorclass);
        if (client_data.hostname)
                udhcp_add_binary_option(packet, client_data.hostname);
        if (client_data.fqdn)
                udhcp_add_binary_option(packet, client_data.fqdn);

function                                             old     new   delta
udhcp_insert_new_option                                -     166    +166
perform_release                                      171     207     +36
perform_d6_release                                   227     259     +32
udhcpc6_main                                        2558    2580     +22
init_d6_packet                                       103      84     -19
udhcpc_main                                         2585    2564     -21
attach_option                                        397     253    -144
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/3 up/down: 256/-184)           Total: 72 bytes

Signed-off-by: Denys Vlasenko &lt;vda.linux@googlemail.com&gt;
</content>
</entry>
<entry>
<title>udhcpc: ignore zero-length DHCP options, take 2</title>
<updated>2021-03-16T10:42:56+00:00</updated>
<author>
<name>Denys Vlasenko</name>
<email>vda.linux@googlemail.com</email>
</author>
<published>2021-03-16T10:42:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/busybox-w32/commit/?id=fe78d70ec6c48f88126f6deffe04d4707a65c9ac'/>
<id>urn:sha1:fe78d70ec6c48f88126f6deffe04d4707a65c9ac</id>
<content type='text'>
advance the optionptr by two bytes, not one

Signed-off-by: Denys Vlasenko &lt;vda.linux@googlemail.com&gt;
</content>
</entry>
<entry>
<title>udhcpc: ignore zero-length DHCP options</title>
<updated>2021-03-16T10:40:19+00:00</updated>
<author>
<name>Russell Senior</name>
<email>russell@personaltelco.net</email>
</author>
<published>2021-03-16T05:42:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/busybox-w32/commit/?id=1c461df70ab357dc9e1e064540731c58e7859a45'/>
<id>urn:sha1:1c461df70ab357dc9e1e064540731c58e7859a45</id>
<content type='text'>
Discovered that the DHCP server on a TrendNet router (unknown model)
provides a zero-length option 12 (Host Name) in the DHCP ACK message. This
has the effect of causing udhcpc to drop the rest of the options, including
option 51 (IP Address Lease Time), 3 (Router), and 6 (Domain Name Server),
most importantly leaving the OpenWrt device with no default gateway.

The TrendNet behavior violates RFC 2132, which in Section 3.14 declares that
option 12 has a minimum length of 1 octet. It is perhaps not a cosmic coincidence
that I found this behavior on Pi Day.

This patch allows zero length options without bailing out, by simply skipping them.

function                                             old     new   delta
udhcp_scan_options                                   183     172     -11

Signed-off-by: Russell Senior &lt;russell@personaltelco.net&gt;
Signed-off-by: Denys Vlasenko &lt;vda.linux@googlemail.com&gt;
</content>
</entry>
<entry>
<title>avoid using strok - eliminates use of hidden global variable</title>
<updated>2020-10-06T00:36:47+00:00</updated>
<author>
<name>Denys Vlasenko</name>
<email>vda.linux@googlemail.com</email>
</author>
<published>2020-10-06T00:36:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/busybox-w32/commit/?id=2496616b0a8d1c80cd1416b73a4847b59b9f969a'/>
<id>urn:sha1:2496616b0a8d1c80cd1416b73a4847b59b9f969a</id>
<content type='text'>
function                                             old     new   delta
udhcp_str2optset                                     616     650     +34
setpriv_main                                         950     975     +25
switch_root_main                                     688     706     +18
parse                                                958     970     +12
getopt_main                                          622     628      +6
parse_resolvconf                                     302     306      +4
mpstat_main                                         1139    1142      +3
static.p                                               4       -      -4
cdcmd                                                717     702     -15
strtok                                               148       -    -148
------------------------------------------------------------------------------
(add/remove: 0/3 grow/shrink: 7/1 up/down: 102/-167)          Total: -65 bytes

Signed-off-by: Denys Vlasenko &lt;vda.linux@googlemail.com&gt;
</content>
</entry>
</feed>
