netlink: provide an ability to set default extack message
authorLeon Romanovsky <leonro@nvidia.com>
Tue, 31 Jan 2023 13:31:57 +0000 (15:31 +0200)
committerJakub Kicinski <kuba@kernel.org>
Thu, 2 Feb 2023 05:04:09 +0000 (21:04 -0800)
commit028fb19c6ba743ed308ba99ac325afa968795e0f
tree0e9a952b6db48a9c87c98714c6aa6a2540bc5fd0
parent62e395f82d04510b0f86e5e603e29412be88596f
netlink: provide an ability to set default extack message

In netdev common pattern, extack pointer is forwarded to the drivers
to be filled with error message. However, the caller can easily
overwrite the filled message.

Instead of adding multiple "if (!extack->_msg)" checks before any
NL_SET_ERR_MSG() call, which appears after call to the driver, let's
add new macro to common code.

[1] https://lore.kernel.org/all/Y9Irgrgf3uxOjwUm@unreal
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Link: https://lore.kernel.org/r/6993fac557a40a1973dfa0095107c3d03d40bec1.1675171790.git.leon@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/linux/netlink.h
net/bridge/br_switchdev.c
net/dsa/master.c
net/dsa/slave.c
net/xfrm/xfrm_device.c