Subject: Re: [PATCH v5 net-next 4/4] rtnetlink: return EINVAL when request cannot succeed

From: Vinicius Costa Gomes <[email-masked]>
Date: Thu, 21 Apr 2022 18:27:15 -0700

Stephen Hemminger <[email-masked]> writes:

> On Fri, 15 Apr 2022 18:53:30 +0200
> Florent Fourcot <[email-masked]> wrote:
>
>> A request without interface name/interface index/interface group cannot
>> work. We should return EINVAL
>> 
>> Signed-off-by: Florent Fourcot <[email-masked]>
>> Signed-off-by: Brian Baboch <[email-masked]>
>> ---
>>  net/core/rtnetlink.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
>> index 73f2cbc440c9..b943336908a7 100644
>> --- a/net/core/rtnetlink.c
>> +++ b/net/core/rtnetlink.c
>> @@ -3457,7 +3457,7 @@ static int __rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,
>>  			return rtnl_group_changelink(skb, net,
>>  						nla_get_u32(tb[IFLA_GROUP]),
>>  						ifm, extack, tb);
>> -		return -ENODEV;
>> +		return -EINVAL;
>
> Sometimes changing errno can be viewed as ABI change and break applications.

It seems that this is already breaking applications. iproute2 ip-link
depends on the returned error:

https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/tree/ip/iplink.c#n221

Cheers,
-- 
Vinicius