VirtualBox

Changeset 22393 in vbox for trunk/src/VBox/HostDrivers


Ignore:
Timestamp:
Aug 21, 2009 5:01:35 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
51350
Message:

Solaris/VBoxNetFlt: Timed polling for dynamic Ipv6 stream attachment (disabled).

Location:
trunk/src/VBox/HostDrivers/VBoxNetFlt/solaris
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/solaris/VBoxNetFlt-solaris.c

    r22009 r22393  
    3939#include <iprt/err.h>
    4040#include <iprt/ctype.h>
     41#ifdef VBOXNETFLT_SOLARIS_IPV6_POLLING
     42# include <iprt/timer.h>
     43#endif
    4144
    4245#include <inet/ip.h>
     
    8790*******************************************************************************/
    8891/** The module name. */
    89 #define DEVICE_NAME              "vboxflt"
     92#define DEVICE_NAME                     "vboxflt"
    9093/** The module descriptions as seen in 'modinfo'. */
    91 #define DEVICE_DESC_DRV          "VirtualBox NetDrv"
    92 #define DEVICE_DESC_MOD          "VirtualBox NetMod"
     94#define DEVICE_DESC_DRV                 "VirtualBox NetDrv"
     95#define DEVICE_DESC_MOD                 "VirtualBox NetMod"
    9396
    9497#if defined(DEBUG_ramshankar)
     
    97100# undef LogFlow
    98101# define LogFlow    LogRel
     102#endif
     103
     104#ifdef VBOXNETFLT_SOLARIS_IPV6_POLLING
     105/** Driver properties */
     106# define VBOXNETFLT_IP6POLLINTERVAL      "ipv6-pollinterval"
    99107#endif
    100108
     
    313321typedef struct vboxnetflt_promisc_stream_t
    314322{
    315     vboxnetflt_stream_t Stream;           /* The generic stream */
     323    vboxnetflt_stream_t Stream;           /* dedicated/promiscuous stream */
    316324    bool fPromisc;                        /* cached promiscous value */
    317325    bool fRawMode;                        /* whether raw mode request was successful */
    318326    uint32_t ModeReqId;                   /* track MIOCTLs for swallowing our fake request acknowledgements */
     327#ifdef VBOXNETFLT_SOLARIS_IPV6_POLLING
     328    PRTTIMER pIp6Timer;                   /* ipv6 stream poll timer for dynamic ipv6 stream attachment */
     329#endif
    319330    size_t cLoopback;                     /* loopback queue size list */
    320331    PVBOXNETFLTPACKETID pHead;            /* loopback packet identifier head */
     
    673684        pPromiscStream->pTail = NULL;
    674685        pPromiscStream->cLoopback = 0;
     686#ifdef VBOXNETFLT_SOLARIS_IPV6_POLLING
     687        pPromiscStream->pIp6Timer = NULL;
     688#endif
    675689        pStream = (vboxnetflt_stream_t *)pPromiscStream;
    676690    }
     
    838852        pPromiscStream->pTail = NULL;
    839853        pPromiscStream->cLoopback = 0;
     854
     855#ifdef VBOXNETFLT_SOLARIS_IPV6_POLLING
     856        /*
     857         * Sheer paranoia.
     858         */
     859        if (pPromiscStream->pIp6Timer != NULL)
     860        {
     861            RTTimerStop(pPromiscStream->pIp6Timer);
     862            RTTimerDestroy(pPromiscStream->pIp6Timer);
     863            ASMAtomicUoWritePtr((void * volatile *)&pPromiscStream->pIp6Timer, NULL);
     864        }
     865#endif
    840866
    841867        RTSemFastMutexRelease(pStream->pThis->u.s.hFastMtx);
     
    17001726/**
    17011727 * Opens up the DLPI style 2 link that requires explicit PPA attach
    1702  * phase. 
     1728 * phase.
    17031729 *
    17041730 * @returns VBox status code.
     
    17971823        /*
    17981824         * Try DLPI style 2.
    1799          */       
     1825         */
    18001826        rc = vboxNetFltSolarisOpenStyle2(pThis, &DevId);
    18011827        if (RT_FAILURE(rc))
     
    22942320    }
    22952321    else
     2322    {
    22962323        LogFlow((DEVICE_NAME ":vboxNetFltSolarisAttachIp6: failed to get IPv6 flags.\n", pThis->szName));
     2324        rc = VERR_INTNET_FLT_IF_NOT_FOUND;
     2325    }
    22972326
    22982327    ldi_close(Ip6DevHandle, FREAD | FWRITE, kcred);
     
    23052334
    23062335
    2307 /**
    2308  * Wrapper for attaching ourselves to the interface.
     2336#ifdef VBOXNETFLT_SOLARIS_IPV6_POLLING
     2337/**
     2338 * Ipv6 dynamic attachment timer callback to attach to the Ipv6 stream if needed.
     2339 *
     2340 * @param   pThis           Pointer to the timer.
     2341 * @param   pvData          Opaque pointer to the instance.
     2342 * @param   iTick           Timer tick (unused).
     2343 */
     2344static void vboxNetFltSolarispIp6Timer(PRTTIMER pTimer, void *pvData, uint64_t iTick)
     2345{
     2346    LogFlow((DEVICE_NAME ":vboxNetFltSolarispIp6Timer pTimer=%p pvData=%p\n", pTimer, pvData));
     2347
     2348    /** @todo this callback takes a good deal of time attaching to the Ipv6 stream, optimize it. */
     2349    PVBOXNETFLTINS pThis = (PVBOXNETFLTINS)pvData;
     2350    if (   RT_LIKELY(pThis)
     2351        && RT_LIKELY(pTimer))
     2352    {
     2353        vboxnetflt_stream_t *pIp6Stream  = ASMAtomicUoReadPtr((void * volatile *)&pThis->u.s.pvIp6Stream);
     2354        if (!pIp6Stream)
     2355            vboxNetFltSolarisAttachIp6(pThis, true /* fAttach */);
     2356    }
     2357
     2358    NOREF(iTick);
     2359}
     2360
     2361
     2362/**
     2363 * Setups up a kernel timer based on the driver property for attaching to IPv6 stream
     2364 * whenever the stream gets plumbed for the interface.
    23092365 *
    23102366 * @returns VBox status code.
    23112367 * @param   pThis           The instance.
    23122368 */
    2313 static int vboxNetFltSolarisAttachToInterface(PVBOXNETFLTINS pThis)
    2314 {
    2315     int rc = vboxNetFltSolarisOpenStream(pThis);
    2316     if (RT_SUCCESS(rc))
    2317     {
    2318         rc = vboxNetFltSolarisAttachIp4(pThis, true /* fAttach */);
    2319         if (RT_SUCCESS(rc))
    2320         {
    2321             vboxNetFltSolarisAttachIp6(pThis, true /* fAttach */);
    2322             /* Ignore Ipv6 binding errors as it's optional. */
    2323 
    2324             ASMAtomicWriteBool(&pThis->fDisconnectedFromHost, false);
     2369static int vboxNetFltSolarisSetupIp6Polling(PVBOXNETFLTINS pThis)
     2370{
     2371    LogFlow((DEVICE_NAME ":vboxNetFltSolarisSetupIp6Polling pThis=%p\n", pThis));
     2372
     2373    int rc = VINF_SUCCESS;
     2374    vboxnetflt_promisc_stream_t *pPromiscStream = ASMAtomicUoReadPtr((void * volatile *)&pThis->u.s.pvPromiscStream);
     2375    if (RT_LIKELY(pPromiscStream))
     2376    {
     2377        if (RT_LIKELY(pPromiscStream->pIp6Timer == NULL))
     2378        {
     2379            /*
     2380             * Get the user prop. for polling interval.
     2381             */
     2382            int Interval = ddi_getprop(DDI_DEV_T_ANY, g_pVBoxNetFltSolarisDip, DDI_PROP_DONTPASS, VBOXNETFLT_IP6POLLINTERVAL, -1 /* default */);
     2383            if (Interval == -1)
     2384            {
     2385                LogFlow((DEVICE_NAME ":vboxNetFltSolarisSetupIp6Polling: no poll interval property specified. Skipping Ipv6 polling.\n"));
     2386                return VINF_SUCCESS;
     2387            }
     2388
     2389            if (Interval < 1 || Interval > 120)
     2390            {
     2391                LogRel((DEVICE_NAME ":vboxNetFltSolarisSetupIp6Polling: Invalid polling interval %d. Expected between 1 and 120 secs.\n",
     2392                    Interval));
     2393                return VINF_SUCCESS;
     2394            }
     2395
     2396            /*
     2397             * Setup kernel poll timer.
     2398             */
     2399            rc = RTTimerCreateEx(&pPromiscStream->pIp6Timer, Interval * (uint64_t)1000000000, RTTIMER_FLAGS_CPU_ALL,
     2400                                vboxNetFltSolarispIp6Timer, (void *)pThis);
     2401            if (RT_SUCCESS(rc))
     2402                rc = RTTimerStart(pPromiscStream->pIp6Timer, 0 /* fire ASAP */);
    23252403        }
    23262404        else
    2327             vboxNetFltSolarisCloseStream(pThis);
    2328     }
    2329     else
    2330         LogRel((DEVICE_NAME ":vboxNetFltSolarisAttachToInterface vboxNetFltSolarisOpenStream failed rc=%Rrc\n", rc));
    2331 
     2405            LogRel((DEVICE_NAME ":vboxNetFltSolarisSetupIp6Polling: Polling already started.\n"));
     2406    }
    23322407    return rc;
    23332408}
    2334 
     2409#endif
    23352410
    23362411/**
     
    23512426    if (pThis->u.s.pvIp6Stream)
    23522427        rc = vboxNetFltSolarisAttachIp6(pThis, false /* fAttach */);
     2428
     2429#ifdef VBOXNETFLT_SOLARIS_IPV6_POLLING
     2430    vboxnetflt_promisc_stream_t *pPromiscStream = ASMAtomicUoReadPtr((void * volatile *)&pThis->u.s.pvPromiscStream);
     2431    if (   pPromiscStream
     2432        && pPromiscStream->pIp6Timer == NULL)
     2433    {
     2434        RTTimerStop(pPromiscStream->pIp6Timer);
     2435        RTTimerDestroy(pPromiscStream->pIp6Timer);
     2436        ASMAtomicUoWritePtr((void * volatile *)&pPromiscStream->pIp6Timer, NULL);
     2437    }
     2438#endif
     2439
     2440    return rc;
     2441}
     2442
     2443
     2444/**
     2445 * Wrapper for attaching ourselves to the interface.
     2446 *
     2447 * @returns VBox status code.
     2448 * @param   pThis           The instance.
     2449 */
     2450static int vboxNetFltSolarisAttachToInterface(PVBOXNETFLTINS pThis)
     2451{
     2452    LogFlow((DEVICE_NAME ":vboxNetFltSolarisAttachToInterface pThis=%p\n", pThis));
     2453
     2454    int rc = vboxNetFltSolarisOpenStream(pThis);
     2455    if (RT_SUCCESS(rc))
     2456    {
     2457        rc = vboxNetFltSolarisAttachIp4(pThis, true /* fAttach */);
     2458        if (RT_SUCCESS(rc))
     2459        {
     2460            int rc2 = vboxNetFltSolarisAttachIp6(pThis, true /* fAttach */);
     2461#ifdef VBOXNETFLT_SOLARIS_IPV6_POLLING
     2462            if (rc2 == VERR_INTNET_FLT_IF_NOT_FOUND)
     2463            {
     2464                rc = vboxNetFltSolarisSetupIp6Polling(pThis);
     2465                if (RT_FAILURE(rc))
     2466                {
     2467                    ASMAtomicUoWritePtr((void * volatile *)&pThis->u.s.pvIp6Stream, NULL);
     2468                    vboxNetFltSolarisDetachFromInterface(pThis);
     2469                }
     2470            }
     2471            else
     2472#endif
     2473                ASMAtomicWriteBool(&pThis->fDisconnectedFromHost, false);
     2474        }
     2475        else
     2476            vboxNetFltSolarisCloseStream(pThis);
     2477    }
     2478    else
     2479        LogRel((DEVICE_NAME ":vboxNetFltSolarisAttachToInterface vboxNetFltSolarisOpenStream failed rc=%Rrc\n", rc));
    23532480
    23542481    return rc;
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/solaris/vboxflt.conf

    r18265 r22393  
    2424#
    2525name="vboxflt" parent="pseudo" instance=0;
     26
     27# If the interface being used does not have Ipv6 plumbed and you want
     28# vboxflt to automatically attach to it by checking for Ipv6 stream every
     29# "ipv6-pollinterval" seconds.
     30#
     31# By default this is disabled meaning if the interface does not have Ipv6
     32# plumbed when the virtual machine starts, guest<->host Ipv6 will not work
     33# though guest<->remote Ipv6 would work.
     34#
     35# Enable if you have a dynamically plumbing/unplumbing Ipv6 interface for
     36# which you want vboxflt to adjust accordingly, otherwise keep this disabled.
     37# Enabling this option will have some minor performance penalty.
     38#ipv6-pollinterval=3
     39
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