aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2021-02-20 18:09:54 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2021-02-20 18:13:42 +0100
commit64483324c5422ad8e3cf413929b1360ce6245e7e (patch)
tree3be20dd5fdaed3b0d72f3d0a92bdbda9e501ee64
parent6bdfbc4cb5470f63d4905e89f89a9829af354316 (diff)
downloadbusybox-w32-64483324c5422ad8e3cf413929b1360ce6245e7e.tar.gz
busybox-w32-64483324c5422ad8e3cf413929b1360ce6245e7e.tar.bz2
busybox-w32-64483324c5422ad8e3cf413929b1360ce6245e7e.zip
udhcpc: clarify bcast/unicast sends in logs, include server ID
Before: sending discover sending select for 192.168.1.173 lease of 192.168.1.173 obtained, lease time 43200 sending renew to 192.168.1.1 lease of 192.168.1.173 obtained, lease time 43200 After: broadcasting discover broadcasting select for 192.168.1.173, server 192.168.1.1 lease of 192.168.1.173 obtained from 192.168.1.1, lease time 43200 sending renew to server 192.168.1.1 lease of 192.168.1.173 obtained from 192.168.1.1, lease time 43200 function old new delta udhcpc_main 2580 2610 +30 send_select 104 130 +26 send_renew 82 99 +17 send_discover 94 89 -5 send_decline 93 88 -5 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/2 up/down: 73/-10) Total: 63 bytes text data bss dec hex filename 1019732 559 5020 1025311 fa51f busybox_old 1019898 559 5020 1025477 fa5c5 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--networking/udhcp/dhcpc.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index 922c71ebd..f1f6720f3 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -729,7 +729,7 @@ static NOINLINE int send_discover(uint32_t xid, uint32_t requested)
729 */ 729 */
730 add_client_options(&packet); 730 add_client_options(&packet);
731 731
732 bb_info_msg("sending %s", "discover"); 732 bb_simple_info_msg("broadcasting discover");
733 return raw_bcast_from_client_data_ifindex(&packet, INADDR_ANY); 733 return raw_bcast_from_client_data_ifindex(&packet, INADDR_ANY);
734} 734}
735 735
@@ -742,6 +742,7 @@ static NOINLINE int send_select(uint32_t xid, uint32_t server, uint32_t requeste
742{ 742{
743 struct dhcp_packet packet; 743 struct dhcp_packet packet;
744 struct in_addr temp_addr; 744 struct in_addr temp_addr;
745 char server_str[sizeof("255.255.255.255")];
745 746
746/* 747/*
747 * RFC 2131 4.3.2 DHCPREQUEST message 748 * RFC 2131 4.3.2 DHCPREQUEST message
@@ -772,8 +773,13 @@ static NOINLINE int send_select(uint32_t xid, uint32_t server, uint32_t requeste
772 */ 773 */
773 add_client_options(&packet); 774 add_client_options(&packet);
774 775
776 temp_addr.s_addr = server;
777 strcpy(server_str, inet_ntoa(temp_addr));
775 temp_addr.s_addr = requested; 778 temp_addr.s_addr = requested;
776 bb_info_msg("sending select for %s", inet_ntoa(temp_addr)); 779 bb_info_msg("broadcasting select for %s, server %s",
780 inet_ntoa(temp_addr),
781 server_str
782 );
777 return raw_bcast_from_client_data_ifindex(&packet, INADDR_ANY); 783 return raw_bcast_from_client_data_ifindex(&packet, INADDR_ANY);
778} 784}
779 785
@@ -782,7 +788,6 @@ static NOINLINE int send_select(uint32_t xid, uint32_t server, uint32_t requeste
782static NOINLINE int send_renew(uint32_t xid, uint32_t server, uint32_t ciaddr) 788static NOINLINE int send_renew(uint32_t xid, uint32_t server, uint32_t ciaddr)
783{ 789{
784 struct dhcp_packet packet; 790 struct dhcp_packet packet;
785 struct in_addr temp_addr;
786 791
787/* 792/*
788 * RFC 2131 4.3.2 DHCPREQUEST message 793 * RFC 2131 4.3.2 DHCPREQUEST message
@@ -813,8 +818,14 @@ static NOINLINE int send_renew(uint32_t xid, uint32_t server, uint32_t ciaddr)
813 */ 818 */
814 add_client_options(&packet); 819 add_client_options(&packet);
815 820
816 temp_addr.s_addr = server; 821 if (server) {
817 bb_info_msg("sending renew to %s", inet_ntoa(temp_addr)); 822 struct in_addr temp_addr;
823 temp_addr.s_addr = server;
824 bb_info_msg("sending renew to server %s", inet_ntoa(temp_addr));
825 } else {
826 bb_simple_info_msg("broadcasting renew");
827 }
828
818 return bcast_or_ucast(&packet, ciaddr, server); 829 return bcast_or_ucast(&packet, ciaddr, server);
819} 830}
820 831
@@ -843,7 +854,7 @@ static NOINLINE int send_decline(/*uint32_t xid,*/ uint32_t server, uint32_t req
843 854
844 udhcp_add_simple_option(&packet, DHCP_SERVER_ID, server); 855 udhcp_add_simple_option(&packet, DHCP_SERVER_ID, server);
845 856
846 bb_info_msg("sending %s", "decline"); 857 bb_simple_info_msg("broadcasting decline");
847 return raw_bcast_from_client_data_ifindex(&packet, INADDR_ANY); 858 return raw_bcast_from_client_data_ifindex(&packet, INADDR_ANY);
848} 859}
849#endif 860#endif
@@ -1720,6 +1731,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1720 unsigned start; 1731 unsigned start;
1721 uint32_t lease_seconds; 1732 uint32_t lease_seconds;
1722 struct in_addr temp_addr; 1733 struct in_addr temp_addr;
1734 char server_str[sizeof("255.255.255.255")];
1723 uint8_t *temp; 1735 uint8_t *temp;
1724 1736
1725 temp = udhcp_get_option32(&packet, DHCP_LEASE_TIME); 1737 temp = udhcp_get_option32(&packet, DHCP_LEASE_TIME);
@@ -1775,9 +1787,11 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1775 } 1787 }
1776#endif 1788#endif
1777 /* enter bound state */ 1789 /* enter bound state */
1790 temp_addr.s_addr = server_addr;
1791 strcpy(server_str, inet_ntoa(temp_addr));
1778 temp_addr.s_addr = packet.yiaddr; 1792 temp_addr.s_addr = packet.yiaddr;
1779 bb_info_msg("lease of %s obtained, lease time %u", 1793 bb_info_msg("lease of %s obtained from %s, lease time %u",
1780 inet_ntoa(temp_addr), (unsigned)lease_seconds); 1794 inet_ntoa(temp_addr), server_str, (unsigned)lease_seconds);
1781 requested_ip = packet.yiaddr; 1795 requested_ip = packet.yiaddr;
1782 1796
1783 start = monotonic_sec(); 1797 start = monotonic_sec();