Changeset 3621 in MondoRescue for branches/3.3/mindi-busybox/networking/ifplugd.c
- Timestamp:
- Dec 20, 2016, 4:07:32 PM (7 years ago)
- Location:
- branches/3.3
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mindi-busybox/networking/ifplugd.c
r3232 r3621 39 39 #include <linux/ethtool.h> 40 40 #ifdef HAVE_NET_ETHERNET_H 41 # include <net/ethernet.h> 41 /* musl breakage: 42 * In file included from /usr/include/net/ethernet.h:10, 43 * from networking/ifplugd.c:41: 44 * /usr/include/netinet/if_ether.h:96: error: redefinition of 'struct ethhdr' 45 * 46 * Build succeeds without it on musl. Commented it out. 47 * If on your system you need it, consider removing <linux/ethtool.h> 48 * and copy-pasting its definitions here (<linux/ethtool.h> is what pulls in 49 * conflicting definition of struct ethhdr on musl). 50 */ 51 /* # include <net/ethernet.h> */ 42 52 #endif 43 53 #include <linux/netlink.h> … … 48 58 #define __user 49 59 #include <linux/wireless.h> 60 61 #ifndef ETH_ALEN 62 # define ETH_ALEN 6 63 #endif 50 64 51 65 /* … … 290 304 }; 291 305 292 293 294 306 static const char *strstatus(int status) 295 307 { … … 452 464 { 453 465 int iface_len; 454 char replybuf[1024]; 466 /* Buffer was 1K, but on linux-3.9.9 it was reported to be too small. 467 * netlink.h: "limit to 8K to avoid MSG_TRUNC when PAGE_SIZE is very large". 468 * Note: on error returns (-1) we exit, no need to free replybuf. 469 */ 470 enum { BUF_SIZE = 8 * 1024 }; 471 char *replybuf = xmalloc(BUF_SIZE); 455 472 456 473 iface_len = strlen(G.iface); … … 459 476 ssize_t bytes; 460 477 461 bytes = recv(netlink_fd, &replybuf, sizeof(replybuf), MSG_DONTWAIT);478 bytes = recv(netlink_fd, replybuf, BUF_SIZE, MSG_DONTWAIT); 462 479 if (bytes < 0) { 463 480 if (errno == EAGAIN) 464 return G.iface_exists;481 goto ret; 465 482 if (errno == EINTR) 466 483 continue; 467 468 484 bb_perror_msg("netlink: recv"); 469 485 return -1; … … 508 524 } 509 525 526 ret: 527 free(replybuf); 510 528 return G.iface_exists; 511 529 } … … 557 575 if (opts & FLAG_KILL) { 558 576 if (pid_from_pidfile > 0) 559 kill(pid_from_pidfile, SIGQUIT); 577 /* Upstream tool use SIGINT for -k */ 578 kill(pid_from_pidfile, SIGINT); 560 579 return EXIT_SUCCESS; 561 580 } … … 646 665 while (1) { 647 666 int iface_status_old; 648 int iface_exists_old;649 667 650 668 switch (bb_got_signal) { … … 672 690 } 673 691 674 iface_status_old = iface_status;675 iface_exists_old = G.iface_exists;676 677 692 if ((opts & FLAG_MONITOR) 678 693 && (netlink_pollfd[0].revents & POLLIN) 679 694 ) { 695 int iface_exists_old; 696 697 iface_exists_old = G.iface_exists; 680 698 G.iface_exists = check_existence_through_netlink(); 681 699 if (G.iface_exists < 0) /* error */ … … 690 708 691 709 /* note: if !G.iface_exists, returns DOWN */ 710 iface_status_old = iface_status; 692 711 iface_status = detect_link(); 693 712 if (iface_status == IFSTATUS_ERR) { … … 703 722 if (delay_time) { 704 723 /* link restored its old status before 705 * we r un script. don't run the script: */724 * we ran script. don't run the script: */ 706 725 delay_time = 0; 707 726 } else { … … 711 730 if (iface_status == IFSTATUS_DOWN) 712 731 delay_time += G.delay_down; 713 if (delay_time == 0) 714 delay_time++; 732 #if 0 /* if you are back in 1970... */ 733 if (delay_time == 0) { 734 sleep(1); 735 delay_time = 1; 736 } 737 #endif 715 738 } 716 739 } 717 740 718 741 if (delay_time && (int)(monotonic_sec() - delay_time) >= 0) { 719 delay_time = 0;720 742 if (run_script(iface_status_str) != 0) 721 743 goto exiting; 744 delay_time = 0; 722 745 } 723 746 } /* while (1) */
Note:
See TracChangeset
for help on using the changeset viewer.