diff options
author | James Byrne | 2019-07-02 11:35:03 +0200 |
---|---|---|
committer | Denys Vlasenko | 2019-07-02 11:35:03 +0200 |
commit | 6937487be73cd4563b876413277a295a5fe2f32c (patch) | |
tree | f16cc9999a7c827891e6ec8d99c699fc791008ee /networking/udhcp | |
parent | caecfdc20d450686cd1f7e9b5f650322f894b3c2 (diff) | |
download | busybox-6937487be73cd4563b876413277a295a5fe2f32c.zip busybox-6937487be73cd4563b876413277a295a5fe2f32c.tar.gz |
libbb: reduce the overhead of single parameter bb_error_msg() calls
Back in 2007, commit 0c97c9d43707 ("'simple' error message functions by
Loic Grenie") introduced bb_simple_perror_msg() to allow for a lower
overhead call to bb_perror_msg() when only a string was being printed
with no parameters. This saves space for some CPU architectures because
it avoids the overhead of a call to a variadic function. However there
has never been a simple version of bb_error_msg(), and since 2007 many
new calls to bb_perror_msg() have been added that only take a single
parameter and so could have been using bb_simple_perror_message().
This changeset introduces 'simple' versions of bb_info_msg(),
bb_error_msg(), bb_error_msg_and_die(), bb_herror_msg() and
bb_herror_msg_and_die(), and replaces all calls that only take a
single parameter, or use something like ("%s", arg), with calls to the
corresponding 'simple' version.
Since it is likely that single parameter calls to the variadic functions
may be accidentally reintroduced in the future a new debugging config
option WARN_SIMPLE_MSG has been introduced. This uses some macro magic
which will cause any such calls to generate a warning, but this is
turned off by default to avoid use of the unpleasant macros in normal
circumstances.
This is a large changeset due to the number of calls that have been
replaced. The only files that contain changes other than simple
substitution of function calls are libbb.h, libbb/herror_msg.c,
libbb/verror_msg.c and libbb/xfuncs_printf.c. In miscutils/devfsd.c,
networking/udhcp/common.h and util-linux/mdev.c additonal macros have
been added for logging so that single parameter and multiple parameter
logging variants exist.
The amount of space saved varies considerably by architecture, and was
found to be as follows (for 'defconfig' using GCC 7.4):
Arm: -92 bytes
MIPS: -52 bytes
PPC: -1836 bytes
x86_64: -938 bytes
Note that for the MIPS architecture only an exception had to be made
disabling the 'simple' calls for 'udhcp' (in networking/udhcp/common.h)
because it made these files larger on MIPS.
Signed-off-by: James Byrne <james.byrne@origamienergy.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/udhcp')
-rw-r--r-- | networking/udhcp/arpping.c | 4 | ||||
-rw-r--r-- | networking/udhcp/common.c | 2 | ||||
-rw-r--r-- | networking/udhcp/common.h | 19 | ||||
-rw-r--r-- | networking/udhcp/d6_dhcpc.c | 34 | ||||
-rw-r--r-- | networking/udhcp/d6_packet.c | 4 | ||||
-rw-r--r-- | networking/udhcp/d6_socket.c | 2 | ||||
-rw-r--r-- | networking/udhcp/dhcpc.c | 50 | ||||
-rw-r--r-- | networking/udhcp/dhcpd.c | 24 | ||||
-rw-r--r-- | networking/udhcp/dhcprelay.c | 4 | ||||
-rw-r--r-- | networking/udhcp/packet.c | 4 | ||||
-rw-r--r-- | networking/udhcp/signalpipe.c | 2 | ||||
-rw-r--r-- | networking/udhcp/socket.c | 2 |
12 files changed, 85 insertions, 66 deletions
diff --git a/networking/udhcp/arpping.c b/networking/udhcp/arpping.c index 215d023..a395e83 100644 --- a/networking/udhcp/arpping.c +++ b/networking/udhcp/arpping.c @@ -53,12 +53,12 @@ int FAST_FUNC arpping(uint32_t test_nip, s = socket(PF_PACKET, SOCK_PACKET, htons(ETH_P_ARP)); if (s == -1) { - bb_perror_msg(bb_msg_can_not_create_raw_socket); + bb_simple_perror_msg(bb_msg_can_not_create_raw_socket); return -1; } if (setsockopt_broadcast(s) == -1) { - bb_perror_msg("can't enable bcast on raw socket"); + bb_simple_perror_msg("can't enable bcast on raw socket"); goto ret; } diff --git a/networking/udhcp/common.c b/networking/udhcp/common.c index 62ad248..4a452cd 100644 --- a/networking/udhcp/common.c +++ b/networking/udhcp/common.c @@ -240,7 +240,7 @@ uint8_t* FAST_FUNC udhcp_get_option(struct dhcp_packet *packet, int code) while (1) { if (rem <= 0) { complain: - bb_error_msg("bad packet, malformed option field"); + bb_simple_error_msg("bad packet, malformed option field"); return NULL; } diff --git a/networking/udhcp/common.h b/networking/udhcp/common.h index bba3d60..60255ee 100644 --- a/networking/udhcp/common.h +++ b/networking/udhcp/common.h @@ -267,26 +267,45 @@ struct option_set *udhcp_find_option(struct option_set *opt_list, uint8_t code) # define IF_UDHCP_VERBOSE(...) __VA_ARGS__ extern unsigned dhcp_verbose; # define log1(...) do { if (dhcp_verbose >= 1) bb_info_msg(__VA_ARGS__); } while (0) +# define log1s(msg) do { if (dhcp_verbose >= 1) bb_simple_info_msg(msg); } while (0) # if CONFIG_UDHCP_DEBUG >= 2 void udhcp_dump_packet(struct dhcp_packet *packet) FAST_FUNC; # define log2(...) do { if (dhcp_verbose >= 2) bb_info_msg(__VA_ARGS__); } while (0) +# define log2s(msg) do { if (dhcp_verbose >= 2) bb_simple_info_msg(msg); } while (0) # else # define udhcp_dump_packet(...) ((void)0) # define log2(...) ((void)0) +# define log2s(msg) ((void)0) # endif # if CONFIG_UDHCP_DEBUG >= 3 # define log3(...) do { if (dhcp_verbose >= 3) bb_info_msg(__VA_ARGS__); } while (0) +# define log3s(msg) do { if (dhcp_verbose >= 3) bb_simple_info_msg(msg); } while (0) # else # define log3(...) ((void)0) +# define log3s(msg) ((void)0) # endif #else # define IF_UDHCP_VERBOSE(...) # define udhcp_dump_packet(...) ((void)0) # define log1(...) ((void)0) +# define log1s(msg) ((void)0) # define log2(...) ((void)0) +# define log2s(msg) ((void)0) # define log3(...) ((void)0) +# define log3s(msg) ((void)0) #endif +#if defined(__mips__) +/* + * The 'simple' message functions have a negative impact on the size of the + * DHCP code when compiled for MIPS, so don't use them in this case. + */ +#define bb_simple_info_msg bb_info_msg +#define bb_simple_error_msg bb_error_msg +#define bb_simple_perror_msg_and_die bb_perror_msg_and_die +#undef log1s +#define log1s log1 +#endif /*** Other shared functions ***/ diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c index 4eb7ae1..9d8e17c 100644 --- a/networking/udhcp/d6_dhcpc.c +++ b/networking/udhcp/d6_dhcpc.c @@ -235,7 +235,7 @@ static char *string_option_to_env(const uint8_t *option, found: val_len = (option[2] << 8) | option[3]; if (val_len + &option[D6_OPT_DATA] > option_end) { - bb_error_msg("option data exceeds option length"); + bb_simple_error_msg("option data exceeds option length"); return NULL; } return xasprintf("%s=%.*s", name, val_len, (char*)option + 4); @@ -848,19 +848,19 @@ static NOINLINE int d6_recv_raw_packet(struct in6_addr *peer_ipv6, struct d6_pac bytes = safe_read(fd, &packet, sizeof(packet)); if (bytes < 0) { - log1("packet read error, ignoring"); + log1s("packet read error, ignoring"); /* NB: possible down interface, etc. Caller should pause. */ return bytes; /* returns -1 */ } if (bytes < (int) (sizeof(packet.ip6) + sizeof(packet.udp))) { - log1("packet is too short, ignoring"); + log1s("packet is too short, ignoring"); return -2; } if (bytes < sizeof(packet.ip6) + ntohs(packet.ip6.ip6_plen)) { /* packet is bigger than sizeof(packet), we did partial read */ - log1("oversized packet, ignoring"); + log1s("oversized packet, ignoring"); return -2; } @@ -874,7 +874,7 @@ static NOINLINE int d6_recv_raw_packet(struct in6_addr *peer_ipv6, struct d6_pac /* || bytes > (int) sizeof(packet) - can't happen */ || packet.udp.len != packet.ip6.ip6_plen ) { - log1("unrelated/bogus packet, ignoring"); + log1s("unrelated/bogus packet, ignoring"); return -2; } @@ -1003,7 +1003,7 @@ static int d6_raw_socket(int ifindex) } #endif - log1("created raw socket"); + log1s("created raw socket"); return fd; } @@ -1031,7 +1031,7 @@ static void change_listen_mode(int new_mode) /* Called only on SIGUSR1 */ static void perform_renew(void) { - bb_info_msg("performing DHCP renew"); + bb_simple_info_msg("performing DHCP renew"); switch (client_data.state) { case BOUND: change_listen_mode(LISTEN_KERNEL); @@ -1059,10 +1059,10 @@ static void perform_d6_release(struct in6_addr *server_ipv6, struct in6_addr *ou || client_data.state == REBINDING || client_data.state == RENEW_REQUESTED ) { - bb_info_msg("unicasting a release"); + bb_simple_info_msg("unicasting a release"); send_d6_release(server_ipv6, our_cur_ipv6); /* unicast */ } - bb_info_msg("entering released state"); + bb_simple_info_msg("entering released state"); /* * We can be here on: SIGUSR2, * or on exit (SIGTERM) and -R "release on quit" is specified. @@ -1275,7 +1275,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) /* Create pidfile */ write_pidfile(client_data.pidfile); /* Goes to stdout (unless NOMMU) and possibly syslog */ - bb_info_msg("started, v"BB_VER); + bb_simple_info_msg("started, v"BB_VER); client_data.state = INIT_SELECTING; d6_run_script_no_option("deconfig"); @@ -1321,7 +1321,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) continue; } /* Else: an error occured, panic! */ - bb_perror_msg_and_die("poll"); + bb_simple_perror_msg_and_die("poll"); } } @@ -1362,7 +1362,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) d6_run_script_no_option("leasefail"); #if BB_MMU /* -b is not supported on NOMMU */ if (opt & OPT_b) { /* background if no lease */ - bb_info_msg("no lease, forking to background"); + bb_simple_info_msg("no lease, forking to background"); client_background(); /* do not background again! */ opt = ((opt & ~(OPT_b|OPT_n)) | OPT_f); @@ -1375,7 +1375,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) } else #endif if (opt & OPT_n) { /* abort if no lease */ - bb_info_msg("no lease, failing"); + bb_simple_info_msg("no lease, failing"); retval = 1; goto ret; } @@ -1403,7 +1403,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) client_data.state = RENEWING; client_data.first_secs = 0; /* make secs field count from 0 */ change_listen_mode(LISTEN_KERNEL); - log1("entering renew state"); + log1s("entering renew state"); /* fall right through */ case RENEW_REQUESTED: /* manual (SIGUSR1) renew */ case_RENEW_REQUESTED: @@ -1423,7 +1423,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) continue; } /* Timed out, enter rebinding state */ - log1("entering rebinding state"); + log1s("entering rebinding state"); client_data.state = REBINDING; /* fall right through */ case REBINDING: @@ -1438,7 +1438,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) continue; } /* Timed out, enter init state */ - bb_info_msg("lease lost, entering init state"); + bb_simple_info_msg("lease lost, entering init state"); d6_run_script_no_option("deconfig"); client_data.state = INIT_SELECTING; client_data.first_secs = 0; /* make secs field count from 0 */ @@ -1560,7 +1560,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) } option = d6_copy_option(packet.d6_options, packet_end, D6_OPT_SERVERID); if (!option) { - bb_info_msg("no server ID, ignoring packet"); + bb_simple_info_msg("no server ID, ignoring packet"); continue; /* still selecting - this server looks bad */ } diff --git a/networking/udhcp/d6_packet.c b/networking/udhcp/d6_packet.c index 01d1c93..446497e 100644 --- a/networking/udhcp/d6_packet.c +++ b/networking/udhcp/d6_packet.c @@ -35,12 +35,12 @@ int FAST_FUNC d6_recv_kernel_packet(struct in6_addr *peer_ipv6 memset(packet, 0, sizeof(*packet)); bytes = safe_read(fd, packet, sizeof(*packet)); if (bytes < 0) { - log1("packet read error, ignoring"); + log1s("packet read error, ignoring"); return bytes; /* returns -1 */ } if (bytes < offsetof(struct d6_packet, d6_options)) { - bb_info_msg("packet with bad magic, ignoring"); + bb_simple_info_msg("packet with bad magic, ignoring"); return -2; } log1("received %s", "a packet"); diff --git a/networking/udhcp/d6_socket.c b/networking/udhcp/d6_socket.c index 25e622d..8ddee5a 100644 --- a/networking/udhcp/d6_socket.c +++ b/networking/udhcp/d6_socket.c @@ -115,7 +115,7 @@ int FAST_FUNC d6_listen_socket(int port, const char *inf) setsockopt_reuseaddr(fd); if (setsockopt_broadcast(fd) == -1) - bb_perror_msg_and_die("SO_BROADCAST"); + bb_simple_perror_msg_and_die("SO_BROADCAST"); /* NB: bug 1032 says this doesn't work on ethernet aliases (ethN:M) */ if (setsockopt_bindtodevice(fd, inf)) diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index d1a0eaf..656295f 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c @@ -906,7 +906,7 @@ static NOINLINE int udhcp_recv_raw_packet(struct dhcp_packet *dhcp_pkt, int fd) if (bytes < 0) { if (errno == EINTR) continue; - log1("packet read error, ignoring"); + log1s("packet read error, ignoring"); /* NB: possible down interface, etc. Caller should pause. */ return bytes; /* returns -1 */ } @@ -914,13 +914,13 @@ static NOINLINE int udhcp_recv_raw_packet(struct dhcp_packet *dhcp_pkt, int fd) } if (bytes < (int) (sizeof(packet.ip) + sizeof(packet.udp))) { - log1("packet is too short, ignoring"); + log1s("packet is too short, ignoring"); return -2; } if (bytes < ntohs(packet.ip.tot_len)) { /* packet is bigger than sizeof(packet), we did partial read */ - log1("oversized packet, ignoring"); + log1s("oversized packet, ignoring"); return -2; } @@ -935,7 +935,7 @@ static NOINLINE int udhcp_recv_raw_packet(struct dhcp_packet *dhcp_pkt, int fd) /* || bytes > (int) sizeof(packet) - can't happen */ || ntohs(packet.udp.len) != (uint16_t)(bytes - sizeof(packet.ip)) ) { - log1("unrelated/bogus packet, ignoring"); + log1s("unrelated/bogus packet, ignoring"); return -2; } @@ -943,7 +943,7 @@ static NOINLINE int udhcp_recv_raw_packet(struct dhcp_packet *dhcp_pkt, int fd) check = packet.ip.check; packet.ip.check = 0; if (check != inet_cksum((uint16_t *)&packet.ip, sizeof(packet.ip))) { - log1("bad IP header checksum, ignoring"); + log1s("bad IP header checksum, ignoring"); return -2; } @@ -968,13 +968,13 @@ static NOINLINE int udhcp_recv_raw_packet(struct dhcp_packet *dhcp_pkt, int fd) check = packet.udp.check; packet.udp.check = 0; if (check && check != inet_cksum((uint16_t *)&packet, bytes)) { - log1("packet with bad UDP checksum received, ignoring"); + log1s("packet with bad UDP checksum received, ignoring"); return -2; } skip_udp_sum_check: if (packet.data.cookie != htonl(DHCP_MAGIC)) { - bb_info_msg("packet with bad magic, ignoring"); + bb_simple_info_msg("packet with bad magic, ignoring"); return -2; } @@ -1089,10 +1089,10 @@ static int udhcp_raw_socket(int ifindex) if (setsockopt_1(fd, SOL_PACKET, PACKET_AUXDATA) != 0) { if (errno != ENOPROTOOPT) - log1("can't set PACKET_AUXDATA on raw socket"); + log1s("can't set PACKET_AUXDATA on raw socket"); } - log1("created raw socket"); + log1s("created raw socket"); return fd; } @@ -1120,7 +1120,7 @@ static void change_listen_mode(int new_mode) /* Called only on SIGUSR1 */ static void perform_renew(void) { - bb_info_msg("performing DHCP renew"); + bb_simple_info_msg("performing DHCP renew"); switch (client_data.state) { case BOUND: change_listen_mode(LISTEN_KERNEL); @@ -1158,7 +1158,7 @@ static void perform_release(uint32_t server_addr, uint32_t requested_ip) inet_ntoa(temp_addr), buffer); send_release(server_addr, requested_ip); /* unicast */ } - bb_info_msg("entering released state"); + bb_simple_info_msg("entering released state"); /* * We can be here on: SIGUSR2, * or on exit (SIGTERM) and -R "release on quit" is specified. @@ -1303,7 +1303,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) ); if (opt & (OPT_h|OPT_H)) { //msg added 2011-11 - bb_error_msg("option -h NAME is deprecated, use -x hostname:NAME"); + bb_simple_error_msg("option -h NAME is deprecated, use -x hostname:NAME"); client_data.hostname = alloc_dhcp_option(DHCP_HOST_NAME, str_h, 0); } if (opt & OPT_F) { @@ -1397,7 +1397,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) /* Create pidfile */ write_pidfile(client_data.pidfile); /* Goes to stdout (unless NOMMU) and possibly syslog */ - bb_info_msg("started, v"BB_VER); + bb_simple_info_msg("started, v"BB_VER); /* We want random_xid to be random... */ srand(monotonic_us()); @@ -1444,7 +1444,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) continue; } /* Else: an error occurred, panic! */ - bb_perror_msg_and_die("poll"); + bb_simple_perror_msg_and_die("poll"); } } @@ -1485,7 +1485,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) udhcp_run_script(NULL, "leasefail"); #if BB_MMU /* -b is not supported on NOMMU */ if (opt & OPT_b) { /* background if no lease */ - bb_info_msg("no lease, forking to background"); + bb_simple_info_msg("no lease, forking to background"); client_background(); /* do not background again! */ opt = ((opt & ~(OPT_b|OPT_n)) | OPT_f); @@ -1498,7 +1498,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) } else #endif if (opt & OPT_n) { /* abort if no lease */ - bb_info_msg("no lease, failing"); + bb_simple_info_msg("no lease, failing"); retval = 1; goto ret; } @@ -1526,7 +1526,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) client_data.state = RENEWING; client_data.first_secs = 0; /* make secs field count from 0 */ change_listen_mode(LISTEN_KERNEL); - log1("entering renew state"); + log1s("entering renew state"); /* fall right through */ case RENEW_REQUESTED: /* manual (SIGUSR1) renew */ case_RENEW_REQUESTED: @@ -1559,7 +1559,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) */ } /* Timed out or error, enter rebinding state */ - log1("entering rebinding state"); + log1s("entering rebinding state"); client_data.state = REBINDING; /* fall right through */ case REBINDING: @@ -1574,7 +1574,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) continue; } /* Timed out, enter init state */ - bb_info_msg("lease lost, entering init state"); + bb_simple_info_msg("lease lost, entering init state"); udhcp_run_script(NULL, "deconfig"); client_data.state = INIT_SELECTING; client_data.first_secs = 0; /* make secs field count from 0 */ @@ -1660,13 +1660,13 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) || memcmp(packet.chaddr, client_data.client_mac, 6) != 0 ) { //FIXME: need to also check that last 10 bytes are zero - log1("chaddr does not match, ignoring packet"); // log2? + log1("chaddr does not match%s", ", ignoring packet"); // log2? continue; } message = udhcp_get_option(&packet, DHCP_MESSAGE_TYPE); if (message == NULL) { - bb_info_msg("no message type option, ignoring packet"); + bb_info_msg("no message type option%s", ", ignoring packet"); continue; } @@ -1703,7 +1703,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) server_addr = 0; temp = udhcp_get_option32(&packet, DHCP_SERVER_ID); if (!temp) { - bb_info_msg("no server ID, using 0.0.0.0"); + bb_simple_info_msg("no server ID, using 0.0.0.0"); } else { /* it IS unaligned sometimes, don't "optimize" */ move_from_unaligned32(server_addr, temp); @@ -1730,7 +1730,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) temp = udhcp_get_option32(&packet, DHCP_LEASE_TIME); if (!temp) { - bb_info_msg("no lease time with ACK, using 1 hour lease"); + bb_simple_info_msg("no lease time with ACK, using 1 hour lease"); lease_seconds = 60 * 60; } else { /* it IS unaligned sometimes, don't "optimize" */ @@ -1763,7 +1763,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) client_data.interface, arpping_ms) ) { - bb_info_msg("offered address is in use " + bb_simple_info_msg("offered address is in use " "(got ARP reply), declining"); send_decline(/*xid,*/ server_addr, packet.yiaddr); @@ -1827,7 +1827,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) if (!temp) { non_matching_svid: log1("received DHCP NAK with wrong" - " server ID, ignoring packet"); + " server ID%s", ", ignoring packet"); continue; } move_from_unaligned32(svid, temp); diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c index 022b872..3e08ec0 100644 --- a/networking/udhcp/dhcpd.c +++ b/networking/udhcp/dhcpd.c @@ -582,11 +582,11 @@ static void send_packet_to_client(struct dhcp_packet *dhcp_pkt, int force_broadc || (dhcp_pkt->flags & htons(BROADCAST_FLAG)) || dhcp_pkt->ciaddr == 0 ) { - log1("broadcasting packet to client"); + log1s("broadcasting packet to client"); ciaddr = INADDR_BROADCAST; chaddr = MAC_BCAST_ADDR; } else { - log1("unicasting packet to client ciaddr"); + log1s("unicasting packet to client ciaddr"); ciaddr = dhcp_pkt->ciaddr; chaddr = dhcp_pkt->chaddr; } @@ -600,7 +600,7 @@ static void send_packet_to_client(struct dhcp_packet *dhcp_pkt, int force_broadc /* Send a packet to gateway_nip using the kernel ip stack */ static void send_packet_to_relay(struct dhcp_packet *dhcp_pkt) { - log1("forwarding packet to relay"); + log1s("forwarding packet to relay"); udhcp_send_kernel_packet(dhcp_pkt, server_data.server_nip, SERVER_PORT, @@ -754,7 +754,7 @@ static NOINLINE void send_offer(struct dhcp_packet *oldpacket, } if (!packet.yiaddr) { - bb_error_msg("no free IP addresses. OFFER abandoned"); + bb_simple_error_msg("no free IP addresses. OFFER abandoned"); return; } /* Reserve the IP for a short time hoping to get DHCPREQUEST soon */ @@ -765,7 +765,7 @@ static NOINLINE void send_offer(struct dhcp_packet *oldpacket, p_host_name ? (unsigned char)p_host_name[OPT_LEN - OPT_DATA] : 0 ); if (!lease) { - bb_error_msg("no free IP addresses. OFFER abandoned"); + bb_simple_error_msg("no free IP addresses. OFFER abandoned"); return; } } @@ -914,7 +914,7 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv) write_pidfile(server_data.pidfile); /* if (!..) bb_perror_msg("can't create pidfile %s", pidfile); */ - bb_info_msg("started, v"BB_VER); + bb_simple_info_msg("started, v"BB_VER); option = udhcp_find_option(server_data.options, DHCP_LEASE_TIME); server_data.max_lease_sec = DEFAULT_LEASE_TIME; @@ -985,7 +985,7 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv) if (errno == EINTR) goto new_tv; /* < 0 and not EINTR: should not happen */ - bb_perror_msg_and_die("poll"); + bb_simple_perror_msg_and_die("poll"); } if (pfds[0].revents) switch (udhcp_sp_read()) { @@ -1019,16 +1019,16 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv) continue; } if (packet.hlen != 6) { - bb_info_msg("MAC length != 6, ignoring packet"); + bb_info_msg("MAC length != 6%s", ", ignoring packet"); continue; } if (packet.op != BOOTREQUEST) { - bb_info_msg("not a REQUEST, ignoring packet"); + bb_info_msg("not a REQUEST%s", ", ignoring packet"); continue; } state = udhcp_get_option(&packet, DHCP_MESSAGE_TYPE); if (state == NULL || state[0] < DHCP_MINTYPE || state[0] > DHCP_MAXTYPE) { - bb_info_msg("no or bad message type option, ignoring packet"); + bb_info_msg("no or bad message type option%s", ", ignoring packet"); continue; } @@ -1039,7 +1039,7 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv) move_from_unaligned32(server_id_network_order, server_id_opt); if (server_id_network_order != server_data.server_nip) { /* client talks to somebody else */ - log1("server ID doesn't match, ignoring"); + log1("server ID doesn't match%s", ", ignoring"); continue; } } @@ -1162,7 +1162,7 @@ o DHCPREQUEST generated during REBINDING state: if (!requested_ip_opt) { requested_nip = packet.ciaddr; if (requested_nip == 0) { - log1("no requested IP and no ciaddr, ignoring"); + log1("no requested IP and no ciaddr%s", ", ignoring"); break; } } diff --git a/networking/udhcp/dhcprelay.c b/networking/udhcp/dhcprelay.c index 86dcb1a..ef9447b 100644 --- a/networking/udhcp/dhcprelay.c +++ b/networking/udhcp/dhcprelay.c @@ -186,7 +186,7 @@ static int sendto_ip4(int sock, const void *msg, int msg_len, struct sockaddr_in err = sendto(sock, msg, msg_len, 0, (struct sockaddr*) to, sizeof(*to)); err -= msg_len; if (err) - bb_perror_msg("sendto"); + bb_simple_perror_msg("sendto"); return err; } @@ -273,7 +273,7 @@ int dhcprelay_main(int argc UNUSED_PARAM, char **argv) bb_show_usage(); if (argv[3]) { if (!inet_aton(argv[3], &server_addr.sin_addr)) - bb_perror_msg_and_die("bad server IP"); + bb_simple_perror_msg_and_die("bad server IP"); } iface_list = make_iface_list(argv + 1, &num_sockets); diff --git a/networking/udhcp/packet.c b/networking/udhcp/packet.c index 64af802..6d43752 100644 --- a/networking/udhcp/packet.c +++ b/networking/udhcp/packet.c @@ -85,14 +85,14 @@ int FAST_FUNC udhcp_recv_kernel_packet(struct dhcp_packet *packet, int fd) memset(packet, 0, sizeof(*packet)); bytes = safe_read(fd, packet, sizeof(*packet)); if (bytes < 0) { - log1("packet read error, ignoring"); + log1s("packet read error, ignoring"); return bytes; /* returns -1 */ } if (bytes < offsetof(struct dhcp_packet, options) || packet->cookie != htonl(DHCP_MAGIC) ) { - bb_info_msg("packet with bad magic, ignoring"); + bb_simple_info_msg("packet with bad magic, ignoring"); return -2; } log1("received %s", "a packet"); diff --git a/networking/udhcp/signalpipe.c b/networking/udhcp/signalpipe.c index 81d1fc0..7df6712 100644 --- a/networking/udhcp/signalpipe.c +++ b/networking/udhcp/signalpipe.c @@ -28,7 +28,7 @@ static void signal_handler(int sig) int sv = errno; unsigned char ch = sig; /* use char, avoid dealing with partial writes */ if (write(WRITE_FD, &ch, 1) != 1) - bb_perror_msg("can't send signal"); + bb_simple_perror_msg("can't send signal"); errno = sv; } diff --git a/networking/udhcp/socket.c b/networking/udhcp/socket.c index 34049c3..65a1a8e 100644 --- a/networking/udhcp/socket.c +++ b/networking/udhcp/socket.c @@ -87,7 +87,7 @@ int FAST_FUNC udhcp_listen_socket(/*uint32_t ip,*/ int port, const char *inf) setsockopt_reuseaddr(fd); if (setsockopt_broadcast(fd) == -1) - bb_perror_msg_and_die("SO_BROADCAST"); + bb_simple_perror_msg_and_die("SO_BROADCAST"); /* SO_BINDTODEVICE doesn't work on ethernet aliases (ethN:M) */ colon = strrchr(inf, ':'); |