Skip to content

Commit e1c6c38

Browse files
q2venkuba-moo
authored andcommitted
rtnetlink: Remove rtnl_register() and rtnl_register_module().
No one uses rtnl_register() and rtnl_register_module(). Let's remove them. Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Link: https://patch.msgid.link/20241014201828.91221-12-kuniyu@amazon.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent df96b8f commit e1c6c38

File tree

2 files changed

+31
-58
lines changed

2 files changed

+31
-58
lines changed

include/net/rtnetlink.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ static inline enum rtnl_kinds rtnl_msgtype_kind(int msgtype)
2929
return msgtype & RTNL_KIND_MASK;
3030
}
3131

32+
/**
33+
* struct rtnl_msg_handler - rtnetlink message type and handlers
34+
*
35+
* @owner: NULL for built-in, THIS_MODULE for module
36+
* @protocol: Protocol family or PF_UNSPEC
37+
* @msgtype: rtnetlink message type
38+
* @doit: Function pointer called for each request message
39+
* @dumpit: Function pointer called for each dump request (NLM_F_DUMP) message
40+
* @flags: rtnl_link_flags to modify behaviour of doit/dumpit functions
41+
*/
3242
struct rtnl_msg_handler {
3343
struct module *owner;
3444
int protocol;
@@ -38,11 +48,6 @@ struct rtnl_msg_handler {
3848
int flags;
3949
};
4050

41-
void rtnl_register(int protocol, int msgtype,
42-
rtnl_doit_func, rtnl_dumpit_func, unsigned int flags);
43-
int rtnl_register_module(struct module *owner, int protocol, int msgtype,
44-
rtnl_doit_func, rtnl_dumpit_func, unsigned int flags);
45-
int rtnl_unregister(int protocol, int msgtype);
4651
void rtnl_unregister_all(int protocol);
4752

4853
int __rtnl_register_many(const struct rtnl_msg_handler *handlers, int n);

net/core/rtnetlink.c

Lines changed: 21 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -338,65 +338,14 @@ static int rtnl_register_internal(struct module *owner,
338338
return ret;
339339
}
340340

341-
/**
342-
* rtnl_register_module - Register a rtnetlink message type
343-
*
344-
* @owner: module registering the hook (THIS_MODULE)
345-
* @protocol: Protocol family or PF_UNSPEC
346-
* @msgtype: rtnetlink message type
347-
* @doit: Function pointer called for each request message
348-
* @dumpit: Function pointer called for each dump request (NLM_F_DUMP) message
349-
* @flags: rtnl_link_flags to modify behaviour of doit/dumpit functions
350-
*
351-
* Like rtnl_register, but for use by removable modules.
352-
*/
353-
int rtnl_register_module(struct module *owner,
354-
int protocol, int msgtype,
355-
rtnl_doit_func doit, rtnl_dumpit_func dumpit,
356-
unsigned int flags)
357-
{
358-
return rtnl_register_internal(owner, protocol, msgtype,
359-
doit, dumpit, flags);
360-
}
361-
EXPORT_SYMBOL_GPL(rtnl_register_module);
362-
363-
/**
364-
* rtnl_register - Register a rtnetlink message type
365-
* @protocol: Protocol family or PF_UNSPEC
366-
* @msgtype: rtnetlink message type
367-
* @doit: Function pointer called for each request message
368-
* @dumpit: Function pointer called for each dump request (NLM_F_DUMP) message
369-
* @flags: rtnl_link_flags to modify behaviour of doit/dumpit functions
370-
*
371-
* Registers the specified function pointers (at least one of them has
372-
* to be non-NULL) to be called whenever a request message for the
373-
* specified protocol family and message type is received.
374-
*
375-
* The special protocol family PF_UNSPEC may be used to define fallback
376-
* function pointers for the case when no entry for the specific protocol
377-
* family exists.
378-
*/
379-
void rtnl_register(int protocol, int msgtype,
380-
rtnl_doit_func doit, rtnl_dumpit_func dumpit,
381-
unsigned int flags)
382-
{
383-
int err;
384-
385-
err = rtnl_register_internal(NULL, protocol, msgtype, doit, dumpit,
386-
flags);
387-
if (err)
388-
pr_err("Unable to register rtnetlink message handler, "
389-
"protocol = %d, message type = %d\n", protocol, msgtype);
390-
}
391-
392341
/**
393342
* rtnl_unregister - Unregister a rtnetlink message type
394343
* @protocol: Protocol family or PF_UNSPEC
395344
* @msgtype: rtnetlink message type
396345
*
397346
* Returns 0 on success or a negative error code.
398347
*/
399-
int rtnl_unregister(int protocol, int msgtype)
348+
static int rtnl_unregister(int protocol, int msgtype)
400349
{
401350
struct rtnl_link __rcu **tab;
402351
struct rtnl_link *link;
@@ -419,7 +368,6 @@ int rtnl_unregister(int protocol, int msgtype)
419368

420369
return 0;
421370
}
422-
EXPORT_SYMBOL_GPL(rtnl_unregister);
423371

424372
/**
425373
* rtnl_unregister_all - Unregister all rtnetlink message type of a protocol
@@ -454,6 +402,26 @@ void rtnl_unregister_all(int protocol)
454402
}
455403
EXPORT_SYMBOL_GPL(rtnl_unregister_all);
456404

405+
/**
406+
* __rtnl_register_many - Register rtnetlink message types
407+
* @handlers: Array of struct rtnl_msg_handlers
408+
* @n: The length of @handlers
409+
*
410+
* Registers the specified function pointers (at least one of them has
411+
* to be non-NULL) to be called whenever a request message for the
412+
* specified protocol family and message type is received.
413+
*
414+
* The special protocol family PF_UNSPEC may be used to define fallback
415+
* function pointers for the case when no entry for the specific protocol
416+
* family exists.
417+
*
418+
* When one element of @handlers fails to register,
419+
* 1) built-in: panics.
420+
* 2) modules : the previous successful registrations are unwinded
421+
* and an error is returned.
422+
*
423+
* Use rtnl_register_many().
424+
*/
457425
int __rtnl_register_many(const struct rtnl_msg_handler *handlers, int n)
458426
{
459427
const struct rtnl_msg_handler *handler;

0 commit comments

Comments
 (0)