From patchwork Thu Sep 2 23:11:40 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 151491 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o82NBhYO016123 for ; Thu, 2 Sep 2010 23:11:43 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753036Ab0IBXLm (ORCPT ); Thu, 2 Sep 2010 19:11:42 -0400 Received: from quartz.orcorp.ca ([139.142.54.143]:55632 "EHLO quartz.orcorp.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752531Ab0IBXLl (ORCPT ); Thu, 2 Sep 2010 19:11:41 -0400 Received: from [10.0.0.11] (helo=jggl.edm.orcorp.ca) by quartz.orcorp.ca with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.68) (envelope-from ) id 1OrIwW-0005B6-9h; Thu, 02 Sep 2010 17:11:40 -0600 Received: from jgg by jggl.edm.orcorp.ca with local (Exim 4.69) (envelope-from ) id 1OrIwW-0007a8-7p; Thu, 02 Sep 2010 17:11:40 -0600 Date: Thu, 2 Sep 2010 17:11:40 -0600 From: Jason Gunthorpe To: linux-rdma@vger.kernel.org, Roland Dreier Subject: [PATCH] [IPOIB] Check for a MTU overflow on the GSO path Message-ID: <20100902231140.GW24971@obsidianresearch.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) X-Broken-Reverse-DNS: no host name found for IP address 10.0.0.11 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Thu, 02 Sep 2010 23:11:43 +0000 (UTC) diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c index ec6b4fb..aa9f9cf 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c @@ -532,6 +532,7 @@ void ipoib_send(struct net_device *dev, struct sk_buff *skb, struct ipoib_tx_buf *tx_req; int hlen, rc; void *phead; + unsigned int required_mtu; if (skb_is_gso(skb)) { hlen = skb_transport_offset(skb) + tcp_hdrlen(skb); @@ -543,17 +544,21 @@ void ipoib_send(struct net_device *dev, struct sk_buff *skb, dev_kfree_skb_any(skb); return; } + + required_mtu = skb_shinfo(skb)->gso_size + hlen; } else { - if (unlikely(skb->len > priv->mcast_mtu + IPOIB_ENCAP_LEN)) { - ipoib_warn(priv, "packet len %d (> %d) too long to send, dropping\n", - skb->len, priv->mcast_mtu + IPOIB_ENCAP_LEN); - ++dev->stats.tx_dropped; - ++dev->stats.tx_errors; - ipoib_cm_skb_too_long(dev, skb, priv->mcast_mtu); - return; - } phead = NULL; hlen = 0; + required_mtu = skb->len; + } + + if (unlikely(required_mtu > priv->mcast_mtu + IPOIB_ENCAP_LEN)) { + ipoib_warn(priv, "packet len %d (> %d) too long to send, dropping\n", + required_mtu, priv->mcast_mtu + IPOIB_ENCAP_LEN); + ++dev->stats.tx_dropped; + ++dev->stats.tx_errors; + ipoib_cm_skb_too_long(dev, skb, priv->mcast_mtu); + return; } ipoib_dbg_data(priv, "sending packet, length=%d address=%p qpn=0x%06x\n",