Revision 24e32363 net.c
b/net.c | ||
---|---|---|
1261 | 1261 |
|
1262 | 1262 |
#endif /* CONFIG_SLIRP */ |
1263 | 1263 |
|
1264 |
#if !defined(_WIN32) |
|
1264 |
#if defined(_WIN32) |
|
1265 |
int tap_has_vnet_hdr(VLANClientState *vc) |
|
1266 |
{ |
|
1267 |
return 0; |
|
1268 |
} |
|
1269 |
void tap_using_vnet_hdr(VLANClientState *vc, int using_vnet_hdr) |
|
1270 |
{ |
|
1271 |
} |
|
1272 |
#else /* !defined(_WIN32) */ |
|
1265 | 1273 |
|
1266 | 1274 |
/* Maximum GSO packet size (64k) plus plenty of room for |
1267 | 1275 |
* the ethernet and virtio_net headers |
... | ... | |
1277 | 1285 |
unsigned int read_poll : 1; |
1278 | 1286 |
unsigned int write_poll : 1; |
1279 | 1287 |
unsigned int has_vnet_hdr : 1; |
1288 |
unsigned int using_vnet_hdr : 1; |
|
1280 | 1289 |
} TAPState; |
1281 | 1290 |
|
1282 | 1291 |
static int launch_script(const char *setup_script, const char *ifname, int fd); |
... | ... | |
1339 | 1348 |
struct iovec iov_copy[iovcnt + 1]; |
1340 | 1349 |
struct virtio_net_hdr hdr = { 0, }; |
1341 | 1350 |
|
1342 |
if (s->has_vnet_hdr) { |
|
1351 |
if (s->has_vnet_hdr && !s->using_vnet_hdr) {
|
|
1343 | 1352 |
iov_copy[0].iov_base = &hdr; |
1344 | 1353 |
iov_copy[0].iov_len = sizeof(hdr); |
1345 | 1354 |
memcpy(&iov_copy[1], iov, iovcnt * sizeof(*iov)); |
... | ... | |
1357 | 1366 |
int iovcnt = 0; |
1358 | 1367 |
struct virtio_net_hdr hdr = { 0, }; |
1359 | 1368 |
|
1360 |
if (s->has_vnet_hdr) { |
|
1369 |
if (s->has_vnet_hdr && !s->using_vnet_hdr) {
|
|
1361 | 1370 |
iov[iovcnt].iov_base = &hdr; |
1362 | 1371 |
iov[iovcnt].iov_len = sizeof(hdr); |
1363 | 1372 |
iovcnt++; |
... | ... | |
1414 | 1423 |
break; |
1415 | 1424 |
} |
1416 | 1425 |
|
1417 |
if (s->has_vnet_hdr) { |
|
1426 |
if (s->has_vnet_hdr && !s->using_vnet_hdr) {
|
|
1418 | 1427 |
buf += sizeof(struct virtio_net_hdr); |
1419 | 1428 |
size -= sizeof(struct virtio_net_hdr); |
1420 | 1429 |
} |
... | ... | |
1449 | 1458 |
return 0; |
1450 | 1459 |
} |
1451 | 1460 |
|
1461 |
int tap_has_vnet_hdr(VLANClientState *vc) |
|
1462 |
{ |
|
1463 |
TAPState *s = vc->opaque; |
|
1464 |
|
|
1465 |
assert(vc->type == NET_CLIENT_TYPE_TAP); |
|
1466 |
|
|
1467 |
return s->has_vnet_hdr; |
|
1468 |
} |
|
1469 |
|
|
1470 |
void tap_using_vnet_hdr(VLANClientState *vc, int using_vnet_hdr) |
|
1471 |
{ |
|
1472 |
TAPState *s = vc->opaque; |
|
1473 |
|
|
1474 |
using_vnet_hdr = using_vnet_hdr != 0; |
|
1475 |
|
|
1476 |
assert(vc->type == NET_CLIENT_TYPE_TAP); |
|
1477 |
assert(s->has_vnet_hdr == using_vnet_hdr); |
|
1478 |
|
|
1479 |
s->using_vnet_hdr = using_vnet_hdr; |
|
1480 |
} |
|
1481 |
|
|
1452 | 1482 |
static int tap_probe_vnet_hdr(int fd) |
1453 | 1483 |
{ |
1454 | 1484 |
struct ifreq ifr; |
... | ... | |
1489 | 1519 |
s = qemu_mallocz(sizeof(TAPState)); |
1490 | 1520 |
s->fd = fd; |
1491 | 1521 |
s->has_vnet_hdr = vnet_hdr != 0; |
1522 |
s->using_vnet_hdr = 0; |
|
1492 | 1523 |
s->vc = qemu_new_vlan_client(NET_CLIENT_TYPE_TAP, |
1493 | 1524 |
vlan, NULL, model, name, NULL, |
1494 | 1525 |
tap_receive, tap_receive_iov, |
Also available in: Unified diff