Commit 2279994d authored by pravin shelar's avatar pravin shelar Committed by David S. Miller

openvswitch: avoid resetting flow key while installing new flow.

since commit commit db74a333 ("openvswitch: use percpu
flow stats") flow alloc resets flow-key. So there is no need
to reset the flow-key again if OVS is using newly allocated
flow-key.
Signed-off-by: default avatarPravin B Shelar <pshelar@ovn.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 190aa3e7
...@@ -955,7 +955,7 @@ static int ovs_flow_cmd_new(struct sk_buff *skb, struct genl_info *info) ...@@ -955,7 +955,7 @@ static int ovs_flow_cmd_new(struct sk_buff *skb, struct genl_info *info)
} }
/* Extract key. */ /* Extract key. */
ovs_match_init(&match, &new_flow->key, &mask); ovs_match_init(&match, &new_flow->key, false, &mask);
error = ovs_nla_get_match(net, &match, a[OVS_FLOW_ATTR_KEY], error = ovs_nla_get_match(net, &match, a[OVS_FLOW_ATTR_KEY],
a[OVS_FLOW_ATTR_MASK], log); a[OVS_FLOW_ATTR_MASK], log);
if (error) if (error)
...@@ -1124,7 +1124,7 @@ static int ovs_flow_cmd_set(struct sk_buff *skb, struct genl_info *info) ...@@ -1124,7 +1124,7 @@ static int ovs_flow_cmd_set(struct sk_buff *skb, struct genl_info *info)
ufid_present = ovs_nla_get_ufid(&sfid, a[OVS_FLOW_ATTR_UFID], log); ufid_present = ovs_nla_get_ufid(&sfid, a[OVS_FLOW_ATTR_UFID], log);
if (a[OVS_FLOW_ATTR_KEY]) { if (a[OVS_FLOW_ATTR_KEY]) {
ovs_match_init(&match, &key, &mask); ovs_match_init(&match, &key, true, &mask);
error = ovs_nla_get_match(net, &match, a[OVS_FLOW_ATTR_KEY], error = ovs_nla_get_match(net, &match, a[OVS_FLOW_ATTR_KEY],
a[OVS_FLOW_ATTR_MASK], log); a[OVS_FLOW_ATTR_MASK], log);
} else if (!ufid_present) { } else if (!ufid_present) {
...@@ -1241,7 +1241,7 @@ static int ovs_flow_cmd_get(struct sk_buff *skb, struct genl_info *info) ...@@ -1241,7 +1241,7 @@ static int ovs_flow_cmd_get(struct sk_buff *skb, struct genl_info *info)
ufid_present = ovs_nla_get_ufid(&ufid, a[OVS_FLOW_ATTR_UFID], log); ufid_present = ovs_nla_get_ufid(&ufid, a[OVS_FLOW_ATTR_UFID], log);
if (a[OVS_FLOW_ATTR_KEY]) { if (a[OVS_FLOW_ATTR_KEY]) {
ovs_match_init(&match, &key, NULL); ovs_match_init(&match, &key, true, NULL);
err = ovs_nla_get_match(net, &match, a[OVS_FLOW_ATTR_KEY], NULL, err = ovs_nla_get_match(net, &match, a[OVS_FLOW_ATTR_KEY], NULL,
log); log);
} else if (!ufid_present) { } else if (!ufid_present) {
...@@ -1300,7 +1300,7 @@ static int ovs_flow_cmd_del(struct sk_buff *skb, struct genl_info *info) ...@@ -1300,7 +1300,7 @@ static int ovs_flow_cmd_del(struct sk_buff *skb, struct genl_info *info)
ufid_present = ovs_nla_get_ufid(&ufid, a[OVS_FLOW_ATTR_UFID], log); ufid_present = ovs_nla_get_ufid(&ufid, a[OVS_FLOW_ATTR_UFID], log);
if (a[OVS_FLOW_ATTR_KEY]) { if (a[OVS_FLOW_ATTR_KEY]) {
ovs_match_init(&match, &key, NULL); ovs_match_init(&match, &key, true, NULL);
err = ovs_nla_get_match(net, &match, a[OVS_FLOW_ATTR_KEY], err = ovs_nla_get_match(net, &match, a[OVS_FLOW_ATTR_KEY],
NULL, log); NULL, log);
if (unlikely(err)) if (unlikely(err))
......
...@@ -767,8 +767,6 @@ int ovs_flow_key_extract_userspace(struct net *net, const struct nlattr *attr, ...@@ -767,8 +767,6 @@ int ovs_flow_key_extract_userspace(struct net *net, const struct nlattr *attr,
{ {
int err; int err;
memset(key, 0, OVS_SW_FLOW_KEY_METADATA_SIZE);
/* Extract metadata from netlink attributes. */ /* Extract metadata from netlink attributes. */
err = ovs_nla_get_flow_metadata(net, attr, key, log); err = ovs_nla_get_flow_metadata(net, attr, key, log);
if (err) if (err)
......
...@@ -1996,13 +1996,15 @@ static int validate_and_copy_sample(struct net *net, const struct nlattr *attr, ...@@ -1996,13 +1996,15 @@ static int validate_and_copy_sample(struct net *net, const struct nlattr *attr,
void ovs_match_init(struct sw_flow_match *match, void ovs_match_init(struct sw_flow_match *match,
struct sw_flow_key *key, struct sw_flow_key *key,
bool reset_key,
struct sw_flow_mask *mask) struct sw_flow_mask *mask)
{ {
memset(match, 0, sizeof(*match)); memset(match, 0, sizeof(*match));
match->key = key; match->key = key;
match->mask = mask; match->mask = mask;
memset(key, 0, sizeof(*key)); if (reset_key)
memset(key, 0, sizeof(*key));
if (mask) { if (mask) {
memset(&mask->key, 0, sizeof(mask->key)); memset(&mask->key, 0, sizeof(mask->key));
...@@ -2049,7 +2051,7 @@ static int validate_and_copy_set_tun(const struct nlattr *attr, ...@@ -2049,7 +2051,7 @@ static int validate_and_copy_set_tun(const struct nlattr *attr,
struct nlattr *a; struct nlattr *a;
int err = 0, start, opts_type; int err = 0, start, opts_type;
ovs_match_init(&match, &key, NULL); ovs_match_init(&match, &key, true, NULL);
opts_type = ip_tun_from_nlattr(nla_data(attr), &match, false, log); opts_type = ip_tun_from_nlattr(nla_data(attr), &match, false, log);
if (opts_type < 0) if (opts_type < 0)
return opts_type; return opts_type;
......
...@@ -41,7 +41,8 @@ size_t ovs_tun_key_attr_size(void); ...@@ -41,7 +41,8 @@ size_t ovs_tun_key_attr_size(void);
size_t ovs_key_attr_size(void); size_t ovs_key_attr_size(void);
void ovs_match_init(struct sw_flow_match *match, void ovs_match_init(struct sw_flow_match *match,
struct sw_flow_key *key, struct sw_flow_mask *mask); struct sw_flow_key *key, bool reset_key,
struct sw_flow_mask *mask);
int ovs_nla_put_key(const struct sw_flow_key *, const struct sw_flow_key *, int ovs_nla_put_key(const struct sw_flow_key *, const struct sw_flow_key *,
int attr, bool is_mask, struct sk_buff *); int attr, bool is_mask, struct sk_buff *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment