netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] rtnl: don't account unused struct ifla_port_vsi in rtnl_port_size
@ 2017-02-17  0:56 Daniel Borkmann
  2017-02-17 19:57 ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Borkmann @ 2017-02-17  0:56 UTC (permalink / raw)
  To: davem; +Cc: roopa, netdev, Daniel Borkmann

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>
---
 ( Found while reviewing NLA_BINARY longer time ago. )

 net/core/rtnetlink.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index adfb54b..ed1ab03 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -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 int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
 	[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] = {
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] rtnl: don't account unused struct ifla_port_vsi in rtnl_port_size
  2017-02-17  0:56 [PATCH net-next] rtnl: don't account unused struct ifla_port_vsi in rtnl_port_size Daniel Borkmann
@ 2017-02-17 19:57 ` David Miller
  2017-02-17 20:40   ` Daniel Borkmann
  0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2017-02-17 19:57 UTC (permalink / raw)
  To: daniel; +Cc: roopa, netdev

From: Daniel Borkmann <daniel@iogearbox.net>
Date: Fri, 17 Feb 2017 01:56:11 +0100

> 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>
> ---
>  ( Found while reviewing NLA_BINARY longer time ago. )

Applied, but whether or not this is emitted it controlled by how a driver
implements ->ndo_get_vf_port().

Therefore, in the future some driver could fill this in.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] rtnl: don't account unused struct ifla_port_vsi in rtnl_port_size
  2017-02-17 19:57 ` David Miller
@ 2017-02-17 20:40   ` Daniel Borkmann
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Borkmann @ 2017-02-17 20:40 UTC (permalink / raw)
  To: David Miller; +Cc: roopa, netdev

On 02/17/2017 08:57 PM, David Miller wrote:
> From: Daniel Borkmann <daniel@iogearbox.net>
> Date: Fri, 17 Feb 2017 01:56:11 +0100
>
>> 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>
>> ---
>>   ( Found while reviewing NLA_BINARY longer time ago. )
>
> Applied, but whether or not this is emitted it controlled by how a driver
> implements ->ndo_get_vf_port().
>
> Therefore, in the future some driver could fill this in.

Agree, in that case, it can be undone; when I checked, this part
was added 7 years ago via 57b610805ce9 ("net: Add netlink support
for virtual port management (was iovnl)") and never had a single
user since then.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-02-17 20:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-17  0:56 [PATCH net-next] rtnl: don't account unused struct ifla_port_vsi in rtnl_port_size Daniel Borkmann
2017-02-17 19:57 ` David Miller
2017-02-17 20:40   ` Daniel Borkmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).