Changeset 29691 in vbox for trunk/src/VBox/HostDrivers/VBoxNetFlt/solaris/VBoxNetFltBow-solaris.c
- Timestamp:
- May 20, 2010 12:38:20 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxNetFlt/solaris/VBoxNetFltBow-solaris.c
r29662 r29691 178 178 }; 179 179 180 /** 181 * VBOXNETFLTVNIC: Per-VNIC instance data. 182 */ 183 typedef struct VBOXNETFLTVNIC 184 { 185 void *pvIf; /* The VirtualBox interface */ 186 mac_handle_t hInterface; /* The lower MAC handle */ 187 datalink_id_t hLinkId; /* The link ID */ 188 mac_client_handle_t hClient; /* Client handle */ 189 mac_unicast_handle_t hUnicast; /* Unicast address handle */ 190 mac_promisc_handle_t hPromiscuous; /* Promiscuous handle */ 191 list_node_t hNode; /* Handle to the next VNIC in the list */ 192 } VBOXNETFLTVNIC; 193 typedef struct VBOXNETFLTVNIC *PVBOXNETFLTVNIC; 194 180 195 181 196 /******************************************************************************* … … 673 688 LOCAL void vboxNetFltSolarisDestroyVNIC(PVBOXNETFLTINS pThis) 674 689 { 690 #if 0 675 691 if (pThis->u.s.fCreatedVNIC) 676 692 { … … 679 695 pThis->u.s.fCreatedVNIC = false; 680 696 } 697 #endif 681 698 } 682 699 … … 691 708 LOCAL int vboxNetFltSolarisCreateVNIC(PVBOXNETFLTINS pThis) 692 709 { 710 #if 0 693 711 LogFlow((DEVICE_NAME ":vboxNetFltSolarisCreateVNIC pThis=%p\n", pThis)); 694 712 … … 748 766 749 767 return rc; 768 #endif 750 769 } 751 770 … … 761 780 LOCAL int vboxNetFltSolarisAttachToInterface(PVBOXNETFLTINS pThis, bool fRediscovery) 762 781 { 782 #if 0 763 783 LogFlow((DEVICE_NAME ":vboxNetFltSolarisAttachToInterface pThis=%p fRediscovery=%d\n", pThis, fRediscovery)); 764 784 … … 929 949 930 950 return RTErrConvertFromErrno(rc); 951 #endif 931 952 } 932 953 … … 941 962 LOCAL int vboxNetFltSolarisDetachFromInterface(PVBOXNETFLTINS pThis) 942 963 { 964 #if 0 943 965 AssertPtrReturn(pThis, VERR_INVALID_POINTER); 944 966 … … 970 992 971 993 vboxNetFltSolarisDestroyVNIC(pThis); 994 #endif 972 995 } 973 996 … … 979 1002 { 980 1003 LogFlow((DEVICE_NAME ":vboxNetFltPortOsSetActive pThis=%p fActive=%d\n", pThis, fActive)); 981 1004 #if 0 982 1005 if (fActive) 983 1006 { … … 1004 1027 } 1005 1028 } 1029 #endif 1006 1030 } 1007 1031 … … 1010 1034 { 1011 1035 LogFlow((DEVICE_NAME ":vboxNetFltOsDisconnectIt pThis=%p\n", pThis)); 1012 return vboxNetFltSolarisDetachFromInterface(pThis); 1036 // return vboxNetFltSolarisDetachFromInterface(pThis); 1037 return VINF_SUCCESS; 1013 1038 } 1014 1039 … … 1017 1042 { 1018 1043 LogFlow((DEVICE_NAME ":vboxNetFltOsConnectIt pThis=%p\n", pThis)); 1019 return vboxNetFltSolarisAttachToInterface(pThis, false /* fRediscovery */); 1044 // return vboxNetFltSolarisAttachToInterface(pThis, false /* fRediscovery */); 1045 return VINF_SUCCESS; 1020 1046 } 1021 1047 … … 1024 1050 { 1025 1051 LogFlow((DEVICE_NAME ":vboxNetFltOsDeleteInstance pThis=%p\n", pThis)); 1052 1053 /* 1054 * If this is a VNIC remove the callbacks and close it. 1055 */ 1056 if (pThis->u.s.fIsVNIC) 1057 { 1058 if (pThis->u.s.hPromiscuous) 1059 { 1060 mac_promisc_remove(pThis->u.s.hPromiscuous); 1061 pThis->u.s.hPromiscuous = NULL; 1062 } 1063 1064 if (pThis->u.s.hClient) 1065 { 1066 if (pThis->u.s.hUnicast) 1067 { 1068 mac_unicast_remove(pThis->u.s.hClient, pThis->u.s.hUnicast); 1069 pThis->u.s.hUnicast = NULL; 1070 } 1071 1072 mac_rx_clear(pThis->u.s.hClient); 1073 1074 mac_client_close(pThis->u.s.hClient, 0 /* fFlags */); 1075 pThis->u.s.hClient = NULL; 1076 } 1077 1078 if (pThis->u.s.hInterface) 1079 { 1080 mac_close(pThis->u.s.hInterface); 1081 pThis->u.s.hInterface = NULL; 1082 } 1083 } 1084 1085 /** @todo clean-up for physical interfaces */ 1026 1086 } 1027 1087 … … 1031 1091 LogFlow((DEVICE_NAME ":vboxNetFltOsInitInstance pThis=%p pvContext=%p\n", pThis, pvContext)); 1032 1092 1033 return VINF_SUCCESS; 1093 /* 1094 * Figure out if the interface is a VNIC or a physical/etherstub/whatever NIC. 1095 */ 1096 int rc = mac_open_by_linkname(pThis->szName, &pThis->u.s.hInterface); 1097 if (RT_LIKELY(!rc)) 1098 { 1099 /* 1100 * Check if this is a VNIC. If it's not we will create a VNIC per guest interface 1101 * later (see vboxNetFltPortOsConnectInterface). 1102 */ 1103 rc = mac_is_vnic(pThis->u.s.hInterface); 1104 if (!rc) 1105 { 1106 mac_close(pThis->u.s.hInterface); 1107 pThis->u.s.hInterface = NULL; 1108 pThis->u.s.fIsVNIC = false; 1109 return VINF_SUCCESS; 1110 } 1111 1112 /* 1113 * User has passed in a VNIC, we can proceed to open it. 1114 * Open a client connection to the lower MAC interface. 1115 */ 1116 pThis->u.s.fIsVNIC = true; 1117 rc = mac_client_open(pThis->u.s.hInterface, &pThis->u.s.hClient, 1118 NULL, /* name of this client */ 1119 MAC_OPEN_FLAGS_USE_DATALINK_NAME | /* client name same as underlying NIC */ 1120 MAC_OPEN_FLAGS_MULTI_PRIMARY /* allow multiple primary unicasts */ 1121 ); 1122 if (RT_LIKELY(!rc)) 1123 { 1124 /* 1125 * Obtain the data link ID for this VNIC, it's needed for modifying the MAC address among other things. 1126 */ 1127 rc = dls_mgmt_get_linkid(pThis->szName, &pThis->u.s.hLinkId); 1128 if (RT_LIKELY(!rc)) 1129 { 1130 /* 1131 * Set the RX callback. 1132 */ 1133 mac_diag_t Diag = MAC_DIAG_NONE; 1134 rc = mac_unicast_add_set_rx(pThis->u.s.hClient, 1135 NULL /* MAC address, use existing VNIC address */, 1136 MAC_UNICAST_PRIMARY | /* Use Primary address of the VNIC */ 1137 MAC_UNICAST_NODUPCHECK, /* Don't fail for conflicting MAC/VLAN-id combinations */ 1138 &pThis->u.s.hUnicast, 1139 0 /* VLAN-id */, 1140 &Diag, 1141 vboxNetFltSolarisRecv, /* RX callback */ 1142 pThis /* callback private data */ 1143 ); 1144 if (RT_LIKELY(!rc)) 1145 { 1146 /* 1147 * Get the MAC handle of the underlying physical interface (or etherstub whatever). 1148 */ 1149 mac_handle_t hLowerMac = mac_get_lower_mac_handle(pThis->u.s.hInterface); 1150 if (RT_LIKELY(hLowerMac)) 1151 { 1152 /* 1153 * Obtain the MAC address & report. 1154 */ 1155 mac_unicast_primary_get(hLowerMac, (uint8_t *)&pThis->u.s.MacAddr.au8); 1156 if (vboxNetFltTryRetainBusyNotDisconnected(pThis)) 1157 { 1158 Assert(pThis->pSwitchPort); 1159 pThis->pSwitchPort->pfnReportMacAddress(pThis->pSwitchPort, &pThis->u.s.MacAddr); 1160 pThis->pSwitchPort->pfnReportPromiscuousMode(pThis->pSwitchPort, false); /** @todo Promisc */ 1161 pThis->pSwitchPort->pfnReportGsoCapabilities(pThis->pSwitchPort, 0, INTNETTRUNKDIR_WIRE | INTNETTRUNKDIR_HOST); 1162 pThis->pSwitchPort->pfnReportNoPreemptDsts(pThis->pSwitchPort, 0 /* none */); 1163 vboxNetFltRelease(pThis, true /*fBusy*/); 1164 } 1165 1166 LogFlow((DEVICE_NAME ":vboxNetFltOsInitInstance successfully opened VNIC '%s'\n", pThis->szName)); 1167 return VINF_SUCCESS; 1168 } 1169 else 1170 { 1171 LogRel((DEVICE_NAME ":vboxNetFltOsInitInstance failed to get lower MAC handle for '%s'\n", pThis->szName)); 1172 rc = ENODEV; 1173 } 1174 1175 mac_unicast_remove(pThis->u.s.hClient, pThis->u.s.hUnicast); 1176 mac_rx_clear(pThis->u.s.hClient); 1177 pThis->u.s.hUnicast = NULL; 1178 } 1179 else 1180 LogRel((DEVICE_NAME ":vboxNetFltOsInitInstance failed to set RX callback. rc=%d Diag=%d\n", rc, Diag)); 1181 } 1182 else 1183 LogRel((DEVICE_NAME ":vboxNetFltOsInitInstance failed to open link id for '%s' rc=%d\n", pThis->szName, rc)); 1184 1185 mac_client_close(pThis->u.s.hClient, 0 /* flags */); 1186 pThis->u.s.hClient = NULL; 1187 } 1188 else 1189 LogRel((DEVICE_NAME ":vboxNetFltOsInitInstance failed to open mac client for '%s' rc=%d\n", pThis->szName, rc)); 1190 } 1191 else 1192 LogRel((DEVICE_NAME ":vboxNetFltOsInitInstance failed to open link '%s'! rc=%d\n", pThis->szName)); 1193 1194 return RTErrConvertFromErrno(rc); 1034 1195 } 1035 1196 … … 1040 1201 * Init. the solaris specific data. 1041 1202 */ 1042 pThis->u.s. VNICLinkId = DATALINK_INVALID_LINKID;1203 pThis->u.s.fIsVNIC = false; 1043 1204 pThis->u.s.uInstance = 0; 1044 pThis->u.s.fCreatedVNIC = false;1045 1205 pThis->u.s.hInterface = NULL; 1206 pThis->u.s.hLinkId = DATALINK_INVALID_LINKID; 1046 1207 pThis->u.s.hClient = NULL; 1047 1208 pThis->u.s.hUnicast = NULL; … … 1098 1259 { 1099 1260 LogRel((DEVICE_NAME ":vboxNetFltPortOSNotifyMacAddress %s %.6Rhxs\n", pThis->szName, pMac)); 1261 1262 uchar_t au8GuestMac[MAXMACADDRLEN]; 1263 bcopy(pMac->au8, au8GuestMac, sizeof(RTMAC)); 1264 1265 if (pThis->u.s.fIsVNIC) 1266 { 1267 vnic_mac_addr_type_t AddrType = VNIC_MAC_ADDR_TYPE_FIXED; 1268 vnic_ioc_diag_t Diag = VNIC_IOC_DIAG_NONE; 1269 int MacSlot = 0; 1270 int MacLen = sizeof(RTMAC); 1271 1272 int rc = vnic_modify_addr(pThis->u.s.hLinkId, &AddrType, &MacLen, au8GuestMac, &MacSlot, 0 /* Mac-Prefix Length */, &Diag); 1273 if (!rc) 1274 LogFlow((DEVICE_NAME ":vboxNetFltPortOsNotifyMacAddress set '%s' MAC address to %.6Rhxs\n", pThis->szName, pMac)); 1275 else 1276 LogRel((DEVICE_NAME ":vboxNetFltPortOsNotifyMacAddress failed! rc=%d Diag=%d\n", rc, Diag)); 1277 } 1278 1279 /** @todo set MAC address for created VNICs */ 1100 1280 } 1101 1281
Note:
See TracChangeset
for help on using the changeset viewer.