[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <874j4mknkv.fsf@nvidia.com>
Date: Tue, 5 Nov 2024 10:45:04 +0100
From: Petr Machata <petrm@...dia.com>
To: Paolo Abeni <pabeni@...hat.com>
CC: Petr Machata <petrm@...dia.com>, Jakub Kicinski <kuba@...nel.org>, "David
S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
<netdev@...r.kernel.org>, Ido Schimmel <idosch@...dia.com>, Amit Cohen
<amcohen@...dia.com>, Vladimir Oltean <vladimir.oltean@....com>, Andy Roulin
<aroulin@...dia.com>, <mlxsw@...dia.com>
Subject: Re: [PATCH net-next v2 0/8] net: Shift responsibility for FDB
notifications to drivers
Paolo Abeni <pabeni@...hat.com> writes:
> On 11/4/24 12:43, Petr Machata wrote:
>> Jakub Kicinski <kuba@...nel.org> writes:
>>> On Thu, 24 Oct 2024 18:57:35 +0200 Petr Machata wrote:
>>>> Besides this approach, we considered just passing a boolean back from the
>>>> driver, which would indicate whether the notification was done. But the
>>>> approach presented here seems cleaner.
>>>
>>> Oops, I missed the v2, same question:
>>>
>>> What about adding a bit to the ops struct to indicate that
>>> the driver will generate the notification? Seems smaller in
>>> terms of LoC and shifts the responsibility of doing extra
>>> work towards more complex users.
>>>
>>> https://lore.kernel.org/all/20241029121619.1a710601@kernel.org/
>>
>> Sorry for only responding now, I was out of office last week.
>>
>> The reason I went with outright responsibility shift is that the
>> alternatives are more complex.
>>
>> For the flag in particular, first there's no place to set the flag
>> currently, we'd need a field in struct net_device_ops. But mainly, then
>> you have a code that needs to corrently handle both states of the flag,
>> and new-style drivers need to remember to set the flag, which is done in
>> a different place from the fdb_add/del themselves. It might be fewer
>> LOCs, but it's a harder to understand system.
>>
>> Responsibility shift is easy. "Thou shalt notify." Done, easy to
>> understand, easy to document. When cut'n'pasting, you won't miss it.
>>
>> Let me know what you think.
>
> I think that keeping as much action/responsibilities as possible in the
> core code is in general a better option - at very least to avoid
> duplicate code.
>
> I don't think that the C&P is a very good argument, as I would argue
> against C&P without understanding of the underlying code. Still I agree
> that keeping all the relevant info together is better, and a separate
> flag would be not so straight-forward.
>
> What about using the return value of fbd_add/fdb_del to tell the core
> that the driver did the notification? a positive value means 'already
> notified', a negative one error, zero 'please notify.
That would work.
How about passing an explicit bool* argument for the callee to set? I'm
suspicious of these one-off errno protocols. Most of the time the return
value is an errno, these aberrations feel easy to miss.
We decided against a dedicated argument originally, because it's not
very pretty, but if the callback itself should somehow carry the
please-notify interface (and I think it should), an argument is a more
explicit and obvious way to do it.
Powered by blists - more mailing lists