diff options
author | James Byrne <james.byrne@origamienergy.com> | 2019-04-12 17:01:51 +0000 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2019-04-30 10:51:27 +0200 |
commit | 253c4e787a799a3e1f92957ed791b5222f8d2f64 (patch) | |
tree | 36204e05aaaf2cdcbd89eaadeff0193f99b063bf /networking/udhcp/d6_dhcpc.c | |
parent | f3a064f4956e113978e74486300dcd1e3e044efa (diff) | |
download | busybox-w32-253c4e787a799a3e1f92957ed791b5222f8d2f64.tar.gz busybox-w32-253c4e787a799a3e1f92957ed791b5222f8d2f64.tar.bz2 busybox-w32-253c4e787a799a3e1f92957ed791b5222f8d2f64.zip |
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>
Diffstat (limited to 'networking/udhcp/d6_dhcpc.c')
-rw-r--r-- | networking/udhcp/d6_dhcpc.c | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c index 3562988fd..1a0a5739e 100644 --- a/networking/udhcp/d6_dhcpc.c +++ b/networking/udhcp/d6_dhcpc.c | |||
@@ -670,7 +670,7 @@ static NOINLINE int send_d6_discover(uint32_t xid, struct in6_addr *requested_ip | |||
670 | */ | 670 | */ |
671 | opt_ptr = add_d6_client_options(opt_ptr); | 671 | opt_ptr = add_d6_client_options(opt_ptr); |
672 | 672 | ||
673 | bb_error_msg("sending %s", "discover"); | 673 | bb_info_msg("sending %s", "discover"); |
674 | return d6_mcast_from_client_config_ifindex(&packet, opt_ptr); | 674 | return d6_mcast_from_client_config_ifindex(&packet, opt_ptr); |
675 | } | 675 | } |
676 | 676 | ||
@@ -727,7 +727,7 @@ static NOINLINE int send_d6_select(uint32_t xid) | |||
727 | */ | 727 | */ |
728 | opt_ptr = add_d6_client_options(opt_ptr); | 728 | opt_ptr = add_d6_client_options(opt_ptr); |
729 | 729 | ||
730 | bb_error_msg("sending %s", "select"); | 730 | bb_info_msg("sending %s", "select"); |
731 | return d6_mcast_from_client_config_ifindex(&packet, opt_ptr); | 731 | return d6_mcast_from_client_config_ifindex(&packet, opt_ptr); |
732 | } | 732 | } |
733 | 733 | ||
@@ -800,7 +800,7 @@ static NOINLINE int send_d6_renew(uint32_t xid, struct in6_addr *server_ipv6, st | |||
800 | */ | 800 | */ |
801 | opt_ptr = add_d6_client_options(opt_ptr); | 801 | opt_ptr = add_d6_client_options(opt_ptr); |
802 | 802 | ||
803 | bb_error_msg("sending %s", "renew"); | 803 | bb_info_msg("sending %s", "renew"); |
804 | if (server_ipv6) | 804 | if (server_ipv6) |
805 | return d6_send_kernel_packet( | 805 | return d6_send_kernel_packet( |
806 | &packet, (opt_ptr - (uint8_t*) &packet), | 806 | &packet, (opt_ptr - (uint8_t*) &packet), |
@@ -830,7 +830,7 @@ int send_d6_release(struct in6_addr *server_ipv6, struct in6_addr *our_cur_ipv6) | |||
830 | if (client6_data.ia_pd) | 830 | if (client6_data.ia_pd) |
831 | opt_ptr = mempcpy(opt_ptr, client6_data.ia_pd, client6_data.ia_pd->len + 2+2); | 831 | opt_ptr = mempcpy(opt_ptr, client6_data.ia_pd, client6_data.ia_pd->len + 2+2); |
832 | 832 | ||
833 | bb_error_msg("sending %s", "release"); | 833 | bb_info_msg("sending %s", "release"); |
834 | return d6_send_kernel_packet( | 834 | return d6_send_kernel_packet( |
835 | &packet, (opt_ptr - (uint8_t*) &packet), | 835 | &packet, (opt_ptr - (uint8_t*) &packet), |
836 | our_cur_ipv6, CLIENT_PORT6, | 836 | our_cur_ipv6, CLIENT_PORT6, |
@@ -1033,7 +1033,7 @@ static void change_listen_mode(int new_mode) | |||
1033 | /* Called only on SIGUSR1 */ | 1033 | /* Called only on SIGUSR1 */ |
1034 | static void perform_renew(void) | 1034 | static void perform_renew(void) |
1035 | { | 1035 | { |
1036 | bb_error_msg("performing DHCP renew"); | 1036 | bb_info_msg("performing DHCP renew"); |
1037 | switch (state) { | 1037 | switch (state) { |
1038 | case BOUND: | 1038 | case BOUND: |
1039 | change_listen_mode(LISTEN_KERNEL); | 1039 | change_listen_mode(LISTEN_KERNEL); |
@@ -1061,10 +1061,10 @@ static void perform_d6_release(struct in6_addr *server_ipv6, struct in6_addr *ou | |||
1061 | || state == REBINDING | 1061 | || state == REBINDING |
1062 | || state == RENEW_REQUESTED | 1062 | || state == RENEW_REQUESTED |
1063 | ) { | 1063 | ) { |
1064 | bb_error_msg("unicasting a release"); | 1064 | bb_info_msg("unicasting a release"); |
1065 | send_d6_release(server_ipv6, our_cur_ipv6); /* unicast */ | 1065 | send_d6_release(server_ipv6, our_cur_ipv6); /* unicast */ |
1066 | } | 1066 | } |
1067 | bb_error_msg("entering released state"); | 1067 | bb_info_msg("entering released state"); |
1068 | /* | 1068 | /* |
1069 | * We can be here on: SIGUSR2, | 1069 | * We can be here on: SIGUSR2, |
1070 | * or on exit (SIGTERM) and -R "release on quit" is specified. | 1070 | * or on exit (SIGTERM) and -R "release on quit" is specified. |
@@ -1274,7 +1274,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1274 | /* Create pidfile */ | 1274 | /* Create pidfile */ |
1275 | write_pidfile(client_config.pidfile); | 1275 | write_pidfile(client_config.pidfile); |
1276 | /* Goes to stdout (unless NOMMU) and possibly syslog */ | 1276 | /* Goes to stdout (unless NOMMU) and possibly syslog */ |
1277 | bb_error_msg("started, v"BB_VER); | 1277 | bb_info_msg("started, v"BB_VER); |
1278 | /* Set up the signal pipe */ | 1278 | /* Set up the signal pipe */ |
1279 | udhcp_sp_setup(); | 1279 | udhcp_sp_setup(); |
1280 | 1280 | ||
@@ -1363,7 +1363,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1363 | d6_run_script_no_option("leasefail"); | 1363 | d6_run_script_no_option("leasefail"); |
1364 | #if BB_MMU /* -b is not supported on NOMMU */ | 1364 | #if BB_MMU /* -b is not supported on NOMMU */ |
1365 | if (opt & OPT_b) { /* background if no lease */ | 1365 | if (opt & OPT_b) { /* background if no lease */ |
1366 | bb_error_msg("no lease, forking to background"); | 1366 | bb_info_msg("no lease, forking to background"); |
1367 | client_background(); | 1367 | client_background(); |
1368 | /* do not background again! */ | 1368 | /* do not background again! */ |
1369 | opt = ((opt & ~(OPT_b|OPT_n)) | OPT_f); | 1369 | opt = ((opt & ~(OPT_b|OPT_n)) | OPT_f); |
@@ -1376,7 +1376,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1376 | } else | 1376 | } else |
1377 | #endif | 1377 | #endif |
1378 | if (opt & OPT_n) { /* abort if no lease */ | 1378 | if (opt & OPT_n) { /* abort if no lease */ |
1379 | bb_error_msg("no lease, failing"); | 1379 | bb_info_msg("no lease, failing"); |
1380 | retval = 1; | 1380 | retval = 1; |
1381 | goto ret; | 1381 | goto ret; |
1382 | } | 1382 | } |
@@ -1439,7 +1439,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1439 | continue; | 1439 | continue; |
1440 | } | 1440 | } |
1441 | /* Timed out, enter init state */ | 1441 | /* Timed out, enter init state */ |
1442 | bb_error_msg("lease lost, entering init state"); | 1442 | bb_info_msg("lease lost, entering init state"); |
1443 | d6_run_script_no_option("deconfig"); | 1443 | d6_run_script_no_option("deconfig"); |
1444 | state = INIT_SELECTING; | 1444 | state = INIT_SELECTING; |
1445 | client_config.first_secs = 0; /* make secs field count from 0 */ | 1445 | client_config.first_secs = 0; /* make secs field count from 0 */ |
@@ -1484,7 +1484,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1484 | timeout = INT_MAX; | 1484 | timeout = INT_MAX; |
1485 | continue; | 1485 | continue; |
1486 | case SIGTERM: | 1486 | case SIGTERM: |
1487 | bb_error_msg("received %s", "SIGTERM"); | 1487 | bb_info_msg("received %s", "SIGTERM"); |
1488 | goto ret0; | 1488 | goto ret0; |
1489 | } | 1489 | } |
1490 | 1490 | ||
@@ -1544,7 +1544,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1544 | option = d6_find_option(packet.d6_options, packet_end, D6_OPT_STATUS_CODE); | 1544 | option = d6_find_option(packet.d6_options, packet_end, D6_OPT_STATUS_CODE); |
1545 | if (option && (option->data[0] | option->data[1]) != 0) { | 1545 | if (option && (option->data[0] | option->data[1]) != 0) { |
1546 | /* return to init state */ | 1546 | /* return to init state */ |
1547 | bb_error_msg("received DHCP NAK (%u)", option->data[4]); | 1547 | bb_info_msg("received DHCP NAK (%u)", option->data[4]); |
1548 | d6_run_script(packet.d6_options, | 1548 | d6_run_script(packet.d6_options, |
1549 | packet_end, "nak"); | 1549 | packet_end, "nak"); |
1550 | if (state != REQUESTING) | 1550 | if (state != REQUESTING) |
@@ -1561,7 +1561,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1561 | } | 1561 | } |
1562 | option = d6_copy_option(packet.d6_options, packet_end, D6_OPT_SERVERID); | 1562 | option = d6_copy_option(packet.d6_options, packet_end, D6_OPT_SERVERID); |
1563 | if (!option) { | 1563 | if (!option) { |
1564 | bb_error_msg("no server ID, ignoring packet"); | 1564 | bb_info_msg("no server ID, ignoring packet"); |
1565 | continue; | 1565 | continue; |
1566 | /* still selecting - this server looks bad */ | 1566 | /* still selecting - this server looks bad */ |
1567 | } | 1567 | } |
@@ -1670,11 +1670,11 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1670 | free(client6_data.ia_na); | 1670 | free(client6_data.ia_na); |
1671 | client6_data.ia_na = d6_copy_option(packet.d6_options, packet_end, D6_OPT_IA_NA); | 1671 | client6_data.ia_na = d6_copy_option(packet.d6_options, packet_end, D6_OPT_IA_NA); |
1672 | if (!client6_data.ia_na) { | 1672 | if (!client6_data.ia_na) { |
1673 | bb_error_msg("no %s option, ignoring packet", "IA_NA"); | 1673 | bb_info_msg("no %s option, ignoring packet", "IA_NA"); |
1674 | continue; | 1674 | continue; |
1675 | } | 1675 | } |
1676 | if (client6_data.ia_na->len < (4 + 4 + 4) + (2 + 2 + 16 + 4 + 4)) { | 1676 | if (client6_data.ia_na->len < (4 + 4 + 4) + (2 + 2 + 16 + 4 + 4)) { |
1677 | bb_error_msg("%s option is too short:%d bytes", | 1677 | bb_info_msg("%s option is too short:%d bytes", |
1678 | "IA_NA", client6_data.ia_na->len); | 1678 | "IA_NA", client6_data.ia_na->len); |
1679 | continue; | 1679 | continue; |
1680 | } | 1680 | } |
@@ -1683,11 +1683,11 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1683 | D6_OPT_IAADDR | 1683 | D6_OPT_IAADDR |
1684 | ); | 1684 | ); |
1685 | if (!iaaddr) { | 1685 | if (!iaaddr) { |
1686 | bb_error_msg("no %s option, ignoring packet", "IAADDR"); | 1686 | bb_info_msg("no %s option, ignoring packet", "IAADDR"); |
1687 | continue; | 1687 | continue; |
1688 | } | 1688 | } |
1689 | if (iaaddr->len < (16 + 4 + 4)) { | 1689 | if (iaaddr->len < (16 + 4 + 4)) { |
1690 | bb_error_msg("%s option is too short:%d bytes", | 1690 | bb_info_msg("%s option is too short:%d bytes", |
1691 | "IAADDR", iaaddr->len); | 1691 | "IAADDR", iaaddr->len); |
1692 | continue; | 1692 | continue; |
1693 | } | 1693 | } |
@@ -1698,7 +1698,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1698 | move_from_unaligned32(lease_seconds, iaaddr->data + 16 + 4); | 1698 | move_from_unaligned32(lease_seconds, iaaddr->data + 16 + 4); |
1699 | lease_seconds = ntohl(lease_seconds); | 1699 | lease_seconds = ntohl(lease_seconds); |
1700 | /// TODO: check for 0 lease time? | 1700 | /// TODO: check for 0 lease time? |
1701 | bb_error_msg("%s obtained, lease time %u", | 1701 | bb_info_msg("%s obtained, lease time %u", |
1702 | "IPv6", /*inet_ntoa(temp_addr),*/ (unsigned)lease_seconds); | 1702 | "IPv6", /*inet_ntoa(temp_addr),*/ (unsigned)lease_seconds); |
1703 | address_timeout = lease_seconds; | 1703 | address_timeout = lease_seconds; |
1704 | } | 1704 | } |
@@ -1708,11 +1708,11 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1708 | free(client6_data.ia_pd); | 1708 | free(client6_data.ia_pd); |
1709 | client6_data.ia_pd = d6_copy_option(packet.d6_options, packet_end, D6_OPT_IA_PD); | 1709 | client6_data.ia_pd = d6_copy_option(packet.d6_options, packet_end, D6_OPT_IA_PD); |
1710 | if (!client6_data.ia_pd) { | 1710 | if (!client6_data.ia_pd) { |
1711 | bb_error_msg("no %s option, ignoring packet", "IA_PD"); | 1711 | bb_info_msg("no %s option, ignoring packet", "IA_PD"); |
1712 | continue; | 1712 | continue; |
1713 | } | 1713 | } |
1714 | if (client6_data.ia_pd->len < (4 + 4 + 4) + (2 + 2 + 4 + 4 + 1 + 16)) { | 1714 | if (client6_data.ia_pd->len < (4 + 4 + 4) + (2 + 2 + 4 + 4 + 1 + 16)) { |
1715 | bb_error_msg("%s option is too short:%d bytes", | 1715 | bb_info_msg("%s option is too short:%d bytes", |
1716 | "IA_PD", client6_data.ia_pd->len); | 1716 | "IA_PD", client6_data.ia_pd->len); |
1717 | continue; | 1717 | continue; |
1718 | } | 1718 | } |
@@ -1721,17 +1721,17 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1721 | D6_OPT_IAPREFIX | 1721 | D6_OPT_IAPREFIX |
1722 | ); | 1722 | ); |
1723 | if (!iaprefix) { | 1723 | if (!iaprefix) { |
1724 | bb_error_msg("no %s option, ignoring packet", "IAPREFIX"); | 1724 | bb_info_msg("no %s option, ignoring packet", "IAPREFIX"); |
1725 | continue; | 1725 | continue; |
1726 | } | 1726 | } |
1727 | if (iaprefix->len < (4 + 4 + 1 + 16)) { | 1727 | if (iaprefix->len < (4 + 4 + 1 + 16)) { |
1728 | bb_error_msg("%s option is too short:%d bytes", | 1728 | bb_info_msg("%s option is too short:%d bytes", |
1729 | "IAPREFIX", iaprefix->len); | 1729 | "IAPREFIX", iaprefix->len); |
1730 | continue; | 1730 | continue; |
1731 | } | 1731 | } |
1732 | move_from_unaligned32(lease_seconds, iaprefix->data + 4); | 1732 | move_from_unaligned32(lease_seconds, iaprefix->data + 4); |
1733 | lease_seconds = ntohl(lease_seconds); | 1733 | lease_seconds = ntohl(lease_seconds); |
1734 | bb_error_msg("%s obtained, lease time %u", | 1734 | bb_info_msg("%s obtained, lease time %u", |
1735 | "prefix", /*inet_ntoa(temp_addr),*/ (unsigned)lease_seconds); | 1735 | "prefix", /*inet_ntoa(temp_addr),*/ (unsigned)lease_seconds); |
1736 | prefix_timeout = lease_seconds; | 1736 | prefix_timeout = lease_seconds; |
1737 | } | 1737 | } |
@@ -1781,4 +1781,3 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1781 | /*if (client_config.pidfile) - remove_pidfile has its own check */ | 1781 | /*if (client_config.pidfile) - remove_pidfile has its own check */ |
1782 | remove_pidfile(client_config.pidfile); | 1782 | remove_pidfile(client_config.pidfile); |
1783 | return retval; | 1783 | return retval; |
1784 | } | ||