From patchwork Sat Mar 9 21:16:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Anastasov X-Patchwork-Id: 226388 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 8348E2C02E8 for ; Sun, 10 Mar 2013 08:16:54 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752113Ab3CIVQh (ORCPT ); Sat, 9 Mar 2013 16:16:37 -0500 Received: from ja.ssi.bg ([178.16.129.10]:46857 "EHLO ja.ssi.bg" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751560Ab3CIVP6 (ORCPT ); Sat, 9 Mar 2013 16:15:58 -0500 Received: from ja.ssi.bg (localhost.localdomain [127.0.0.1]) by ja.ssi.bg (8.14.4/8.14.4) with ESMTP id r29LH7bU005929; Sat, 9 Mar 2013 23:17:07 +0200 Received: (from root@localhost) by ja.ssi.bg (8.14.4/8.14.4/Submit) id r29LH7Qc005928; Sat, 9 Mar 2013 23:17:07 +0200 From: Julian Anastasov To: Simon Horman Cc: lvs-devel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCHv2 net-next 01/15] net: add skb_dst_set_unref Date: Sat, 9 Mar 2013 23:16:41 +0200 Message-Id: <1362863815-5898-2-git-send-email-ja@ssi.bg> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1362863815-5898-1-git-send-email-ja@ssi.bg> References: <1362863815-5898-1-git-send-email-ja@ssi.bg> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org skb_dst_set_unref will use noref version even for DST_NOCACHE entries because DST_NOCACHE means dst is not cached in routing structures, still dst could be cached by routing users and used to produce noref instances. Signed-off-by: Julian Anastasov --- include/linux/skbuff.h | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 821c7f4..4d422af 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -573,6 +573,20 @@ static inline void skb_dst_set(struct sk_buff *skb, struct dst_entry *dst) extern void skb_dst_set_noref(struct sk_buff *skb, struct dst_entry *dst); /** + * skb_dst_set_unref - sets skb dst, without a reference + * @skb: buffer + * @dst: dst entry + * + * Sets skb dst, assuming a reference was not taken on dst + * skb_dst_drop() should not dst_release() this dst + */ +static inline void skb_dst_set_unref(struct sk_buff *skb, struct dst_entry *dst) +{ + WARN_ON(!rcu_read_lock_held() && !rcu_read_lock_bh_held()); + skb->_skb_refdst = (unsigned long)dst | SKB_DST_NOREF; +} + +/** * skb_dst_is_noref - Test if skb dst isn't refcounted * @skb: buffer */