aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2021-06-02 19:51:52 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2021-06-02 19:51:52 +0200
commit4bbc391c7f925d9c7d878c851887aa1545bd9bcd (patch)
tree5a4d538a5cc096067e518d88bf6915fabc464fc2
parent0ae53451cf6fd61bcfa4bc78ef575fe6606373b4 (diff)
downloadbusybox-w32-4bbc391c7f925d9c7d878c851887aa1545bd9bcd.tar.gz
busybox-w32-4bbc391c7f925d9c7d878c851887aa1545bd9bcd.tar.bz2
busybox-w32-4bbc391c7f925d9c7d878c851887aa1545bd9bcd.zip
udhcpc: improve logs - show offer as it is received
function old new delta udhcpc_main 2566 2608 +42 .rodata 103248 103272 +24 udhcp_recv_raw_packet 559 562 +3 d6_recv_raw_packet 254 255 +1 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/0 up/down: 70/0) Total: 70 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--networking/udhcp/d6_dhcpc.c3
-rw-r--r--networking/udhcp/d6_packet.c3
-rw-r--r--networking/udhcp/dhcpc.c13
-rw-r--r--networking/udhcp/packet.c3
4 files changed, 14 insertions, 8 deletions
diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c
index b2df9f091..ef555bc8a 100644
--- a/networking/udhcp/d6_dhcpc.c
+++ b/networking/udhcp/d6_dhcpc.c
@@ -954,7 +954,8 @@ static NOINLINE int d6_recv_raw_packet(struct in6_addr *peer_ipv6, struct d6_pac
954 if (peer_ipv6) 954 if (peer_ipv6)
955 *peer_ipv6 = packet.ip6.ip6_src; /* struct copy */ 955 *peer_ipv6 = packet.ip6.ip6_src; /* struct copy */
956 956
957 log1("received %s", "a packet"); 957 log2("received %s", "a packet");
958 /* log2 because more informative msg for valid packets is printed later at log1 level */
958 d6_dump_packet(&packet.data); 959 d6_dump_packet(&packet.data);
959 960
960 bytes -= sizeof(packet.ip6) + sizeof(packet.udp); 961 bytes -= sizeof(packet.ip6) + sizeof(packet.udp);
diff --git a/networking/udhcp/d6_packet.c b/networking/udhcp/d6_packet.c
index 172f8e1ab..c1949f6e3 100644
--- a/networking/udhcp/d6_packet.c
+++ b/networking/udhcp/d6_packet.c
@@ -44,7 +44,8 @@ int FAST_FUNC d6_recv_kernel_packet(struct in6_addr *peer_ipv6
44 bb_simple_info_msg("packet with bad magic, ignoring"); 44 bb_simple_info_msg("packet with bad magic, ignoring");
45 return -2; 45 return -2;
46 } 46 }
47 log1("received %s", "a packet"); 47 log2("received %s", "a packet");
48 /* log2 because more informative msg for valid packets is printed later at log1 level */
48 d6_dump_packet(packet); 49 d6_dump_packet(packet);
49 50
50 return bytes; 51 return bytes;
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index 5fb96c2d8..a30632d86 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -975,11 +975,12 @@ static NOINLINE int udhcp_recv_raw_packet(struct dhcp_packet *dhcp_pkt, int fd)
975 skip_udp_sum_check: 975 skip_udp_sum_check:
976 976
977 if (packet.data.cookie != htonl(DHCP_MAGIC)) { 977 if (packet.data.cookie != htonl(DHCP_MAGIC)) {
978 bb_simple_info_msg("packet with bad magic, ignoring"); 978 log1s("packet with bad magic, ignoring");
979 return -2; 979 return -2;
980 } 980 }
981 981
982 log1("received %s", "a packet"); 982 log2("received %s", "a packet");
983 /* log2 because more informative msg for valid packets is printed later at log1 level */
983 udhcp_dump_packet(&packet.data); 984 udhcp_dump_packet(&packet.data);
984 985
985 bytes -= sizeof(packet.ip) + sizeof(packet.udp); 986 bytes -= sizeof(packet.ip) + sizeof(packet.udp);
@@ -1649,13 +1650,13 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1649 || memcmp(packet.chaddr, client_data.client_mac, 6) != 0 1650 || memcmp(packet.chaddr, client_data.client_mac, 6) != 0
1650 ) { 1651 ) {
1651//FIXME: need to also check that last 10 bytes are zero 1652//FIXME: need to also check that last 10 bytes are zero
1652 log1("chaddr does not match%s", ", ignoring packet"); // log2? 1653 log1("chaddr does not match%s", ", ignoring packet");
1653 continue; 1654 continue;
1654 } 1655 }
1655 1656
1656 message = udhcp_get_option(&packet, DHCP_MESSAGE_TYPE); 1657 message = udhcp_get_option(&packet, DHCP_MESSAGE_TYPE);
1657 if (message == NULL) { 1658 if (message == NULL) {
1658 bb_info_msg("no message type option%s", ", ignoring packet"); 1659 log1("no message type option%s", ", ignoring packet");
1659 continue; 1660 continue;
1660 } 1661 }
1661 1662
@@ -1663,6 +1664,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1663 case INIT_SELECTING: 1664 case INIT_SELECTING:
1664 /* Must be a DHCPOFFER */ 1665 /* Must be a DHCPOFFER */
1665 if (*message == DHCPOFFER) { 1666 if (*message == DHCPOFFER) {
1667 struct in_addr temp_addr;
1666 uint8_t *temp; 1668 uint8_t *temp;
1667 1669
1668/* What exactly is server's IP? There are several values. 1670/* What exactly is server's IP? There are several values.
@@ -1698,7 +1700,8 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1698 move_from_unaligned32(server_addr, temp); 1700 move_from_unaligned32(server_addr, temp);
1699 } 1701 }
1700 /*xid = packet.xid; - already is */ 1702 /*xid = packet.xid; - already is */
1701 requested_ip = packet.yiaddr; 1703 temp_addr.s_addr = requested_ip = packet.yiaddr;
1704 log1("received an offer of %s", inet_ntoa(temp_addr));
1702 1705
1703 /* enter requesting state */ 1706 /* enter requesting state */
1704 client_data.state = REQUESTING; 1707 client_data.state = REQUESTING;
diff --git a/networking/udhcp/packet.c b/networking/udhcp/packet.c
index 4d8e005d4..78f580ce9 100644
--- a/networking/udhcp/packet.c
+++ b/networking/udhcp/packet.c
@@ -95,7 +95,8 @@ int FAST_FUNC udhcp_recv_kernel_packet(struct dhcp_packet *packet, int fd)
95 bb_simple_info_msg("packet with bad magic, ignoring"); 95 bb_simple_info_msg("packet with bad magic, ignoring");
96 return -2; 96 return -2;
97 } 97 }
98 log1("received %s", "a packet"); 98 log2("received %s", "a packet");
99 /* log2 because more informative msg for valid packets is printed later at log1 level */
99 udhcp_dump_packet(packet); 100 udhcp_dump_packet(packet);
100 101
101 return bytes; 102 return bytes;