Changeset 67525 in vbox for trunk/src/VBox/Devices/Network
- Timestamp:
- Jun 21, 2017 7:57:59 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DevVirtioNet.cpp
r66521 r67525 1154 1154 } 1155 1155 1156 static int vnetTransmitFrame(PVNETSTATE pThis, PPDMSCATTERGATHER pSgBuf, PPDMNETWORKGSO pGso, PVNETHDR pHdr) 1157 { 1158 vnetPacketDump(pThis, (uint8_t *)pSgBuf->aSegs[0].pvSeg, pSgBuf->cbUsed, "--> Outgoing"); 1159 LogRel(("vnet: Outgoing %spacket %d bytes, csum_start=%x\n", pGso?"GSO ":"", pSgBuf->cbUsed, pHdr->u16CSumStart)); 1160 if (pGso) 1161 { 1162 /* Some guests (RHEL) may report HdrLen excluding transport layer header! */ 1163 /* 1164 * We cannot use cdHdrs provided by the guest because of different ways 1165 * it gets filled out by different versions of kernels. 1166 */ 1167 //if (pGso->cbHdrs < pHdr->u16CSumStart + pHdr->u16CSumOffset + 2) 1168 { 1169 Log4(("%s vnetTransmitPendingPackets: HdrLen before adjustment %d.\n", 1170 INSTANCE(pThis), pGso->cbHdrsTotal)); 1171 switch (pGso->u8Type) 1172 { 1173 case PDMNETWORKGSOTYPE_IPV4_TCP: 1174 case PDMNETWORKGSOTYPE_IPV6_TCP: 1175 pGso->cbHdrsTotal = pHdr->u16CSumStart + 1176 ((PRTNETTCP)(((uint8_t*)pSgBuf->aSegs[0].pvSeg) + pHdr->u16CSumStart))->th_off * 4; 1177 pGso->cbHdrsSeg = pGso->cbHdrsTotal; 1178 break; 1179 case PDMNETWORKGSOTYPE_IPV4_UDP: 1180 pGso->cbHdrsTotal = (uint8_t)(pHdr->u16CSumStart + sizeof(RTNETUDP)); 1181 pGso->cbHdrsSeg = pHdr->u16CSumStart; 1182 break; 1183 } 1184 /* Update GSO structure embedded into the frame */ 1185 ((PPDMNETWORKGSO)pSgBuf->pvUser)->cbHdrsTotal = pGso->cbHdrsTotal; 1186 ((PPDMNETWORKGSO)pSgBuf->pvUser)->cbHdrsSeg = pGso->cbHdrsSeg; 1187 Log4(("%s vnetTransmitPendingPackets: adjusted HdrLen to %d.\n", 1188 INSTANCE(pThis), pGso->cbHdrsTotal)); 1189 } 1190 Log2(("%s vnetTransmitPendingPackets: gso type=%x cbHdrsTotal=%u cbHdrsSeg=%u mss=%u off1=0x%x off2=0x%x\n", 1191 INSTANCE(pThis), pGso->u8Type, pGso->cbHdrsTotal, pGso->cbHdrsSeg, pGso->cbMaxSeg, pGso->offHdr1, pGso->offHdr2)); 1192 STAM_REL_COUNTER_INC(&pThis->StatTransmitGSO); 1193 } 1194 else if (pHdr->u8Flags & VNETHDR_F_NEEDS_CSUM) 1195 { 1196 STAM_REL_COUNTER_INC(&pThis->StatTransmitCSum); 1197 /* 1198 * This is not GSO frame but checksum offloading is requested. 1199 */ 1200 vnetCompleteChecksum((uint8_t*)pSgBuf->aSegs[0].pvSeg, pSgBuf->cbUsed, 1201 pHdr->u16CSumStart, pHdr->u16CSumOffset); 1202 } 1203 1204 return pThis->pDrv->pfnSendBuf(pThis->pDrv, pSgBuf, false); 1205 } 1206 1156 1207 static void vnetTransmitPendingPackets(PVNETSTATE pThis, PVQUEUE pQueue, bool fOnWorkerThread) 1157 1208 { … … 1249 1300 uSize -= cbSegment; 1250 1301 } 1251 vnetPacketDump(pThis, (uint8_t *)pSgBuf->aSegs[0].pvSeg, pSgBuf->cbUsed, "--> Outgoing"); 1252 if (pGso) 1253 { 1254 /* Some guests (RHEL) may report HdrLen excluding transport layer header! */ 1255 /* 1256 * We cannot use cdHdrs provided by the guest because of different ways 1257 * it gets filled out by different versions of kernels. 1258 */ 1259 //if (pGso->cbHdrs < Hdr.u16CSumStart + Hdr.u16CSumOffset + 2) 1260 { 1261 Log4(("%s vnetTransmitPendingPackets: HdrLen before adjustment %d.\n", 1262 INSTANCE(pThis), pGso->cbHdrsTotal)); 1263 switch (pGso->u8Type) 1264 { 1265 case PDMNETWORKGSOTYPE_IPV4_TCP: 1266 case PDMNETWORKGSOTYPE_IPV6_TCP: 1267 pGso->cbHdrsTotal = Hdr.u16CSumStart + 1268 ((PRTNETTCP)(((uint8_t*)pSgBuf->aSegs[0].pvSeg) + Hdr.u16CSumStart))->th_off * 4; 1269 pGso->cbHdrsSeg = pGso->cbHdrsTotal; 1270 break; 1271 case PDMNETWORKGSOTYPE_IPV4_UDP: 1272 pGso->cbHdrsTotal = (uint8_t)(Hdr.u16CSumStart + sizeof(RTNETUDP)); 1273 pGso->cbHdrsSeg = Hdr.u16CSumStart; 1274 break; 1275 } 1276 /* Update GSO structure embedded into the frame */ 1277 ((PPDMNETWORKGSO)pSgBuf->pvUser)->cbHdrsTotal = pGso->cbHdrsTotal; 1278 ((PPDMNETWORKGSO)pSgBuf->pvUser)->cbHdrsSeg = pGso->cbHdrsSeg; 1279 Log4(("%s vnetTransmitPendingPackets: adjusted HdrLen to %d.\n", 1280 INSTANCE(pThis), pGso->cbHdrsTotal)); 1281 } 1282 Log2(("%s vnetTransmitPendingPackets: gso type=%x cbHdrsTotal=%u cbHdrsSeg=%u mss=%u off1=0x%x off2=0x%x\n", 1283 INSTANCE(pThis), pGso->u8Type, pGso->cbHdrsTotal, pGso->cbHdrsSeg, pGso->cbMaxSeg, pGso->offHdr1, pGso->offHdr2)); 1284 STAM_REL_COUNTER_INC(&pThis->StatTransmitGSO); 1285 } 1286 else if (Hdr.u8Flags & VNETHDR_F_NEEDS_CSUM) 1287 { 1288 STAM_REL_COUNTER_INC(&pThis->StatTransmitCSum); 1289 /* 1290 * This is not GSO frame but checksum offloading is requested. 1291 */ 1292 vnetCompleteChecksum((uint8_t*)pSgBuf->aSegs[0].pvSeg, pSgBuf->cbUsed, 1293 Hdr.u16CSumStart, Hdr.u16CSumOffset); 1294 } 1295 1296 rc = pThis->pDrv->pfnSendBuf(pThis->pDrv, pSgBuf, false); 1302 rc = vnetTransmitFrame(pThis, pSgBuf, pGso, &Hdr); 1297 1303 } 1298 1304 else
Note:
See TracChangeset
for help on using the changeset viewer.