datapath: refactor ovs flow extract API.
[cascardo/ovs.git] / datapath / flow_netlink.c
index 4b07d96..d0f1e90 100644 (file)
@@ -853,7 +853,7 @@ int ovs_nla_get_match(struct sw_flow_match *match,
 
 /**
  * ovs_nla_get_flow_metadata - parses Netlink attributes into a flow key.
- * @flow: Receives extracted in_port, priority, tun_key and skb_mark.
+ * @key: Receives extracted in_port, priority, tun_key and skb_mark.
  * @attr: Netlink attribute holding nested %OVS_KEY_ATTR_* Netlink attribute
  * sequence.
  *
@@ -862,35 +862,23 @@ int ovs_nla_get_match(struct sw_flow_match *match,
  * get the metadata, that is, the parts of the flow key that cannot be
  * extracted from the packet itself.
  */
-
-int ovs_nla_get_flow_metadata(struct sw_flow *flow,
-                             const struct nlattr *attr)
+int ovs_nla_get_flow_metadata(const struct nlattr *attr,
+                             struct sw_flow_key *key)
 {
-       struct ovs_key_ipv4_tunnel *tun_key = &flow->key.tun_key;
        const struct nlattr *a[OVS_KEY_ATTR_MAX + 1];
+       struct sw_flow_match match;
        u64 attrs = 0;
        int err;
-       struct sw_flow_match match;
-
-       flow->key.phy.in_port = DP_MAX_PORTS;
-       flow->key.phy.priority = 0;
-       flow->key.phy.skb_mark = 0;
-       flow->key.ovs_flow_hash = 0;
-       flow->key.recirc_id = 0;
-       memset(tun_key, 0, sizeof(flow->key.tun_key));
 
        err = parse_flow_nlattrs(attr, a, &attrs);
        if (err)
                return -EINVAL;
 
        memset(&match, 0, sizeof(match));
-       match.key = &flow->key;
+       match.key = key;
 
-       err = metadata_from_nlattrs(&match, &attrs, a, false);
-       if (err)
-               return err;
-
-       return 0;
+       key->phy.in_port = DP_MAX_PORTS;
+       return metadata_from_nlattrs(&match, &attrs, a, false);
 }
 
 int ovs_nla_put_flow(const struct sw_flow_key *swkey,