From: Ben Pfaff Date: Fri, 17 Dec 2010 22:58:52 +0000 (-0800) Subject: datapath: Avoid calling flow_hash() twice for the same key. X-Git-Tag: v1.1.0~595 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=58f8f0e703234efbd915009d184dba7c3c90059b;p=sliver-openvswitch.git datapath: Avoid calling flow_hash() twice for the same key. This is a small optimization for the case where a new flow is being added to the flow table. Signed-off-by: Ben Pfaff Acked-by: Jesse Gross --- diff --git a/datapath/datapath.c b/datapath/datapath.c index cf1632340..b95c8f255 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -817,9 +817,11 @@ static int do_put_flow(struct datapath *dp, struct odp_flow_put *uf, struct sw_flow *flow; struct tbl *table; int error; + u32 hash; + hash = flow_hash(&uf->flow.key); table = get_table_protected(dp); - flow_node = tbl_lookup(table, &uf->flow.key, flow_hash(&uf->flow.key), flow_cmp); + flow_node = tbl_lookup(table, &uf->flow.key, hash, flow_cmp); if (!flow_node) { /* No such flow. */ struct sw_flow_actions *acts; @@ -853,7 +855,7 @@ static int do_put_flow(struct datapath *dp, struct odp_flow_put *uf, rcu_assign_pointer(flow->sf_acts, acts); /* Put flow in bucket. */ - error = tbl_insert(table, &flow->tbl_node, flow_hash(&flow->key)); + error = tbl_insert(table, &flow->tbl_node, hash); if (error) goto error_free_flow_acts;