Changeset 3bb5735 in mainline


Ignore:
Timestamp:
2010-11-23T20:50:09Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
442ebbe
Parents:
da9f13f3
git-author:
Radim Vansa <radim.vansa@…> (2010-11-23 20:50:09)
git-committer:
Jakub Jermar <jakub@…> (2010-11-23 20:50:09)
Message:

Cherry pick fixes from changeset lp:~helenos-nicf/helenos/nicf,705.

Original description:
Solved first ping timeout

Cleaned up a little and replaced EBUSY with EAGAIN.

Location:
uspace/srv/net/il
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/il/arp/arp.c

    rda9f13f3 r3bb5735  
    516516 * @param[in] protocol  The protocol service.
    517517 * @param[in] target    The target protocol address.
    518  * @return              The hardware address of the target.
    519  * @return              NULL if the target parameter is NULL.
    520  * @return              NULL if the device is not found.
    521  * @return              NULL if the device packet is too small to send a
    522  *                      request.
    523  * @return              NULL if the hardware address is not found in the cache.
    524  */
    525 static measured_string_t *
     518 * @param[out] translation Where the hardware address of the target is stored.
     519 * @return              EOK on success.
     520 * @return              EAGAIN if the caller should try again.
     521 * @return              Other error codes in case of error.
     522 */
     523static int
    526524arp_translate_message(device_id_t device_id, services_t protocol,
    527     measured_string_t *target)
     525    measured_string_t *target, measured_string_t **translation)
    528526{
    529527        arp_device_t *device;
     
    533531        packet_t *packet;
    534532        arp_header_t *header;
    535 
    536         if (!target)
    537                 return NULL;
     533        int rc;
     534
     535        if (!target || !translation)
     536                return EBADMEM;
    538537
    539538        device = arp_cache_find(&arp_globals.cache, device_id);
    540539        if (!device)
    541                 return NULL;
     540                return ENOENT;
    542541
    543542        proto = arp_protos_find(&device->protos, protocol);
    544543        if (!proto || (proto->addr->length != target->length))
    545                 return NULL;
     544                return ENOENT;
    546545
    547546        addr = arp_addr_find(&proto->addresses, target->value, target->length);
    548         if (addr)
    549                 return addr;
     547        if (addr) {
     548                *translation = addr;
     549                return EOK;
     550        }
    550551
    551552        /* ARP packet content size = header + (address + translation) * 2 */
     
    553554            CONVERT_SIZE(char, uint8_t, device->addr->length));
    554555        if (length > device->packet_dimension.content)
    555                 return NULL;
     556                return ELIMIT;
    556557
    557558        packet = packet_get_4_remote(arp_globals.net_phone,
     
    559560            length, device->packet_dimension.suffix);
    560561        if (!packet)
    561                 return NULL;
     562                return ENOMEM;
    562563
    563564        header = (arp_header_t *) packet_suffix(packet, length);
    564565        if (!header) {
    565566                pq_release_remote(arp_globals.net_phone, packet_get_id(packet));
    566                 return NULL;
     567                return ENOMEM;
    567568        }
    568569
     
    583584        memcpy(((uint8_t *) header) + length, target->value, target->length);
    584585
    585         if (packet_set_addr(packet, (uint8_t *) device->addr->value,
     586        rc = packet_set_addr(packet, (uint8_t *) device->addr->value,
    586587            (uint8_t *) device->broadcast_addr->value,
    587             CONVERT_SIZE(char, uint8_t, device->addr->length)) != EOK) {
     588            CONVERT_SIZE(char, uint8_t, device->addr->length));
     589        if (rc != EOK) {
    588590                pq_release_remote(arp_globals.net_phone, packet_get_id(packet));
    589                 return NULL;
     591                return rc;
    590592        }
    591593
    592594        nil_send_msg(device->phone, device_id, packet, SERVICE_ARP);
    593         return NULL;
     595        return EAGAIN;
    594596}
    595597
     
    643645               
    644646                fibril_rwlock_read_lock(&arp_globals.lock);
    645                 translation = arp_translate_message(IPC_GET_DEVICE(call),
    646                     IPC_GET_SERVICE(call), address);
     647                rc = arp_translate_message(IPC_GET_DEVICE(call),
     648                    IPC_GET_SERVICE(call), address, &translation);
    647649                free(address);
    648650                free(data);
     651                if (rc != EOK) {
     652                        fibril_rwlock_read_unlock(&arp_globals.lock);
     653                        return rc;
     654                }
    649655                if (!translation) {
    650656                        fibril_rwlock_read_unlock(&arp_globals.lock);
  • uspace/srv/net/il/ip/ip.c

    rda9f13f3 r3bb5735  
    115115/** The IP localhost address. */
    116116#define IPV4_LOCALHOST_ADDRESS  htonl((127 << 24) + 1)
     117
     118/** How many times can arp_translate_req respond EAGAIN before IP gives up */
     119#define ARP_EAGAIN_MAX_COUNT 10
    117120
    118121/** IP global data. */
     
    10081011                destination.length = CONVERT_SIZE(dest.s_addr, char, 1);
    10091012
    1010                 rc = arp_translate_req(netif->arp->phone, netif->device_id,
    1011                     SERVICE_IP, &destination, &translation, &data);
     1013                /** Try calling translate several times, then give up */
     1014                int count = 0;
     1015                do {
     1016                        rc = arp_translate_req(netif->arp->phone,
     1017                            netif->device_id, SERVICE_IP, &destination,
     1018                            &translation, &data);
     1019                        count++;
     1020                } while (rc == EAGAIN && count <= ARP_EAGAIN_MAX_COUNT);
    10121021                if (rc != EOK) {
    10131022                        pq_release_remote(ip_globals.net_phone,
Note: See TracChangeset for help on using the changeset viewer.