VirtualBox

Changeset 27466 in vbox


Ignore:
Timestamp:
Mar 18, 2010 7:09:37 AM (15 years ago)
Author:
vboxsync
Message:

NAT: ICMP Solaris specific ip_len calculation was added.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/slirp/socket.c

    r27457 r27466  
    10571057    ip = (struct ip *)buff;
    10581058    hlen = (ip->ip_hl << 2);
    1059     if (RT_N2H_U16(ip->ip_len) < hlen + ICMP_MINLEN)
     1059    /* Note: ip->ip_len in host byte order */
     1060    ip->ip_len = RT_N2H_U16(ip->ip_len);
     1061#ifdef RT_OS_SOLARIS
     1062    /* Solaris doesn't pass raw IP datagram, ip_len is size of payload only */
     1063    ip->ip_len += hlen;
     1064#endif
     1065    if (ip->ip_len < hlen + ICMP_MINLEN)
    10601066    {
    10611067       Log(("send_icmp_to_guest: ICMP header is too small to understand which type/subtype of the datagram\n"));
     
    10771083     * icmp_{type(8), code(8), cksum(16),identifier(16),seqnum(16)}
    10781084     */
    1079     if (RT_N2H_U16(ip->ip_len) < hlen + 8)
     1085    if (ip->ip_len < hlen + 8)
    10801086    {
    10811087        Log(("send_icmp_to_guest: NAT accept ICMP_{ECHOREPLY, TIMXCEED, UNREACH} the minimum size is 64 (see rfc792)\n"));
     
    10911097         * icmp_{type(8), code(8), cksum(16),unused(32)} + IP header + 64 bit of original datagram
    10921098         */
    1093         if (RT_N2H_U16(ip->ip_len) < hlen + 2*8 + sizeof(struct ip))
     1099        if (ip->ip_len < hlen + 2*8 + sizeof(struct ip))
    10941100        {
    10951101            Log(("send_icmp_to_guest: NAT accept ICMP_{TIMXCEED, UNREACH} the minimum size of ipheader + 64 bit of data (see rfc792)\n"));
     
    11111117
    11121118    src = addr->sin_addr.s_addr;
    1113 #if 0
    1114     /* @todo: check why it's too strict. */
    11151119    if (type == ICMP_ECHOREPLY)
    11161120    {
     
    11221126            return;
    11231127        }
    1124         if (   (RT_N2H_U16(ip->ip_len) - hlen )
    1125             != (ip0->ip_len - (ip0->ip_hl << 2))) /* the IP header in the list is in host format */
    1126         {
    1127             Log(("NAT: ECHO lenght doesn't match ECHOREPLY\n"));
     1128#if 0
     1129        /*
     1130         * @todo ip0 seems have different byte order on different OSes, e.g. on Solaris it's required
     1131         * to N2H, but on Linux no convertaion required.
     1132         */
     1133        if (   (ip->ip_len - hlen )
     1134            != (ip0->ip_len - (ip0->ip_hl << 2)))
     1135        {
     1136            Log(("NAT: ECHO(%d) lenght doesn't match ECHOREPLY(%d)\n",
     1137                (ip->ip_len - hlen ), (ip0->ip_len - (ip0->ip_hl << 2))));
    11281138            return;
    11291139        }
    1130     }
    1131 #endif
    1132 
     1140#endif
     1141    }
     1142
     1143    /* ip points on origianal ip header */
    11331144    ip = mtod(m, struct ip *);
    11341145    proto = ip->ip_p;
     
    13731384
    13741385    len = RT_N2H_U16(ip.ip_len);
     1386#ifdef RT_OS_SOLARIS
     1387    len += (ip.ip_hl << 2); /* Solaris: reports only payload length */
     1388#endif
    13751389    buff = RTMemAlloc(len);
    13761390    if (buff == NULL)
     
    13961410    }
    13971411    if (   len < 0
     1412#ifndef RT_OS_SOLARIS
    13981413        || len < (RT_N2H_U16(ip.ip_len))
     1414#else
     1415        || len < ((RT_N2H_U16(ip.ip_len)) + (ip.ip_hl << 2))
     1416#endif
    13991417        || len == 0)
    14001418    {
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette