netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [QUERY] mctp: getsockopt unknown option return code -EINVAL
@ 2025-09-01  7:11 Alok Tiwari
  2025-09-01  7:24 ` Jeremy Kerr
  0 siblings, 1 reply; 4+ messages in thread
From: Alok Tiwari @ 2025-09-01  7:11 UTC (permalink / raw)
  To: jk, matt, davem, edumazet, kuba, pabeni, horms, netdev; +Cc: alok.a.tiwari

net/mctp/af_mctp.c
In mctp_getsockopt(), unknown options currently return -EINVAL.
In contrast, mctp_setsockopt() returns -ENOPROTOOPT for unknown
options.

Would it be ideal to return -ENOPROTOOPT instead of -EINVAL in
mctp_getsockopt() when an option is unrecognized?
This would match the behavior of mctp_setsockopt() and follow the
standard kernel socket API convention for unknown options.

---
 net/mctp/af_mctp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/mctp/af_mctp.c b/net/mctp/af_mctp.c
index df4e8cf33899b..e8938ca35a066 100644
--- a/net/mctp/af_mctp.c
+++ b/net/mctp/af_mctp.c
@@ -425,7 +425,7 @@ static int mctp_getsockopt(struct socket *sock, int level, int optname,
 		return 0;
 	}
 
-	return -EINVAL;
+	return -EINVAL; // > ENOPROTOOPT
 }
 
 /* helpers for reading/writing the tag ioc, handling compatibility across the
-- 
2.50.1


Thanks,
Alok

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

* Re: [QUERY] mctp: getsockopt unknown option return code -EINVAL
  2025-09-01  7:11 [QUERY] mctp: getsockopt unknown option return code -EINVAL Alok Tiwari
@ 2025-09-01  7:24 ` Jeremy Kerr
  2025-09-01  9:59   ` ALOK TIWARI
  0 siblings, 1 reply; 4+ messages in thread
From: Jeremy Kerr @ 2025-09-01  7:24 UTC (permalink / raw)
  To: Alok Tiwari, matt, davem, edumazet, kuba, pabeni, horms, netdev

Hi Alok,

> Would it be ideal to return -ENOPROTOOPT instead of -EINVAL in
> mctp_getsockopt() when an option is unrecognized?
> This would match the behavior of mctp_setsockopt() and follow the
> standard kernel socket API convention for unknown options.

Yes, I think this makes sense, and probably extended to the level !=
SOL_MCTP checks too.

Is there a particular path you're looking at here?

Cheers,


Jeremy

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

* Re: [QUERY] mctp: getsockopt unknown option return code -EINVAL
  2025-09-01  7:24 ` Jeremy Kerr
@ 2025-09-01  9:59   ` ALOK TIWARI
  2025-09-02  3:59     ` Jeremy Kerr
  0 siblings, 1 reply; 4+ messages in thread
From: ALOK TIWARI @ 2025-09-01  9:59 UTC (permalink / raw)
  To: Jeremy Kerr, matt, davem, edumazet, kuba, pabeni, horms, netdev
  Cc: alok.a.tiwari



On 9/1/2025 12:54 PM, Jeremy Kerr wrote:
> Hi Alok,
> 
>> Would it be ideal to return -ENOPROTOOPT instead of -EINVAL in
>> mctp_getsockopt() when an option is unrecognized?
>> This would match the behavior of mctp_setsockopt() and follow the
>> standard kernel socket API convention for unknown options.
> 
> Yes, I think this makes sense, and probably extended to the level !=
> SOL_MCTP checks too.
> 
> Is there a particular path you're looking at here?
> 
> Cheers,
> 
> 
> Jeremy


Thanks Jeremy.

I was not looking at a specific path, I just noticed the inconsistency 
in the return codes between getsockopt and setsockopt.

Extending this to the level != SOL_MCTP case would also require changes 
in the mctp_setsockopt() API.
Would it be better to handle that in a separate patch? For now,
I can limit this change to mctp_getsockopt() as "returning -ENOPROTOOPT 
instead of -EINVAL".

Also, would it be fine if I send this patch to [net-next] without a 
Fixes tag?

Thanks,
Alok

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

* Re: [QUERY] mctp: getsockopt unknown option return code -EINVAL
  2025-09-01  9:59   ` ALOK TIWARI
@ 2025-09-02  3:59     ` Jeremy Kerr
  0 siblings, 0 replies; 4+ messages in thread
From: Jeremy Kerr @ 2025-09-02  3:59 UTC (permalink / raw)
  To: ALOK TIWARI, matt, davem, edumazet, kuba, pabeni, horms, netdev

Hi Alok,

> I was not looking at a specific path, I just noticed the
> inconsistency in the return codes between getsockopt and setsockopt.
> 
> Extending this to the level != SOL_MCTP case would also require
> changes in the mctp_setsockopt() API.

Yep. The changes to the level error path may have different semantics,
so if you'd prefer to look at that separately, that's fine.

> Also, would it be fine if I send this patch to [net-next] without a 
> Fixes tag?

All fine by me.

We're fairly safe from any side-effects here, as we only have the one
sockopt, but we do want to ensure that remains the case in future,
particularly if any new sockopts are introduced.

Cheers,


Jeremy

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

end of thread, other threads:[~2025-09-02  3:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-01  7:11 [QUERY] mctp: getsockopt unknown option return code -EINVAL Alok Tiwari
2025-09-01  7:24 ` Jeremy Kerr
2025-09-01  9:59   ` ALOK TIWARI
2025-09-02  3:59     ` Jeremy Kerr

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