Skip to content

Commit 2279994

Browse files
pshelardavem330
authored andcommitted
openvswitch: avoid resetting flow key while installing new flow.
since commit commit db74a33 ("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: Pravin B Shelar <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 190aa3e commit 2279994

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

net/openvswitch/datapath.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ static int ovs_flow_cmd_new(struct sk_buff *skb, struct genl_info *info)
955955
}
956956

957957
/* Extract key. */
958-
ovs_match_init(&match, &new_flow->key, &mask);
958+
ovs_match_init(&match, &new_flow->key, false, &mask);
959959
error = ovs_nla_get_match(net, &match, a[OVS_FLOW_ATTR_KEY],
960960
a[OVS_FLOW_ATTR_MASK], log);
961961
if (error)
@@ -1124,7 +1124,7 @@ static int ovs_flow_cmd_set(struct sk_buff *skb, struct genl_info *info)
11241124

11251125
ufid_present = ovs_nla_get_ufid(&sfid, a[OVS_FLOW_ATTR_UFID], log);
11261126
if (a[OVS_FLOW_ATTR_KEY]) {
1127-
ovs_match_init(&match, &key, &mask);
1127+
ovs_match_init(&match, &key, true, &mask);
11281128
error = ovs_nla_get_match(net, &match, a[OVS_FLOW_ATTR_KEY],
11291129
a[OVS_FLOW_ATTR_MASK], log);
11301130
} else if (!ufid_present) {
@@ -1241,7 +1241,7 @@ static int ovs_flow_cmd_get(struct sk_buff *skb, struct genl_info *info)
12411241

12421242
ufid_present = ovs_nla_get_ufid(&ufid, a[OVS_FLOW_ATTR_UFID], log);
12431243
if (a[OVS_FLOW_ATTR_KEY]) {
1244-
ovs_match_init(&match, &key, NULL);
1244+
ovs_match_init(&match, &key, true, NULL);
12451245
err = ovs_nla_get_match(net, &match, a[OVS_FLOW_ATTR_KEY], NULL,
12461246
log);
12471247
} else if (!ufid_present) {
@@ -1300,7 +1300,7 @@ static int ovs_flow_cmd_del(struct sk_buff *skb, struct genl_info *info)
13001300

13011301
ufid_present = ovs_nla_get_ufid(&ufid, a[OVS_FLOW_ATTR_UFID], log);
13021302
if (a[OVS_FLOW_ATTR_KEY]) {
1303-
ovs_match_init(&match, &key, NULL);
1303+
ovs_match_init(&match, &key, true, NULL);
13041304
err = ovs_nla_get_match(net, &match, a[OVS_FLOW_ATTR_KEY],
13051305
NULL, log);
13061306
if (unlikely(err))

net/openvswitch/flow.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -767,8 +767,6 @@ int ovs_flow_key_extract_userspace(struct net *net, const struct nlattr *attr,
767767
{
768768
int err;
769769

770-
memset(key, 0, OVS_SW_FLOW_KEY_METADATA_SIZE);
771-
772770
/* Extract metadata from netlink attributes. */
773771
err = ovs_nla_get_flow_metadata(net, attr, key, log);
774772
if (err)

net/openvswitch/flow_netlink.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1996,13 +1996,15 @@ static int validate_and_copy_sample(struct net *net, const struct nlattr *attr,
19961996

19971997
void ovs_match_init(struct sw_flow_match *match,
19981998
struct sw_flow_key *key,
1999+
bool reset_key,
19992000
struct sw_flow_mask *mask)
20002001
{
20012002
memset(match, 0, sizeof(*match));
20022003
match->key = key;
20032004
match->mask = mask;
20042005

2005-
memset(key, 0, sizeof(*key));
2006+
if (reset_key)
2007+
memset(key, 0, sizeof(*key));
20062008

20072009
if (mask) {
20082010
memset(&mask->key, 0, sizeof(mask->key));
@@ -2049,7 +2051,7 @@ static int validate_and_copy_set_tun(const struct nlattr *attr,
20492051
struct nlattr *a;
20502052
int err = 0, start, opts_type;
20512053

2052-
ovs_match_init(&match, &key, NULL);
2054+
ovs_match_init(&match, &key, true, NULL);
20532055
opts_type = ip_tun_from_nlattr(nla_data(attr), &match, false, log);
20542056
if (opts_type < 0)
20552057
return opts_type;

net/openvswitch/flow_netlink.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ size_t ovs_tun_key_attr_size(void);
4141
size_t ovs_key_attr_size(void);
4242

4343
void ovs_match_init(struct sw_flow_match *match,
44-
struct sw_flow_key *key, struct sw_flow_mask *mask);
44+
struct sw_flow_key *key, bool reset_key,
45+
struct sw_flow_mask *mask);
4546

4647
int ovs_nla_put_key(const struct sw_flow_key *, const struct sw_flow_key *,
4748
int attr, bool is_mask, struct sk_buff *);

0 commit comments

Comments
 (0)