Ignore:
Timestamp:
Nov 6, 2007, 11:01:53 AM (16 years ago)
Author:
Bruno Cornec
Message:
  • Better output for mindi-busybox revision
  • Remove dummy file created on NFS - report from Arnaud Tiger <arnaud.tiger_at_hp.com>
  • strace useful for debug
  • fix new versions for pb (2.0.0 for mindi and 1.7.2 for mindi-busybox)
  • fix build process for mindi-busybox + options used in that version (dd for label-partitions-as-necessary)
  • fix typo in label-partitions-as-necessary which doesn't seem to work
  • Update to busybox 1.7.2
  • perl is now required at restore time to support uuid swap partitions (and will be used for many other thigs

in the future for sure)

  • next mindi version will be 2.0.0 due to all the changes made in it (udev may break working distros)
  • small optimization in mindi on keyboard handling (one single find instead of multiple)
  • better interaction for USB device when launching mindi manually
  • attempt to automatically guess block disk size for ramdisk
  • fix typos in bkphw
  • Fix the remaining problem with UUID support for swap partitions
  • Updates mondoarchive man page for USB support
  • Adds preliminary Hardware support to mindi (Proliant SSSTK)
  • Tries to add udev support also for rhel4
  • Fix UUID support which was still broken.
  • Be conservative in test for the start-nfs script
  • Update config file for mindi-busybox for 1.7.2 migration
  • Try to run around a busybox bug (1.2.2 pb on inexistant links)
  • Add build content for mindi-busybox in pb
  • Remove distributions content for mindi-busybox
  • Fix a warning on inexistant raidtab
  • Solve problem on tmpfs in restore init (Problem of inexistant symlink and busybox)
  • Create MONDO_CACHE and use it everywhere + creation at start
  • Really never try to eject a USB device
  • Fix a issue with &> usage (replaced with 1> and 2>)
  • Adds magic file to depllist in order to have file working + ldd which helps for debugging issues
  • tty modes correct to avoid sh error messages
  • Use ext3 normally and not ext2 instead
  • USB device should be corrected after reading (take 1st part)
  • Adds a mount_USB_here function derived from mount_CDROM_here
  • usb detection place before /dev detection in device name at restore time
  • Fix when restoring from USB: media is asked in interactive mode
  • Adds USB support for mondorestore
  • mount_cdrom => mount_media
  • elilo.efi is now searched throughout /boot/efi and not in a fixed place as there is no standard
  • untar-and-softlink => untar (+ interface change)
  • suppress useless softlinks creation/removal in boot process
  • avoids udevd messages on groups
  • Increase # of disks to 99 as in mindi at restore time (should be a conf file parameter)
  • skip existing big file creation
  • seems to work correctly for USB mindi boot
  • Adds group and tty link to udev conf
  • Always load usb-torage (even 2.6) to initiate USB bus discovery
  • Better printing of messages
  • Attempt to fix a bug in supporting OpenSusE 10.3 kernel for initramfs (mindi may now use multiple regex for kernel initrd detection)
  • Links were not correctly done as non relative for modules in mindi
  • exclusion of modules denied now works
  • Also create modules in their ordinary place, so that classical modprobe works + copy modules.dep
  • Fix bugs for DENY_MODS handling
  • Add device /dev/console for udev
  • ide-generic should now really be excluded
  • Fix a bug in major number for tty
  • If udev then adds modprobe/insmod to rootfs
  • tty0 is also cretaed with udev
  • ide-generic put rather in DENY_MODS
  • udevd remove from deplist s handled in mindi directly
  • better default for mindi when using --usb
  • Handles dynamically linked busybox (in case we want to use it soon ;-)
  • Adds fixed devices to create for udev
  • ide-generic should not be part of the initrd when using libata v2
  • support a dynamically linked udev (case on Ubuntu 7.10 and Mandriva 2008.0 so should be quite generic) This will give incitation to move to dyn. linked binaries in the initrd which will help for other tasks (ia6 4)
  • Improvement in udev support (do not use cl options not available in busybox)
  • Udev in mindi
    • auto creation of the right links at boot time with udev-links.conf(from Mandriva 2008.0)
    • rework startup of udev as current makes kernel crash (from Mandriva 2008.0)
    • add support for 64 bits udev
  • Try to render MyInsmod silent at boot time
  • Adds udev support (mandatory for newest distributions to avoid remapping of devices in a different way as on the original system)
  • We also need vaft format support for USB boot
  • Adds libusual support (Ubuntu 7.10 needs it for USB)
  • Improve Ubuntu/Debian keyboard detection and support
  • pbinit adapted to new pb (0.8.10). Filtering of docs done in it
  • Suppress some mondo warnings and errors on USB again
  • Tries to fix lack of files in deb mindi package
  • Verify should now work for USB devices
  • More log/mesages improvement for USB support
  • - Supress g_erase_tmpdir_and_scratchdir
  • Improve some log messages for USB support
  • Try to improve install in mindi to avoid issues with isolinux.cfg not installed vene if in the pkg :-(
  • Improve mindi-busybox build
  • In conformity with pb 0.8.9
  • Add support for Ubuntu 7.10 in build process
  • Add USB Key button to Menu UI (CD streamer removed)
  • Attempt to fix error messages on tmp/scratch files at the end by removing those dir at the latest possible.
  • Fix a bug linked to the size of the -E param which could be used (Arnaud Tiger/René Ribaud).
  • Integrate ~/.pbrc content into mondorescue.pb (required project-builder >= 0.8.7)
  • Put mondorescue in conformity with new pb filtering rules
  • Add USB support at restore time (no test done yet). New start-usb script PB varibale added where useful
  • Unmounting USB device before removal of temporary scratchdir
  • Stil refining USB copy back to mondo (one command was not executed)
  • No need to have the image subdor in the csratchdir when USB.
  • umount the USB partition before attempting to use it
  • Remove useless copy from mindi to mondo at end of USB handling

(risky merge, we are raising the limits of 2 diverging branches. The status of stable is not completely sure as such. Will need lots of tests, but it's not yet done :-()
(merge -r1692:1769 $SVN_M/branches/2.2.5)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mindi-busybox/networking/libiproute/ipaddress.c

    r821 r1770  
     1/* vi: set sw=4 ts=4: */
    12/*
    23 * ipaddress.c      "ip address".
     
    1011 */
    1112
    12 #include "libbb.h"
    13 #include <sys/socket.h>
    14 #include <sys/ioctl.h>
    15 
     13//#include <sys/socket.h>
     14//#include <sys/ioctl.h>
    1615#include <fnmatch.h>
    17 #include <string.h>
    18 #include <unistd.h>
    19 
    2016#include <net/if.h>
    2117#include <net/if_arp.h>
    2218
     19#include "ip_common.h"  /* #include "libbb.h" is inside */
    2320#include "rt_names.h"
    2421#include "utils.h"
    25 #include "ip_common.h"
    26 
    27 
    28 static struct
    29 {
     22
     23
     24typedef struct filter_t {
    3025    int ifindex;
    3126    int family;
     
    4237    int flushe;
    4338    struct rtnl_handle *rth;
    44 } filter;
     39} filter_t;
     40
     41#define filter (*(filter_t*)&bb_common_bufsiz1)
     42
    4543
    4644static void print_link_flags(FILE *fp, unsigned flags, unsigned mdown)
     
    4947    flags &= ~IFF_RUNNING;
    5048#define _PF(f) if (flags&IFF_##f) { \
    51           flags &= ~IFF_##f ; \
     49          flags &= ~IFF_##f; \
    5250          fprintf(fp, #f "%s", flags ? "," : ""); }
    5351    _PF(LOOPBACK);
     
    8684
    8785    memset(&ifr, 0, sizeof(ifr));
    88     strcpy(ifr.ifr_name, name);
    89     if (ioctl(s, SIOCGIFTXQLEN, &ifr) < 0) {
    90         perror("SIOCGIFXQLEN");
     86    strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
     87    if (ioctl_or_warn(s, SIOCGIFTXQLEN, &ifr) < 0) {
    9188        close(s);
    9289        return;
     
    9996
    10097static int print_linkinfo(struct sockaddr_nl ATTRIBUTE_UNUSED *who,
    101         struct nlmsghdr *n, void ATTRIBUTE_UNUSED *arg)
     98        const struct nlmsghdr *n, void ATTRIBUTE_UNUSED *arg)
    10299{
    103100    FILE *fp = (FILE*)arg;
     
    125122        return -1;
    126123    }
    127     if (filter.label &&
    128         (!filter.family || filter.family == AF_PACKET) &&
    129         fnmatch(filter.label, RTA_DATA(tb[IFLA_IFNAME]), 0))
    130         return 0;
     124    if (filter.label
     125     && (!filter.family || filter.family == AF_PACKET)
     126     && fnmatch(filter.label, RTA_DATA(tb[IFLA_IFNAME]), 0)
     127    ) {
     128        return 0;
     129    }
    131130
    132131    if (n->nlmsg_type == RTM_DELLINK)
     
    166165    if (!filter.family || filter.family == AF_PACKET) {
    167166        SPRINT_BUF(b1);
    168         fprintf(fp, "%s", _SL_);
    169         fprintf(fp, "    link/%s ", ll_type_n2a(ifi->ifi_type, b1, sizeof(b1)));
     167        fprintf(fp, "%c    link/%s ", _SL_, ll_type_n2a(ifi->ifi_type, b1, sizeof(b1)));
    170168
    171169        if (tb[IFLA_ADDRESS]) {
     
    186184        }
    187185    }
    188     fprintf(fp, "\n");
     186    fputc('\n', fp);
    189187    fflush(fp);
    190188    return 0;
     
    194192{
    195193    if (rtnl_send(filter.rth, filter.flushb, filter.flushp) < 0) {
    196         perror("Failed to send flush request\n");
     194        bb_perror_msg("failed to send flush request");
    197195        return -1;
    198196    }
     
    341339        struct ifa_cacheinfo *ci = RTA_DATA(rta_tb[IFA_CACHEINFO]);
    342340        char buf[128];
    343         fprintf(fp, "%s", _SL_);
     341        fputc(_SL_, fp);
    344342        if (ci->ifa_valid == 0xFFFFFFFFU)
    345343            sprintf(buf, "valid_lft forever");
     
    352350        fprintf(fp, "       %s", buf);
    353351    }
    354     fprintf(fp, "\n");
     352    fputc('\n', fp);
    355353    fflush(fp);
    356354    return 0;
     
    366364static int print_selected_addrinfo(int ifindex, struct nlmsg_list *ainfo, FILE *fp)
    367365{
    368     for ( ;ainfo ; ainfo = ainfo->next) {
     366    for (; ainfo; ainfo = ainfo->next) {
    369367        struct nlmsghdr *n = &ainfo->h;
    370368        struct ifaddrmsg *ifa = NLMSG_DATA(n);
     
    412410}
    413411
     412/* Return value becomes exitcode. It's okay to not return at all */
    414413int ipaddr_list_or_flush(int argc, char **argv, int flush)
    415414{
    416     static const char *const option[] = { "to", "scope", "up", "label", "dev", 0 };
     415    static const char option[] ALIGN1 = "to\0""scope\0""up\0""label\0""dev\0";
    417416
    418417    struct nlmsg_list *linfo = NULL;
     
    431430    if (flush) {
    432431        if (argc <= 0) {
    433             bb_error_msg(bb_msg_requires_arg, "flush");
    434             return -1;
     432            bb_error_msg_and_die(bb_msg_requires_arg, "flush");
    435433        }
    436434        if (filter.family == AF_PACKET) {
    437             bb_error_msg("Cannot flush link addresses.");
    438             return -1;
     435            bb_error_msg_and_die("cannot flush link addresses");
    439436        }
    440437    }
    441438
    442439    while (argc > 0) {
    443         const int option_num = compare_string_array(option, *argv);
     440        const int option_num = index_in_strings(option, *argv);
    444441        switch (option_num) {
    445442            case 0: /* to */
     
    484481    }
    485482
    486     if (rtnl_open(&rth, 0) < 0)
    487         exit(1);
    488 
    489     if (rtnl_wilddump_request(&rth, preferred_family, RTM_GETLINK) < 0) {
    490         bb_perror_msg_and_die("Cannot send dump request");
    491     }
    492 
    493     if (rtnl_dump_filter(&rth, store_nlmsg, &linfo, NULL, NULL) < 0) {
    494         bb_error_msg_and_die("Dump terminated");
    495     }
     483    xrtnl_open(&rth);
     484
     485    xrtnl_wilddump_request(&rth, preferred_family, RTM_GETLINK);
     486    xrtnl_dump_filter(&rth, store_nlmsg, &linfo);
    496487
    497488    if (filter_dev) {
    498         filter.ifindex = ll_name_to_index(filter_dev);
    499         if (filter.ifindex <= 0) {
    500             bb_error_msg("Device \"%s\" does not exist", filter_dev);
    501             return -1;
    502         }
     489        filter.ifindex = xll_name_to_index(filter_dev);
    503490    }
    504491
     
    512499
    513500        for (;;) {
    514             if (rtnl_wilddump_request(&rth, filter.family, RTM_GETADDR) < 0) {
    515                 perror("Cannot send dump request");
    516                 exit(1);
    517             }
     501            xrtnl_wilddump_request(&rth, filter.family, RTM_GETADDR);
    518502            filter.flushed = 0;
    519             if (rtnl_dump_filter(&rth, print_addrinfo, stdout, NULL, NULL) < 0) {
    520                 fprintf(stderr, "Flush terminated\n");
    521                 exit(1);
    522             }
     503            xrtnl_dump_filter(&rth, print_addrinfo, stdout);
    523504            if (filter.flushed == 0) {
    524                 fflush(stdout);
    525505                return 0;
    526506            }
    527507            if (flush_update() < 0)
    528                 exit(1);
     508                return 1;
    529509        }
    530510    }
    531511
    532512    if (filter.family != AF_PACKET) {
    533         if (rtnl_wilddump_request(&rth, filter.family, RTM_GETADDR) < 0) {
    534             bb_perror_msg_and_die("Cannot send dump request");
    535         }
    536 
    537         if (rtnl_dump_filter(&rth, store_nlmsg, &ainfo, NULL, NULL) < 0) {
    538             bb_error_msg_and_die("Dump terminated");
    539         }
     513        xrtnl_wilddump_request(&rth, filter.family, RTM_GETADDR);
     514        xrtnl_dump_filter(&rth, store_nlmsg, &ainfo);
    540515    }
    541516
     
    601576    }
    602577
    603     for (l=linfo; l; l = l->next) {
     578    for (l = linfo; l; l = l->next) {
    604579        if (no_link || print_linkinfo(NULL, &l->h, stdout) == 0) {
    605580            struct ifinfomsg *ifi = NLMSG_DATA(&l->h);
     
    607582                print_selected_addrinfo(ifi->ifi_index, ainfo, stdout);
    608583        }
    609         fflush(stdout);
    610     }
    611 
    612     exit(0);
     584        fflush(stdout); /* why? */
     585    }
     586
     587    return 0;
    613588}
    614589
     
    616591{
    617592    if (lcl->family == AF_INET) {
    618         if (lcl->bytelen >= 1 && *(__u8*)&lcl->data == 127)
     593        if (lcl->bytelen >= 1 && *(uint8_t*)&lcl->data == 127)
    619594            return RT_SCOPE_HOST;
    620595    }
     
    622597}
    623598
     599/* Return value becomes exitcode. It's okay to not return at all */
    624600static int ipaddr_modify(int cmd, int argc, char **argv)
    625601{
    626     static const char *const option[] = {
    627         "peer", "remote", "broadcast", "brd",
    628         "anycast", "scope", "dev", "label", "local", 0
    629     };
    630 
     602    static const char option[] ALIGN1 =
     603        "peer\0""remote\0""broadcast\0""brd\0"
     604        "anycast\0""scope\0""dev\0""label\0""local\0";
    631605    struct rtnl_handle rth;
    632606    struct {
    633         struct nlmsghdr     n;
    634         struct ifaddrmsg    ifa;
    635         char            buf[256];
     607        struct nlmsghdr  n;
     608        struct ifaddrmsg ifa;
     609        char             buf[256];
    636610    } req;
    637     char  *d = NULL;
    638     char  *l = NULL;
     611    char *d = NULL;
     612    char *l = NULL;
    639613    inet_prefix lcl;
    640614    inet_prefix peer;
     
    643617    int brd_len = 0;
    644618    int any_len = 0;
    645     int scoped = 0;
     619    bool scoped = 0;
    646620
    647621    memset(&req, 0, sizeof(req));
     
    653627
    654628    while (argc > 0) {
    655         const int option_num = compare_string_array(option, *argv);
     629        const int option_num = index_in_strings(option, *argv);
    656630        switch (option_num) {
    657631            case 0: /* peer */
     
    678652                    duparg("broadcast", *argv);
    679653                }
    680                 if (strcmp(*argv, "+") == 0) {
     654                if (LONE_CHAR(*argv, '+')) {
    681655                    brd_len = -1;
    682656                }
    683                 else if (strcmp(*argv, "-") == 0) {
     657                else if (LONE_DASH(*argv)) {
    684658                    brd_len = -2;
    685659                } else {
     
    748722        return -1;
    749723    }
    750     if (l && matches(d, l) != 0) {
     724    if (l && strncmp(d, l, strlen(d)) != 0) {
    751725        bb_error_msg_and_die("\"dev\" (%s) must match \"label\" (%s)", d, l);
    752726    }
     
    763737        int i;
    764738        if (req.ifa.ifa_family != AF_INET) {
    765             bb_error_msg("Broadcast can be set only for IPv4 addresses");
    766             return -1;
     739            bb_error_msg_and_die("broadcast can be set only for IPv4 addresses");
    767740        }
    768741        brd = peer;
     
    781754        req.ifa.ifa_scope = default_scope(&lcl);
    782755
    783     if (rtnl_open(&rth, 0) < 0)
    784         exit(1);
     756    xrtnl_open(&rth);
    785757
    786758    ll_init_map(&rth);
    787759
    788     if ((req.ifa.ifa_index = ll_name_to_index(d)) == 0) {
    789         bb_error_msg("Cannot find device \"%s\"", d);
    790         return -1;
    791     }
     760    req.ifa.ifa_index = xll_name_to_index(d);
    792761
    793762    if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0)
    794         exit(2);
    795 
    796     exit(0);
    797 }
    798 
     763        return 2;
     764
     765    return 0;
     766}
     767
     768/* Return value becomes exitcode. It's okay to not return at all */
    799769int do_ipaddr(int argc, char **argv)
    800770{
    801     static const char *const commands[] = {
    802         "add", "delete", "list", "show", "lst", "flush", 0
    803     };
    804 
    805     int command_num = 2;
     771    static const char commands[] ALIGN1 =
     772        "add\0""delete\0""list\0""show\0""lst\0""flush\0";
     773
     774    int command_num = 2; /* default command is list */
    806775
    807776    if (*argv) {
    808         command_num = compare_string_array(commands, *argv);
    809     }
    810     switch (command_num) {
    811         case 0: /* add */
    812             return ipaddr_modify(RTM_NEWADDR, argc-1, argv+1);
    813         case 1: /* delete */
    814             return ipaddr_modify(RTM_DELADDR, argc-1, argv+1);
    815         case 2: /* list */
    816         case 3: /* show */
    817         case 4: /* lst */
    818             return ipaddr_list_or_flush(argc-1, argv+1, 0);
    819         case 5: /* flush */
    820             return ipaddr_list_or_flush(argc-1, argv+1, 1);
    821     }
    822     bb_error_msg_and_die("Unknown command %s", *argv);
    823 }
     777        command_num = index_in_substrings(commands, *argv);
     778    }
     779    if (command_num < 0 || command_num > 5)
     780        bb_error_msg_and_die("unknown command %s", *argv);
     781    --argc;
     782    ++argv;
     783    if (command_num == 0) /* add */
     784        return ipaddr_modify(RTM_NEWADDR, argc, argv);
     785    else if (command_num == 1) /* delete */
     786        return ipaddr_modify(RTM_DELADDR, argc, argv);
     787    else if (command_num == 5) /* flush */
     788        return ipaddr_list_or_flush(argc, argv, 1);
     789    else /* 2 == list, 3 == show, 4 == lst */
     790        return ipaddr_list_or_flush(argc, argv, 0);
     791}
Note: See TracChangeset for help on using the changeset viewer.