]> git.proxmox.com Git - mirror_ovs.git/commitdiff
datapath: fix flow command message size
authorPaolo Abeni <pabeni@redhat.com>
Mon, 12 Oct 2020 20:25:02 +0000 (13:25 -0700)
committerIlya Maximets <i.maximets@ovn.org>
Sat, 17 Oct 2020 15:32:06 +0000 (17:32 +0200)
Upstream commit:
    commit 4e81c0b3fa93d07653e2415fa71656b080a112fd
    Author: Paolo Abeni <pabeni@redhat.com>
    Date:   Tue Nov 26 12:55:50 2019 +0100

    openvswitch: fix flow command message size

    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: 74ed7ab9264c ("openvswitch: Add support for unique flow IDs.")
Reported-by: Qi Jun Ding <qding@redhat.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Acked-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
datapath/datapath.c

index ddc0b449185171e4453f84bde3165de10b3342d0..1020fee41d056041b19f3a27dc6d967ba70b6a8d 100644 (file)
@@ -763,9 +763,13 @@ static size_t ovs_flow_cmd_msg_size(const struct sw_flow_actions *acts,
 {
        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))
                len += nla_total_size(sfid->ufid_len);
+       else
+               len += nla_total_size(ovs_key_attr_size());
 
        /* OVS_FLOW_ATTR_KEY */
        if (!sfid || should_fill_key(sfid, ufid_flags))