[ovs-dev] [PATCH] ofproto-dpif: More efficient implementation of get_odp_port().

Ben Pfaff blp at nicira.com
Wed Jan 9 18:30:25 UTC 2013


On Wed, Jan 09, 2013 at 02:21:47PM +0200, Jarno Rajahalme wrote:
> Avoids unnecessary hash bucket traversal (ofproto_get_port()), since we
> have the ofport_dpif already after odp_port_to_ofport().
> 
> Signed-off-by: Jarno Rajahalme <jarno.rajahalme at nsn.com>

Thanks!

I was able to simplify the test to eliminate the ofproto_dpif_cast()
call.  I applied the following to master.

--8<--------------------------cut here-------------------------->8--

From: Jarno Rajahalme <jarno.rajahalme at nsn.com>
Date: Wed, 9 Jan 2013 14:21:47 +0200
Subject: [PATCH] ofproto-dpif: More efficient implementation of get_odp_port().

Avoids unnecessary hash bucket traversal (ofproto_get_port()), since we
have the ofport_dpif already after odp_port_to_ofport().

Signed-off-by: Jarno Rajahalme <jarno.rajahalme at nsn.com>
[blp at nicira.com simplified the test]
Signed-off-by: Ben Pfaff <blp at nicira.com>
---
 ofproto/ofproto-dpif.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 186f0a7..5b86d46 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -2792,7 +2792,8 @@ get_ofp_port(const struct ofproto_dpif *ofproto, uint16_t ofp_port)
 static struct ofport_dpif *
 get_odp_port(const struct ofproto_dpif *ofproto, uint32_t odp_port)
 {
-    return get_ofp_port(ofproto, odp_port_to_ofp_port(ofproto, odp_port));
+    struct ofport_dpif *port = odp_port_to_ofport(ofproto->backer, odp_port);
+    return port && &ofproto->up == port->up.ofproto ? port : NULL;
 }
 
 static void
-- 
1.7.2.5




More information about the dev mailing list