Revision 15ac913b net/tap.c

b/net/tap.c
209 209
    } while (size > 0);
210 210
}
211 211

  
212
/* sndbuf should be set to a value lower than the tx queue
213
 * capacity of any destination network interface.
214
 * Ethernet NICs generally have txqueuelen=1000, so 1Mb is
215
 * a good default, given a 1500 byte MTU.
216
 */
217
#define TAP_DEFAULT_SNDBUF 1024*1024
218

  
219
static int tap_set_sndbuf(TAPState *s, QemuOpts *opts)
220
{
221
    int sndbuf;
222

  
223
    sndbuf = qemu_opt_get_size(opts, "sndbuf", TAP_DEFAULT_SNDBUF);
224
    if (!sndbuf) {
225
        sndbuf = INT_MAX;
226
    }
227

  
228
    if (ioctl(s->fd, TUNSETSNDBUF, &sndbuf) == -1 && qemu_opt_get(opts, "sndbuf")) {
229
        qemu_error("TUNSETSNDBUF ioctl failed: %s\n", strerror(errno));
230
        return -1;
231
    }
232
    return 0;
233
}
234

  
235 212
int tap_has_ufo(VLANClientState *vc)
236 213
{
237 214
    TAPState *s = vc->opaque;
......
465 442
        return -1;
466 443
    }
467 444

  
468
    if (tap_set_sndbuf(s, opts) < 0) {
445
    if (tap_set_sndbuf(s->fd, opts) < 0) {
469 446
        return -1;
470 447
    }
471 448

  

Also available in: Unified diff