Use ioctl TUNSETOFFLOAD if kernel supports to enable TSO
offloading in the tap device.
Fixes: 29cf9c1b3b9c ("userspace: Add TCP Segmentation Offload support")
Reported-by: "Yi Yang (杨�D)-云服务集团" <[email protected]>
Tested-by: William Tu <[email protected]>
Signed-off-by: Flavio Leitner <[email protected]>
---
lib/netdev-linux.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
It would be great to have this patch applied to branch-2.13 as well.
diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
index 432645601..c6e46f188 100644
--- a/lib/netdev-linux.c
+++ b/lib/netdev-linux.c
@@ -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;
--
2.24.1
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev