Skip to content

Commit 8e2fed1

Browse files
joestringerdavem330
authored andcommitted
openvswitch: Serialize acts with original netlink len
Previously, we used the kernel-internal netlink actions length to calculate the size of messages to serialize back to userspace. However,the sw_flow_actions may not be formatted exactly the same as the actions on the wire, so store the original actions length when de-serializing and re-use the original length when serializing. Signed-off-by: Joe Stringer <[email protected]> Acked-by: Pravin B Shelar <[email protected]> Acked-by: Thomas Graf <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 538e456 commit 8e2fed1

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

net/openvswitch/datapath.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ static size_t ovs_flow_cmd_msg_size(const struct sw_flow_actions *acts,
713713

714714
/* OVS_FLOW_ATTR_ACTIONS */
715715
if (should_fill_actions(ufid_flags))
716-
len += nla_total_size(acts->actions_len);
716+
len += nla_total_size(acts->orig_len);
717717

718718
return len
719719
+ nla_total_size(sizeof(struct ovs_flow_stats)) /* OVS_FLOW_ATTR_STATS */

net/openvswitch/flow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ struct sw_flow_id {
144144

145145
struct sw_flow_actions {
146146
struct rcu_head rcu;
147+
size_t orig_len; /* From flow_cmd_new netlink actions size */
147148
u32 actions_len;
148149
struct nlattr actions[];
149150
};

net/openvswitch/flow_netlink.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,6 +1619,7 @@ static struct nlattr *reserve_sfa_size(struct sw_flow_actions **sfa,
16191619

16201620
memcpy(acts->actions, (*sfa)->actions, (*sfa)->actions_len);
16211621
acts->actions_len = (*sfa)->actions_len;
1622+
acts->orig_len = (*sfa)->orig_len;
16221623
kfree(*sfa);
16231624
*sfa = acts;
16241625

@@ -2223,6 +2224,7 @@ int ovs_nla_copy_actions(const struct nlattr *attr,
22232224
if (IS_ERR(*sfa))
22242225
return PTR_ERR(*sfa);
22252226

2227+
(*sfa)->orig_len = nla_len(attr);
22262228
err = __ovs_nla_copy_actions(attr, key, 0, sfa, key->eth.type,
22272229
key->eth.tci, log);
22282230
if (err)

0 commit comments

Comments
 (0)