Revision 15ac913b

b/net/tap-aix.c
30 30
    fprintf(stderr, "no tap on AIX\n");
31 31
    return -1;
32 32
}
33

  
34
int tap_set_sndbuf(int fd, QemuOpts *opts)
35
{
36
    return 0;
37
}
38

  
b/net/tap-bsd.c
60 60
    fcntl(fd, F_SETFL, O_NONBLOCK);
61 61
    return fd;
62 62
}
63

  
64
int tap_set_sndbuf(int fd, QemuOpts *opts)
65
{
66
    return 0;
67
}
b/net/tap-linux.c
76 76
    fcntl(fd, F_SETFL, O_NONBLOCK);
77 77
    return fd;
78 78
}
79

  
80
/* sndbuf should be set to a value lower than the tx queue
81
 * capacity of any destination network interface.
82
 * Ethernet NICs generally have txqueuelen=1000, so 1Mb is
83
 * a good default, given a 1500 byte MTU.
84
 */
85
#define TAP_DEFAULT_SNDBUF 1024*1024
86

  
87
int tap_set_sndbuf(int fd, QemuOpts *opts)
88
{
89
    int sndbuf;
90

  
91
    sndbuf = qemu_opt_get_size(opts, "sndbuf", TAP_DEFAULT_SNDBUF);
92
    if (!sndbuf) {
93
        sndbuf = INT_MAX;
94
    }
95

  
96
    if (ioctl(fd, TUNSETSNDBUF, &sndbuf) == -1 && qemu_opt_get(opts, "sndbuf")) {
97
        qemu_error("TUNSETSNDBUF ioctl failed: %s\n", strerror(errno));
98
        return -1;
99
    }
100
    return 0;
101
}
b/net/tap-solaris.c
183 183
    fcntl(fd, F_SETFL, O_NONBLOCK);
184 184
    return fd;
185 185
}
186

  
187
int tap_set_sndbuf(int fd, QemuOpts *opts)
188
{
189
    return 0;
190
}
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

  
b/net/tap.h
43 43
void tap_using_vnet_hdr(VLANClientState *vc, int using_vnet_hdr);
44 44
void tap_set_offload(VLANClientState *vc, int csum, int tso4, int tso6, int ecn, int ufo);
45 45

  
46
int tap_set_sndbuf(int fd, QemuOpts *opts);
47

  
46 48
#endif /* QEMU_NET_TAP_H */

Also available in: Unified diff