net: dcb: add new common function for set/del of app/rewr entries
authorDaniel Machon <daniel.machon@microchip.com>
Wed, 18 Jan 2023 21:08:26 +0000 (22:08 +0100)
committerDavid S. Miller <davem@davemloft.net>
Fri, 20 Jan 2023 09:33:22 +0000 (09:33 +0000)
commit30568334b657e77629293dd88a35d9c21b3258fb
tree802213cd013c89f3f790caeaed6f50eadbc6437f
parent34b7074d3fba0d3f3ca8c66b6105b7f575e77e98
net: dcb: add new common function for set/del of app/rewr entries

In preparation for DCB rewrite. Add a new function for setting and
deleting both app and rewrite entries. Moving this into a separate
function reduces duplicate code, as both type of entries requires the
same set of checks. The function will now iterate through a configurable
nested attribute (app or rewrite attr), validate each attribute and call
the appropriate set- or delete function.

Note that this function always checks for nla_len(attr_itr) <
sizeof(struct dcb_app), which was only done in dcbnl_ieee_set and not in
dcbnl_ieee_del prior to this patch. This means, that any userspace tool
that used to shove in data < sizeof(struct dcb_app) would now receive
-ERANGE.

Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/dcb/dcbnl.c