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/route.c

    r3232 r3621  
    5656#define RTF_IRTT        0x0100  /* Initial round trip time      */
    5757#define RTF_REJECT      0x0200  /* Reject route                 */
     58#define RTF_NONEXTHOP   0x00200000 /* route with no nexthop */
    5859#endif
    5960
     
    129130;
    130131
    131 static const int flags_ipvx[] = { /* MUST match tbl_ipvx[] values above. */
     132static const uint16_t flags_ipvx[] = { /* MUST match tbl_ipvx[] values above. */
    132133#ifdef RTF_REJECT
    133134    RTF_REJECT,
     
    284285            rt->rt_flags |= RTF_IRTT;
    285286            rt->rt_irtt = xatoul(args_m1);
    286             rt->rt_irtt *= (sysconf(_SC_CLK_TCK) / 100);    /* FIXME */
     287            rt->rt_irtt *= (bb_clk_tck() / 100);    /* FIXME */
    287288#if 0                   /* FIXME: do we need to check anything of this? */
    288289            if (rt->rt_irtt < 1 || rt->rt_irtt > (120 * HZ)) {
     
    450451#endif
    451452
    452 static const unsigned flagvals[] = { /* Must agree with flagchars[]. */
     453static const
     454IF_NOT_FEATURE_IPV6(uint16_t)
     455IF_FEATURE_IPV6(unsigned)
     456flagvals[] = { /* Must agree with flagchars[]. */
     457    RTF_UP,
    453458    RTF_GATEWAY,
    454459    RTF_HOST,
     
    459464    RTF_DEFAULT,
    460465    RTF_ADDRCONF,
    461     RTF_CACHE
     466    RTF_CACHE,
     467    RTF_REJECT,
     468    RTF_NONEXTHOP, /* this one doesn't fit into 16 bits */
    462469#endif
    463470};
    464 
    465 #define IPV4_MASK (RTF_GATEWAY|RTF_HOST|RTF_REINSTATE|RTF_DYNAMIC|RTF_MODIFIED)
    466 #define IPV6_MASK (RTF_GATEWAY|RTF_HOST|RTF_DEFAULT|RTF_ADDRCONF|RTF_CACHE)
    467 
    468471/* Must agree with flagvals[]. */
    469472static const char flagchars[] ALIGN1 =
    470     "GHRDM"
     473    "UGHRDM"
    471474#if ENABLE_FEATURE_IPV6
    472     "DAC"
     475    "DAC!n"
    473476#endif
    474477;
     478#define IPV4_MASK (RTF_UP|RTF_GATEWAY|RTF_HOST|RTF_REINSTATE|RTF_DYNAMIC|RTF_MODIFIED)
     479#define IPV6_MASK (RTF_UP|RTF_GATEWAY|RTF_HOST|RTF_DEFAULT|RTF_ADDRCONF|RTF_CACHE|RTF_REJECT|RTF_NONEXTHOP)
    475480
    476481static void set_flags(char *flagstr, int flags)
    477482{
    478483    int i;
    479 
    480     *flagstr++ = 'U';
    481484
    482485    for (i = 0; (*flagstr = flagchars[i]) != 0; i++) {
     
    492495    char devname[64], flags[16], *sdest, *sgw;
    493496    unsigned long d, g, m;
     497    int r;
    494498    int flgs, ref, use, metric, mtu, win, ir;
    495499    struct sockaddr_in s_addr;
     
    502506            netstatfmt ? "  MSS Window  irtt" : "Metric Ref    Use");
    503507
    504     if (fscanf(fp, "%*[^\n]\n") < 0) { /* Skip the first line. */
    505         goto ERROR;                /* Empty or missing line, or read error. */
     508    /* Skip the first line. */
     509    r = fscanf(fp, "%*[^\n]\n");
     510    if (r < 0) {
     511        /* Empty line, read error, or EOF. Yes, if routing table
     512         * is completely empty, /proc/net/route has no header.
     513         */
     514        goto ERROR;
    506515    }
    507516    while (1) {
    508         int r;
    509517        r = fscanf(fp, "%63s%lx%lx%X%d%d%d%lx%d%d%d\n",
    510518                devname, &d, &g, &flgs, &ref, &use, &metric, &m,
    511519                &mtu, &win, &ir);
    512520        if (r != 11) {
     521 ERROR:
    513522            if ((r < 0) && feof(fp)) { /* EOF with no (nonspace) chars read. */
    514523                break;
    515524            }
    516  ERROR:
    517             bb_error_msg_and_die("fscanf");
     525            bb_perror_msg_and_die(bb_msg_read_error);
    518526        }
    519527
     
    575583        r = fscanf(fp, "%32s%x%*s%x%32s%x%x%x%x%s\n",
    576584                addr6x+14, &prefix_len, &slen, addr6x+40+7,
    577                 &metric, &use, &refcnt, &iflags, iface);
     585                &metric, &refcnt, &use, &iflags, iface);
    578586        if (r != 9) {
    579587            if ((r < 0) && feof(fp)) { /* EOF with no (nonspace) chars read. */
     
    581589            }
    582590 ERROR:
    583             bb_error_msg_and_die("fscanf");
     591            bb_perror_msg_and_die(bb_msg_read_error);
    584592        }
    585593
     
    607615        }
    608616
    609         if (!(iflags & RTF_UP)) { /* Skip interfaces that are down. */
    610             continue;
    611         }
    612 
    613617        set_flags(flags, (iflags & IPV6_MASK));
    614618
Note: See TracChangeset for help on using the changeset viewer.