Changeset 22393 in vbox for trunk/src/VBox/HostDrivers
- Timestamp:
- Aug 21, 2009 5:01:35 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 51350
- 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 39 39 #include <iprt/err.h> 40 40 #include <iprt/ctype.h> 41 #ifdef VBOXNETFLT_SOLARIS_IPV6_POLLING 42 # include <iprt/timer.h> 43 #endif 41 44 42 45 #include <inet/ip.h> … … 87 90 *******************************************************************************/ 88 91 /** The module name. */ 89 #define DEVICE_NAME "vboxflt"92 #define DEVICE_NAME "vboxflt" 90 93 /** 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" 93 96 94 97 #if defined(DEBUG_ramshankar) … … 97 100 # undef LogFlow 98 101 # define LogFlow LogRel 102 #endif 103 104 #ifdef VBOXNETFLT_SOLARIS_IPV6_POLLING 105 /** Driver properties */ 106 # define VBOXNETFLT_IP6POLLINTERVAL "ipv6-pollinterval" 99 107 #endif 100 108 … … 313 321 typedef struct vboxnetflt_promisc_stream_t 314 322 { 315 vboxnetflt_stream_t Stream; /* The genericstream */323 vboxnetflt_stream_t Stream; /* dedicated/promiscuous stream */ 316 324 bool fPromisc; /* cached promiscous value */ 317 325 bool fRawMode; /* whether raw mode request was successful */ 318 326 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 319 330 size_t cLoopback; /* loopback queue size list */ 320 331 PVBOXNETFLTPACKETID pHead; /* loopback packet identifier head */ … … 673 684 pPromiscStream->pTail = NULL; 674 685 pPromiscStream->cLoopback = 0; 686 #ifdef VBOXNETFLT_SOLARIS_IPV6_POLLING 687 pPromiscStream->pIp6Timer = NULL; 688 #endif 675 689 pStream = (vboxnetflt_stream_t *)pPromiscStream; 676 690 } … … 838 852 pPromiscStream->pTail = NULL; 839 853 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 840 866 841 867 RTSemFastMutexRelease(pStream->pThis->u.s.hFastMtx); … … 1700 1726 /** 1701 1727 * Opens up the DLPI style 2 link that requires explicit PPA attach 1702 * phase. 1728 * phase. 1703 1729 * 1704 1730 * @returns VBox status code. … … 1797 1823 /* 1798 1824 * Try DLPI style 2. 1799 */ 1825 */ 1800 1826 rc = vboxNetFltSolarisOpenStyle2(pThis, &DevId); 1801 1827 if (RT_FAILURE(rc)) … … 2294 2320 } 2295 2321 else 2322 { 2296 2323 LogFlow((DEVICE_NAME ":vboxNetFltSolarisAttachIp6: failed to get IPv6 flags.\n", pThis->szName)); 2324 rc = VERR_INTNET_FLT_IF_NOT_FOUND; 2325 } 2297 2326 2298 2327 ldi_close(Ip6DevHandle, FREAD | FWRITE, kcred); … … 2305 2334 2306 2335 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 */ 2344 static 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. 2309 2365 * 2310 2366 * @returns VBox status code. 2311 2367 * @param pThis The instance. 2312 2368 */ 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); 2369 static 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 */); 2325 2403 } 2326 2404 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 } 2332 2407 return rc; 2333 2408 } 2334 2409 #endif 2335 2410 2336 2411 /** … … 2351 2426 if (pThis->u.s.pvIp6Stream) 2352 2427 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 */ 2450 static 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)); 2353 2480 2354 2481 return rc; -
trunk/src/VBox/HostDrivers/VBoxNetFlt/solaris/vboxflt.conf
r18265 r22393 24 24 # 25 25 name="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.