rtnl: don't account unused struct ifla_port_vsi in rtnl_port_size
authorDaniel Borkmann <daniel@iogearbox.net>
Fri, 17 Feb 2017 00:56:11 +0000 (01:56 +0100)
committerDavid S. Miller <davem@davemloft.net>
Fri, 17 Feb 2017 19:56:11 +0000 (14:56 -0500)
When allocating rtnl dump messages, struct ifla_port_vsi is never dumped,
so we can save header plus payload in rtnl_port_size(). Infact, attribute
IFLA_PORT_VSI_TYPE and struct ifla_port_vsi are not used anywhere in
the kernel. We only need to keep the nla policy should applications in
user space be filling this out. Same NLA_BINARY issue exists as was fixed
in 364d5716a7ad ("rtnetlink: ifla_vf_policy: fix misuses of NLA_BINARY")
and others, but then again IFLA_PORT_VSI_TYPE is not used anywhere, so
just add a comment that it's unused.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/rtnetlink.c

index adfb54b896da7d3cddf66cc98189c62db7f22c82..e3286d32eca57d562e4cb79f9aec0afd202a6977 100644 (file)
@@ -876,8 +876,6 @@ static size_t rtnl_port_size(const struct net_device *dev,
 {
        size_t port_size = nla_total_size(4)            /* PORT_VF */
                + nla_total_size(PORT_PROFILE_MAX)      /* PORT_PROFILE */
-               + nla_total_size(sizeof(struct ifla_port_vsi))
-                                                       /* PORT_VSI_TYPE */
                + nla_total_size(PORT_UUID_MAX)         /* PORT_INSTANCE_UUID */
                + nla_total_size(PORT_UUID_MAX)         /* PORT_HOST_UUID */
                + nla_total_size(1)                     /* PROT_VDP_REQUEST */
@@ -1491,14 +1489,19 @@ static const struct nla_policy ifla_port_policy[IFLA_PORT_MAX+1] = {
        [IFLA_PORT_VF]          = { .type = NLA_U32 },
        [IFLA_PORT_PROFILE]     = { .type = NLA_STRING,
                                    .len = PORT_PROFILE_MAX },
-       [IFLA_PORT_VSI_TYPE]    = { .type = NLA_BINARY,
-                                   .len = sizeof(struct ifla_port_vsi)},
        [IFLA_PORT_INSTANCE_UUID] = { .type = NLA_BINARY,
                                      .len = PORT_UUID_MAX },
        [IFLA_PORT_HOST_UUID]   = { .type = NLA_STRING,
                                    .len = PORT_UUID_MAX },
        [IFLA_PORT_REQUEST]     = { .type = NLA_U8, },
        [IFLA_PORT_RESPONSE]    = { .type = NLA_U16, },
+
+       /* Unused, but we need to keep it here since user space could
+        * fill it. It's also broken with regard to NLA_BINARY use in
+        * combination with structs.
+        */
+       [IFLA_PORT_VSI_TYPE]    = { .type = NLA_BINARY,
+                                   .len = sizeof(struct ifla_port_vsi) },
 };
 
 static const struct nla_policy ifla_xdp_policy[IFLA_XDP_MAX + 1] = {