Changeset 23361 in vbox for trunk/src/VBox/HostDrivers/VBoxNetFlt
- Timestamp:
- Sep 28, 2009 9:35:48 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxNetFlt/solaris/VBoxNetFlt-solaris.c
r23325 r23361 372 372 373 373 /** The list of all opened streams. */ 374 vboxnetflt_stream_t *g_VBoxNetFltSolarisStreams ;374 vboxnetflt_stream_t *g_VBoxNetFltSolarisStreams = NULL; 375 375 376 376 /** Global mutex protecting open/close. */ … … 384 384 * in ModOpen. This is just shared global data between the dynamic attach and the ModOpen procedure. 385 385 */ 386 PVBOXNETFLTINS volatile g_VBoxNetFltSolarisInstance ;386 PVBOXNETFLTINS volatile g_VBoxNetFltSolarisInstance = NULL; 387 387 388 388 /** Goes along with the instance to determine type of stream being opened/created. */ … … 391 391 #ifdef VBOXNETFLT_SOLARIS_IPV6_POLLING 392 392 /** Global IPv6 polling interval */ 393 static int g_VBoxNetFltSolarisPollInterval = 0;393 static int g_VBoxNetFltSolarisPollInterval = -1; 394 394 #endif 395 395 … … 422 422 g_VBoxNetFltSolarisStreams = NULL; 423 423 g_VBoxNetFltSolarisInstance = NULL; 424 425 int rc = RTSemFastMutexCreate(&g_VBoxNetFltSolarisMtx); 426 if (RT_SUCCESS(rc)) 427 { 428 /* 429 * Initialize the globals and connect to the support driver. 430 * 431 * This will call back vboxNetFltOsOpenSupDrv (and maybe vboxNetFltOsCloseSupDrv) 432 * for establishing the connect to the support driver. 433 */ 434 memset(&g_VBoxNetFltSolarisGlobals, 0, sizeof(g_VBoxNetFltSolarisGlobals)); 435 rc = vboxNetFltInitGlobalsAndIdc(&g_VBoxNetFltSolarisGlobals); 424 g_pVBoxNetFltSolarisCred = crdup(kcred); 425 if (RT_LIKELY(g_pVBoxNetFltSolarisCred)) 426 { 427 rc = RTSemFastMutexCreate(&g_VBoxNetFltSolarisMtx); 436 428 if (RT_SUCCESS(rc)) 437 429 { 438 rc = mod_install(&g_VBoxNetFltSolarisModLinkage); 439 if (!rc) 440 return rc; 441 442 LogRel((DEVICE_NAME ":mod_install failed. rc=%d\n", rc)); 443 vboxNetFltTryDeleteIdcAndGlobals(&g_VBoxNetFltSolarisGlobals); 430 /* 431 * Initialize the globals and connect to the support driver. 432 * 433 * This will call back vboxNetFltOsOpenSupDrv (and maybe vboxNetFltOsCloseSupDrv) 434 * for establishing the connect to the support driver. 435 */ 436 memset(&g_VBoxNetFltSolarisGlobals, 0, sizeof(g_VBoxNetFltSolarisGlobals)); 437 rc = vboxNetFltInitGlobalsAndIdc(&g_VBoxNetFltSolarisGlobals); 438 if (RT_SUCCESS(rc)) 439 { 440 rc = mod_install(&g_VBoxNetFltSolarisModLinkage); 441 if (!rc) 442 return rc; 443 444 LogRel((DEVICE_NAME ":mod_install failed. rc=%d\n", rc)); 445 vboxNetFltTryDeleteIdcAndGlobals(&g_VBoxNetFltSolarisGlobals); 446 } 447 else 448 LogRel((DEVICE_NAME ":failed to initialize globals.\n")); 449 450 RTSemFastMutexDestroy(g_VBoxNetFltSolarisMtx); 451 g_VBoxNetFltSolarisMtx = NIL_RTSEMFASTMUTEX; 444 452 } 445 else446 LogRel((DEVICE_NAME ":failed to initialize globals.\n"));447 448 RTSemFastMutexDestroy(g_VBoxNetFltSolarisMtx);449 g_VBoxNetFltSolarisMtx = NIL_RTSEMFASTMUTEX;453 } 454 else 455 { 456 LogRel((DEVICE_NAME ":failed to allocate credentials.\n")); 457 rc = VERR_NO_MEMORY; 450 458 } 451 459 … … 478 486 if (!rc) 479 487 { 488 if (g_pVBoxNetFltSolarisCred) 489 { 490 crfree(g_pVBoxNetFltSolarisCred); 491 g_pVBoxNetFltSolarisCred = NULL; 492 } 493 480 494 if (g_VBoxNetFltSolarisMtx != NIL_RTSEMFASTMUTEX) 481 495 { … … 523 537 { 524 538 g_pVBoxNetFltSolarisDip = pDip; 525 g_pVBoxNetFltSolarisCred = crdup(kcred); 526 if (RT_LIKELY(g_pVBoxNetFltSolarisCred)) 539 #ifdef VBOXNETFLT_SOLARIS_IPV6_POLLING 540 /* 541 * Get the user prop. for polling interval. 542 */ 543 int Interval = ddi_getprop(DDI_DEV_T_ANY, pDip, DDI_PROP_DONTPASS, VBOXNETFLT_IP6POLLINTERVAL, -1 /* default */); 544 if (Interval == -1) 545 LogFlow((DEVICE_NAME ":vboxNetFltSolarisSetupIp6Polling: no poll interval property specified. Skipping Ipv6 polling.\n")); 546 else if (Interval < 1 || Interval > 120) 527 547 { 528 #ifdef VBOXNETFLT_SOLARIS_IPV6_POLLING 529 /* 530 * Get the user prop. for polling interval. 531 */ 532 int Interval = ddi_getprop(DDI_DEV_T_ANY, pDip, DDI_PROP_DONTPASS, VBOXNETFLT_IP6POLLINTERVAL, -1 /* default */); 533 if (Interval == -1) 534 LogFlow((DEVICE_NAME ":vboxNetFltSolarisSetupIp6Polling: no poll interval property specified. Skipping Ipv6 polling.\n")); 535 else if (Interval < 1 || Interval > 120) 536 { 537 LogRel((DEVICE_NAME ":vboxNetFltSolarisSetupIp6Polling: Invalid polling interval %d. Expected between 1 and 120 secs.\n", 538 Interval)); 539 Interval = -1; 540 } 541 542 g_VBoxNetFltSolarisPollInterval = Interval; 548 LogRel((DEVICE_NAME ":vboxNetFltSolarisSetupIp6Polling: Invalid polling interval %d. Expected between 1 and 120 secs.\n", 549 Interval)); 550 Interval = -1; 551 } 552 553 g_VBoxNetFltSolarisPollInterval = Interval; 543 554 #endif 544 ddi_report_dev(pDip); 545 return DDI_SUCCESS; 546 } 547 else 548 LogRel((DEVICE_NAME ":failed to alloc credentials.\n")); 555 ddi_report_dev(pDip); 556 return DDI_SUCCESS; 549 557 } 550 558 else … … 580 588 { 581 589 int instance = ddi_get_instance(pDip); 582 if (g_pVBoxNetFltSolarisCred)583 {584 crfree(g_pVBoxNetFltSolarisCred);585 g_pVBoxNetFltSolarisCred = NULL;586 }587 590 ddi_remove_minor_node(pDip, NULL); 588 591 return DDI_SUCCESS; … … 1906 1909 if (!ret) 1907 1910 { 1908 rc = RTSemFastMutexRequest(g_VBoxNetFltSolarisMtx); 1909 AssertRCReturn(rc, rc); 1910 1911 g_VBoxNetFltSolarisInstance = pThis; 1912 g_VBoxNetFltSolarisStreamType = kPromiscStream; 1913 1914 rc = ldi_ioctl(pThis->u.s.hIface, I_PUSH, (intptr_t)DEVICE_NAME, FKIOCTL, g_pVBoxNetFltSolarisCred, &ret); 1915 1916 g_VBoxNetFltSolarisInstance = NULL; 1917 g_VBoxNetFltSolarisStreamType = kUndefined; 1918 1919 RTSemFastMutexRelease(g_VBoxNetFltSolarisMtx); 1911 if (RT_LIKELY(g_pVBoxNetFltSolarisCred)) /* Paranoia */ 1912 { 1913 rc = RTSemFastMutexRequest(g_VBoxNetFltSolarisMtx); 1914 AssertRCReturn(rc, rc); 1915 1916 g_VBoxNetFltSolarisInstance = pThis; 1917 g_VBoxNetFltSolarisStreamType = kPromiscStream; 1918 1919 rc = ldi_ioctl(pThis->u.s.hIface, I_PUSH, (intptr_t)DEVICE_NAME, FKIOCTL, g_pVBoxNetFltSolarisCred, &ret); 1920 1921 g_VBoxNetFltSolarisInstance = NULL; 1922 g_VBoxNetFltSolarisStreamType = kUndefined; 1923 1924 RTSemFastMutexRelease(g_VBoxNetFltSolarisMtx); 1925 } 1926 else 1927 { 1928 LogRel((DEVICE_NAME ":vboxNetFltSolarisOpenStream huh!? Missing credentials.\n")); 1929 rc = VERR_INVALID_POINTER; 1930 } 1920 1931 1921 1932 if (!rc) … … 1929 1940 else 1930 1941 LogRel((DEVICE_NAME ":vboxNetFltSolarisOpenStream Failed to search for filter in interface '%s'.\n", pThis->szName)); 1942 1943 ldi_close(pThis->u.s.hIface, FREAD | FWRITE, kcred); 1931 1944 1932 1945 return VERR_INTNET_FLT_IF_FAILED; … … 2174 2187 fAttach ? "inject into" : "eject from", rc)); 2175 2188 } 2176 2177 g_VBoxNetFltSolarisInstance = NULL;2178 g_VBoxNetFltSolarisStreamType = kUndefined;2179 2189 } 2180 2190 else
Note:
See TracChangeset
for help on using the changeset viewer.