aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/dhcpd.c
diff options
context:
space:
mode:
authorJames Byrne <james.byrne@origamienergy.com>2019-04-12 17:01:51 +0000
committerDenys Vlasenko <vda.linux@googlemail.com>2019-04-30 10:51:27 +0200
commit253c4e787a799a3e1f92957ed791b5222f8d2f64 (patch)
tree36204e05aaaf2cdcbd89eaadeff0193f99b063bf /networking/udhcp/dhcpd.c
parentf3a064f4956e113978e74486300dcd1e3e044efa (diff)
downloadbusybox-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/dhcpd.c')
-rw-r--r--networking/udhcp/dhcpd.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c
index 0c55fa5e4..d248d2b67 100644
--- a/networking/udhcp/dhcpd.c
+++ b/networking/udhcp/dhcpd.c
@@ -104,7 +104,7 @@ static void log_static_leases(struct static_lease **st_lease_pp)
104 104
105 cur = *st_lease_pp; 105 cur = *st_lease_pp;
106 while (cur) { 106 while (cur) {
107 bb_error_msg("static lease: mac:%02x:%02x:%02x:%02x:%02x:%02x nip:%x", 107 bb_info_msg("static lease: mac:%02x:%02x:%02x:%02x:%02x:%02x nip:%x",
108 cur->mac[0], cur->mac[1], cur->mac[2], 108 cur->mac[0], cur->mac[1], cur->mac[2],
109 cur->mac[3], cur->mac[4], cur->mac[5], 109 cur->mac[3], cur->mac[4], cur->mac[5],
110 cur->nip 110 cur->nip
@@ -242,7 +242,7 @@ static int nobody_responds_to_arp(uint32_t nip, const uint8_t *safe_mac, unsigne
242 return r; 242 return r;
243 243
244 temp.s_addr = nip; 244 temp.s_addr = nip;
245 bb_error_msg("%s belongs to someone, reserving it for %u seconds", 245 bb_info_msg("%s belongs to someone, reserving it for %u seconds",
246 inet_ntoa(temp), (unsigned)server_config.conflict_time); 246 inet_ntoa(temp), (unsigned)server_config.conflict_time);
247 add_lease(NULL, nip, server_config.conflict_time, NULL, 0); 247 add_lease(NULL, nip, server_config.conflict_time, NULL, 0);
248 return 0; 248 return 0;
@@ -722,7 +722,7 @@ static NOINLINE void send_offer(struct dhcp_packet *oldpacket,
722 add_server_options(&packet); 722 add_server_options(&packet);
723 723
724 addr.s_addr = packet.yiaddr; 724 addr.s_addr = packet.yiaddr;
725 bb_error_msg("sending OFFER of %s", inet_ntoa(addr)); 725 bb_info_msg("sending OFFER of %s", inet_ntoa(addr));
726 /* send_packet emits error message itself if it detects failure */ 726 /* send_packet emits error message itself if it detects failure */
727 send_packet(&packet, /*force_bcast:*/ 0); 727 send_packet(&packet, /*force_bcast:*/ 0);
728} 728}
@@ -755,7 +755,7 @@ static NOINLINE void send_ACK(struct dhcp_packet *oldpacket, uint32_t yiaddr)
755 add_server_options(&packet); 755 add_server_options(&packet);
756 756
757 addr.s_addr = yiaddr; 757 addr.s_addr = yiaddr;
758 bb_error_msg("sending ACK to %s", inet_ntoa(addr)); 758 bb_info_msg("sending ACK to %s", inet_ntoa(addr));
759 send_packet(&packet, /*force_bcast:*/ 0); 759 send_packet(&packet, /*force_bcast:*/ 0);
760 760
761 p_host_name = (const char*) udhcp_get_option(oldpacket, DHCP_HOST_NAME); 761 p_host_name = (const char*) udhcp_get_option(oldpacket, DHCP_HOST_NAME);
@@ -865,7 +865,7 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
865 write_pidfile(server_config.pidfile); 865 write_pidfile(server_config.pidfile);
866 /* if (!..) bb_perror_msg("can't create pidfile %s", pidfile); */ 866 /* if (!..) bb_perror_msg("can't create pidfile %s", pidfile); */
867 867
868 bb_error_msg("started, v"BB_VER); 868 bb_info_msg("started, v"BB_VER);
869 869
870 option = udhcp_find_option(server_config.options, DHCP_LEASE_TIME); 870 option = udhcp_find_option(server_config.options, DHCP_LEASE_TIME);
871 server_config.max_lease_sec = DEFAULT_LEASE_TIME; 871 server_config.max_lease_sec = DEFAULT_LEASE_TIME;
@@ -944,12 +944,12 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
944 944
945 if (pfds[0].revents) switch (udhcp_sp_read()) { 945 if (pfds[0].revents) switch (udhcp_sp_read()) {
946 case SIGUSR1: 946 case SIGUSR1:
947 bb_error_msg("received %s", "SIGUSR1"); 947 bb_info_msg("received %s", "SIGUSR1");
948 write_leases(); 948 write_leases();
949 /* why not just reset the timeout, eh */ 949 /* why not just reset the timeout, eh */
950 goto continue_with_autotime; 950 goto continue_with_autotime;
951 case SIGTERM: 951 case SIGTERM:
952 bb_error_msg("received %s", "SIGTERM"); 952 bb_info_msg("received %s", "SIGTERM");
953 write_leases(); 953 write_leases();
954 goto ret0; 954 goto ret0;
955 } 955 }
@@ -973,16 +973,16 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
973 continue; 973 continue;
974 } 974 }
975 if (packet.hlen != 6) { 975 if (packet.hlen != 6) {
976 bb_error_msg("MAC length != 6, ignoring packet"); 976 bb_info_msg("MAC length != 6, ignoring packet");
977 continue; 977 continue;
978 } 978 }
979 if (packet.op != BOOTREQUEST) { 979 if (packet.op != BOOTREQUEST) {
980 bb_error_msg("not a REQUEST, ignoring packet"); 980 bb_info_msg("not a REQUEST, ignoring packet");
981 continue; 981 continue;
982 } 982 }
983 state = udhcp_get_option(&packet, DHCP_MESSAGE_TYPE); 983 state = udhcp_get_option(&packet, DHCP_MESSAGE_TYPE);
984 if (state == NULL || state[0] < DHCP_MINTYPE || state[0] > DHCP_MAXTYPE) { 984 if (state == NULL || state[0] < DHCP_MINTYPE || state[0] > DHCP_MAXTYPE) {
985 bb_error_msg("no or bad message type option, ignoring packet"); 985 bb_info_msg("no or bad message type option, ignoring packet");
986 continue; 986 continue;
987 } 987 }
988 988
@@ -1001,7 +1001,7 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
1001 /* Look for a static/dynamic lease */ 1001 /* Look for a static/dynamic lease */
1002 static_lease_nip = get_static_nip_by_mac(server_config.static_leases, &packet.chaddr); 1002 static_lease_nip = get_static_nip_by_mac(server_config.static_leases, &packet.chaddr);
1003 if (static_lease_nip) { 1003 if (static_lease_nip) {
1004 bb_error_msg("found static lease: %x", static_lease_nip); 1004 bb_info_msg("found static lease: %x", static_lease_nip);
1005 memcpy(&fake_lease.lease_mac, &packet.chaddr, 6); 1005 memcpy(&fake_lease.lease_mac, &packet.chaddr, 6);
1006 fake_lease.lease_nip = static_lease_nip; 1006 fake_lease.lease_nip = static_lease_nip;
1007 fake_lease.expires = 0; 1007 fake_lease.expires = 0;