From patchwork Tue Jan 22 21:20:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pravin B Shelar X-Patchwork-Id: 214665 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 580812C007B for ; Wed, 23 Jan 2013 08:20:03 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755373Ab3AVVT7 (ORCPT ); Tue, 22 Jan 2013 16:19:59 -0500 Received: from na3sys009aog124.obsmtp.com ([74.125.149.151]:32817 "HELO na3sys009aog124.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1752769Ab3AVVT6 (ORCPT ); Tue, 22 Jan 2013 16:19:58 -0500 Received: from mail-qc0-f197.google.com ([209.85.216.197]) (using TLSv1) by na3sys009aob124.postini.com ([74.125.148.12]) with SMTP ID DSNKUP8CftCNC/byd9uW/0CLzygu3SEoraPB@postini.com; Tue, 22 Jan 2013 13:19:58 PST Received: by mail-qc0-f197.google.com with SMTP id x40so7045671qcs.4 for ; Tue, 22 Jan 2013 13:19:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=kF1iTHTlaeL6wlY3q9rHyiEqN+bUWnjfaHZjxFfJWsw=; b=cifqgn1rB6thljpoP+AwPysUXYBhfJ3PpXtsMXfOmH2zMZ6Gm2Ulc27gi8OcH9nuN1 NwPk00RYT2IvH0At7ub6FVFknv1kI+IJy2YRzbvay4VhElI78ue+Ro3G3+MelSFkqmpF FCgGD/O3eP4D1qYHfbyXjiwgfkfU++AQEQAINW3qYY8++4pyK/aMXH5Pt9MbgTU8n8Af pVlb6Z8j2aIys1cRq1PMVHvXfNN5R74cnb7HvExkl45qI6ZwhTL8TVx+NjekhdVDNCTV gQYNdjtcE2kHRd0m/WNP+wVWurUOQjobiuRxO/hh/ojNUN3xTTgrgz+BknHzfWtwdmY8 HvyA== X-Received: by 10.49.118.38 with SMTP id kj6mr28632319qeb.53.1358889597325; Tue, 22 Jan 2013 13:19:57 -0800 (PST) X-Received: by 10.49.118.38 with SMTP id kj6mr28632313qeb.53.1358889597228; Tue, 22 Jan 2013 13:19:57 -0800 (PST) Received: from localhost ([64.125.181.92]) by mx.google.com with ESMTPS id dj2sm11896578qab.9.2013.01.22.13.19.56 (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Tue, 22 Jan 2013 13:19:56 -0800 (PST) From: Pravin B Shelar To: netdev@vger.kernel.org Cc: jesse@nicira.com, Pravin B Shelar Subject: [PATCH 2/2] IP_GRE: Linearize skb before csum. Date: Tue, 22 Jan 2013 13:20:48 -0800 Message-Id: <1358889648-1684-1-git-send-email-pshelar@nicira.com> X-Mailer: git-send-email 1.7.12.315.g682ce8b X-Gm-Message-State: ALoCoQnhfWU3cMKO9WLNejiTlHXIr0X9pxWung7zpbV5Xn4jKxB1wvzOk+uXcjg7oz3pDqyWj8QWN958wI7uLZh2545PupXgf3saTAg54fzJfBDbnByIjzoNLROqfvRq2fRPKSWtaS79Z+akb56MWXGYLEHMc14IjVvn7BICEioJeW+TUvpCyvo= Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Make copy of skb sharable data by linearizing skb. so that csum remain consistent when skb is actually transmitted. Signed-off-by: Pravin B Shelar --- net/ipv4/ip_gre.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index 7cdf1fe..20d3d37 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c @@ -738,7 +738,7 @@ drop: static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev) { struct ip_tunnel *tunnel = netdev_priv(dev); - const struct iphdr *old_iph = ip_hdr(skb); + const struct iphdr *old_iph; const struct iphdr *tiph; struct flowi4 fl4; u8 tos; @@ -752,9 +752,23 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev int mtu; u8 ttl; - if (skb->ip_summed == CHECKSUM_PARTIAL && - skb_checksum_help(skb)) - goto tx_error; + if (skb->ip_summed == CHECKSUM_PARTIAL) { + int err; + + /* Pages aren't locked and could change at any time. + * If this happens after we compute the checksum, the + * checksum will be wrong. We linearize now to avoid + * this problem. + */ + err = __skb_linearize(skb); + if (unlikely(err)) + goto tx_error; + + err = skb_checksum_help(skb); + if (unlikely(err)) + goto tx_error; + } + old_iph = ip_hdr(skb); if (dev->type == ARPHRD_ETHER) IPCB(skb)->flags = 0;