linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Resend PATCH net] bridge: uapi: mrp: Fix MRP_PORT_ROLE
@ 2020-06-20 13:14 Horatiu Vultur
  2020-06-22 23:07 ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Horatiu Vultur @ 2020-06-20 13:14 UTC (permalink / raw)
  To: nikolay, davem, UNGLinuxDriver, linux-kernel, netdev; +Cc: Horatiu Vultur

Currently the MRP_PORT_ROLE_NONE has the value 0x2 but this is in conflict
with the IEC 62439-2 standard. The standard defines the following port
roles: primary (0x0), secondary(0x1), interconnect(0x2).
Therefore remove the port role none.

Fixes: 4714d13791f831 ("bridge: uapi: mrp: Add mrp attributes.")
Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
---
 include/uapi/linux/mrp_bridge.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/uapi/linux/mrp_bridge.h b/include/uapi/linux/mrp_bridge.h
index 84f15f48a7cb1..bee3665402129 100644
--- a/include/uapi/linux/mrp_bridge.h
+++ b/include/uapi/linux/mrp_bridge.h
@@ -36,7 +36,6 @@ enum br_mrp_port_state_type {
 enum br_mrp_port_role_type {
 	BR_MRP_PORT_ROLE_PRIMARY,
 	BR_MRP_PORT_ROLE_SECONDARY,
-	BR_MRP_PORT_ROLE_NONE,
 };
 
 enum br_mrp_tlv_header_type {
-- 
2.26.2


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

* Re: [Resend PATCH net] bridge: uapi: mrp: Fix MRP_PORT_ROLE
  2020-06-20 13:14 [Resend PATCH net] bridge: uapi: mrp: Fix MRP_PORT_ROLE Horatiu Vultur
@ 2020-06-22 23:07 ` David Miller
  2020-06-23  8:02   ` Horatiu Vultur
  0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2020-06-22 23:07 UTC (permalink / raw)
  To: horatiu.vultur; +Cc: nikolay, UNGLinuxDriver, linux-kernel, netdev

From: Horatiu Vultur <horatiu.vultur@microchip.com>
Date: Sat, 20 Jun 2020 15:14:03 +0200

> Currently the MRP_PORT_ROLE_NONE has the value 0x2 but this is in conflict
> with the IEC 62439-2 standard. The standard defines the following port
> roles: primary (0x0), secondary(0x1), interconnect(0x2).
> Therefore remove the port role none.
> 
> Fixes: 4714d13791f831 ("bridge: uapi: mrp: Add mrp attributes.")
> Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>

The code accepts arbitrary 32-bit values for the role in a configuration
but only PRIMARY and SECONDARY seem to be valid.

There is no validation that the value used makes sense.

In the future if we handle type interconnect, and we add checks, it will
break any existing applications.  Because they can validly pass any
non-zero valid and the code treats that as SECONDARY currently.

So you really can't just remove NONE, you have to add validation code
too so we don't run into problem in the future.

Thanks.

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

* Re: [Resend PATCH net] bridge: uapi: mrp: Fix MRP_PORT_ROLE
  2020-06-22 23:07 ` David Miller
@ 2020-06-23  8:02   ` Horatiu Vultur
  0 siblings, 0 replies; 3+ messages in thread
From: Horatiu Vultur @ 2020-06-23  8:02 UTC (permalink / raw)
  To: David Miller; +Cc: nikolay, UNGLinuxDriver, linux-kernel, netdev

The 06/22/2020 16:07, David Miller wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> From: Horatiu Vultur <horatiu.vultur@microchip.com>
> Date: Sat, 20 Jun 2020 15:14:03 +0200
> 
> > Currently the MRP_PORT_ROLE_NONE has the value 0x2 but this is in conflict
> > with the IEC 62439-2 standard. The standard defines the following port
> > roles: primary (0x0), secondary(0x1), interconnect(0x2).
> > Therefore remove the port role none.
> >
> > Fixes: 4714d13791f831 ("bridge: uapi: mrp: Add mrp attributes.")
> > Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
> 
> The code accepts arbitrary 32-bit values for the role in a configuration
> but only PRIMARY and SECONDARY seem to be valid.
> 
> There is no validation that the value used makes sense.
> 
> In the future if we handle type interconnect, and we add checks, it will
> break any existing applications.  Because they can validly pass any
> non-zero valid and the code treats that as SECONDARY currently.
> 
> So you really can't just remove NONE, you have to add validation code
> too so we don't run into problem in the future.

Thanks for the explanation. I will add some code that checks
specifically for primary(0x0) and secondary(0x1) values and for any
other value to return -EINVAL.
Then in the future when we handle the type interconnect(0x2), we will
just extend this code to check for this value.

> 
> Thanks.

-- 
/Horatiu

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

end of thread, other threads:[~2020-06-23  8:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-20 13:14 [Resend PATCH net] bridge: uapi: mrp: Fix MRP_PORT_ROLE Horatiu Vultur
2020-06-22 23:07 ` David Miller
2020-06-23  8:02   ` Horatiu Vultur

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).