169
brHasBridge(brControl *ctl,
180
if ((len = strlen(name)) >= BR_IFNAME_MAXLEN) {
185
memset(&ifr, 0, sizeof(struct ifreq));
187
strncpy(ifr.ifr_name, name, len);
188
ifr.ifr_name[len] = '\0';
190
if (ioctl(ctl->fd, SIOCGIFFLAGS, &ifr))
197
brHasBridge(brControl *ctl,
167
205
* brDeleteBridge:
168
206
* @ctl: bridge control pointer
408
* @tapfd: a tun/tap file descriptor
410
* Check whether it is safe to enable the IFF_VNET_HDR flag on the
413
* Setting IFF_VNET_HDR enables QEMU's virtio_net driver to allow
414
* guests to pass larger (GSO) packets, with partial checksums, to
415
* the host. This greatly increases the achievable throughput.
417
* It is only useful to enable this when we're setting up a virtio
418
* interface. And it is only *safe* to enable it when we know for
419
* sure that a) qemu has support for IFF_VNET_HDR and b) the running
420
* kernel implements the TUNGETIFF ioctl(), which qemu needs to query
421
* the supplied tapfd.
423
* Returns 0 in case of success or an errno code in case of failure.
426
brProbeVnetHdr(int tapfd)
428
#if defined(IFF_VNET_HDR) && defined(TUNGETFEATURES) && defined(TUNGETIFF)
429
unsigned int features;
432
if (ioctl(tapfd, TUNGETFEATURES, &features) != 0) {
433
VIR_INFO0(_("Not enabling IFF_VNET_HDR; "
434
"TUNGETFEATURES ioctl() not implemented"));
438
if (!(features & IFF_VNET_HDR)) {
439
VIR_INFO0(_("Not enabling IFF_VNET_HDR; "
440
"TUNGETFEATURES ioctl() reports no IFF_VNET_HDR"));
444
/* The kernel will always return -1 at this point.
445
* If TUNGETIFF is not implemented then errno == EBADFD.
447
if (ioctl(tapfd, TUNGETIFF, &dummy) != -1 || errno != EBADFD) {
448
VIR_INFO0(_("Not enabling IFF_VNET_HDR; "
449
"TUNGETIFF ioctl() not implemented"));
453
VIR_INFO0(_("Enabling IFF_VNET_HDR"));
457
VIR_INFO0(_("Not enabling IFF_VNET_HDR; disabled at build time"));
370
464
* @ctl: bridge control pointer
371
465
* @bridge: the bridge name
372
466
* @ifname: the interface name (or name template)
467
* @vnet_hdr: whether to try enabling IFF_VNET_HDR
373
468
* @tapfd: file descriptor return value for the new tap device
375
470
* This function creates a new tap device on a bridge. @ifname can be either
407
506
try.ifr_flags = IFF_TAP|IFF_NO_PI;
510
try.ifr_flags |= IFF_VNET_HDR;
410
514
len = snprintf(try.ifr_name, BR_IFNAME_MAXLEN, *ifname, id);
411
515
if (len >= BR_IFNAME_MAXLEN) {