net: move tap_set_offload() code into tap-linux.c
TUNSETOFFLOAD is only available on Linux Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
dc69004c7d
commit
1faac1f7d4
@ -40,3 +40,8 @@ int tap_probe_vnet_hdr(int fd)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void tap_fd_set_offload(int fd, int csum, int tso4,
|
||||
int tso6, int ecn, int ufo)
|
||||
{
|
||||
}
|
||||
|
@ -70,3 +70,8 @@ int tap_probe_vnet_hdr(int fd)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void tap_fd_set_offload(int fd, int csum, int tso4,
|
||||
int tso6, int ecn, int ufo)
|
||||
{
|
||||
}
|
||||
|
@ -111,3 +111,29 @@ int tap_probe_vnet_hdr(int fd)
|
||||
|
||||
return ifr.ifr_flags & IFF_VNET_HDR;
|
||||
}
|
||||
|
||||
void tap_fd_set_offload(int fd, int csum, int tso4,
|
||||
int tso6, int ecn, int ufo)
|
||||
{
|
||||
unsigned int offload = 0;
|
||||
|
||||
if (csum) {
|
||||
offload |= TUN_F_CSUM;
|
||||
if (tso4)
|
||||
offload |= TUN_F_TSO4;
|
||||
if (tso6)
|
||||
offload |= TUN_F_TSO6;
|
||||
if ((tso4 || tso6) && ecn)
|
||||
offload |= TUN_F_TSO_ECN;
|
||||
if (ufo)
|
||||
offload |= TUN_F_UFO;
|
||||
}
|
||||
|
||||
if (ioctl(fd, TUNSETOFFLOAD, offload) != 0) {
|
||||
offload &= ~TUN_F_UFO;
|
||||
if (ioctl(fd, TUNSETOFFLOAD, offload) != 0) {
|
||||
fprintf(stderr, "TUNSETOFFLOAD ioctl() failed: %s\n",
|
||||
strerror(errno));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -193,3 +193,8 @@ int tap_probe_vnet_hdr(int fd)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void tap_fd_set_offload(int fd, int csum, int tso4,
|
||||
int tso6, int ecn, int ufo)
|
||||
{
|
||||
}
|
||||
|
21
net/tap.c
21
net/tap.c
@ -243,27 +243,8 @@ void tap_set_offload(VLANClientState *vc, int csum, int tso4,
|
||||
int tso6, int ecn, int ufo)
|
||||
{
|
||||
TAPState *s = vc->opaque;
|
||||
unsigned int offload = 0;
|
||||
|
||||
if (csum) {
|
||||
offload |= TUN_F_CSUM;
|
||||
if (tso4)
|
||||
offload |= TUN_F_TSO4;
|
||||
if (tso6)
|
||||
offload |= TUN_F_TSO6;
|
||||
if ((tso4 || tso6) && ecn)
|
||||
offload |= TUN_F_TSO_ECN;
|
||||
if (ufo)
|
||||
offload |= TUN_F_UFO;
|
||||
}
|
||||
|
||||
if (ioctl(s->fd, TUNSETOFFLOAD, offload) != 0) {
|
||||
offload &= ~TUN_F_UFO;
|
||||
if (ioctl(s->fd, TUNSETOFFLOAD, offload) != 0) {
|
||||
fprintf(stderr, "TUNSETOFFLOAD ioctl() failed: %s\n",
|
||||
strerror(errno));
|
||||
}
|
||||
}
|
||||
return tap_fd_set_offload(s->fd, csum, tso4, tso6, ecn, ufo);
|
||||
}
|
||||
|
||||
static void tap_cleanup(VLANClientState *vc)
|
||||
|
@ -45,5 +45,6 @@ void tap_set_offload(VLANClientState *vc, int csum, int tso4, int tso6, int ecn,
|
||||
|
||||
int tap_set_sndbuf(int fd, QemuOpts *opts);
|
||||
int tap_probe_vnet_hdr(int fd);
|
||||
void tap_fd_set_offload(int fd, int csum, int tso4, int tso6, int ecn, int ufo);
|
||||
|
||||
#endif /* QEMU_NET_TAP_H */
|
||||
|
Loading…
Reference in New Issue
Block a user