diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2016-03-30 18:41:23 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2016-03-30 18:41:23 +0200 |
commit | 8f2e99c813dcac25faf58162ed18848a02888ff6 (patch) | |
tree | b8e0371701511e7600aad1874c0871148331a36f /networking/udhcp/d6_dhcpc.c | |
parent | 80f0f1d712fb3ab236e1fc8b37dfa7a9224d7849 (diff) | |
download | busybox-w32-8f2e99c813dcac25faf58162ed18848a02888ff6.tar.gz busybox-w32-8f2e99c813dcac25faf58162ed18848a02888ff6.tar.bz2 busybox-w32-8f2e99c813dcac25faf58162ed18848a02888ff6.zip |
udhcp: get rid of bb_info_msg()
function old new delta
udhcpd_main 1501 1531 +30
d6_recv_raw_packet 251 264 +13
perform_d6_release 188 198 +10
udhcpc6_main 2443 2449 +6
udhcp_recv_raw_packet 582 588 +6
udhcp_recv_kernel_packet 132 138 +6
send_d6_renew 140 146 +6
d6_recv_kernel_packet 118 124 +6
send_renew 77 82 +5
send_discover 85 90 +5
send_decline 84 89 +5
send_d6_select 97 102 +5
send_d6_discover 174 179 +5
perform_release 167 172 +5
count_lines 72 74 +2
udhcpc_main 2836 2837 +1
bb_info_msg 125 - -125
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 17/4 up/down: 117/-180) Total: -63 bytes
text data bss dec hex filename
924935 906 17160 943001 e6399 busybox_old
924736 906 17160 942802 e62d2 busybox_unstripped
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 | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c index 4e9b705b9..422254d62 100644 --- a/networking/udhcp/d6_dhcpc.c +++ b/networking/udhcp/d6_dhcpc.c | |||
@@ -251,7 +251,7 @@ static void d6_run_script(struct d6_packet *packet, const char *name) | |||
251 | envp = fill_envp(packet); | 251 | envp = fill_envp(packet); |
252 | 252 | ||
253 | /* call script */ | 253 | /* call script */ |
254 | log1("Executing %s %s", client_config.script, name); | 254 | log1("executing %s %s", client_config.script, name); |
255 | argv[0] = (char*) client_config.script; | 255 | argv[0] = (char*) client_config.script; |
256 | argv[1] = (char*) name; | 256 | argv[1] = (char*) name; |
257 | argv[2] = NULL; | 257 | argv[2] = NULL; |
@@ -428,7 +428,7 @@ static NOINLINE int send_d6_discover(uint32_t xid, struct in6_addr *requested_ip | |||
428 | */ | 428 | */ |
429 | opt_ptr = add_d6_client_options(opt_ptr); | 429 | opt_ptr = add_d6_client_options(opt_ptr); |
430 | 430 | ||
431 | bb_info_msg("Sending discover..."); | 431 | bb_error_msg("sending %s", "discover"); |
432 | return d6_mcast_from_client_config_ifindex(&packet, opt_ptr); | 432 | return d6_mcast_from_client_config_ifindex(&packet, opt_ptr); |
433 | } | 433 | } |
434 | 434 | ||
@@ -481,7 +481,7 @@ static NOINLINE int send_d6_select(uint32_t xid) | |||
481 | */ | 481 | */ |
482 | opt_ptr = add_d6_client_options(opt_ptr); | 482 | opt_ptr = add_d6_client_options(opt_ptr); |
483 | 483 | ||
484 | bb_info_msg("Sending select..."); | 484 | bb_error_msg("sending %s", "select"); |
485 | return d6_mcast_from_client_config_ifindex(&packet, opt_ptr); | 485 | return d6_mcast_from_client_config_ifindex(&packet, opt_ptr); |
486 | } | 486 | } |
487 | 487 | ||
@@ -550,7 +550,7 @@ static NOINLINE int send_d6_renew(uint32_t xid, struct in6_addr *server_ipv6, st | |||
550 | */ | 550 | */ |
551 | opt_ptr = add_d6_client_options(opt_ptr); | 551 | opt_ptr = add_d6_client_options(opt_ptr); |
552 | 552 | ||
553 | bb_info_msg("Sending renew..."); | 553 | bb_error_msg("sending %s", "renew"); |
554 | if (server_ipv6) | 554 | if (server_ipv6) |
555 | return d6_send_kernel_packet( | 555 | return d6_send_kernel_packet( |
556 | &packet, (opt_ptr - (uint8_t*) &packet), | 556 | &packet, (opt_ptr - (uint8_t*) &packet), |
@@ -573,7 +573,7 @@ static int send_d6_release(struct in6_addr *server_ipv6, struct in6_addr *our_cu | |||
573 | /* IA NA (contains our current IP) */ | 573 | /* IA NA (contains our current IP) */ |
574 | opt_ptr = d6_store_blob(opt_ptr, client6_data.ia_na, client6_data.ia_na->len + 2+2); | 574 | opt_ptr = d6_store_blob(opt_ptr, client6_data.ia_na, client6_data.ia_na->len + 2+2); |
575 | 575 | ||
576 | bb_info_msg("Sending release..."); | 576 | bb_error_msg("sending %s", "release"); |
577 | return d6_send_kernel_packet( | 577 | return d6_send_kernel_packet( |
578 | &packet, (opt_ptr - (uint8_t*) &packet), | 578 | &packet, (opt_ptr - (uint8_t*) &packet), |
579 | our_cur_ipv6, CLIENT_PORT6, | 579 | our_cur_ipv6, CLIENT_PORT6, |
@@ -592,19 +592,19 @@ static NOINLINE int d6_recv_raw_packet(struct in6_addr *peer_ipv6 | |||
592 | 592 | ||
593 | bytes = safe_read(fd, &packet, sizeof(packet)); | 593 | bytes = safe_read(fd, &packet, sizeof(packet)); |
594 | if (bytes < 0) { | 594 | if (bytes < 0) { |
595 | log1("Packet read error, ignoring"); | 595 | log1("packet read error, ignoring"); |
596 | /* NB: possible down interface, etc. Caller should pause. */ | 596 | /* NB: possible down interface, etc. Caller should pause. */ |
597 | return bytes; /* returns -1 */ | 597 | return bytes; /* returns -1 */ |
598 | } | 598 | } |
599 | 599 | ||
600 | if (bytes < (int) (sizeof(packet.ip6) + sizeof(packet.udp))) { | 600 | if (bytes < (int) (sizeof(packet.ip6) + sizeof(packet.udp))) { |
601 | log1("Packet is too short, ignoring"); | 601 | log1("packet is too short, ignoring"); |
602 | return -2; | 602 | return -2; |
603 | } | 603 | } |
604 | 604 | ||
605 | if (bytes < sizeof(packet.ip6) + ntohs(packet.ip6.ip6_plen)) { | 605 | if (bytes < sizeof(packet.ip6) + ntohs(packet.ip6.ip6_plen)) { |
606 | /* packet is bigger than sizeof(packet), we did partial read */ | 606 | /* packet is bigger than sizeof(packet), we did partial read */ |
607 | log1("Oversized packet, ignoring"); | 607 | log1("oversized packet, ignoring"); |
608 | return -2; | 608 | return -2; |
609 | } | 609 | } |
610 | 610 | ||
@@ -618,7 +618,7 @@ static NOINLINE int d6_recv_raw_packet(struct in6_addr *peer_ipv6 | |||
618 | /* || bytes > (int) sizeof(packet) - can't happen */ | 618 | /* || bytes > (int) sizeof(packet) - can't happen */ |
619 | || packet.udp.len != packet.ip6.ip6_plen | 619 | || packet.udp.len != packet.ip6.ip6_plen |
620 | ) { | 620 | ) { |
621 | log1("Unrelated/bogus packet, ignoring"); | 621 | log1("unrelated/bogus packet, ignoring"); |
622 | return -2; | 622 | return -2; |
623 | } | 623 | } |
624 | 624 | ||
@@ -630,11 +630,11 @@ static NOINLINE int d6_recv_raw_packet(struct in6_addr *peer_ipv6 | |||
630 | // check = packet.udp.check; | 630 | // check = packet.udp.check; |
631 | // packet.udp.check = 0; | 631 | // packet.udp.check = 0; |
632 | // if (check && check != inet_cksum((uint16_t *)&packet, bytes)) { | 632 | // if (check && check != inet_cksum((uint16_t *)&packet, bytes)) { |
633 | // log1("Packet with bad UDP checksum received, ignoring"); | 633 | // log1("packet with bad UDP checksum received, ignoring"); |
634 | // return -2; | 634 | // return -2; |
635 | // } | 635 | // } |
636 | 636 | ||
637 | log1("Received a packet"); | 637 | log1("received %s", "a packet"); |
638 | d6_dump_packet(&packet.data); | 638 | d6_dump_packet(&packet.data); |
639 | 639 | ||
640 | bytes -= sizeof(packet.ip6) + sizeof(packet.udp); | 640 | bytes -= sizeof(packet.ip6) + sizeof(packet.udp); |
@@ -722,10 +722,10 @@ static int d6_raw_socket(int ifindex) | |||
722 | }; | 722 | }; |
723 | #endif | 723 | #endif |
724 | 724 | ||
725 | log1("Opening raw socket on ifindex %d", ifindex); //log2? | 725 | log1("opening raw socket on ifindex %d", ifindex); //log2? |
726 | 726 | ||
727 | fd = xsocket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IPV6)); | 727 | fd = xsocket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IPV6)); |
728 | log1("Got raw socket fd %d", fd); //log2? | 728 | log1("got raw socket fd %d", fd); //log2? |
729 | 729 | ||
730 | sock.sll_family = AF_PACKET; | 730 | sock.sll_family = AF_PACKET; |
731 | sock.sll_protocol = htons(ETH_P_IPV6); | 731 | sock.sll_protocol = htons(ETH_P_IPV6); |
@@ -738,18 +738,18 @@ static int d6_raw_socket(int ifindex) | |||
738 | /* Ignoring error (kernel may lack support for this) */ | 738 | /* Ignoring error (kernel may lack support for this) */ |
739 | if (setsockopt(fd, SOL_SOCKET, SO_ATTACH_FILTER, &filter_prog, | 739 | if (setsockopt(fd, SOL_SOCKET, SO_ATTACH_FILTER, &filter_prog, |
740 | sizeof(filter_prog)) >= 0) | 740 | sizeof(filter_prog)) >= 0) |
741 | log1("Attached filter to raw socket fd %d", fd); // log? | 741 | log1("attached filter to raw socket fd %d", fd); // log? |
742 | } | 742 | } |
743 | #endif | 743 | #endif |
744 | 744 | ||
745 | log1("Created raw socket"); | 745 | log1("created raw socket"); |
746 | 746 | ||
747 | return fd; | 747 | return fd; |
748 | } | 748 | } |
749 | 749 | ||
750 | static void change_listen_mode(int new_mode) | 750 | static void change_listen_mode(int new_mode) |
751 | { | 751 | { |
752 | log1("Entering listen mode: %s", | 752 | log1("entering listen mode: %s", |
753 | new_mode != LISTEN_NONE | 753 | new_mode != LISTEN_NONE |
754 | ? (new_mode == LISTEN_KERNEL ? "kernel" : "raw") | 754 | ? (new_mode == LISTEN_KERNEL ? "kernel" : "raw") |
755 | : "none" | 755 | : "none" |
@@ -770,7 +770,7 @@ static void change_listen_mode(int new_mode) | |||
770 | /* Called only on SIGUSR1 */ | 770 | /* Called only on SIGUSR1 */ |
771 | static void perform_renew(void) | 771 | static void perform_renew(void) |
772 | { | 772 | { |
773 | bb_info_msg("Performing a DHCP renew"); | 773 | bb_error_msg("performing DHCP renew"); |
774 | switch (state) { | 774 | switch (state) { |
775 | case BOUND: | 775 | case BOUND: |
776 | change_listen_mode(LISTEN_KERNEL); | 776 | change_listen_mode(LISTEN_KERNEL); |
@@ -794,11 +794,11 @@ static void perform_d6_release(struct in6_addr *server_ipv6, struct in6_addr *ou | |||
794 | { | 794 | { |
795 | /* send release packet */ | 795 | /* send release packet */ |
796 | if (state == BOUND || state == RENEWING || state == REBINDING) { | 796 | if (state == BOUND || state == RENEWING || state == REBINDING) { |
797 | bb_info_msg("Unicasting a release"); | 797 | bb_error_msg("unicasting a release"); |
798 | send_d6_release(server_ipv6, our_cur_ipv6); /* unicast */ | 798 | send_d6_release(server_ipv6, our_cur_ipv6); /* unicast */ |
799 | d6_run_script(NULL, "deconfig"); | 799 | d6_run_script(NULL, "deconfig"); |
800 | } | 800 | } |
801 | bb_info_msg("Entering released state"); | 801 | bb_error_msg("entering released state"); |
802 | 802 | ||
803 | change_listen_mode(LISTEN_NONE); | 803 | change_listen_mode(LISTEN_NONE); |
804 | state = RELEASED; | 804 | state = RELEASED; |
@@ -1034,7 +1034,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1034 | /* Create pidfile */ | 1034 | /* Create pidfile */ |
1035 | write_pidfile(client_config.pidfile); | 1035 | write_pidfile(client_config.pidfile); |
1036 | /* Goes to stdout (unless NOMMU) and possibly syslog */ | 1036 | /* Goes to stdout (unless NOMMU) and possibly syslog */ |
1037 | bb_info_msg("%s (v"BB_VER") started", applet_name); | 1037 | bb_error_msg("started, v"BB_VER); |
1038 | /* Set up the signal pipe */ | 1038 | /* Set up the signal pipe */ |
1039 | udhcp_sp_setup(); | 1039 | udhcp_sp_setup(); |
1040 | /* We want random_xid to be random... */ | 1040 | /* We want random_xid to be random... */ |
@@ -1074,7 +1074,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1074 | retval = 0; | 1074 | retval = 0; |
1075 | /* If we already timed out, fall through with retval = 0, else... */ | 1075 | /* If we already timed out, fall through with retval = 0, else... */ |
1076 | if ((int)tv.tv_sec > 0) { | 1076 | if ((int)tv.tv_sec > 0) { |
1077 | log1("Waiting on select %u seconds", (int)tv.tv_sec); | 1077 | log1("waiting on select %u seconds", (int)tv.tv_sec); |
1078 | timestamp_before_wait = (unsigned)monotonic_sec(); | 1078 | timestamp_before_wait = (unsigned)monotonic_sec(); |
1079 | retval = select(max_fd + 1, &rfds, NULL, NULL, &tv); | 1079 | retval = select(max_fd + 1, &rfds, NULL, NULL, &tv); |
1080 | if (retval < 0) { | 1080 | if (retval < 0) { |
@@ -1124,14 +1124,14 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1124 | d6_run_script(NULL, "leasefail"); | 1124 | d6_run_script(NULL, "leasefail"); |
1125 | #if BB_MMU /* -b is not supported on NOMMU */ | 1125 | #if BB_MMU /* -b is not supported on NOMMU */ |
1126 | if (opt & OPT_b) { /* background if no lease */ | 1126 | if (opt & OPT_b) { /* background if no lease */ |
1127 | bb_info_msg("No lease, forking to background"); | 1127 | bb_error_msg("no lease, forking to background"); |
1128 | client_background(); | 1128 | client_background(); |
1129 | /* do not background again! */ | 1129 | /* do not background again! */ |
1130 | opt = ((opt & ~OPT_b) | OPT_f); | 1130 | opt = ((opt & ~OPT_b) | OPT_f); |
1131 | } else | 1131 | } else |
1132 | #endif | 1132 | #endif |
1133 | if (opt & OPT_n) { /* abort if no lease */ | 1133 | if (opt & OPT_n) { /* abort if no lease */ |
1134 | bb_info_msg("No lease, failing"); | 1134 | bb_error_msg("no lease, failing"); |
1135 | retval = 1; | 1135 | retval = 1; |
1136 | goto ret; | 1136 | goto ret; |
1137 | } | 1137 | } |
@@ -1159,7 +1159,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1159 | state = RENEWING; | 1159 | state = RENEWING; |
1160 | client_config.first_secs = 0; /* make secs field count from 0 */ | 1160 | client_config.first_secs = 0; /* make secs field count from 0 */ |
1161 | change_listen_mode(LISTEN_KERNEL); | 1161 | change_listen_mode(LISTEN_KERNEL); |
1162 | log1("Entering renew state"); | 1162 | log1("entering renew state"); |
1163 | /* fall right through */ | 1163 | /* fall right through */ |
1164 | case RENEW_REQUESTED: /* manual (SIGUSR1) renew */ | 1164 | case RENEW_REQUESTED: /* manual (SIGUSR1) renew */ |
1165 | case_RENEW_REQUESTED: | 1165 | case_RENEW_REQUESTED: |
@@ -1179,7 +1179,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1179 | continue; | 1179 | continue; |
1180 | } | 1180 | } |
1181 | /* Timed out, enter rebinding state */ | 1181 | /* Timed out, enter rebinding state */ |
1182 | log1("Entering rebinding state"); | 1182 | log1("entering rebinding state"); |
1183 | state = REBINDING; | 1183 | state = REBINDING; |
1184 | /* fall right through */ | 1184 | /* fall right through */ |
1185 | case REBINDING: | 1185 | case REBINDING: |
@@ -1194,7 +1194,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1194 | continue; | 1194 | continue; |
1195 | } | 1195 | } |
1196 | /* Timed out, enter init state */ | 1196 | /* Timed out, enter init state */ |
1197 | bb_info_msg("Lease lost, entering init state"); | 1197 | bb_error_msg("lease lost, entering init state"); |
1198 | d6_run_script(NULL, "deconfig"); | 1198 | d6_run_script(NULL, "deconfig"); |
1199 | state = INIT_SELECTING; | 1199 | state = INIT_SELECTING; |
1200 | client_config.first_secs = 0; /* make secs field count from 0 */ | 1200 | client_config.first_secs = 0; /* make secs field count from 0 */ |
@@ -1242,7 +1242,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1242 | timeout = INT_MAX; | 1242 | timeout = INT_MAX; |
1243 | continue; | 1243 | continue; |
1244 | case SIGTERM: | 1244 | case SIGTERM: |
1245 | bb_info_msg("Received SIGTERM"); | 1245 | bb_error_msg("received %s", "SIGTERM"); |
1246 | goto ret0; | 1246 | goto ret0; |
1247 | } | 1247 | } |
1248 | 1248 | ||
@@ -1260,7 +1260,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1260 | len = d6_recv_raw_packet(&srv6_buf, &packet, sockfd); | 1260 | len = d6_recv_raw_packet(&srv6_buf, &packet, sockfd); |
1261 | if (len == -1) { | 1261 | if (len == -1) { |
1262 | /* Error is severe, reopen socket */ | 1262 | /* Error is severe, reopen socket */ |
1263 | bb_info_msg("Read error: %s, reopening socket", strerror(errno)); | 1263 | bb_error_msg("read error: %s, reopening socket", strerror(errno)); |
1264 | sleep(discover_timeout); /* 3 seconds by default */ | 1264 | sleep(discover_timeout); /* 3 seconds by default */ |
1265 | change_listen_mode(listen_mode); /* just close and reopen */ | 1265 | change_listen_mode(listen_mode); /* just close and reopen */ |
1266 | } | 1266 | } |
@@ -1298,7 +1298,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1298 | option = d6_find_option(packet.d6_options, packet_end, D6_OPT_STATUS_CODE); | 1298 | option = d6_find_option(packet.d6_options, packet_end, D6_OPT_STATUS_CODE); |
1299 | if (option && option->data[4] != 0) { | 1299 | if (option && option->data[4] != 0) { |
1300 | /* return to init state */ | 1300 | /* return to init state */ |
1301 | bb_info_msg("Received DHCP NAK (%u)", option->data[4]); | 1301 | bb_error_msg("received DHCP NAK (%u)", option->data[4]); |
1302 | d6_run_script(&packet, "nak"); | 1302 | d6_run_script(&packet, "nak"); |
1303 | if (state != REQUESTING) | 1303 | if (state != REQUESTING) |
1304 | d6_run_script(NULL, "deconfig"); | 1304 | d6_run_script(NULL, "deconfig"); |
@@ -1453,7 +1453,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1453 | lease_seconds = 0x0fffffff; | 1453 | lease_seconds = 0x0fffffff; |
1454 | /* enter bound state */ | 1454 | /* enter bound state */ |
1455 | timeout = lease_seconds / 2; | 1455 | timeout = lease_seconds / 2; |
1456 | bb_info_msg("Lease obtained, lease time %u", | 1456 | bb_error_msg("lease obtained, lease time %u", |
1457 | /*inet_ntoa(temp_addr),*/ (unsigned)lease_seconds); | 1457 | /*inet_ntoa(temp_addr),*/ (unsigned)lease_seconds); |
1458 | d6_run_script(&packet, state == REQUESTING ? "bound" : "renew"); | 1458 | d6_run_script(&packet, state == REQUESTING ? "bound" : "renew"); |
1459 | 1459 | ||