Thread (34 messages) 34 messages, 4 authors, 2025-08-28

Re: [PATCH net-next v2 06/13] macsec: use NLA_UINT for MACSEC_SA_ATTR_PN

From: Sabrina Dubroca <sd@queasysnail.net>
Date: 2025-08-28 14:25:45

2025-08-27, 18:55:40 -0700, Jakub Kicinski wrote:
On Wed, 27 Aug 2025 18:54:15 -0700 Jakub Kicinski wrote:
quoted
On Tue, 26 Aug 2025 15:16:24 +0200 Sabrina Dubroca wrote:
quoted
MACSEC_SA_ATTR_PN is either a u32 or a u64, we can now use NLA_UINT
for this instead of a custom binary type. We can then use a min check
within the policy.

We need to keep the length checks done in macsec_{add,upd}_{rx,tx}sa
based on whether the device is set up for XPN (with 64b PNs instead of
32b).

On the dump side, keep the existing custom code as userspace may
expect a u64 when using XPN, and nla_put_uint may only output a u32
attribute if the value fits.  
I think this is a slight functional change on big endian.
I suppose we don't care..
we don't care == the change is not intentional, so in the unlikely case
BE users exist aligning with LE is better in the first place.
I don't think this is changing the behavior. The previous check was
copying whatever bytes were in the attribute into a u64 (incorrectly
on BE) and setting the rest to 0, and then checking that this u64 is
!= 0. The new check is reading the value correctly and also checking
that it's != 0.

Converting the nla_get_u64(MACSEC_SA_ATTR_PN) in
macsec_{add,upd}_{rx,tx}sa to get_uint would change the behavior on
BE, but the current code hasn't worked correctly since XPN was
introduced? We use 1<<32 instead of 1 as our PN, which doesn't make
sense when using 32bit PNs. So I think we'll want to change all the
nla_get_u64(MACSEC_SA_ATTR_PN) into
nla_get_uint(MACSEC_SA_ATTR_PN). WDYT?

-- 
Sabrina
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help