Changeset 67975 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Jul 14, 2017 1:52:25 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DevVirtioNet.cpp
r67970 r67975 1156 1156 } 1157 1157 1158 static bool vnetReadHeader(PVNETSTATE pThis, RTGCPHYS GCPhys, PVNETHDR pHdr, uint32_t cbMax) 1159 { 1160 int rc = PDMDevHlpPhysRead(pThis->VPCI.CTX_SUFF(pDevIns), GCPhys, pHdr, sizeof(*pHdr)); 1161 if (RT_FAILURE(rc)) 1162 return false; 1163 1164 Log4(("virtio-net: header flags=%x gso-type=%x len=%x gso-size=%x csum-start=%x csum-offset=%x cb=%x\n", 1165 pHdr->u8Flags, pHdr->u8GSOType, pHdr->u16HdrLen, pHdr->u16GSOSize, pHdr->u16CSumStart, pHdr->u16CSumOffset, cbMax)); 1166 1167 if (pHdr->u8GSOType) 1168 { 1169 uint32_t u32MinHdrSize; 1170 1171 /* Segmentation offloading cannot be done without checksumming. */ 1172 if (RT_UNLIKELY(!(pHdr->u8Flags & VNETHDR_F_NEEDS_CSUM))) 1173 return false; 1174 /* We do not support ECN. */ 1175 if (RT_UNLIKELY(pHdr->u8GSOType & VNETHDR_GSO_ECN)) 1176 return false; 1177 switch (pHdr->u8GSOType) 1178 { 1179 case VNETHDR_GSO_TCPV4: 1180 case VNETHDR_GSO_TCPV6: 1181 u32MinHdrSize = sizeof(RTNETTCP); 1182 break; 1183 case VNETHDR_GSO_UDP: 1184 u32MinHdrSize = 0; 1185 break; 1186 default: 1187 return false; 1188 } 1189 /* Header+MSS must not exceed the packet size. */ 1190 if (RT_UNLIKELY(u32MinHdrSize + pHdr->u16CSumStart + pHdr->u16GSOSize > cbMax)) 1191 return false; 1192 } 1193 /* Checksum must fit into the frame (validating both checksum fields). */ 1194 if ( (pHdr->u8Flags & VNETHDR_F_NEEDS_CSUM) 1195 && sizeof(uint16_t) + pHdr->u16CSumStart + pHdr->u16CSumOffset > cbMax) 1196 return false; 1197 Log4(("virtio-net: return true\n")); 1198 return true; 1199 } 1200 1158 1201 static int vnetTransmitFrame(PVNETSTATE pThis, PPDMSCATTERGATHER pSgBuf, PPDMNETWORKGSO pGso, PVNETHDR pHdr) 1159 1202 { … … 1261 1304 else 1262 1305 { 1306 VNETHDR Hdr; 1263 1307 unsigned int uSize = 0; 1264 1308 STAM_PROFILE_ADV_START(&pThis->StatTransmit, a); … … 1271 1315 if (uSize > VNET_MAX_FRAME_SIZE) 1272 1316 uSize = VNET_MAX_FRAME_SIZE; 1273 if (pThis->pDrv )1317 if (pThis->pDrv && vnetReadHeader(pThis, elem.aSegsOut[0].addr, &Hdr, uSize)) 1274 1318 { 1275 VNETHDR Hdr;1276 1319 PDMNETWORKGSO Gso, *pGso; 1277 1278 PDMDevHlpPhysRead(pThis->VPCI.CTX_SUFF(pDevIns), elem.aSegsOut[0].addr,1279 &Hdr, sizeof(Hdr));1280 1320 1281 1321 STAM_REL_COUNTER_INC(&pThis->StatTransmitPackets);
Note:
See TracChangeset
for help on using the changeset viewer.