]> git.baikalelectronics.ru Git - kernel.git/commit
net: dcb: flush lingering app table entries for unregistered devices
authorVladimir Oltean <vladimir.oltean@nxp.com>
Thu, 24 Feb 2022 16:01:54 +0000 (18:01 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 25 Feb 2022 10:42:34 +0000 (10:42 +0000)
commiteb876603e80da92b5923e72633d374a05be54b5c
treeb4224fc16b116b946205c9c97d43de06f2eeee1d
parent70bb9d3f0faf2c383f849b4272a1c9a584ead6ba
net: dcb: flush lingering app table entries for unregistered devices

If I'm not mistaken (and I don't think I am), the way in which the
dcbnl_ops work is that drivers call dcb_ieee_setapp() and this populates
the application table with dynamically allocated struct dcb_app_type
entries that are kept in the module-global dcb_app_list.

However, nobody keeps exact track of these entries, and although
dcb_ieee_delapp() is supposed to remove them, nobody does so when the
interface goes away (example: driver unbinds from device). So the
dcb_app_list will contain lingering entries with an ifindex that no
longer matches any device in dcb_app_lookup().

Reclaim the lost memory by listening for the NETDEV_UNREGISTER event and
flushing the app table entries of interfaces that are now gone.

In fact something like this used to be done as part of the initial
commit (blamed below), but it was done in dcbnl_exit() -> dcb_flushapp(),
essentially at module_exit time. That became dead code after commit
efa851a0378e ("DCB: fix kconfig option") which essentially merged
"tristate config DCB" and "bool config DCBNL" into a single "bool config
DCB", so net/dcb/dcbnl.c could not be built as a module anymore.

Commit ab2b574e1f38 ("net/dcb: make dcbnl.c explicitly non-modular")
recognized this and deleted dcbnl_exit() and dcb_flushapp() altogether,
leaving us with the version we have today.

Since flushing application table entries can and should be done as soon
as the netdevice disappears, fundamentally the commit that is to blame
is the one that introduced the design of this API.

Fixes: 8eca27adfd35 ("dcbnl: add appliction tlv handlers")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/dcb/dcbnl.c