2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 06:15:47 +00:00

netdev-linux: Enable TSO in the TAP device.

Use ioctl TUNSETOFFLOAD if kernel supports to enable TSO
offloading in the tap device.

Fixes: 29cf9c1b3b ("userspace: Add TCP Segmentation Offload support")
Reported-by: "Yi Yang (杨�D)-云服务集团" <yangyi01@inspur.com>
Tested-by: William Tu <u9012063@gmail.com>
Signed-off-by: Flavio Leitner <fbl@sysclose.org>
Signed-off-by: William Tu <u9012063@gmail.com>
This commit is contained in:
Flavio Leitner
2020-02-29 20:29:35 -03:00
committed by William Tu
parent 7cc77b301f
commit 6211ad5708

View File

@@ -1012,6 +1012,23 @@ netdev_linux_construct_tap(struct netdev *netdev_)
goto error_close;
}
if (userspace_tso_enabled()) {
/* Old kernels don't support TUNSETOFFLOAD. If TUNSETOFFLOAD is
* available, it will return EINVAL when a flag is unknown.
* Therefore, try enabling offload with no flags to check
* if TUNSETOFFLOAD support is available or not. */
if (ioctl(netdev->tap_fd, TUNSETOFFLOAD, 0) == 0 || errno != EINVAL) {
unsigned long oflags = TUN_F_CSUM | TUN_F_TSO4 | TUN_F_TSO6;
if (ioctl(netdev->tap_fd, TUNSETOFFLOAD, oflags) == -1) {
VLOG_WARN("%s: enabling tap offloading failed: %s", name,
ovs_strerror(errno));
error = errno;
goto error_close;
}
}
}
netdev->present = true;
return 0;