Ignore:
Timestamp:
Dec 20, 2016, 4:07:32 PM (7 years ago)
Author:
Bruno Cornec
Message:

New 3?3 banch for incorporation of latest busybox 1.25. Changing minor version to handle potential incompatibilities.

Location:
branches/3.3
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/3.3/mindi-busybox/networking/ifplugd.c

    r3232 r3621  
    3939#include <linux/ethtool.h>
    4040#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> */
    4252#endif
    4353#include <linux/netlink.h>
     
    4858#define __user
    4959#include <linux/wireless.h>
     60
     61#ifndef ETH_ALEN
     62# define ETH_ALEN  6
     63#endif
    5064
    5165/*
     
    290304};
    291305
    292 
    293 
    294306static const char *strstatus(int status)
    295307{
     
    452464{
    453465    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);
    455472
    456473    iface_len = strlen(G.iface);
     
    459476        ssize_t bytes;
    460477
    461         bytes = recv(netlink_fd, &replybuf, sizeof(replybuf), MSG_DONTWAIT);
     478        bytes = recv(netlink_fd, replybuf, BUF_SIZE, MSG_DONTWAIT);
    462479        if (bytes < 0) {
    463480            if (errno == EAGAIN)
    464                 return G.iface_exists;
     481                goto ret;
    465482            if (errno == EINTR)
    466483                continue;
    467 
    468484            bb_perror_msg("netlink: recv");
    469485            return -1;
     
    508524    }
    509525
     526 ret:
     527    free(replybuf);
    510528    return G.iface_exists;
    511529}
     
    557575    if (opts & FLAG_KILL) {
    558576        if (pid_from_pidfile > 0)
    559             kill(pid_from_pidfile, SIGQUIT);
     577            /* Upstream tool use SIGINT for -k */
     578            kill(pid_from_pidfile, SIGINT);
    560579        return EXIT_SUCCESS;
    561580    }
     
    646665    while (1) {
    647666        int iface_status_old;
    648         int iface_exists_old;
    649667
    650668        switch (bb_got_signal) {
     
    672690        }
    673691
    674         iface_status_old = iface_status;
    675         iface_exists_old = G.iface_exists;
    676 
    677692        if ((opts & FLAG_MONITOR)
    678693         && (netlink_pollfd[0].revents & POLLIN)
    679694        ) {
     695            int iface_exists_old;
     696
     697            iface_exists_old = G.iface_exists;
    680698            G.iface_exists = check_existence_through_netlink();
    681699            if (G.iface_exists < 0) /* error */
     
    690708
    691709        /* note: if !G.iface_exists, returns DOWN */
     710        iface_status_old = iface_status;
    692711        iface_status = detect_link();
    693712        if (iface_status == IFSTATUS_ERR) {
     
    703722            if (delay_time) {
    704723                /* link restored its old status before
    705                  * we run script. don't run the script: */
     724                 * we ran script. don't run the script: */
    706725                delay_time = 0;
    707726            } else {
     
    711730                if (iface_status == IFSTATUS_DOWN)
    712731                    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
    715738            }
    716739        }
    717740
    718741        if (delay_time && (int)(monotonic_sec() - delay_time) >= 0) {
    719             delay_time = 0;
    720742            if (run_script(iface_status_str) != 0)
    721743                goto exiting;
     744            delay_time = 0;
    722745        }
    723746    } /* while (1) */
Note: See TracChangeset for help on using the changeset viewer.