Changeset 12825 in vbox for trunk/src/VBox/HostDrivers/VBoxNetFlt
- Timestamp:
- Sep 30, 2008 10:06:17 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxNetFlt/solaris/VBoxNetFlt-solaris.c
r12783 r12825 81 81 #endif 82 82 83 /** Dynamic module binding specific oddities. */84 #define VBOXNETFLT_IFNAME_LEN LIFNAMSIZ + 185 86 83 /** Maximum loopback packet queue size per interface */ 87 84 #define VBOXNETFLT_LOOPBACK_SIZE 32 … … 303 300 struct vboxnetflt_stream_t *pNext; /* next stream in list */ 304 301 PVBOXNETFLTINS volatile pThis; /* the backend instance */ 305 VBOXNETFLTSTREAMTYPE Type; /* the type of the stream Ip/Arp*/302 VBOXNETFLTSTREAMTYPE Type; /* the type of the stream */ 306 303 } vboxnetflt_stream_t; 307 304 … … 1017 1014 LogFlow((DEVICE_NAME ":VBoxNetFltSolarisModWritePut pQueue=%p pMsg=%p\n", pQueue, pMsg)); 1018 1015 1019 /* 1020 * Check for the VirtualBox connection. 1021 */ 1022 bool fSendDownstream = true; 1023 bool fActive = false; 1024 vboxnetflt_stream_t *pStream = pQueue->q_ptr; 1025 PVBOXNETFLTINS pThis = NULL; 1026 1027 #if 0 1028 /* 1029 * In the unlikely case where VirtualBox crashed and this filter 1030 * is somehow still in the host stream we must try not to panic the host. 1031 */ 1032 if ( pStream 1033 && pStream->Type == kIpStream 1034 && pMsg) 1035 { 1036 pThis = vboxNetFltSolarisFindInstance(pStream); 1037 if (RT_LIKELY(pThis)) 1038 { 1039 /* 1040 * Retain the instance if we're actively filtering. 1041 */ 1042 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 1043 RTSpinlockAcquire(pThis->hSpinlock, &Tmp); 1044 fActive = ASMAtomicUoReadBool(&pThis->fActive); 1045 if (fActive) 1046 vboxNetFltRetain(pThis, true); 1047 RTSpinlockRelease(pThis->hSpinlock, &Tmp); 1048 1049 switch (DB_TYPE(pMsg)) 1050 { 1051 case M_DATA: 1052 { 1053 LogFlow((DEVICE_NAME ":VBoxNetFltSolarisModWritePut M_DATA\n")); 1054 break; 1055 } 1056 1057 case M_PROTO: 1058 case M_PCPROTO: 1059 { 1060 /* 1061 * If we are not yet in raw mode; just pass through. 1062 */ 1063 if (!pStream->fRawMode) 1064 break; 1065 1066 /* 1067 * Queue up other primitives to the service routine. 1068 */ 1069 LogFlow((DEVICE_NAME ":VBoxNetFltSolarisModWritePut M_PROTO/M_PCPROTO\n")); 1070 1071 union DL_primitives *pPrim = (union DL_primitives *)pMsg->b_rptr; 1072 t_uscalar_t Prim = pPrim->dl_primitive; 1073 switch (Prim) 1074 { 1075 case DL_UNITDATA_REQ: 1076 { 1077 LogFlow((DEVICE_NAME ":VBoxNetFltSolarisModWritePut DL_UNITDATA_REQ\n")); 1078 mblk_t *pRawMsg; 1079 int rc = vboxNetFltSolarisUnitDataToRaw(pThis, pMsg, &pRawMsg); 1080 if (RT_SUCCESS(rc)) 1081 pMsg = pRawMsg; 1082 else 1083 fSendDownstream = false; 1084 break; 1085 } 1086 1087 default: 1088 { 1089 /* 1090 * Enqueue other DLPI primitives and service them later. 1091 */ 1092 fSendDownstream = false; 1093 putq(pQueue, pMsg); 1094 break; 1095 } 1096 } 1097 break; 1098 } 1099 1100 case M_IOCTL: 1101 { 1102 struct iocblk *pIOC = (struct iocblk *)pMsg->b_rptr; 1103 if (pIOC->ioc_cmd == DL_IOC_HDR_INFO) 1104 { 1105 fSendDownstream = false; 1106 1107 /* 1108 * Some sanity checks. 1109 */ 1110 if ( !pMsg->b_cont 1111 || (MBLKL(pMsg->b_cont) < sizeof(dl_unitdata_req_t) + VBOXNETFLT_DLADDRL) 1112 || (*((uint32_t *)pMsg->b_cont->b_rptr) != DL_UNITDATA_REQ)) 1113 { 1114 LogRel((DEVICE_NAME ":VBoxNetFltSolarisModWritePut: Invalid fast path request!\n")); 1115 miocnak(pQueue, pMsg, 0, EPROTO); 1116 break; 1117 } 1118 1119 dl_unitdata_req_t *pDlReq = (dl_unitdata_req_t *)pMsg->b_cont->b_rptr; 1120 size_t cbOffset = pDlReq->dl_dest_addr_offset; 1121 size_t cbAddr = pDlReq->dl_dest_addr_length; 1122 if ( !MBLKIN(pMsg->b_cont, cbOffset, cbAddr) 1123 || cbAddr != VBOXNETFLT_DLADDRL) 1124 { 1125 LogRel((DEVICE_NAME ":VBoxNetFltSolarisModWritePut: Invalid header in fast path request!\n")); 1126 miocnak(pQueue, pMsg, 0, EPROTO); 1127 break; 1128 } 1129 1130 vboxnetflt_dladdr_t *pDLSapAddr = (vboxnetflt_dladdr_t *)(pMsg->b_cont->b_rptr + cbOffset); 1131 mblk_t *pReplyMsg = allocb(sizeof(RTNETETHERHDR), BPRI_MED); 1132 if (RT_UNLIKELY(!pReplyMsg)) 1133 { 1134 LogRel((DEVICE_NAME ":VBoxNetFltSolarisModWritePut: Invalid header in fast path request!\n")); 1135 miocnak(pQueue, pMsg, 0, ENOMEM); 1136 break; 1137 } 1138 1139 PRTNETETHERHDR pEthHdr = (PRTNETETHERHDR)pMsg->b_rptr; 1140 bcopy(&pDLSapAddr->Mac, &pEthHdr->DstMac, sizeof(RTMAC)); 1141 bcopy(&pThis->u.s.Mac, &pEthHdr->SrcMac, sizeof(RTMAC)); 1142 pEthHdr->EtherType = RT_H2BE_U16(pDLSapAddr->SAP); 1143 1144 linkb(pMsg, pReplyMsg); 1145 1146 /* 1147 * Somebody is wanting fast path when we need raw mode. 1148 * Since we are evil, let's acknowledge the request ourselves! 1149 */ 1150 miocack(pQueue, pMsg, msgsize(pMsg->b_cont), EINVAL); 1151 LogFlow((DEVICE_NAME ":VBoxNetFltSolarisModWritePut: Fast path request acknowledged.\n")); 1152 } 1153 break; 1154 } 1155 1156 case M_FLUSH: 1157 { 1158 /* 1159 * Canonical flush courtesy man qreply(9F) while we have a service routine. 1160 */ 1161 LogFlow((DEVICE_NAME ":VBoxNetFltSolarisModWritePut M_FLUSH\n")); 1162 if (*pMsg->b_rptr & FLUSHW) 1163 { 1164 /* 1165 * Flush and mark as serviced. 1166 */ 1167 flushq(pQueue, FLUSHALL); 1168 *pMsg->b_rptr &= ~FLUSHW; 1169 } 1170 1171 if (*pMsg->b_rptr & FLUSHR) 1172 { 1173 /* 1174 * Send the request upstream. 1175 */ 1176 flushq(RD(pQueue), FLUSHALL); 1177 qreply(pQueue, pMsg); 1178 } 1179 else 1180 freemsg(pMsg); 1181 1182 break; 1183 } 1184 } 1185 } 1186 else 1187 LogRel((DEVICE_NAME ":VBoxNetFltSolarisModWritePut: Could not find VirtualBox instance!!\n")); 1188 } 1189 #endif 1190 1191 1192 if ( fSendDownstream 1193 && pMsg) 1016 if (pMsg) 1194 1017 { 1195 1018 /* … … 1205 1028 putbq(pQueue, pMsg); 1206 1029 } 1207 1208 if (fActive)1209 vboxNetFltRelease(pThis, true);1210 1030 1211 1031 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.