Changeset 29469 in vbox
- Timestamp:
- May 14, 2010 12:30:51 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Config.kmk
r29430 r29469 595 595 VBOX_SOLARIS_NSL_RESOLVED = 1 596 596 ifeq ($(KBUILD_TARGET),solaris) 597 VBOX_WITH_NETFLT_CROSSBOW = 1 597 # Disabled until some Nevada version ships the required headers. 598 # VBOX_WITH_NETFLT_CROSSBOW = 1 598 599 endif 599 600 if1of ($(KBUILD_TARGET), darwin freebsd linux solaris) -
trunk/src/VBox/HostDrivers/VBoxNetFlt/solaris/VBoxNetFltBow-solaris.c
r28830 r29469 46 46 #include <sys/sunddi.h> 47 47 48 #include <sys/vnic_mgmt.h> 49 #include <sys/mac_client.h> 50 #include <sys/mac_provider.h> 51 #include <sys/dls.h> 52 53 #if 0 48 54 #include "include/mac_provider.h" /* dependency for other headers */ 49 55 #include "include/mac_client.h" /* for mac_* */ 50 56 #include "include/mac_client_priv.h" /* for mac_info, mac_capab_get etc. */ 51 #if 057 #if 1 52 58 #include "include/dls.h" /* for dls_mgmt_* */ 53 59 #include "include/dld_ioc.h" /* required by vnic.h */ 54 60 #include "include/vnic.h" /* for vnic_ioc_diag_t */ 55 61 #include "include/vnic_impl.h" /* for vnic_dev_create */ 62 #endif 56 63 #endif 57 64 … … 69 76 #define VBOXFLT_VNIC_NAME "vboxvnic" 70 77 /** Debugging switch for using symbols in kmdb */ 71 # define LOCAL static78 # define LOCAL static 72 79 73 80 #if defined(DEBUG_ramshankar) … … 79 86 # define LOCAL 80 87 #endif 88 89 /** VLAN tag masking, should probably be in IPRT? */ 90 #define VLAN_ID(vlan) (((vlan) >> 0) & 0x0fffu) 91 #define VLAN_CFI(vlan) (((vlan) >> 12) & 0x0001u) 92 #define VLAN_PRI(vlan) (((vlan) >> 13) & 0x0007u) 93 #define VLAN_TAG(pri,cfi,vid) (((pri) << 13) | ((cfi) << 12) | ((vid) << 0)) 94 95 typedef struct VLANHEADER 96 { 97 uint16_t Type; 98 uint16_t Data; 99 } VLANHEADER; 100 typedef struct VLANHEADER *PVLANHEADER; 81 101 82 102 … … 521 541 * @param pMsg Pointer to the message to analyze and dump. 522 542 */ 523 staticvoid vboxNetFltSolarisAnalyzeMBlk(mblk_t *pMsg)524 { 525 LogFlow ((DEVICE_NAME ":vboxNetFltSolarisAnalyzeMBlk pMsg=%p\n", pMsg));543 LOCAL void vboxNetFltSolarisAnalyzeMBlk(mblk_t *pMsg) 544 { 545 LogFlowFunc((DEVICE_NAME ":vboxNetFltSolarisAnalyzeMBlk pMsg=%p\n", pMsg)); 526 546 527 547 PCRTNETETHERHDR pEthHdr = (PCRTNETETHERHDR)pMsg->b_rptr; … … 533 553 { 534 554 if (pIpHdr->ip_p == RTNETIPV4_PROT_ICMP) 535 Log Flow((DEVICE_NAME ":ICMP D=%.6Rhxs S=%.6Rhxs T=%04x\n", pb, pb + 6, RT_BE2H_U16(*(uint16_t *)(pb + 12))));555 LogRel((DEVICE_NAME ":ICMP D=%.6Rhxs S=%.6Rhxs T=%04x\n", pb, pb + 6, RT_BE2H_U16(*(uint16_t *)(pb + 12)))); 536 556 else if (pIpHdr->ip_p == RTNETIPV4_PROT_TCP) 537 Log Flow((DEVICE_NAME ":TCP D=%.6Rhxs S=%.6Rhxs\n", pb, pb + 6));557 LogRel((DEVICE_NAME ":TCP D=%.6Rhxs S=%.6Rhxs\n", pb, pb + 6)); 538 558 else if (pIpHdr->ip_p == RTNETIPV4_PROT_UDP) 539 559 { … … 554 574 else if (pEthHdr->EtherType == RT_H2BE_U16(RTNET_ETHERTYPE_VLAN)) 555 575 { 556 typedef struct VLANHEADER 557 { 558 int Pcp:3; 559 int Cfi:1; 560 int Vid:12; 561 } VLANHEADER; 562 563 VLANHEADER *pVlanHdr = (VLANHEADER *)(pMsg->b_rptr + sizeof(RTNETETHERHDR)); 564 LogFlow((DEVICE_NAME ":VLAN Pcp=%d Cfi=%d Id=%d\n", pVlanHdr->Pcp, pVlanHdr->Cfi, pVlanHdr->Vid >> 4)); 565 LogFlow((DEVICE_NAME "%.*Rhxd\n", MBLKL(pMsg), pMsg->b_rptr)); 576 PVLANHEADER pVlanHdr = (PVLANHEADER)(pMsg->b_rptr + sizeof(RTNETETHERHDR) - sizeof(pEthHdr->EtherType)); 577 LogRel((DEVICE_NAME ":VLAN Pcp=%u Cfi=%u Id=%u\n", VLAN_PRI(RT_BE2H_U16(pVlanHdr->Data)), VLAN_CFI(RT_BE2H_U16(pVlanHdr->Data)), VLAN_ID(RT_BE2H_U16(pVlanHdr->Data)))); 578 LogRel((DEVICE_NAME "%.*Rhxd\n", sizeof(VLANHEADER), pVlanHdr)); 566 579 } 567 580 else if (pEthHdr->EtherType == RT_H2BE_U16(RTNET_ETHERTYPE_ARP)) 568 581 { 569 582 PRTNETARPHDR pArpHdr = (PRTNETARPHDR)(pEthHdr + 1); 570 Log Flow((DEVICE_NAME ":ARP Op=%d\n", pArpHdr->ar_oper));583 LogRel((DEVICE_NAME ":ARP Op=%d\n", pArpHdr->ar_oper)); 571 584 } 572 585 else if (pEthHdr->EtherType == RT_H2BE_U16(RTNET_ETHERTYPE_IPV6)) 573 586 { 574 Log Flow((DEVICE_NAME ":IPv6 D=%.6Rhxs S=%.6Rhxs\n", pb, pb + 6));587 LogRel((DEVICE_NAME ":IPv6 D=%.6Rhxs S=%.6Rhxs\n", pb, pb + 6)); 575 588 } 576 589 else if (pEthHdr->EtherType == RT_H2BE_U16(RTNET_ETHERTYPE_IPX_1) … … 578 591 || pEthHdr->EtherType == RT_H2BE_U16(RTNET_ETHERTYPE_IPX_3)) 579 592 { 580 Log Flow((DEVICE_NAME ":IPX packet.\n"));593 LogRel((DEVICE_NAME ":IPX packet.\n")); 581 594 } 582 595 else 583 596 { 584 Log Flow((DEVICE_NAME ":Unknown EtherType=%x D=%.6Rhxs S=%.6Rhxs\n", RT_H2BE_U16(pEthHdr->EtherType), &pEthHdr->DstMac,597 LogRel((DEVICE_NAME ":Unknown EtherType=%x D=%.6Rhxs S=%.6Rhxs\n", RT_H2BE_U16(pEthHdr->EtherType), &pEthHdr->DstMac, 585 598 &pEthHdr->SrcMac)); 586 599 /* LogFlow((DEVICE_NAME ":%.*Rhxd\n", MBLKL(pMsg), pMsg->b_rptr)); */ … … 631 644 * Route all received packets into the internal network. 632 645 */ 633 unsigned cSegs = vboxNetFltSolarisMBlkCalcSGSegs(pThis, pMsg); 634 PINTNETSG pSG = (PINTNETSG)alloca(RT_OFFSETOF(INTNETSG, aSegs[cSegs])); 635 int rc = vboxNetFltSolarisMBlkToSG(pThis, pMsg, pSG, cSegs, fSrc); 636 if (RT_SUCCESS(rc)) 637 pThis->pSwitchPort->pfnRecv(pThis->pSwitchPort, pSG, fSrc); 646 uint16_t cFailed = 0; 647 for (mblk_t *pCurMsg = pMsg; pCurMsg != NULL; pCurMsg = pCurMsg->b_next) 648 { 649 unsigned cSegs = vboxNetFltSolarisMBlkCalcSGSegs(pThis, pCurMsg); 650 PINTNETSG pSG = (PINTNETSG)alloca(RT_OFFSETOF(INTNETSG, aSegs[cSegs])); 651 int rc = vboxNetFltSolarisMBlkToSG(pThis, pMsg, pSG, cSegs, fSrc); 652 if (RT_SUCCESS(rc)) 653 pThis->pSwitchPort->pfnRecv(pThis->pSwitchPort, pSG, fSrc); 654 else 655 cFailed++; 656 } 657 vboxNetFltRelease(pThis, true /* fBusy */); 658 659 if (RT_UNLIKELY(cFailed)) 660 LogRel((DEVICE_NAME ":vboxNetFltSolarisMBlkToSG failed for %u packets.\n", cFailed)); 661 662 freemsgchain(pMsg); 663 664 NOREF(hResource); 665 } 666 667 668 /** 669 * Destroy a created VNIC. 670 * 671 * @param pThis The VM connection instance. 672 */ 673 LOCAL void vboxNetFltSolarisDestroyVNIC(PVBOXNETFLTINS pThis) 674 { 675 if (pThis->u.s.fCreatedVNIC) 676 { 677 vnic_delete(pThis->u.s.VNICLinkId, 0 /* Flags */); 678 pThis->u.s.VNICLinkId = DATALINK_INVALID_LINKID; 679 pThis->u.s.fCreatedVNIC = false; 680 } 681 } 682 683 684 /** 685 * Create a non-persistent VNIC over the given interface. 686 * 687 * @param pThis The VM connection instance. 688 * 689 * @returns corresponding VBox error code. 690 */ 691 LOCAL int vboxNetFltSolarisCreateVNIC(PVBOXNETFLTINS pThis) 692 { 693 LogFlow((DEVICE_NAME ":vboxNetFltSolarisCreateVNIC pThis=%p\n", pThis)); 694 695 char szVNICName[sizeof(VBOXFLT_VNIC_NAME) + 32]; 696 RTStrPrintf(szVNICName, sizeof(szVNICName), "%s%d", VBOXFLT_VNIC_NAME, pThis->u.s.uInstance); 697 698 /* -XXX- @todo remove hardcoded Guest MAC address, should be sent from guest later. */ 699 RTMAC GuestMac; 700 GuestMac.au8[0] = 0x08; 701 GuestMac.au8[1] = 0x00; 702 GuestMac.au8[2] = 0x27; 703 GuestMac.au8[3] = 0xFE; 704 GuestMac.au8[4] = 0x21; 705 GuestMac.au8[5] = 0x03; 706 707 AssertCompile(sizeof(RTMAC) <= MAXMACADDRLEN); 708 uchar_t MacAddr[MAXMACADDRLEN]; 709 bzero(MacAddr, sizeof(MacAddr)); 710 bcopy(GuestMac.au8, MacAddr, RT_MIN(sizeof(GuestMac), sizeof(MacAddr))); 711 712 vnic_mac_addr_type_t AddrType = VNIC_MAC_ADDR_TYPE_FIXED; 713 vnic_ioc_diag_t Diag = VNIC_IOC_DIAG_NONE; 714 int MacSlot = 0; 715 int MacLen = sizeof(GuestMac); 716 uint32_t fFlags = 0; /* no VNIC_IOC_CREATE_NODUPCHECK */ 717 int rc = vnic_create(szVNICName, pThis->szName, &AddrType, &MacLen, MacAddr, &MacSlot, 0 /* Mac-Prefix Length */, 0 /* VLAN-ID */, 718 fFlags, &pThis->u.s.VNICLinkId, &Diag, NULL /* Reserved */); 719 if (!rc) 720 { 721 pThis->u.s.fCreatedVNIC = true; 722 pThis->u.s.uInstance++; 723 724 /* 725 * Now try opening the created VNIC. 726 */ 727 rc = mac_open_by_linkid(pThis->u.s.VNICLinkId, &pThis->u.s.hInterface); 728 if (!rc) 729 { 730 Assert(pThis->u.s.hInterface); 731 LogFlow((DEVICE_NAME ":vboxNetFltSolarisCreateVNIC successfully created VNIC '%s' over '%s'\n", szVNICName, pThis->szName)); 732 return VINF_SUCCESS; 733 } 734 else 735 { 736 LogRel((DEVICE_NAME ":vboxNetFltSolarisCreateVNIC failed to open VNIC '%s' over '%s'. rc=%d\n", szVNICName, 737 pThis->szName, rc)); 738 } 739 740 vboxNetFltSolarisDestroyVNIC(pThis); 741 rc = VERR_INTNET_FLT_IF_FAILED; 742 } 638 743 else 639 LogRel((DEVICE_NAME ":vboxNetFltSolarisMBlkToSG failed. rc=%d\n", rc)); 640 641 vboxNetFltRelease(pThis, true /* fBusy */); 642 freemsgchain(pMsg); 643 644 NOREF(hResource); 645 } 646 647 648 /** 649 * Create a VNIC dynamically over the given interface. 650 * 651 * @param pThis The VM connection instance. 652 * 653 * @returns corresponding VBox error code. 654 */ 655 LOCAL int vboxNetFltSolarisCreateVNIC(PVBOXNETFLTINS pThis) 656 { 657 #if 0 658 LogFlow((DEVICE_NAME ":vboxNetFltSolarisCreateVNIC pThis=%p\n", pThis)); 659 660 datalink_id_t InterfaceLinkId; 661 int rc = dls_mgmt_get_linkid(pThis->szName, &InterfaceLinkId); 662 if (!rc) 663 { 664 dev_t DeviceNum = makedevice(ddi_driver_major(g_pVBoxNetFltSolarisDip), pThis->u.s.uInstance); 665 char szVNICName[sizeof(VBOXFLT_VNIC_NAME) + 16]; 666 RTStrPrintf(szVNICName, sizeof(szVNICName), "%s%d", VBOXFLT_VNIC_NAME, pThis->u.s.uInstance); 667 LogRel((DEVICE_NAME ":vboxNetFltSolarisCreateVNIC Creating VNIC '%s' over '%s'\n", szVNICName, pThis->szName)); 668 rc = dls_mgmt_create(szVNICName, DeviceNum, DATALINK_CLASS_VNIC, DL_ETHER, B_FALSE /* Persist */, &pThis->u.s.VNICLinkId); 669 if (!rc) 670 { 671 /* -XXX- @todo remove hardcoded Guest MAC address, should be sent from guest later. */ 672 RTMAC GuestMac; 673 GuestMac.au8[0] = 0x08; 674 GuestMac.au8[1] = 0x00; 675 GuestMac.au8[2] = 0x27; 676 GuestMac.au8[3] = 0xFE; 677 GuestMac.au8[4] = 0x21; 678 GuestMac.au8[5] = 0x03; 679 680 AssertCompile(sizeof(RTMAC) <= MAXMACADDRLEN); 681 uchar_t MacAddr[MAXMACADDRLEN]; 682 bzero(MacAddr, sizeof(MacAddr)); 683 bcopy(GuestMac.au8, MacAddr, RT_MIN(sizeof(GuestMac), sizeof(MacAddr))); 684 685 int MacSlot = 0; 686 vnic_ioc_diag_t Diag = VNIC_IOC_DIAG_NONE; 687 vnic_mac_addr_type_t MacAddrType = VNIC_MAC_ADDR_TYPE_FIXED; 688 int cbMac = sizeof(RTMAC); 689 int fFlags = VNIC_IOC_CREATE_NODUPCHECK | VNIC_IOC_CREATE_REQ_HWRINGS; 690 rc = vnic_dev_create(pThis->u.s.VNICLinkId, InterfaceLinkId, &MacAddrType, &cbMac, MacAddr, 691 &MacSlot, 0 /* Mac Prefix */, 0 /* VLAN Id */, NULL /* Resources Caps */, 692 fFlags, &Diag, kcred); 693 if (rc) 694 { 695 if (Diag == VNIC_IOC_DIAG_NO_HWRINGS) 696 { 697 /* 698 * No hardware rings available, retry without requesting hardware ring. 699 */ 700 LogRel((DEVICE_NAME ":vboxNetFltSolarisCreateVNIC No hardware rings available for VNIC over '%s'. Recreating VNIC '%s'\n", pThis->szName, 701 szVNICName)); 702 703 fFlags = VNIC_IOC_CREATE_NODUPCHECK; 704 rc = vnic_dev_create(pThis->u.s.VNICLinkId, InterfaceLinkId, &MacAddrType, &cbMac, MacAddr, 705 &MacSlot, 0 /* Mac Prefix */, 0 /* VLAN Id */, NULL /* Resources Caps */, 706 fFlags, &Diag, kcred); 707 } 708 } 709 710 if (!rc) 711 { 712 pThis->u.s.fCreatedVNIC = true; 713 pThis->u.s.uInstance++; 714 LogFlow((DEVICE_NAME ":vboxNetFltSolarisCreateVNIC successfully created VNIC '%s' over '%s'\n", "vboxvnic", pThis->szName)); 715 return VINF_SUCCESS; 716 } 717 else 718 { 719 LogRel((DEVICE_NAME ":vboxNetFltSolarisCreateVNIC failed to create VNIC over '%s'. rc=%d Diagnosis=%d\n", pThis->szName, 720 rc, Diag)); 721 rc = VERR_INTNET_FLT_VNIC_CREATE_FAILED; 722 } 723 724 dls_mgmt_destroy(pThis->u.s.VNICLinkId, B_FALSE /* Persist */); 725 } 726 else 727 { 728 LogRel((DEVICE_NAME ":vboxNetFltSolarisCreateVNIC failed to create a link id for a VNIC over '%s' rc=%d\n", pThis->szName, rc)); 729 rc = VERR_INTNET_FLT_VNIC_CREATE_FAILED; 730 } 731 } 732 else 733 { 734 LogRel((DEVICE_NAME ":vboxNetFltSolarisCreateVNIC failed to find interface '%s' rc=%d\n", pThis->szName, rc)); 735 rc = VERR_INTNET_FLT_IF_NOT_FOUND; 744 { 745 LogRel((DEVICE_NAME ":vboxNetFltSolarisCreateVNIC failed! rc=%d Diag=%d\n", rc, (int)Diag)); 746 rc = VERR_INTNET_FLT_IF_FAILED; 736 747 } 737 748 738 749 return rc; 739 #endif740 750 } 741 751 … … 772 782 pThis->u.s.hInterface = NULL; 773 783 rc = vboxNetFltSolarisCreateVNIC(pThis); 774 if (RT_SUCCESS(rc))775 rc = mac_open_by_linkid(pThis->u.s.VNICLinkId, &pThis->u.s.hInterface);776 else777 {778 pThis->u.s.hInterface = NULL;779 LogRel((DEVICE_NAME ":vboxNetFltSolarisAttachToInterface failed to create VNIC. rc=%Rrc\n", rc));780 }781 784 } 782 785 else … … 789 792 if (RT_SUCCESS(rc)) 790 793 { 791 const mac_info_t *pMacInfo = mac_info(pThis->u.s.hInterface); 792 if (RT_LIKELY(pMacInfo)) 794 /* 795 * Obtain the MAC address of the interface. 796 */ 797 Assert(pThis->u.s.hInterface); 798 AssertCompile(sizeof(RTMAC) == ETHERADDRL); 799 mac_unicast_primary_get(pThis->u.s.hInterface, (uint8_t *)&pThis->u.s.MacAddr.au8); 800 801 LogFlow((DEVICE_NAME ":vboxNetFltSolarisAttachToInterface MAC address of %s is %.*Rhxs\n", pThis->szName, 802 sizeof(pThis->u.s.MacAddr), &pThis->u.s.MacAddr)); 803 804 /** @todo Obtain the MTU size using mac_sdu_get() */ 805 /** @todo Obtain capabilities (hardware checksum etc.) using mac_capab_get() */ 806 807 /* 808 * Open a client connection to the lower MAC interface. 809 */ 810 rc = mac_client_open(pThis->u.s.hInterface, &pThis->u.s.hClient, 811 NULL, /* name of this client */ 812 MAC_OPEN_FLAGS_USE_DATALINK_NAME | /* client name same as underlying NIC */ 813 MAC_OPEN_FLAGS_MULTI_PRIMARY /* allow multiple primary unicasts */ 814 ); 815 if (RT_LIKELY(!rc)) 793 816 { 794 if ( pMacInfo->mi_media == DL_ETHER 795 && pMacInfo->mi_nativemedia == DL_ETHER) 817 /** @todo -XXX- if possible we must move unicast_add and rx_set to when the Guest advertises it's MAC to us. */ 818 819 /* 820 * Set a unicast address for this client and the packet receive callback. 821 * We want to use the primary unicast address of the underlying interface (VNIC) hence we pass NULL. 822 * Also we don't really set the RX function here, this is done when we activate promiscuous mode. 823 */ 824 mac_diag_t MacDiag; 825 rc = mac_unicast_add(pThis->u.s.hClient, NULL /* MAC Address */, 826 MAC_UNICAST_PRIMARY | MAC_UNICAST_STRIP_DISABLE | 827 MAC_UNICAST_DISABLE_TX_VID_CHECK | MAC_UNICAST_NODUPCHECK | MAC_UNICAST_HW, 828 &pThis->u.s.hUnicast, 0 /* VLAN id */, &MacDiag); 829 if (!rc) 796 830 { 831 if (vboxNetFltTryRetainBusyNotDisconnected(pThis)) 832 { 833 Assert(pThis->pSwitchPort); 834 pThis->pSwitchPort->pfnReportMacAddress(pThis->pSwitchPort, &pThis->u.s.MacAddr); 835 pThis->pSwitchPort->pfnReportPromiscuousMode(pThis->pSwitchPort, false); /** @todo Promisc */ 836 pThis->pSwitchPort->pfnReportGsoCapabilities(pThis->pSwitchPort, 0, INTNETTRUNKDIR_WIRE | INTNETTRUNKDIR_HOST); 837 pThis->pSwitchPort->pfnReportNoPreemptDsts(pThis->pSwitchPort, 0 /* none */); 838 vboxNetFltRelease(pThis, true /*fBusy*/); 839 } 840 797 841 /* 798 * Obtain the MAC address of the interface.842 * If the user passed in the VNIC, we need to obtain the datalink ID now. 799 843 */ 800 AssertCompile(sizeof(RTMAC) == ETHERADDRL); 801 mac_unicast_primary_get(pThis->u.s.hInterface, (uint8_t *)&pThis->u.s.MacAddr.au8); 802 803 LogFlow((DEVICE_NAME ":vboxNetFltSolarisAttachToInterface MAC address of %s is %.*Rhxs\n", pThis->szName, 804 sizeof(pThis->u.s.MacAddr), &pThis->u.s.MacAddr)); 805 806 /** @todo Obtain the MTU size using mac_sdu_get() */ 807 /** @todo Obtain capabilities (hardware checksum etc.) using mac_capab_get() */ 808 809 /* 810 * Open a client connection to the lower MAC interface. 811 */ 812 rc = mac_client_open(pThis->u.s.hInterface, &pThis->u.s.hClient, 813 NULL /* name of this client */, 814 MAC_OPEN_FLAGS_USE_DATALINK_NAME | /* client name same as underlying NIC */ 815 MAC_OPEN_FLAGS_MULTI_PRIMARY /* allow multiple primary unicasts */ 816 ); 817 if (RT_LIKELY(!rc)) 844 if (pThis->u.s.fCreatedVNIC == false) 845 rc = dls_mgmt_get_linkid(pThis->szName, &pThis->u.s.VNICLinkId); 846 847 if (!rc) 818 848 { 819 /** @todo -XXX- if possible we must move unicast_add and rx_set to when the Guest advertises it's MAC to us. */820 821 849 /* 822 * Set a unicast address for this client and the packet receive callback. 823 * We want to use the primary unicast address of the underlying interface (VNIC) hence we pass NULL. 824 * Also we don't really set the RX function here, this is done when we activate promiscuous mode. 850 * Modify the MAC address of the VNIC to match the guest's MAC address 825 851 */ 826 mac_diag_t MacDiag; 827 rc = mac_unicast_add(pThis->u.s.hClient, NULL /* MAC Address */, 828 MAC_UNICAST_PRIMARY | MAC_UNICAST_STRIP_DISABLE | 829 MAC_UNICAST_DISABLE_TX_VID_CHECK | MAC_UNICAST_NODUPCHECK | MAC_UNICAST_HW, 830 &pThis->u.s.hUnicast, 0 /* VLAN id */, &MacDiag); 852 LogRel((DEVICE_NAME ":vboxNetFltSolarisAttachToInterface success!\n")); 853 854 RTMAC GuestMac; 855 GuestMac.au8[0] = 0x08; 856 GuestMac.au8[1] = 0x00; 857 GuestMac.au8[2] = 0x27; 858 GuestMac.au8[3] = 0xFE; 859 GuestMac.au8[4] = 0x21; 860 GuestMac.au8[5] = 0x03; 861 862 uchar_t MacAddr[MAXMACADDRLEN]; 863 bcopy(GuestMac.au8, MacAddr, sizeof(GuestMac)); 864 865 vnic_mac_addr_type_t AddrType = VNIC_MAC_ADDR_TYPE_FIXED; 866 vnic_ioc_diag_t Result = VNIC_IOC_DIAG_NONE; 867 int MacSlot = 0; 868 int MacLen = sizeof(GuestMac); 869 rc = vnic_modify_addr(pThis->u.s.VNICLinkId, &AddrType, &MacLen, MacAddr, &MacSlot, 0 /* Mac-Prefix Length */, &Result); 831 870 if (!rc) 832 871 { 833 /*834 * Report MAC address, promiscuous mode and capabilities.835 */ 836 if (vboxNetFltTryRetainBusyNotDisconnected(pThis))837 {838 Assert(pThis->pSwitchPort);839 pThis->pSwitchPort->pfnReportMacAddress(pThis->pSwitchPort, &pThis->u.s.MacAddr);840 pThis->pSwitchPort->pfnReportPromiscuousMode(pThis->pSwitchPort, false); /** @todo Promisc */841 pThis->pSwitchPort->pfnReportGsoCapabilities(pThis->pSwitchPort, 0, INTNETTRUNKDIR_WIRE | INTNETTRUNKDIR_HOST);842 pThis->pSwitchPort->pfnReportNoPreemptDsts(pThis->pSwitchPort, 0 /* none */); 843 vboxNetFltRelease(pThis, true /*fBusy*/);844 }845 846 Log Flow((DEVICE_NAME ":vboxNetFltSolarisAttachToInterface successfully attached over '%s'\n", pThis->szName));847 return VINF_SUCCESS;872 LogRel((DEVICE_NAME ":vboxNetFltSolarisAttachToInterface vnic_modify successful %s mac %.*Rhxs\n", pThis->szName, 873 sizeof(GuestMac), &GuestMac)); 874 875 mac_unicast_remove(pThis->u.s.hClient, pThis->u.s.hUnicast); 876 pThis->u.s.hUnicast = NULL; 877 rc = mac_unicast_add(pThis->u.s.hClient, NULL /* MAC Address */, 878 MAC_UNICAST_PRIMARY | MAC_UNICAST_STRIP_DISABLE | 879 MAC_UNICAST_DISABLE_TX_VID_CHECK | MAC_UNICAST_NODUPCHECK | MAC_UNICAST_HW, 880 &pThis->u.s.hUnicast, 0 /* VLAN id */, &MacDiag); 881 882 if (!rc) 883 return VINF_SUCCESS; 884 885 LogRel((DEVICE_NAME ":vboxNetFltSolarisAttachToInterface failed to set client MAC address (2) '%s' rc=%d\n", 886 pThis->szName, rc)); 848 887 } 849 850 LogRel((DEVICE_NAME ":vboxNetFltSolarisAttachToInterface failed to set client MAC address over link '%s' rc=%d\n", 851 pThis->szName, rc)); 852 853 mac_client_close(pThis->u.s.hClient, 0 /* fFlags */); 854 pThis->u.s.hClient = NULL; 888 else 889 { 890 LogRel((DEVICE_NAME ":vboxNetFltSolarisAttachToInterface failed to modify MAC address for VNIC over '%s' rc=%d\n", 891 pThis->szName, rc)); 892 } 855 893 } 856 894 else 857 895 { 858 LogRel((DEVICE_NAME ":vboxNetFltSolarisAttachToInterface failed to create client over link'%s' rc=%d\n",859 pThis->szName, rc));896 LogRel((DEVICE_NAME ":vboxNetFltSolarisAttachToInterface failed to obtain VNIC link id for '%s' rc=%d\n", 897 pThis->szName, rc)); 860 898 } 861 899 } 862 900 else 863 {864 LogRel((DEVICE_NAME ":vboxNetFltSolarisAttachToInterface media type incompatible: %d %d\n", pMacInfo->mi_media,865 pMacInfo->mi_nativemedia)); 866 rc = EPROTO;867 }901 LogRel((DEVICE_NAME ":vboxNetFltSolarisAttachToInterface failed to set client MAC address over link '%s' rc=%d\n", 902 pThis->szName, rc)); 903 904 mac_client_close(pThis->u.s.hClient, 0 /* fFlags */); 905 pThis->u.s.hClient = NULL; 868 906 } 869 907 else 870 908 { 871 LogRel((DEVICE_NAME ":vboxNetFltSolarisAttachToInterface failed to obtain info for link '%s'\n", pThis->szName));872 rc = ENXIO;909 LogRel((DEVICE_NAME ":vboxNetFltSolarisAttachToInterface failed to create client over link '%s' rc=%d\n", 910 pThis->szName, rc)); 873 911 } 874 912 } … … 884 922 pThis->u.s.hInterface = NULL; 885 923 } 924 925 vboxNetFltSolarisDestroyVNIC(pThis); 886 926 } 887 927 else … … 929 969 } 930 970 931 if (pThis->u.s.fCreatedVNIC) 932 { 933 #if 0 934 vnic_dev_delete(pThis->u.s.VNICLinkId, 0 /* Flags -- ununsed in snv_127 */, kcred); 935 dls_mgmt_destroy(pThis->u.s.VNICLinkId, B_FALSE /* Persist */); 936 pThis->u.s.VNICLinkId = DATALINK_INVALID_LINKID; 937 pThis->u.s.fCreatedVNIC = false; 938 #endif 939 } 971 vboxNetFltSolarisDestroyVNIC(pThis); 940 972 } 941 973
Note:
See TracChangeset
for help on using the changeset viewer.