From patchwork Mon May 10 21:32:55 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 52236 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 C9721B7D70 for ; Tue, 11 May 2010 07:33:05 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755996Ab0EJVdA (ORCPT ); Mon, 10 May 2010 17:33:00 -0400 Received: from mail-wy0-f174.google.com ([74.125.82.174]:41372 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753889Ab0EJVc7 (ORCPT ); Mon, 10 May 2010 17:32:59 -0400 Received: by mail-wy0-f174.google.com with SMTP id 32so463791wyb.19 for ; Mon, 10 May 2010 14:32:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:to:cc :content-type:date:message-id:mime-version:x-mailer :content-transfer-encoding; bh=mv3O/fzPBPUa+FL1U25sf/j6aQnhmZPlLg0uCgF5SuU=; b=vNfFx5zMq6VxfPAOZ8gZIBKtYL19dHrWqJp2mDd7X7RKa+5bPmkDGdxziX7esGtQRu gR5qKJR2SfIjtcS7WnbyTkC2Di5vUpT5K9iKg0w0AqZxySV54e3dEO7WSjWuWf/8aRv1 aQdXRPb4ZTEdlkA2SHpR7sn1JfBK8xUGjc1XA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:cc:content-type:date:message-id:mime-version :x-mailer:content-transfer-encoding; b=jKn4rLxpYL3FJrB8yCDKev/2zKCjhSNeF+j1xCxR34GDQEnbYPJWnOrijay5EbsB9C Gx0doMFMZim/kBjdymP65nRHVSxC/amuVAdAGbT84Lm9pn4+8TdYYK8XX2A0i8Piu7FZ TUwmQkXLzlboG2uAbV7hx7kwlx2+aBPc/U3qc= Received: by 10.216.168.135 with SMTP id k7mr2863624wel.129.1273527178210; Mon, 10 May 2010 14:32:58 -0700 (PDT) Received: from [127.0.0.1] (gw1.cosmosbay.com [212.99.114.194]) by mx.google.com with ESMTPS id v59sm1892117wec.3.2010.05.10.14.32.57 (version=SSLv3 cipher=RC4-MD5); Mon, 10 May 2010 14:32:57 -0700 (PDT) Subject: [PATCH V4 2/4] net: implements ip_route_input_noref() From: Eric Dumazet To: David Miller Cc: netdev Date: Mon, 10 May 2010 23:32:55 +0200 Message-ID: <1273527175.10889.11.camel@edumazet-laptop> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org ip_route_input() is the version returning a refcounted dst, while ip_route_input_noref() returns a non refcounted one. Signed-off-by: Eric Dumazet --- include/net/route.h | 17 ++++++++++++++++- net/ipv4/route.c | 15 ++++++++++----- 2 files changed, 26 insertions(+), 6 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/net/route.h b/include/net/route.h index 2c9fba7..af6cf4b 100644 --- a/include/net/route.h +++ b/include/net/route.h @@ -112,7 +112,22 @@ extern void rt_cache_flush_batch(void); extern int __ip_route_output_key(struct net *, struct rtable **, const struct flowi *flp); extern int ip_route_output_key(struct net *, struct rtable **, struct flowi *flp); extern int ip_route_output_flow(struct net *, struct rtable **rp, struct flowi *flp, struct sock *sk, int flags); -extern int ip_route_input(struct sk_buff*, __be32 dst, __be32 src, u8 tos, struct net_device *devin); + +extern int ip_route_input_common(struct sk_buff *skb, __be32 dst, __be32 src, + u8 tos, struct net_device *devin, bool noref); + +static inline int ip_route_input(struct sk_buff *skb, __be32 dst, __be32 src, + u8 tos, struct net_device *devin) +{ + return ip_route_input_common(skb, dst, src, tos, devin, false); +} + +static inline int ip_route_input_noref(struct sk_buff *skb, __be32 dst, __be32 src, + u8 tos, struct net_device *devin) +{ + return ip_route_input_common(skb, dst, src, tos, devin, true); +} + extern unsigned short ip_rt_frag_needed(struct net *net, struct iphdr *iph, unsigned short new_mtu, struct net_device *dev); extern void ip_rt_send_redirect(struct sk_buff *skb); diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 705eccf..560acc6 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -2277,8 +2277,8 @@ martian_source: goto e_inval; } -int ip_route_input(struct sk_buff *skb, __be32 daddr, __be32 saddr, - u8 tos, struct net_device *dev) +int ip_route_input_common(struct sk_buff *skb, __be32 daddr, __be32 saddr, + u8 tos, struct net_device *dev, bool noref) { struct rtable * rth; unsigned hash; @@ -2304,10 +2304,15 @@ int ip_route_input(struct sk_buff *skb, __be32 daddr, __be32 saddr, rth->fl.mark == skb->mark && net_eq(dev_net(rth->u.dst.dev), net) && !rt_is_expired(rth)) { - dst_use(&rth->u.dst, jiffies); + if (noref) { + dst_use_noref(&rth->u.dst, jiffies); + skb_dst_set_noref(skb, &rth->u.dst); + } else { + dst_use(&rth->u.dst, jiffies); + skb_dst_set(skb, &rth->u.dst); + } RT_CACHE_STAT_INC(in_hit); rcu_read_unlock(); - skb_dst_set(skb, &rth->u.dst); return 0; } RT_CACHE_STAT_INC(in_hlist_search); @@ -2350,6 +2355,7 @@ skip_cache: } return ip_route_input_slow(skb, daddr, saddr, tos, dev); } +EXPORT_SYMBOL(ip_route_input_common); static int __mkroute_output(struct rtable **result, struct fib_result *res, @@ -3361,5 +3367,4 @@ void __init ip_static_sysctl_init(void) #endif EXPORT_SYMBOL(__ip_select_ident); -EXPORT_SYMBOL(ip_route_input); EXPORT_SYMBOL(ip_route_output_key);