From patchwork Fri Jun 4 11:57:38 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steffen Klassert X-Patchwork-Id: 54567 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 C2958B7D78 for ; Fri, 4 Jun 2010 21:58:18 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754360Ab0FDL6N (ORCPT ); Fri, 4 Jun 2010 07:58:13 -0400 Received: from a.mx.secunet.com ([195.81.216.161]:44499 "EHLO a.mx.secunet.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753253Ab0FDL6M (ORCPT ); Fri, 4 Jun 2010 07:58:12 -0400 Received: from localhost (alg1 [127.0.0.1]) by a.mx.secunet.com (Postfix) with ESMTP id 83CCD1A00AC; Fri, 4 Jun 2010 13:58:11 +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 A53301A00AB; Fri, 4 Jun 2010 13:58:10 +0200 (CEST) Received: from gauss.dd.secunet.de ([10.182.7.102]) by mail-srv1.secumail.de over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Fri, 4 Jun 2010 13:58:11 +0200 Received: from klassert by gauss.dd.secunet.de with local (Exim 4.69) (envelope-from ) id 1OKVWs-0001WC-0q; Fri, 04 Jun 2010 13:57:38 +0200 Date: Fri, 4 Jun 2010 13:57:38 +0200 From: Steffen Klassert To: Eric Dumazet Cc: David Miller , netdev@vger.kernel.org Subject: [PATCH v2] net: check for refcount if pop a stacked dst_entry Message-ID: <20100604115737.GA5570@secunet.com> References: <20100604104012.GA13408@secunet.com> <20100604104115.GB13408@secunet.com> <1275648679.2482.43.camel@edumazet-laptop> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1275648679.2482.43.camel@edumazet-laptop> User-Agent: Mutt/1.5.20 (2009-06-14) X-OriginalArrivalTime: 04 Jun 2010 11:58:11.0317 (UTC) FILETIME=[3478AA50:01CB03DD] Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org xfrm triggers a warning if dst_pop() drops a refcount on a noref dst. This patch changes dst_pop() to skb_dst_pop(). skb_dst_pop() drops the refcnt only on a refcounted dst. Also we don't clone the child dst_entry, so it is not refcounted and we can use skb_dst_set_noref() in xfrm_output_one(). Signed-off-by: Steffen Klassert Signed-off-by: Eric Dumazet --- include/net/dst.h | 6 +++--- net/xfrm/xfrm_output.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/net/dst.h b/include/net/dst.h index 612069b..81d1413 100644 --- a/include/net/dst.h +++ b/include/net/dst.h @@ -250,11 +250,11 @@ static inline void skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev) * Linux networking. Thus, destinations are stackable. */ -static inline struct dst_entry *dst_pop(struct dst_entry *dst) +static inline struct dst_entry *skb_dst_pop(struct sk_buff *skb) { - struct dst_entry *child = dst_clone(dst->child); + struct dst_entry *child = skb_dst(skb)->child; - dst_release(dst); + skb_dst_drop(skb); return child; } diff --git a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c index 6a32915..a3cca0a 100644 --- a/net/xfrm/xfrm_output.c +++ b/net/xfrm/xfrm_output.c @@ -95,13 +95,13 @@ resume: goto error_nolock; } - dst = dst_pop(dst); + dst = skb_dst_pop(skb); if (!dst) { XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTERROR); err = -EHOSTUNREACH; goto error_nolock; } - skb_dst_set(skb, dst); + skb_dst_set_noref(skb, dst); x = dst->xfrm; } while (x && !(x->outer_mode->flags & XFRM_MODE_FLAG_TUNNEL));