From patchwork Thu Dec 13 08:25:52 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li RongQing X-Patchwork-Id: 205780 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 9FCB82C0091 for ; Thu, 13 Dec 2012 19:26:04 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752830Ab2LMI0B (ORCPT ); Thu, 13 Dec 2012 03:26:01 -0500 Received: from mail-pa0-f46.google.com ([209.85.220.46]:56390 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751011Ab2LMI0A (ORCPT ); Thu, 13 Dec 2012 03:26:00 -0500 Received: by mail-pa0-f46.google.com with SMTP id bh2so1367671pad.19 for ; Thu, 13 Dec 2012 00:26:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:x-mailer; bh=G1KY1AoEutyMYH46vZi7DCxUT5vHid4JiepCHHFoLiI=; b=ru3tpilf3hSawykoWg6kHWPpdo8GjmBfGSydUk079WcckZ93yoxW4tHQKLt5Hjmx/0 EhSGDb8E2SyXoilYPMdf59grYagTUne2g0D3Jpf4W7cExbnQxHWPugHT7j/COb9nhSoY azoaQ51eRyZq5BHKUk3m++3trjO5m40nqj8NcRUYhF4oRLyaUk2L3bUH60qL8cBfDQnp JkW/xAM75bCDyxH3mjhF6GKTdcTkX27/BscFTfZozP0B0pb+oO00n/5aUtEsWaEP8LGc xCrDI9mAyoITqjkh7r36XWMi/v9mQ+mfLj6dm/TPT0NsrlPLTMBjBzWZWF12tNI55aGU 0hcA== Received: by 10.68.241.232 with SMTP id wl8mr3031527pbc.144.1355387160220; Thu, 13 Dec 2012 00:26:00 -0800 (PST) Received: from localhost ([61.148.56.138]) by mx.google.com with ESMTPS id u1sm865784pav.16.2012.12.13.00.25.56 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 13 Dec 2012 00:25:59 -0800 (PST) From: roy.qing.li@gmail.com To: netdev@vger.kernel.org Subject: [RFC PATCH] xfrm: avoid to send/receive the exceeding hard lifetime data Date: Thu, 13 Dec 2012 16:25:52 +0800 Message-Id: <1355387152-9963-1-git-send-email-roy.qing.li@gmail.com> X-Mailer: git-send-email 1.7.5.4 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Li RongQing If setkey sets both bh and bs as 1024, and the total send and receive package size is 1024, then if next package size is too large, this package should be discard. Example, first package size is 1000, send success, then the second package is 500, 1000+500 is larger than 1024, so the second package should be discard. Signed-off-by: Li RongQing --- net/xfrm/xfrm_input.c | 6 +++--- net/xfrm/xfrm_output.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/net/xfrm/xfrm_input.c b/net/xfrm/xfrm_input.c index ab2bb42..d0de8f3 100644 --- a/net/xfrm/xfrm_input.c +++ b/net/xfrm/xfrm_input.c @@ -178,6 +178,9 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type) goto drop_unlock; } + x->curlft.bytes += skb->len; + x->curlft.packets++; + if (xfrm_state_check_expire(x)) { XFRM_INC_STATS(net, LINUX_MIB_XFRMINSTATEEXPIRED); goto drop_unlock; @@ -219,9 +222,6 @@ resume: x->repl->advance(x, seq); - x->curlft.bytes += skb->len; - x->curlft.packets++; - spin_unlock(&x->lock); XFRM_MODE_SKB_CB(skb)->protocol = nexthdr; diff --git a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c index 95a338c..0f38cb2 100644 --- a/net/xfrm/xfrm_output.c +++ b/net/xfrm/xfrm_output.c @@ -61,6 +61,9 @@ static int xfrm_output_one(struct sk_buff *skb, int err) } spin_lock_bh(&x->lock); + + x->curlft.bytes += skb->len; + x->curlft.packets++; err = xfrm_state_check_expire(x); if (err) { XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTSTATEEXPIRED); @@ -73,9 +76,6 @@ static int xfrm_output_one(struct sk_buff *skb, int err) goto error; } - x->curlft.bytes += skb->len; - x->curlft.packets++; - spin_unlock_bh(&x->lock); skb_dst_force(skb);