VirtualBox

Changeset 53448 in vbox for trunk


Ignore:
Timestamp:
Dec 5, 2014 9:12:22 AM (10 years ago)
Author:
vboxsync
Message:

NAT: trac ticket 13630 - use generation numbers as poor man's weak
references to prevent dnsproxy from using stale request::dns_server.

This commit has some extra LogRel() for the user to confirm the fix,
which are to be changed to Log2.

XXX: TOO: Clean up in dnsproxy_query() needs more investigation.
Existing code just punts with an "XXX" comment on sendto() failure,
which doesn't doesn't look right.

Location:
trunk/src/VBox/Devices/Network/slirp
Files:
4 edited

Legend:

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

    r50673 r53448  
    121121    AssertPtrReturnVoid(arg);
    122122
    123     if (   req->dns_server == NULL
     123    if (   req->dnsgen != pData->dnsgen
     124        || req->dns_server == NULL
    124125        || (de = TAILQ_PREV(req->dns_server, dns_list_head, de_list)) == NULL)
    125126    {
     127        if (req->dnsgen != pData->dnsgen)
     128        {
     129            /* XXX: Log2 */
     130            LogRel(("NAT: dnsproxy: timeout: req %p dnsgen %u != %u on %R[natsock]\n",
     131                    req, req->dnsgen, pData->dnsgen, so));
     132        }
    126133        hash_remove_request(pData, req);
    127134        RTMemFree(req);
     
    356363        memcpy(&req->clientid, &buf[0], 2);
    357364        req->dns_server = TAILQ_LAST(&pData->pDnsList, dns_list_head);
     365        req->dnsgen = pData->dnsgen;
    358366        if (req->dns_server == NULL)
    359367        {
     
    375383    else
    376384    {
    377          retransmit = 1;
     385        if (req->dnsgen != pData->dnsgen)
     386        {
     387            /* XXX: Log2 */
     388            LogRel(("NAT: dnsproxy: query: req %p dnsgen %u != %u on %R[natsock]\n",
     389                    req, req->dnsgen, pData->dnsgen, so));
     390            /*
     391             * XXX: TODO: this probably requires more cleanup.
     392             * Cf. XXX comment for sendto() failure below, but that
     393             * error leg is probably untested since ~never taken.
     394             */
     395            ++dropped_queries;
     396            return;
     397        }
     398        retransmit = 1;
    378399    }
    379400
     
    404425
    405426    /* send it to our authoritative server */
    406     Log2(("NAT: request will be sent to %RTnaipv4 on %R[natsock]\n", addr.sin_addr, so));
     427    Log2(("NAT: request will be %ssent to %RTnaipv4 on %R[natsock]\n",
     428          retransmit ? "re" : "", addr.sin_addr, so));
    407429
    408430    byte = sendto(so->s, buf, (unsigned int)byte, 0,
     
    418440
    419441    so->so_state = SS_ISFCONNECTED; /* now it's selected */
    420     Log2(("NAT: request was sent to %RTnaipv4 on %R[natsock]\n", addr.sin_addr, so));
     442    Log2(("NAT: request was %ssent to %RTnaipv4 on %R[natsock]\n",
     443          retransmit ? "re" : "", addr.sin_addr, so));
    421444
    422445    ++authoritative_queries;
  • trunk/src/VBox/Devices/Network/slirp/dnsproxy/dnsproxy.h

    r26495 r53448  
    8282     * it's value on next server. And dnsproxy_query should
    8383     * initializate with first server in the list
     84     *
     85     * dnsgen is a generation number - a copy of pData->dnsgen at the
     86     * time of request creation (poor man's weak reference).
     87     * dns_server must not be used if pData->dnsgen changed.
    8488     */
    8589    struct dns_entry    *dns_server;
     90    uint32_t            dnsgen;
    8691    int nbyte; /* length of dns request */
    8792    char byte[1]; /* copy of original request */
  • trunk/src/VBox/Devices/Network/slirp/slirp_dns.c

    r51642 r53448  
    304304        RTMemFree(pDomain);
    305305    }
     306
     307    /* tell any pending dnsproxy requests their copy is expired */
     308    ++pData->dnsgen;
     309
    306310    LogFlowFuncLeaveRC(rc);
    307311    return rc;
  • trunk/src/VBox/Devices/Network/slirp/slirp_state.h

    r53399 r53448  
    151151    struct dns_list_head pDnsList;
    152152    struct dns_domain_list_head pDomainList;
     153    uint32_t dnsgen;            /* XXX: merge with dnsLastUpdate? */
    153154    struct in_addr tftp_server;
    154155    struct in_addr loopback_addr;
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