Skip to content

Commit

Permalink
link-api: check for required callbacks on rtnl_link_info_ops registra…
Browse files Browse the repository at this point in the history
…tion

If a rtnl_link_info_ops implements io_alloc(), it also needs to
implement io_free() and io_clone(), so error out early when trying to
register such a rtnl_link_info_ops.

Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de>
  • Loading branch information
KanjiMonster committed Jul 16, 2024
1 parent 15cc0ff commit 023b94d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/route/link/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ int rtnl_link_register_info(struct rtnl_link_info_ops *ops)

BUG_ON(!ops->io_name);

NL_DBG(1, "Registering link info operations %s\n", ops->io_name);

BUG_ON(ops->io_alloc && !(ops->io_free && ops->io_clone));

nl_write_lock(&info_lock);
if (__rtnl_link_info_ops_lookup(ops->io_name)) {
err = -NLE_EXIST;
Expand Down

0 comments on commit 023b94d

Please sign in to comment.