udhcp: reuse strings

text	   data	    bss	    dec	    hex	filename
1019916	    559	   5020	1025495	  fa5d7	busybox_old
1019906	    559	   5020	1025485	  fa5cd	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2021-02-21 16:32:07 +01:00
parent 855aeacfba
commit a4959eef71
3 changed files with 14 additions and 10 deletions

View File

@ -1589,8 +1589,10 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
} }
if ((packet.d6_xid32 & htonl(0x00ffffff)) != xid) { if ((packet.d6_xid32 & htonl(0x00ffffff)) != xid) {
log1("xid %x (our is %x), ignoring packet", log1("xid %x (our is %x)%s",
(unsigned)(packet.d6_xid32 & htonl(0x00ffffff)), (unsigned)xid); (unsigned)(packet.d6_xid32 & htonl(0x00ffffff)), (unsigned)xid,
", ignoring packet"
);
continue; continue;
} }
@ -1743,7 +1745,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
free(client6_data.ia_na); free(client6_data.ia_na);
client6_data.ia_na = d6_copy_option(packet.d6_options, packet_end, D6_OPT_IA_NA); client6_data.ia_na = d6_copy_option(packet.d6_options, packet_end, D6_OPT_IA_NA);
if (!client6_data.ia_na) { if (!client6_data.ia_na) {
bb_info_msg("no %s option, ignoring packet", "IA_NA"); bb_info_msg("no %s option%s", "IA_NA", ", ignoring packet");
continue; continue;
} }
if (client6_data.ia_na->len < (4 + 4 + 4) + (2 + 2 + 16 + 4 + 4)) { if (client6_data.ia_na->len < (4 + 4 + 4) + (2 + 2 + 16 + 4 + 4)) {
@ -1756,7 +1758,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
D6_OPT_IAADDR D6_OPT_IAADDR
); );
if (!iaaddr) { if (!iaaddr) {
bb_info_msg("no %s option, ignoring packet", "IAADDR"); bb_info_msg("no %s option%s", "IAADDR", ", ignoring packet");
continue; continue;
} }
if (iaaddr->len < (16 + 4 + 4)) { if (iaaddr->len < (16 + 4 + 4)) {
@ -1781,7 +1783,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
free(client6_data.ia_pd); free(client6_data.ia_pd);
client6_data.ia_pd = d6_copy_option(packet.d6_options, packet_end, D6_OPT_IA_PD); client6_data.ia_pd = d6_copy_option(packet.d6_options, packet_end, D6_OPT_IA_PD);
if (!client6_data.ia_pd) { if (!client6_data.ia_pd) {
bb_info_msg("no %s option, ignoring packet", "IA_PD"); bb_info_msg("no %s option%s", "IA_PD", ", ignoring packet");
continue; continue;
} }
if (client6_data.ia_pd->len < (4 + 4 + 4) + (2 + 2 + 4 + 4 + 1 + 16)) { if (client6_data.ia_pd->len < (4 + 4 + 4) + (2 + 2 + 4 + 4 + 1 + 16)) {
@ -1794,7 +1796,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
D6_OPT_IAPREFIX D6_OPT_IAPREFIX
); );
if (!iaprefix) { if (!iaprefix) {
bb_info_msg("no %s option, ignoring packet", "IAPREFIX"); bb_info_msg("no %s option%s", "IAPREFIX", ", ignoring packet");
continue; continue;
} }
if (iaprefix->len < (4 + 4 + 1 + 16)) { if (iaprefix->len < (4 + 4 + 1 + 16)) {

View File

@ -1655,8 +1655,10 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
} }
if (packet.xid != xid) { if (packet.xid != xid) {
log1("xid %x (our is %x), ignoring packet", log1("xid %x (our is %x)%s",
(unsigned)packet.xid, (unsigned)xid); (unsigned)packet.xid, (unsigned)xid,
", ignoring packet"
);
continue; continue;
} }

View File

@ -1048,7 +1048,7 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
move_from_unaligned32(server_id_network_order, server_id_opt); move_from_unaligned32(server_id_network_order, server_id_opt);
if (server_id_network_order != server_data.server_nip) { if (server_id_network_order != server_data.server_nip) {
/* client talks to somebody else */ /* client talks to somebody else */
log1("server ID doesn't match%s", ", ignoring"); log1("server ID doesn't match%s", ", ignoring packet");
continue; continue;
} }
} }
@ -1171,7 +1171,7 @@ o DHCPREQUEST generated during REBINDING state:
if (!requested_ip_opt) { if (!requested_ip_opt) {
requested_nip = packet.ciaddr; requested_nip = packet.ciaddr;
if (requested_nip == 0) { if (requested_nip == 0) {
log1("no requested IP and no ciaddr%s", ", ignoring"); log1("no requested IP and no ciaddr%s", ", ignoring packet");
break; break;
} }
} }