summaryrefslogtreecommitdiff
path: root/networking/udhcp
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 /networking/udhcp
parent0ae53451cf6fd61bcfa4bc78ef575fe6606373b4 (diff)
downloadbusybox-4bbc391c7f925d9c7d878c851887aa1545bd9bcd.tar.gz
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>
Diffstat (limited to 'networking/udhcp')
-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
if (peer_ipv6)
*peer_ipv6 = packet.ip6.ip6_src; /* struct copy */
- log1("received %s", "a packet");
+ log2("received %s", "a packet");
+ /* log2 because more informative msg for valid packets is printed later at log1 level */
d6_dump_packet(&packet.data);
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
bb_simple_info_msg("packet with bad magic, ignoring");
return -2;
}
- log1("received %s", "a packet");
+ log2("received %s", "a packet");
+ /* log2 because more informative msg for valid packets is printed later at log1 level */
d6_dump_packet(packet);
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)
skip_udp_sum_check:
if (packet.data.cookie != htonl(DHCP_MAGIC)) {
- bb_simple_info_msg("packet with bad magic, ignoring");
+ log1s("packet with bad magic, ignoring");
return -2;
}
- log1("received %s", "a packet");
+ log2("received %s", "a packet");
+ /* log2 because more informative msg for valid packets is printed later at log1 level */
udhcp_dump_packet(&packet.data);
bytes -= sizeof(packet.ip) + sizeof(packet.udp);
@@ -1649,13 +1650,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%s", ", ignoring packet"); // log2?
+ log1("chaddr does not match%s", ", ignoring packet");
continue;
}
message = udhcp_get_option(&packet, DHCP_MESSAGE_TYPE);
if (message == NULL) {
- bb_info_msg("no message type option%s", ", ignoring packet");
+ log1("no message type option%s", ", ignoring packet");
continue;
}
@@ -1663,6 +1664,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
case INIT_SELECTING:
/* Must be a DHCPOFFER */
if (*message == DHCPOFFER) {
+ struct in_addr temp_addr;
uint8_t *temp;
/* What exactly is server's IP? There are several values.
@@ -1698,7 +1700,8 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
move_from_unaligned32(server_addr, temp);
}
/*xid = packet.xid; - already is */
- requested_ip = packet.yiaddr;
+ temp_addr.s_addr = requested_ip = packet.yiaddr;
+ log1("received an offer of %s", inet_ntoa(temp_addr));
/* enter requesting state */
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)
bb_simple_info_msg("packet with bad magic, ignoring");
return -2;
}
- log1("received %s", "a packet");
+ log2("received %s", "a packet");
+ /* log2 because more informative msg for valid packets is printed later at log1 level */
udhcp_dump_packet(packet);
return bytes;