From patchwork Mon Jun 6 06:48:47 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steffen Klassert X-Patchwork-Id: 98808 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 24AEEB6FA8 for ; Mon, 6 Jun 2011 16:45:33 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754280Ab1FFGp3 (ORCPT ); Mon, 6 Jun 2011 02:45:29 -0400 Received: from a.mx.secunet.com ([195.81.216.161]:54577 "EHLO a.mx.secunet.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752940Ab1FFGp1 (ORCPT ); Mon, 6 Jun 2011 02:45:27 -0400 Received: from localhost (alg1 [127.0.0.1]) by a.mx.secunet.com (Postfix) with ESMTP id 3908F1A005D; Mon, 6 Jun 2011 08:45:27 +0200 (CEST) X-Virus-Scanned: by secunet Received: from mail-srv1.secumail.de (unknown [10.53.40.200]) by a.mx.secunet.com (Postfix) with ESMTP id 83EB51A0066; Mon, 6 Jun 2011 08:45:26 +0200 (CEST) Received: from gauss.dd.secunet.de ([10.182.7.102]) by mail-srv1.secumail.de with Microsoft SMTPSVC(6.0.3790.4675); Mon, 6 Jun 2011 08:45:25 +0200 Received: by gauss.dd.secunet.de (Postfix, from userid 1000) id C22075C061A; Mon, 6 Jun 2011 08:48:47 +0200 (CEST) Date: Mon, 6 Jun 2011 08:48:47 +0200 From: Steffen Klassert To: David Miller , Herbert Xu Cc: netdev@vger.kernel.org Subject: [PATCH 3/3] ipv4: Fix packet size calculation for raw IPsec packets in __ip_append_data Message-ID: <20110606064847.GD31505@secunet.com> References: <20110606064603.GB31505@secunet.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20110606064603.GB31505@secunet.com> User-Agent: Mutt/1.5.20 (2009-06-14) X-OriginalArrivalTime: 06 Jun 2011 06:45:25.0320 (UTC) FILETIME=[50AB0480:01CC2415] Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We assume that transhdrlen is positive on the first fragment which is wrong for raw packets. So we don't add exthdrlen to the packet size for raw packets. This leads to a reallocation on IPsec because we have not enough headroom on the skb to place the IPsec headers. This patch fixes this by adding exthdrlen to the packet size whenever the send queue of the socket is empty. This issue was introduced with git commit 1470ddf7 (inet: Remove explicit write references to sk/inet in ip_append_data) Signed-off-by: Steffen Klassert --- net/ipv4/ip_output.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index a16859b..6b894d4 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c @@ -799,7 +799,9 @@ static int __ip_append_data(struct sock *sk, int csummode = CHECKSUM_NONE; struct rtable *rt = (struct rtable *)cork->dst; - exthdrlen = transhdrlen ? rt->dst.header_len : 0; + skb = skb_peek_tail(queue); + + exthdrlen = !skb ? rt->dst.header_len : 0; length += exthdrlen; transhdrlen += exthdrlen; mtu = cork->fragsize; @@ -825,8 +827,6 @@ static int __ip_append_data(struct sock *sk, !exthdrlen) csummode = CHECKSUM_PARTIAL; - skb = skb_peek_tail(queue); - cork->length += length; if (((length > mtu) || (skb && skb_is_gso(skb))) && (sk->sk_protocol == IPPROTO_UDP) &&