Changeset 23293 in vbox for trunk/src/VBox/HostDrivers
- Timestamp:
- Sep 24, 2009 4:23:43 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 52786
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxNetFlt/solaris/VBoxNetFlt-solaris.c
r23281 r23293 377 377 static RTSEMFASTMUTEX g_VBoxNetFltSolarisMtx = NIL_RTSEMFASTMUTEX; 378 378 379 /** Global credentials using during open/close. */ 380 static cred_t *g_pVBoxNetFltSolarisCred = NULL; 381 379 382 /** 380 383 * g_VBoxNetFltInstance is the current PVBOXNETFLTINS to be associated with the stream being created … … 520 523 { 521 524 g_pVBoxNetFltSolarisDip = pDip; 522 523 /* 524 * Get the user prop. for polling interval. 525 */ 526 int Interval = ddi_getprop(DDI_DEV_T_ANY, pDip, DDI_PROP_DONTPASS, VBOXNETFLT_IP6POLLINTERVAL, -1 /* default */); 527 if (Interval == -1) 528 LogFlow((DEVICE_NAME ":vboxNetFltSolarisSetupIp6Polling: no poll interval property specified. Skipping Ipv6 polling.\n")); 529 else if (Interval < 1 || Interval > 120) 525 g_pVBoxNetFltSolarisCred = crdup(kcred); 526 if (RT_LIKELY(g_pVBoxNetFltSolarisCred)) 530 527 { 531 LogRel((DEVICE_NAME ":vboxNetFltSolarisSetupIp6Polling: Invalid polling interval %d. Expected between 1 and 120 secs.\n", 532 Interval)); 533 Interval = -1; 528 /* 529 * Get the user prop. for polling interval. 530 */ 531 int Interval = ddi_getprop(DDI_DEV_T_ANY, pDip, DDI_PROP_DONTPASS, VBOXNETFLT_IP6POLLINTERVAL, -1 /* default */); 532 if (Interval == -1) 533 LogFlow((DEVICE_NAME ":vboxNetFltSolarisSetupIp6Polling: no poll interval property specified. Skipping Ipv6 polling.\n")); 534 else if (Interval < 1 || Interval > 120) 535 { 536 LogRel((DEVICE_NAME ":vboxNetFltSolarisSetupIp6Polling: Invalid polling interval %d. Expected between 1 and 120 secs.\n", 537 Interval)); 538 Interval = -1; 539 } 540 541 g_VBoxNetFltSolarisPollInterval = Interval; 542 ddi_report_dev(pDip); 543 return DDI_SUCCESS; 534 544 } 535 536 g_VBoxNetFltSolarisPollInterval = Interval; 537 ddi_report_dev(pDip); 538 return DDI_SUCCESS; 545 else 546 LogRel((DEVICE_NAME ":failed to alloc credentials.\n")); 539 547 } 540 548 else … … 570 578 { 571 579 int instance = ddi_get_instance(pDip); 580 if (g_pVBoxNetFltSolarisCred) 581 { 582 crfree(g_pVBoxNetFltSolarisCred); 583 g_pVBoxNetFltSolarisCred = NULL; 584 } 572 585 ddi_remove_minor_node(pDip, NULL); 573 586 return DDI_SUCCESS; … … 637 650 fOpenMode, fStreamMode)); 638 651 639 int rc = RTSemFastMutexRequest(g_VBoxNetFltSolarisMtx);640 AssertRCReturn(rc, rc);641 642 652 /* 643 653 * Already open? … … 646 656 { 647 657 LogRel((DEVICE_NAME ":VBoxNetFltSolarisModOpen invalid open.\n")); 648 RTSemFastMutexRelease(g_VBoxNetFltSolarisMtx);649 658 return ENOENT; 659 } 660 661 /* 662 * Check kernel credentials. 663 * Protects us to a minor degree, is someone uses kcred besides us, this check is not sufficient. 664 */ 665 if (pCred != g_pVBoxNetFltSolarisCred) 666 { 667 LogRel((DEVICE_NAME ":VBoxNetFltSolarisModOpen invalid credentials.\n")); 668 return EACCES; 650 669 } 651 670 … … 657 676 { 658 677 LogRel((DEVICE_NAME ":VBoxNetFltSolarisModOpen failed to get VirtualBox instance.\n")); 659 RTSemFastMutexRelease(g_VBoxNetFltSolarisMtx);660 678 return ENOENT; 661 679 } … … 670 688 { 671 689 LogRel((DEVICE_NAME ":VBoxNetFltSolarisModOpen failed due to undefined VirtualBox open mode. Type=%d\n", g_VBoxNetFltSolarisStreamType)); 672 RTSemFastMutexRelease(g_VBoxNetFltSolarisMtx);673 690 return ENOENT; 674 691 } … … 699 716 { 700 717 LogRel((DEVICE_NAME ":VBoxNetFltSolarisModOpen failed to allocate promiscuous stream data.\n")); 701 RTSemFastMutexRelease(g_VBoxNetFltSolarisMtx);702 718 return ENOMEM; 703 719 } … … 723 739 { 724 740 LogRel((DEVICE_NAME ":VBoxNetFltSolarisModOpen failed to allocate stream data.\n")); 725 RTSemFastMutexRelease(g_VBoxNetFltSolarisMtx);726 741 return ENOMEM; 727 742 } … … 746 761 LogRel((DEVICE_NAME ":VBoxNetFltSolarisModOpen huh!? Invalid stream type %d\n", pStream->Type)); 747 762 RTMemFree(pStream); 748 RTSemFastMutexRelease(g_VBoxNetFltSolarisMtx);749 763 return EINVAL; 750 764 } … … 764 778 */ 765 779 vboxNetFltRetain(pThis, false /* fBusy */); 766 767 /*768 * Release global lock, & do not hold locks across putnext calls.769 */770 RTSemFastMutexRelease(g_VBoxNetFltSolarisMtx);771 780 772 781 qprocson(pQueue); … … 815 824 816 825 NOREF(fOpenMode); 817 NOREF(pCred);818 826 819 827 LogFlow((DEVICE_NAME ":VBoxNetFltSolarisModOpen returns 0, DevMinor=%d pQueue=%p\n", DevMinor, pStream->pReadQueue)); … … 838 846 LogFlow((DEVICE_NAME ":VBoxNetFltSolarisModClose pQueue=%p fOpenMode=%d\n", pQueue, fOpenMode)); 839 847 840 int rc = RTSemFastMutexRequest(g_VBoxNetFltSolarisMtx);841 AssertRCReturn(rc, rc);842 843 848 vboxnetflt_stream_t *pStream = NULL; 844 849 vboxnetflt_stream_t **ppPrevStream = NULL; … … 851 856 { 852 857 LogRel((DEVICE_NAME ":VBoxNetFltSolarisModClose failed to get stream.\n")); 853 RTSemFastMutexRelease(g_VBoxNetFltSolarisMtx);854 858 return ENXIO; 855 859 } … … 934 938 NOREF(fOpenMode); 935 939 NOREF(pCred); 936 937 RTSemFastMutexRelease(g_VBoxNetFltSolarisMtx);938 940 939 941 return 0; … … 1898 1900 if (!ret) 1899 1901 { 1902 rc = RTSemFastMutexRequest(g_VBoxNetFltSolarisMtx); 1903 AssertRCReturn(rc, rc); 1904 1900 1905 g_VBoxNetFltSolarisInstance = pThis; 1901 1906 g_VBoxNetFltSolarisStreamType = kPromiscStream; 1902 1907 1903 rc = ldi_ioctl(pThis->u.s.hIface, I_PUSH, (intptr_t)DEVICE_NAME, FKIOCTL, kcred, &ret);1908 rc = ldi_ioctl(pThis->u.s.hIface, I_PUSH, (intptr_t)DEVICE_NAME, FKIOCTL, g_pVBoxNetFltSolarisCred, &ret); 1904 1909 1905 1910 g_VBoxNetFltSolarisInstance = NULL; 1906 1911 g_VBoxNetFltSolarisStreamType = kUndefined; 1912 1913 RTSemFastMutexRelease(g_VBoxNetFltSolarisMtx); 1907 1914 1908 1915 if (!rc) … … 2064 2071 * of the inability to pass user data while inserting. 2065 2072 */ 2066 g_VBoxNetFltSolarisInstance = pThis; 2067 g_VBoxNetFltSolarisStreamType = kIp4Stream; 2073 rc = RTSemFastMutexRequest(g_VBoxNetFltSolarisMtx); 2074 AssertRCReturn(rc, rc); 2075 2076 if (fAttach) 2077 { 2078 g_VBoxNetFltSolarisInstance = pThis; 2079 g_VBoxNetFltSolarisStreamType = kIp4Stream; 2080 } 2068 2081 2069 2082 rc = strioctl(pIp4VNode, fAttach ? _I_INSERT : _I_REMOVE, (intptr_t)&StrMod, 0, K_TO_K, 2070 kcred, &ret); 2071 2072 g_VBoxNetFltSolarisInstance = NULL; 2073 g_VBoxNetFltSolarisStreamType = kUndefined; 2083 g_pVBoxNetFltSolarisCred, &ret); 2084 2085 if (fAttach) 2086 { 2087 g_VBoxNetFltSolarisInstance = NULL; 2088 g_VBoxNetFltSolarisStreamType = kUndefined; 2089 } 2090 2091 RTSemFastMutexRelease(g_VBoxNetFltSolarisMtx); 2074 2092 2075 2093 if (!rc) … … 2078 2096 * Inject/Eject from the host ARP stack. 2079 2097 */ 2080 g_VBoxNetFltSolarisInstance = pThis; 2081 g_VBoxNetFltSolarisStreamType = kArpStream; 2098 rc = RTSemFastMutexRequest(g_VBoxNetFltSolarisMtx); 2099 AssertRCReturn(rc, rc); 2100 2101 if (fAttach) 2102 { 2103 g_VBoxNetFltSolarisInstance = pThis; 2104 g_VBoxNetFltSolarisStreamType = kArpStream; 2105 } 2082 2106 2083 2107 rc = strioctl(pArpVNode, fAttach ? _I_INSERT : _I_REMOVE, (intptr_t)&ArpStrMod, 0, K_TO_K, 2084 kcred, &ret); 2085 2086 g_VBoxNetFltSolarisInstance = NULL; 2087 g_VBoxNetFltSolarisStreamType = kUndefined; 2108 g_pVBoxNetFltSolarisCred, &ret); 2109 2110 if (fAttach) 2111 { 2112 g_VBoxNetFltSolarisInstance = NULL; 2113 g_VBoxNetFltSolarisStreamType = kUndefined; 2114 } 2115 2116 RTSemFastMutexRelease(g_VBoxNetFltSolarisMtx); 2088 2117 2089 2118 if (!rc) … … 2284 2313 * of the inability to pass user data while inserting. 2285 2314 */ 2286 g_VBoxNetFltSolarisInstance = pThis; 2287 g_VBoxNetFltSolarisStreamType = kIp6Stream; 2315 rc = RTSemFastMutexRequest(g_VBoxNetFltSolarisMtx); 2316 AssertRCReturn(rc, rc); 2317 2318 if (fAttach) 2319 { 2320 g_VBoxNetFltSolarisInstance = pThis; 2321 g_VBoxNetFltSolarisStreamType = kIp6Stream; 2322 } 2288 2323 2289 2324 /* … … 2291 2326 */ 2292 2327 rc = strioctl(pIp6VNode, fAttach ? _I_INSERT : _I_REMOVE, (intptr_t)&StrMod, 0, K_TO_K, 2293 kcred, &ret); 2294 if (!rc) 2328 g_pVBoxNetFltSolarisCred, &ret); 2329 2330 if (fAttach) 2295 2331 { 2296 2332 g_VBoxNetFltSolarisInstance = NULL; 2297 2333 g_VBoxNetFltSolarisStreamType = kUndefined; 2298 2334 } 2335 2336 RTSemFastMutexRelease(g_VBoxNetFltSolarisMtx); 2337 2338 if (!rc) 2339 { 2299 2340 /* 2300 2341 * Our job's not yet over; we need to relink the upper and lower streams
Note:
See TracChangeset
for help on using the changeset viewer.