datapath: Calculate flow hash after extracting metadata.
authorJesse Gross <jesse@nicira.com>
Thu, 8 Sep 2011 22:32:24 +0000 (15:32 -0700)
committerJesse Gross <jesse@nicira.com>
Thu, 8 Sep 2011 23:07:36 +0000 (16:07 -0700)
When we execute a packet from userspace we first extract the header
fields from the packet and then add supplied metadata.  However, we
compute the hash of the packet in between these two steps despite
the fact that the metadata can affect the hash.  This can lead to
two separate hashes for packets of the same flow.

Found by code inspection, not an actual real-world problem.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
datapath/datapath.c

index 7499081857ea41220c00b356589c3ba2e0415e13..b92c198d77084a487e1a51c042071563112c401b 100644 (file)
@@ -686,7 +686,6 @@ static int ovs_packet_cmd_execute(struct sk_buff *skb, struct genl_info *info)
        err = flow_extract(packet, -1, &flow->key, &key_len, &is_frag);
        if (err)
                goto err_flow_put;
-       flow->tbl_node.hash = flow_hash(&flow->key, key_len);
 
        err = flow_metadata_from_nlattrs(&flow->key.eth.in_port,
                                         &flow->key.eth.tun_id,
@@ -694,6 +693,8 @@ static int ovs_packet_cmd_execute(struct sk_buff *skb, struct genl_info *info)
        if (err)
                goto err_flow_put;
 
+       flow->tbl_node.hash = flow_hash(&flow->key, key_len);
+
        acts = flow_actions_alloc(a[OVS_PACKET_ATTR_ACTIONS]);
        err = PTR_ERR(acts);
        if (IS_ERR(acts))