VirtualBox

Changeset 88525 in vbox


Ignore:
Timestamp:
Apr 15, 2021 11:40:05 AM (4 years ago)
Author:
vboxsync
Message:

NAT: Handle IP options in the ping echo request. bugref:9986.

File:
1 edited

Legend:

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

    r82968 r88525  
    4646    TAILQ_ENTRY(pong) queue_entry;
    4747
    48     struct ip reqiph;
     48    union {
     49        struct ip ip;
     50        uint8_t au[60];
     51    } reqiph;
    4952    struct icmp_echo reqicmph;
    5053
     
    146149    AssertReturnVoid(ttl > 0);
    147150
    148     reqsize = ip->ip_len - hlen - sizeof(struct icmp_echo);
     151    size_t hdrsize = hlen + sizeof(struct icmp_echo);
     152    reqsize = ip->ip_len - hdrsize;
    149153
    150154    bufsize = sizeof(ICMP_ECHO_REPLY);
     
    172176    {
    173177        /* already in single contiguous buffer */
    174         reqdata = mtod(m, char *) + sizeof(struct ip) + sizeof(struct icmp_echo);
     178        reqdata = mtod(m, char *) + hdrsize;
    175179    }
    176180    else
     
    178182        /* use reply buffer as temporary storage */
    179183        reqdata = pong->buf;
    180         m_copydata(m, sizeof(struct ip) + sizeof(struct icmp_echo),
    181                    (int)reqsize, reqdata);
     184        m_copydata(m, (int)hdrsize, (int)reqsize, reqdata);
    182185    }
    183186
     
    398401        ip->ip_p = IPPROTO_ICMP;
    399402        ip->ip_src.s_addr = reply->Address;
    400         ip->ip_dst = pong->reqiph.ip_src;
     403        ip->ip_dst = pong->reqiph.ip.ip_src;
    401404
    402405        icmp->icmp_type = ICMP_ECHOREPLY;
     
    479482    Log2(("NAT: ping error type %d/code %d\n", type, code));
    480483
    481     reqsize = sizeof(pong->reqiph) + sizeof(pong->reqicmph);
     484    size_t reqhlen = pong->reqiph.ip.ip_hl << 2;
     485    reqsize = reqhlen + sizeof(pong->reqicmph);
    482486
    483487    m = icmpwin_get_mbuf(pData, reqsize);
     
    494498    ip->ip_p = IPPROTO_ICMP;
    495499    ip->ip_src.s_addr = 0;      /* NB */
    496     ip->ip_dst = pong->reqiph.ip_src;
     500    ip->ip_dst = pong->reqiph.ip.ip_src;
    497501
    498502    icmp->icmp_type = type;
     
    502506    icmp->icmp_echo_seq = 0;
    503507
    504     m_append(pData, m, sizeof(pong->reqiph), (caddr_t)&pong->reqiph);
     508    /* payload: the IP and ICMP headers of the original request */
     509    m_append(pData, m, (int)reqhlen, (caddr_t)&pong->reqiph);
    505510    m_append(pData, m, sizeof(pong->reqicmph), (caddr_t)&pong->reqicmph);
    506511
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