rtnetlink: move validate_linkmsg out of do_setlink
authorXin Long <lucien.xin@gmail.com>
Mon, 12 Jun 2023 15:55:34 +0000 (11:55 -0400)
committerJakub Kicinski <kuba@kernel.org>
Thu, 15 Jun 2023 05:34:13 +0000 (22:34 -0700)
commit89da780aa4c7667c8b1a144959206262aebdeabe
treeea242fe5a6946622ffeb6f8f44869de52c089afb
parentfa0e21fa44438a0e856d42224bfa24641d37b979
rtnetlink: move validate_linkmsg out of do_setlink

This patch moves validate_linkmsg() out of do_setlink() to its callers
and deletes the early validate_linkmsg() call in __rtnl_newlink(), so
that it will not call validate_linkmsg() twice in either of the paths:

  - __rtnl_newlink() -> do_setlink()
  - __rtnl_newlink() -> rtnl_newlink_create() -> rtnl_create_link()

Additionally, as validate_linkmsg() is now only called with a real
dev, we can remove the NULL check for dev in validate_linkmsg().

Note that we moved validate_linkmsg() check to the places where it has
not done any changes to the dev, as Jakub suggested.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Link: https://lore.kernel.org/r/cf2ef061e08251faf9e8be25ff0d61150c030475.1686585334.git.lucien.xin@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/core/rtnetlink.c