Commit b6856c9d authored by Paolo Abeni's avatar Paolo Abeni Committed by Kleber Sacilotto de Souza

openvswitch: fix flow command message size

BugLink: https://bugs.launchpad.net/bugs/1855313

[ Upstream commit 4e81c0b3 ]

When user-space sets the OVS_UFID_F_OMIT_* flags, and the relevant
flow has no UFID, we can exceed the computed size, as
ovs_nla_put_identifier() will always dump an OVS_FLOW_ATTR_KEY
attribute.
Take the above in account when computing the flow command message
size.

Fixes: 74ed7ab9 ("openvswitch: Add support for unique flow IDs.")
Reported-by: default avatarQi Jun Ding <qding@redhat.com>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarConnor Kuehl <connor.kuehl@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent dddcab70
...@@ -725,9 +725,13 @@ static size_t ovs_flow_cmd_msg_size(const struct sw_flow_actions *acts, ...@@ -725,9 +725,13 @@ static size_t ovs_flow_cmd_msg_size(const struct sw_flow_actions *acts,
{ {
size_t len = NLMSG_ALIGN(sizeof(struct ovs_header)); size_t len = NLMSG_ALIGN(sizeof(struct ovs_header));
/* OVS_FLOW_ATTR_UFID */ /* OVS_FLOW_ATTR_UFID, or unmasked flow key as fallback
* see ovs_nla_put_identifier()
*/
if (sfid && ovs_identifier_is_ufid(sfid)) if (sfid && ovs_identifier_is_ufid(sfid))
len += nla_total_size(sfid->ufid_len); len += nla_total_size(sfid->ufid_len);
else
len += nla_total_size(ovs_key_attr_size());
/* OVS_FLOW_ATTR_KEY */ /* OVS_FLOW_ATTR_KEY */
if (!sfid || should_fill_key(sfid, ufid_flags)) if (!sfid || should_fill_key(sfid, ufid_flags))
......
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