netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: eric.dumazet@gmail.com
Cc: netdev@vger.kernel.org
Subject: Re: inetpeer with create==0
Date: Thu, 03 Mar 2011 00:30:39 -0800 (PST)	[thread overview]
Message-ID: <20110303.003039.70182283.davem@davemloft.net> (raw)
In-Reply-To: <1299135107.2456.7.camel@edumazet-laptop>

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Thu, 03 Mar 2011 07:51:47 +0100

> Hmm... I'm curious you send this hack to me ;)

Ok, it's so simple :-)

diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
index 48f8d45..a194e91 100644
--- a/net/ipv4/inetpeer.c
+++ b/net/ipv4/inetpeer.c
@@ -492,6 +492,8 @@ struct inet_peer *inet_getpeer(struct inetpeer_addr *daddr, int create)
 		unlink_from_unused(p);
 		return p;
 	}
+	if (!create)
+		return NULL;
 
 	/* retry an exact lookup, taking the lock before.
 	 * At least, nodes should be hot in our cache.
@@ -505,7 +507,7 @@ struct inet_peer *inet_getpeer(struct inetpeer_addr *daddr, int create)
 		unlink_from_unused(p);
 		return p;
 	}
-	p = create ? kmem_cache_alloc(peer_cachep, GFP_ATOMIC) : NULL;
+	p = kmem_cache_alloc(peer_cachep, GFP_ATOMIC);
 	if (p) {
 		p->daddr = *daddr;
 		atomic_set(&p->refcnt, 1);

      reply	other threads:[~2011-03-03  8:30 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-03  4:45 inetpeer with create==0 David Miller
2011-03-03  5:30 ` Changli Gao
2011-03-03  5:36   ` David Miller
2011-03-03  6:27     ` Changli Gao
2011-03-03  6:42       ` David Miller
2011-03-03  7:39         ` Eric Dumazet
2011-03-03  8:32           ` David Miller
2011-03-04 15:09             ` [PATCH net-next-2.6] inetpeer: seqlock optimization Eric Dumazet
2011-03-04 19:17               ` David Miller
2011-03-04 20:45                 ` David Miller
2011-03-04 22:13                   ` Eric Dumazet
2011-03-04 22:44                     ` David Miller
2011-03-04 23:02                       ` Eric Dumazet
2011-03-03  8:07         ` inetpeer with create==0 Changli Gao
2011-03-03  8:34           ` David Miller
2011-03-03  6:51 ` Eric Dumazet
2011-03-03  8:30   ` David Miller [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110303.003039.70182283.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).