Changeset 49bd793b in mainline


Ignore:
Timestamp:
2011-10-07T21:42:14Z (12 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
80099c19
Parents:
00d7e1b
Message:

networking fixes

  • use sysarg_t for packet_id_t to avoid potential overflow
  • fix the confusion in the order of arguments for nil_received_msg(), this fixes the strange ping timeout on 127.0.0.1
Location:
uspace
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/net/packet.c

    r00d7e1b r49bd793b  
    139139packet_t *pm_find(packet_id_t packet_id)
    140140{
    141         packet_t *packet;
    142141        if (!packet_id)
    143142                return NULL;
    144 
     143       
    145144        fibril_rwlock_read_lock(&pm_globals.lock);
    146         link_t *link =
    147             hash_table_find(&pm_globals.packet_map, &packet_id);
     145       
     146        unsigned long key = packet_id;
     147        link_t *link = hash_table_find(&pm_globals.packet_map, &key);
     148       
     149        packet_t *packet;
    148150        if (link != NULL) {
    149151                pm_entry_t *entry =
     
    172174       
    173175        fibril_rwlock_write_lock(&pm_globals.lock);
    174         pm_entry_t *entry = malloc(sizeof (pm_entry_t));
     176       
     177        pm_entry_t *entry = malloc(sizeof(pm_entry_t));
    175178        if (entry == NULL) {
    176179                fibril_rwlock_write_unlock(&pm_globals.lock);
     
    179182       
    180183        entry->packet = packet;
    181         hash_table_insert(&pm_globals.packet_map, &packet->packet_id,
    182             &entry->link);
     184       
     185        unsigned long key = packet->packet_id;
     186        hash_table_insert(&pm_globals.packet_map, &key, &entry->link);
     187       
    183188        fibril_rwlock_write_unlock(&pm_globals.lock);
     189       
    184190        return EOK;
    185191}
     
    195201       
    196202        fibril_rwlock_write_lock(&pm_globals.lock);
    197         hash_table_remove(&pm_globals.packet_map, &packet->packet_id, 1);
     203       
     204        unsigned long key = packet->packet_id;
     205        hash_table_remove(&pm_globals.packet_map, &key, 1);
     206       
    198207        fibril_rwlock_write_unlock(&pm_globals.lock);
    199208}
  • uspace/lib/c/include/net/packet.h

    r00d7e1b r49bd793b  
    3838#define LIBC_PACKET_H_
    3939
     40#include <sys/types.h>
     41
    4042/** Packet identifier type.
    4143 * Value zero is used as an invalid identifier.
    4244 */
    43 typedef unsigned long packet_id_t;
     45typedef sysarg_t packet_id_t;
    4446
    4547/** Type definition of the packet.
     
    5153 * @see packet_dimension
    5254 */
    53 typedef struct packet_dimension packet_dimension_t;
     55typedef struct packet_dimension packet_dimension_t;
    5456
    5557/** Packet dimension. */
  • uspace/lib/net/generic/packet_remote.c

    r00d7e1b r49bd793b  
    115115       
    116116        *packet = pm_find(packet_id);
    117         if (!*packet) {
     117        if (*packet == NULL) {
    118118                async_exch_t *exch = async_exchange_begin(sess);
    119119                sysarg_t size;
     
    130130        }
    131131       
    132         if ((*packet)->next) {
     132        if ((*packet != NULL) && ((*packet)->next)) {
    133133                packet_t *next;
    134134                return packet_translate_remote(sess, &next, (*packet)->next);
  • uspace/lib/nic/src/nic_driver.c

    r00d7e1b r49bd793b  
    671671                }
    672672                fibril_rwlock_write_unlock(&nic_data->stats_lock);
    673                 nil_received_msg(nic_data->nil_session, pid, nic_data->device_id);
     673                nil_received_msg(nic_data->nil_session, nic_data->device_id, pid);
    674674        } else {
    675675                switch (frame_type) {
     
    703703        nic_data->stats.receive_bytes += packet_get_data_length(packet);
    704704        fibril_rwlock_write_unlock(&nic_data->stats_lock);
    705 
    706         nil_received_msg(nic_data->nil_session, packet_get_id(packet),
    707                 nic_data->device_id);
     705       
     706        nil_received_msg(nic_data->nil_session, nic_data->device_id,
     707            packet_get_id(packet));
    708708}
    709709
  • uspace/srv/net/nil/nildummy/nildummy.c

    r00d7e1b r49bd793b  
    136136                        device->mtu = NET_DEFAULT_MTU;
    137137               
    138                 printf("Device %d already exists:\tMTU\t= %zu\n", device->device_id,
     138                printf("Device %d already exists (mtu: %zu)\n", device->device_id,
    139139                    device->mtu);
    140140                fibril_rwlock_write_unlock(&nildummy_globals.devices_lock);
  • uspace/srv/net/tl/icmp/icmp.c

    r00d7e1b r49bd793b  
    753753                        return rc;
    754754               
    755                 rc = icmp_echo(icmp_id, icmp_seq, ICMP_GET_SIZE(*call), 
     755                rc = icmp_echo(icmp_id, icmp_seq, ICMP_GET_SIZE(*call),
    756756                    ICMP_GET_TIMEOUT(*call), ICMP_GET_TTL(*call),
    757757                    ICMP_GET_TOS(*call), ICMP_GET_DONT_FRAGMENT(*call),
  • uspace/srv/net/tl/tcp/tcp.c

    r00d7e1b r49bd793b  
    16511651        /* Sent packet? */
    16521652        packet = pq_find(socket_data->outgoing, sequence_number);
    1653         printf("retransmit %lu\n", packet_get_id(packet));
    16541653        if (packet) {
    16551654                pq_get_order(packet, NULL, &data_length);
     
    17901789
    17911790                        /* Send the packet */
    1792                         printf("connecting %lu\n", packet_get_id(packet));
    17931791                        tcp_send_packets(socket_data->device_id, packet);
    17941792
Note: See TracChangeset for help on using the changeset viewer.