Changeset 37982 in vbox for trunk/src/VBox/HostDrivers/VBoxNetFlt
- Timestamp:
- Jul 15, 2011 2:35:40 PM (13 years ago)
- Location:
- trunk/src/VBox/HostDrivers/VBoxNetFlt
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxNetFlt/Makefile.kmk
r36496 r37982 331 331 vboxnetflt_INCS := \ 332 332 $(PATH_SUB_CURRENT) 333 vboxnetflt_LDFLAGS.solaris += -N drv/vboxdrv 333 vboxnetflt_LDFLAGS.solaris += -N drv/vboxdrv -N misc/ctf 334 334 vboxnetflt_LIBS = \ 335 335 $(PATH_LIB)/SUPR0IdcClient$(VBOX_SUFF_LIB) -
trunk/src/VBox/HostDrivers/VBoxNetFlt/solaris/VBoxNetFlt-solaris.c
r33540 r37982 65 65 #include <sys/sunddi.h> 66 66 #include <sys/sunldi.h> 67 #include <sys/ctf_api.h> 67 68 68 69 // Workaround for very strange define in sys/user.h … … 405 406 #endif 406 407 408 static int s_off_vnode = -1; 409 #define VNODE_FOR_FILE_T(filetpointer) (*(struct vnode **)((char *)(filetpointer) + s_off_vnode)) 410 411 412 static int 413 vboxNetFltSolarisCtfGetMemberOffset(ctf_file_t *pCtfFile, const char *pszStruct, const char *pszMember, int *pOffset) 414 { 415 AssertReturn(pCtfFile, VERR_INVALID_PARAMETER); 416 AssertReturn(pszStruct, VERR_INVALID_PARAMETER); 417 AssertReturn(pszMember, VERR_INVALID_PARAMETER); 418 AssertReturn(pOffset, VERR_INVALID_PARAMETER); 419 420 ctf_id_t TypeId = ctf_lookup_by_name(pCtfFile, pszStruct); 421 if (TypeId != CTF_ERR) 422 { 423 ctf_membinfo_t MemberInfo; 424 bzero(&MemberInfo, sizeof(MemberInfo)); 425 if (ctf_member_info(pCtfFile, TypeId, pszMember, &MemberInfo) != CTF_ERR) 426 { 427 *pOffset = (MemberInfo.ctm_offset >> 3); 428 LogRel((DEVICE_NAME ":%s::%s at %d\n", pszStruct, pszMember, *pOffset)); 429 return VINF_SUCCESS; 430 } 431 else 432 LogRel((DEVICE_NAME ":ctf_member_info failed for struct %s member %s\n", pszStruct, pszMember)); 433 } 434 else 435 LogRel((DEVICE_NAME ":ctf_lookup_by_name failed for struct %s\n", pszStruct)); 436 437 return VERR_NOT_FOUND; 438 } 439 440 441 static int 442 vboxNetFltSolarisProbeCtf(void) 443 { 444 /* 445 * CTF probing for fluid f_vnode member in file_t. 446 */ 447 int rc = VERR_INTERNAL_ERROR; 448 modctl_t *pModCtl = mod_hold_by_name("genunix"); 449 if (pModCtl) 450 { 451 int err; 452 ctf_file_t *pCtfFile = ctf_modopen(pModCtl->mod_mp, &err); 453 if (pCtfFile) 454 rc = vboxNetFltSolarisCtfGetMemberOffset(pCtfFile, "file_t", "f_vnode", &s_off_vnode); 455 else 456 LogRel((DEVICE_NAME ":ctf_modopen failed. err=%d\n", err)); 457 458 mod_release_mod(pModCtl); 459 } 460 else 461 LogRel((DEVICE_NAME ":mod_hold_by_name failed.\n")); 462 463 return rc; 464 } 465 407 466 408 467 /** … … 428 487 if (RT_SUCCESS(rc)) 429 488 { 430 /*431 * Initialize Solaris specific globals here.432 */433 g_VBoxNetFltSolarisStreams = NULL;434 g_VBoxNetFltSolarisInstance = NULL;435 g_pVBoxNetFltSolarisCred = crdup(kcred);436 if (RT_LIKELY(g_pVBoxNetFltSolarisCred))437 {438 rc = RTSemFastMutexCreate(&g_VBoxNetFltSolarisMtx);439 if (RT_ SUCCESS(rc))489 rc = vboxNetFltSolarisProbeCtf(); 490 if (RT_SUCCESS(rc)) 491 { 492 /* 493 * Initialize Solaris specific globals here. 494 */ 495 g_VBoxNetFltSolarisStreams = NULL; 496 g_VBoxNetFltSolarisInstance = NULL; 497 g_pVBoxNetFltSolarisCred = crdup(kcred); 498 if (RT_LIKELY(g_pVBoxNetFltSolarisCred)) 440 499 { 441 /* 442 * Initialize the globals and connect to the support driver. 443 * 444 * This will call back vboxNetFltOsOpenSupDrv (and maybe vboxNetFltOsCloseSupDrv) 445 * for establishing the connect to the support driver. 446 */ 447 memset(&g_VBoxNetFltSolarisGlobals, 0, sizeof(g_VBoxNetFltSolarisGlobals)); 448 rc = vboxNetFltInitGlobalsAndIdc(&g_VBoxNetFltSolarisGlobals); 500 rc = RTSemFastMutexCreate(&g_VBoxNetFltSolarisMtx); 449 501 if (RT_SUCCESS(rc)) 450 502 { 451 rc = mod_install(&g_VBoxNetFltSolarisModLinkage); 452 if (!rc) 453 return rc; 454 455 LogRel((DEVICE_NAME ":mod_install failed. rc=%d\n", rc)); 456 vboxNetFltTryDeleteIdcAndGlobals(&g_VBoxNetFltSolarisGlobals); 503 /* 504 * Initialize the globals and connect to the support driver. 505 * 506 * This will call back vboxNetFltOsOpenSupDrv (and maybe vboxNetFltOsCloseSupDrv) 507 * for establishing the connect to the support driver. 508 */ 509 memset(&g_VBoxNetFltSolarisGlobals, 0, sizeof(g_VBoxNetFltSolarisGlobals)); 510 rc = vboxNetFltInitGlobalsAndIdc(&g_VBoxNetFltSolarisGlobals); 511 if (RT_SUCCESS(rc)) 512 { 513 rc = mod_install(&g_VBoxNetFltSolarisModLinkage); 514 if (!rc) 515 return rc; 516 517 LogRel((DEVICE_NAME ":mod_install failed. rc=%d\n", rc)); 518 vboxNetFltTryDeleteIdcAndGlobals(&g_VBoxNetFltSolarisGlobals); 519 } 520 else 521 LogRel((DEVICE_NAME ":failed to initialize globals.\n")); 522 523 RTSemFastMutexDestroy(g_VBoxNetFltSolarisMtx); 524 g_VBoxNetFltSolarisMtx = NIL_RTSEMFASTMUTEX; 457 525 } 458 else459 LogRel((DEVICE_NAME ":failed to initialize globals.\n"));460 461 RTSemFastMutexDestroy(g_VBoxNetFltSolarisMtx);462 g_VBoxNetFltSolarisMtx = NIL_RTSEMFASTMUTEX;463 526 } 527 else 528 { 529 LogRel((DEVICE_NAME ":failed to allocate credentials.\n")); 530 rc = VERR_NO_MEMORY; 531 } 464 532 } 465 533 else 466 { 467 LogRel((DEVICE_NAME ":failed to allocate credentials.\n")); 468 rc = VERR_NO_MEMORY; 469 } 534 LogRel((DEVICE_NAME ":vboxNetFltSolarisProbeCtf failed. rc=%d\n", rc)); 470 535 471 536 RTR0Term(); … … 1562 1627 if ( pUser 1563 1628 && pUser->fp 1564 && pUser->fp->f_vnode)1629 && VNODE_FOR_FILE_T(pUser->fp)) 1565 1630 { 1566 *ppVNode = pUser->fp->f_vnode;1631 *ppVNode = VNODE_FOR_FILE_T(pUser->fp); 1567 1632 *ppVNodeHeld = pVNodeHeld; 1568 1633 *ppUser = pUser; … … 1572 1637 { 1573 1638 LogRel((DEVICE_NAME ":vboxNetFltSolarisOpenDev failed. pUser=%p fp=%p f_vnode=%p\n", pUser, pUser ? pUser->fp : NULL, 1574 pUser && pUser->fp ? pUser->fp->f_vnode: NULL));1639 pUser && pUser->fp ? VNODE_FOR_FILE_T(pUser->fp) : NULL)); 1575 1640 } 1576 1641 … … 2187 2252 if ( pIpFile 2188 2253 && pArpFile 2189 && pArpFile->f_vnode2190 && pIpFile->f_vnode)2254 && VNODE_FOR_FILE_T(pArpFile) 2255 && VNODE_FOR_FILE_T(pIpFile)) 2191 2256 { 2192 vnode_t *pIp4VNode = pIpFile->f_vnode;2193 vnode_t *pArpVNode = pArpFile->f_vnode;2257 vnode_t *pIp4VNode = VNODE_FOR_FILE_T(pIpFile); 2258 vnode_t *pArpVNode = VNODE_FOR_FILE_T(pArpFile); 2194 2259 2195 2260 /* … … 2431 2496 file_t *pIpFile = getf(Ip6MuxFd); 2432 2497 if ( pIpFile 2433 && pIpFile->f_vnode)2498 && VNODE_FOR_FILE_T(pIpFile)) 2434 2499 { 2435 vnode_t *pIp6VNode = pIpFile->f_vnode;2500 vnode_t *pIp6VNode = VNODE_FOR_FILE_T(pIpFile); 2436 2501 2437 2502 /*
Note:
See TracChangeset
for help on using the changeset viewer.