Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp3376112ybp; Sun, 6 Oct 2019 10:34:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqx3A1UisrSPrdLcJ//cKVfDqcOYGXolEPncHthf0QVVSUdn6tPaxeD0tYvTtVB0NtQWJsHD X-Received: by 2002:aa7:dad3:: with SMTP id x19mr25621961eds.59.1570383247029; Sun, 06 Oct 2019 10:34:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570383247; cv=none; d=google.com; s=arc-20160816; b=uEnRGl/gDREqeeh2WUmfdFTFc6+XrUEnxmSPNslFgl5zfoh3W9IfpgHfBWfnW4iqSo E6eSWpDTU7rrPcThR9Syklq1XttKjSFPq3RTLd671arnhzrVwqcTDRAv4GorpwHSsE7r cumZMzzwiBPVbZVKpNxyneJjB3h5agHMAYWZ4Ft3U630hCs8CrOqWeMsBl6zqkn3GtX0 vsemn8VaGmSOKSgGjheeiitXVdeFLGHWyUPxjRYdc6ptnvWXQtNRJLBT76aFtEV53LdF MFsp6FzgaWq0aR13PQxBs7XvOYuvYptatz1dpKKQOdkZQnJTEdPSDmO3KB1m3lF3Ck+Y aPpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=OAKerwmHuxi6f31Y1TS5e1hqFruHEw4GdltCLWJi69o=; b=Rk21j8kcW4HAS/v+OyWijTHr8qXGDCIqibsAa8nE2k3S9rZf4umH8I5WYL7ZJ/EhK6 vc48el5hKEQh7x+nWjpdYquMNBi26nsBlpAp8SZG+uNB7v7D2cKPXtAarsyNQPdM7iEi EBWg+12VC6xbG90wBGMe7FCY2ee4hfZjQqilzgmqAiaOsngNih+IUcBsf7zpe3DQURiE Xv4V55ZSyyHtDPHHDk/5dO0+fdNdGahfvHJOSfcN0d+5Darbwew5tQi/c5pkgNo4HgnH T8UZdWSw9IOsfOFnc5/H2cuOsTO715VKAVMuDJ2i5GMS9OqFpnv1Du82hK9P3Gu3I/9E JWzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=T6NE+Ely; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q4si5728492eji.152.2019.10.06.10.33.43; Sun, 06 Oct 2019 10:34:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=T6NE+Ely; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728735AbfJFRcF (ORCPT + 99 others); Sun, 6 Oct 2019 13:32:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:58410 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729074AbfJFRcD (ORCPT ); Sun, 6 Oct 2019 13:32:03 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5E9962080F; Sun, 6 Oct 2019 17:32:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570383121; bh=W5ko8dKoTxp+EK2S8StLCSW/oIzptL3OD+fCC+I4QfA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T6NE+ElydK+bv0l3ajf9Gzms46dVLr0m5V/BH5e8hA/wS17CwBP2+5QoMMjo6Kknc 2+KUhUBeKZweFW1LjrI0DsufEhsVoYk2DVDc4PXCnjaBCdOIIW5z6S7i+a7Xu+e58N i6fK7UPY3n7tBWufJgF4Im3sOR7H02kX5znJIptI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Josh Hunt , Willem de Bruijn , Alexander Duyck , "David S. Miller" Subject: [PATCH 4.19 095/106] udp: only do GSO if # of segs > 1 Date: Sun, 6 Oct 2019 19:21:41 +0200 Message-Id: <20191006171201.386527724@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191006171124.641144086@linuxfoundation.org> References: <20191006171124.641144086@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Josh Hunt [ Upstream commit 4094871db1d65810acab3d57f6089aa39ef7f648 ] Prior to this change an application sending <= 1MSS worth of data and enabling UDP GSO would fail if the system had SW GSO enabled, but the same send would succeed if HW GSO offload is enabled. In addition to this inconsistency the error in the SW GSO case does not get back to the application if sending out of a real device so the user is unaware of this failure. With this change we only perform GSO if the # of segments is > 1 even if the application has enabled segmentation. I've also updated the relevant udpgso selftests. Fixes: bec1f6f69736 ("udp: generate gso with UDP_SEGMENT") Signed-off-by: Josh Hunt Reviewed-by: Willem de Bruijn Reviewed-by: Alexander Duyck Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/udp.c | 11 +++++++---- net/ipv6/udp.c | 11 +++++++---- tools/testing/selftests/net/udpgso.c | 16 ++++------------ 3 files changed, 18 insertions(+), 20 deletions(-) --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -775,6 +775,7 @@ static int udp_send_skb(struct sk_buff * int is_udplite = IS_UDPLITE(sk); int offset = skb_transport_offset(skb); int len = skb->len - offset; + int datalen = len - sizeof(*uh); __wsum csum = 0; /* @@ -808,10 +809,12 @@ static int udp_send_skb(struct sk_buff * return -EIO; } - skb_shinfo(skb)->gso_size = cork->gso_size; - skb_shinfo(skb)->gso_type = SKB_GSO_UDP_L4; - skb_shinfo(skb)->gso_segs = DIV_ROUND_UP(len - sizeof(*uh), - cork->gso_size); + if (datalen > cork->gso_size) { + skb_shinfo(skb)->gso_size = cork->gso_size; + skb_shinfo(skb)->gso_type = SKB_GSO_UDP_L4; + skb_shinfo(skb)->gso_segs = DIV_ROUND_UP(datalen, + cork->gso_size); + } goto csum_partial; } --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -1047,6 +1047,7 @@ static int udp_v6_send_skb(struct sk_buf __wsum csum = 0; int offset = skb_transport_offset(skb); int len = skb->len - offset; + int datalen = len - sizeof(*uh); /* * Create a UDP header @@ -1079,10 +1080,12 @@ static int udp_v6_send_skb(struct sk_buf return -EIO; } - skb_shinfo(skb)->gso_size = cork->gso_size; - skb_shinfo(skb)->gso_type = SKB_GSO_UDP_L4; - skb_shinfo(skb)->gso_segs = DIV_ROUND_UP(len - sizeof(*uh), - cork->gso_size); + if (datalen > cork->gso_size) { + skb_shinfo(skb)->gso_size = cork->gso_size; + skb_shinfo(skb)->gso_type = SKB_GSO_UDP_L4; + skb_shinfo(skb)->gso_segs = DIV_ROUND_UP(datalen, + cork->gso_size); + } goto csum_partial; } --- a/tools/testing/selftests/net/udpgso.c +++ b/tools/testing/selftests/net/udpgso.c @@ -90,12 +90,9 @@ struct testcase testcases_v4[] = { .tfail = true, }, { - /* send a single MSS: will fail with GSO, because the segment - * logic in udp4_ufo_fragment demands a gso skb to be > MTU - */ + /* send a single MSS: will fall back to no GSO */ .tlen = CONST_MSS_V4, .gso_len = CONST_MSS_V4, - .tfail = true, .r_num_mss = 1, }, { @@ -140,10 +137,9 @@ struct testcase testcases_v4[] = { .tfail = true, }, { - /* send a single 1B MSS: will fail, see single MSS above */ + /* send a single 1B MSS: will fall back to no GSO */ .tlen = 1, .gso_len = 1, - .tfail = true, .r_num_mss = 1, }, { @@ -197,12 +193,9 @@ struct testcase testcases_v6[] = { .tfail = true, }, { - /* send a single MSS: will fail with GSO, because the segment - * logic in udp4_ufo_fragment demands a gso skb to be > MTU - */ + /* send a single MSS: will fall back to no GSO */ .tlen = CONST_MSS_V6, .gso_len = CONST_MSS_V6, - .tfail = true, .r_num_mss = 1, }, { @@ -247,10 +240,9 @@ struct testcase testcases_v6[] = { .tfail = true, }, { - /* send a single 1B MSS: will fail, see single MSS above */ + /* send a single 1B MSS: will fall back to no GSO */ .tlen = 1, .gso_len = 1, - .tfail = true, .r_num_mss = 1, }, {