Ignore:
Timestamp:
Nov 6, 2007, 11:01:53 AM (13 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/udhcp/clientpacket.c

    r821 r1770  
     1/* vi: set sw=4 ts=4: */
    12/* clientpacket.c
    23 *
     
    89 */
    910
    10 #include <string.h>
    11 #include <sys/socket.h>
    1211#include <features.h>
    13 #if (__GLIBC__ >= 2 && __GLIBC_MINOR >= 1) || defined _NEWLIB_VERSION
     12#if (defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1) || defined _NEWLIB_VERSION
    1413#include <netpacket/packet.h>
    1514#include <net/ethernet.h>
     
    1918#include <linux/if_ether.h>
    2019#endif
    21 #include <stdlib.h>
    22 #include <time.h>
    23 #include <unistd.h>
    24 #include <netinet/in.h>
    25 #include <arpa/inet.h>
    26 #include <fcntl.h>
    27 
    28 
     20
     21#include "common.h"
    2922#include "dhcpd.h"
    30 #include "clientpacket.h"
     23#include "dhcpc.h"
    3124#include "options.h"
    32 #include "dhcpc.h"
    33 #include "common.h"
    3425
    3526
    3627/* Create a random xid */
    37 unsigned long random_xid(void)
    38 {
    39     static int initialized;
     28uint32_t random_xid(void)
     29{
     30    static smallint initialized;
     31
    4032    if (!initialized) {
    41         int fd;
    42         unsigned long seed;
    43 
    44         fd = open("/dev/urandom", 0);
    45         if (fd < 0 || read(fd, &seed, sizeof(seed)) < 0) {
    46             LOG(LOG_WARNING, "Could not load seed from /dev/urandom: %m");
    47             seed = time(0);
    48         }
    49         if (fd >= 0) close(fd);
    50         srand(seed);
    51         initialized++;
     33        srand(monotonic_us());
     34        initialized = 1;
    5235    }
    5336    return rand();
     
    6144    memcpy(packet->chaddr, client_config.arp, 6);
    6245    if (client_config.clientid)
    63         add_option_string(packet->options, client_config.clientid);
    64     if (client_config.hostname) add_option_string(packet->options, client_config.hostname);
    65     if (client_config.fqdn) add_option_string(packet->options, client_config.fqdn);
     46        add_option_string(packet->options, client_config.clientid);
     47    if (client_config.hostname)
     48        add_option_string(packet->options, client_config.hostname);
     49    if (client_config.fqdn)
     50        add_option_string(packet->options, client_config.fqdn);
    6651    add_option_string(packet->options, client_config.vendorclass);
    6752}
     
    8772
    8873/* Broadcast a DHCP discover packet to the network, with an optionally requested IP */
    89 int send_discover(unsigned long xid, unsigned long requested)
     74int send_discover(uint32_t xid, uint32_t requested)
    9075{
    9176    struct dhcpMessage packet;
     
    9782
    9883    add_requests(&packet);
    99     LOG(LOG_DEBUG, "Sending discover...");
     84    bb_info_msg("Sending discover...");
     85    return udhcp_raw_packet(&packet, INADDR_ANY, CLIENT_PORT, INADDR_BROADCAST,
     86            SERVER_PORT, MAC_BCAST_ADDR, client_config.ifindex);
     87}
     88
     89
     90/* Broadcasts a DHCP request message */
     91int send_selecting(uint32_t xid, uint32_t server, uint32_t requested)
     92{
     93    struct dhcpMessage packet;
     94    struct in_addr addr;
     95
     96    init_packet(&packet, DHCPREQUEST);
     97    packet.xid = xid;
     98
     99    add_simple_option(packet.options, DHCP_REQUESTED_IP, requested);
     100    add_simple_option(packet.options, DHCP_SERVER_ID, server);
     101
     102    add_requests(&packet);
     103    addr.s_addr = requested;
     104    bb_info_msg("Sending select for %s...", inet_ntoa(addr));
    100105    return udhcp_raw_packet(&packet, INADDR_ANY, CLIENT_PORT, INADDR_BROADCAST,
    101106                SERVER_PORT, MAC_BCAST_ADDR, client_config.ifindex);
     
    103108
    104109
    105 /* Broadcasts a DHCP request message */
    106 int send_selecting(unsigned long xid, unsigned long server, unsigned long requested)
    107 {
    108     struct dhcpMessage packet;
    109     struct in_addr addr;
    110 
    111     init_packet(&packet, DHCPREQUEST);
    112     packet.xid = xid;
    113 
    114     add_simple_option(packet.options, DHCP_REQUESTED_IP, requested);
    115     add_simple_option(packet.options, DHCP_SERVER_ID, server);
    116 
    117     add_requests(&packet);
    118     addr.s_addr = requested;
    119     LOG(LOG_DEBUG, "Sending select for %s...", inet_ntoa(addr));
    120     return udhcp_raw_packet(&packet, INADDR_ANY, CLIENT_PORT, INADDR_BROADCAST,
    121                 SERVER_PORT, MAC_BCAST_ADDR, client_config.ifindex);
    122 }
    123 
    124 
    125110/* Unicasts or broadcasts a DHCP renew message */
    126 int send_renew(unsigned long xid, unsigned long server, unsigned long ciaddr)
    127 {
    128     struct dhcpMessage packet;
    129     int ret = 0;
     111int send_renew(uint32_t xid, uint32_t server, uint32_t ciaddr)
     112{
     113    struct dhcpMessage packet;
    130114
    131115    init_packet(&packet, DHCPREQUEST);
     
    134118
    135119    add_requests(&packet);
    136     LOG(LOG_DEBUG, "Sending renew...");
     120    bb_info_msg("Sending renew...");
    137121    if (server)
    138         ret = udhcp_kernel_packet(&packet, ciaddr, CLIENT_PORT, server, SERVER_PORT);
    139     else ret = udhcp_raw_packet(&packet, INADDR_ANY, CLIENT_PORT, INADDR_BROADCAST,
     122        return udhcp_kernel_packet(&packet, ciaddr, CLIENT_PORT, server, SERVER_PORT);
     123
     124    return udhcp_raw_packet(&packet, INADDR_ANY, CLIENT_PORT, INADDR_BROADCAST,
    140125                SERVER_PORT, MAC_BCAST_ADDR, client_config.ifindex);
    141     return ret;
    142126}
    143127
    144128
    145129/* Unicasts a DHCP release message */
    146 int send_release(unsigned long server, unsigned long ciaddr)
     130int send_release(uint32_t server, uint32_t ciaddr)
    147131{
    148132    struct dhcpMessage packet;
     
    155139    add_simple_option(packet.options, DHCP_SERVER_ID, server);
    156140
    157     LOG(LOG_DEBUG, "Sending release...");
     141    bb_info_msg("Sending release...");
    158142    return udhcp_kernel_packet(&packet, ciaddr, CLIENT_PORT, server, SERVER_PORT);
    159143}
     
    171155    bytes = read(fd, &packet, sizeof(struct udp_dhcp_packet));
    172156    if (bytes < 0) {
    173         DEBUG(LOG_INFO, "couldn't read on raw listening socket -- ignoring");
     157        DEBUG("Cannot read on raw listening socket - ignoring");
    174158        usleep(500000); /* possible down interface, looping condition */
    175159        return -1;
     
    177161
    178162    if (bytes < (int) (sizeof(struct iphdr) + sizeof(struct udphdr))) {
    179         DEBUG(LOG_INFO, "message too short, ignoring");
     163        DEBUG("Message too short, ignoring");
    180164        return -2;
    181165    }
    182166
    183167    if (bytes < ntohs(packet.ip.tot_len)) {
    184         DEBUG(LOG_INFO, "Truncated packet");
     168        DEBUG("Truncated packet");
    185169        return -2;
    186170    }
     
    190174
    191175    /* Make sure its the right packet for us, and that it passes sanity checks */
    192     if (packet.ip.protocol != IPPROTO_UDP || packet.ip.version != IPVERSION ||
    193         packet.ip.ihl != sizeof(packet.ip) >> 2 || packet.udp.dest != htons(CLIENT_PORT) ||
    194         bytes > (int) sizeof(struct udp_dhcp_packet) ||
    195         ntohs(packet.udp.len) != (uint16_t) (bytes - sizeof(packet.ip))) {
    196         DEBUG(LOG_INFO, "unrelated/bogus packet");
     176    if (packet.ip.protocol != IPPROTO_UDP || packet.ip.version != IPVERSION
     177     || packet.ip.ihl != sizeof(packet.ip) >> 2
     178     || packet.udp.dest != htons(CLIENT_PORT)
     179     || bytes > (int) sizeof(struct udp_dhcp_packet)
     180     || ntohs(packet.udp.len) != (uint16_t)(bytes - sizeof(packet.ip))
     181    ) {
     182        DEBUG("Unrelated/bogus packet");
    197183        return -2;
    198184    }
     
    202188    packet.ip.check = 0;
    203189    if (check != udhcp_checksum(&(packet.ip), sizeof(packet.ip))) {
    204         DEBUG(LOG_INFO, "bad IP header checksum, ignoring");
     190        DEBUG("bad IP header checksum, ignoring");
    205191        return -1;
    206192    }
     
    218204    packet.ip.tot_len = packet.udp.len; /* cheat on the psuedo-header */
    219205    if (check && check != udhcp_checksum(&packet, bytes)) {
    220         DEBUG(LOG_ERR, "packet with bad UDP checksum received, ignoring");
     206        bb_error_msg("packet with bad UDP checksum received, ignoring");
    221207        return -2;
    222208    }
     
    225211
    226212    if (ntohl(payload->cookie) != DHCP_MAGIC) {
    227         LOG(LOG_ERR, "received bogus message (bad magic) -- ignoring");
    228         return -2;
    229     }
    230     DEBUG(LOG_INFO, "oooooh!!! got some!");
     213        bb_error_msg("received bogus message (bad magic) - ignoring");
     214        return -2;
     215    }
     216    DEBUG("oooooh!!! got some!");
    231217    return bytes - (sizeof(packet.ip) + sizeof(packet.udp));
    232 
    233 }
     218}
Note: See TracChangeset for help on using the changeset viewer.