diff options
author | Johannes Berg <johannes.berg@intel.com> | 2023-04-19 15:52:53 +0300 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2023-04-21 06:20:49 +0300 |
commit | 071c0fc6fb919dcf29c676a842dda08a674877d7 (patch) | |
tree | 7062c1fde75461ef4cb2a5a3395f6d56b8812b70 /include/net | |
parent | 5b8285cca6fed9bc5baabe2e5699a5a5c0d96371 (diff) | |
download | linux-071c0fc6fb919dcf29c676a842dda08a674877d7.tar.xz |
net: extend drop reasons for multiple subsystems
Extend drop reasons to make them usable by subsystems
other than core by reserving the high 16 bits for a
new subsystem ID, of which 0 of course is used for the
existing reasons immediately.
To still be able to have string reasons, restructure
that code a bit to make the loopup under RCU, the only
user of this (right now) is drop_monitor.
Link: https://lore.kernel.org/netdev/00659771ed54353f92027702c5bbb84702da62ce.camel@sipsolutions.net
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'include/net')
-rw-r--r-- | include/net/dropreason-core.h | 14 | ||||
-rw-r--r-- | include/net/dropreason.h | 31 |
2 files changed, 41 insertions, 4 deletions
diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h index ade6d5b9186c..a2b953b57689 100644 --- a/include/net/dropreason-core.h +++ b/include/net/dropreason-core.h @@ -340,12 +340,20 @@ enum skb_drop_reason { */ SKB_DROP_REASON_IPV6_NDISC_NS_OTHERHOST, /** - * @SKB_DROP_REASON_MAX: the maximum of drop reason, which shouldn't be - * used as a real 'reason' + * @SKB_DROP_REASON_MAX: the maximum of core drop reasons, which + * shouldn't be used as a real 'reason' - only for tracing code gen */ SKB_DROP_REASON_MAX, + + /** + * @SKB_DROP_REASON_SUBSYS_MASK: subsystem mask in drop reasons, + * see &enum skb_drop_reason_subsys + */ + SKB_DROP_REASON_SUBSYS_MASK = 0xffff0000, }; +#define SKB_DROP_REASON_SUBSYS_SHIFT 16 + #define SKB_DR_INIT(name, reason) \ enum skb_drop_reason name = SKB_DROP_REASON_##reason #define SKB_DR(name) \ @@ -359,6 +367,4 @@ enum skb_drop_reason { SKB_DR_SET(name, reason); \ } while (0) -extern const char * const drop_reasons[]; - #endif diff --git a/include/net/dropreason.h b/include/net/dropreason.h new file mode 100644 index 000000000000..f0f2378dbed0 --- /dev/null +++ b/include/net/dropreason.h @@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#ifndef _LINUX_DROPREASON_H +#define _LINUX_DROPREASON_H +#include <net/dropreason-core.h> + +/** + * enum skb_drop_reason_subsys - subsystem tag for (extended) drop reasons + */ +enum skb_drop_reason_subsys { + /** @SKB_DROP_REASON_SUBSYS_CORE: core drop reasons defined above */ + SKB_DROP_REASON_SUBSYS_CORE, + + /** @SKB_DROP_REASON_SUBSYS_NUM: number of subsystems defined */ + SKB_DROP_REASON_SUBSYS_NUM +}; + +struct drop_reason_list { + const char * const *reasons; + size_t n_reasons; +}; + +/* Note: due to dynamic registrations, access must be under RCU */ +extern const struct drop_reason_list __rcu * +drop_reasons_by_subsys[SKB_DROP_REASON_SUBSYS_NUM]; + +void drop_reasons_register_subsys(enum skb_drop_reason_subsys subsys, + const struct drop_reason_list *list); +void drop_reasons_unregister_subsys(enum skb_drop_reason_subsys subsys); + +#endif |