Skip to content

Commit 301639f

Browse files
jmberg-intelNipaLocal
authored and
NipaLocal
committed
net: drop_monitor: use drop_reason_lookup()
Now that we have drop_reason_lookup(), we can just use it for drop_monitor as well, rather than exporting the list itself. Signed-off-by: Johannes Berg <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent 3fe6222 commit 301639f

File tree

3 files changed

+8
-22
lines changed

3 files changed

+8
-22
lines changed

include/net/dropreason.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ struct drop_reason_list {
3838
size_t n_reasons;
3939
};
4040

41-
/* Note: due to dynamic registrations, access must be under RCU */
42-
extern const struct drop_reason_list __rcu *
43-
drop_reasons_by_subsys[SKB_DROP_REASON_SUBSYS_NUM];
44-
4541
#ifdef CONFIG_TRACEPOINTS
4642
const char *drop_reason_lookup(unsigned long long value);
4743
void drop_reason_show(struct seq_file *m);

net/core/drop_monitor.c

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -610,9 +610,8 @@ static int net_dm_packet_report_fill(struct sk_buff *msg, struct sk_buff *skb,
610610
size_t payload_len)
611611
{
612612
struct net_dm_skb_cb *cb = NET_DM_SKB_CB(skb);
613-
const struct drop_reason_list *list = NULL;
614-
unsigned int subsys, subsys_reason;
615613
char buf[NET_DM_MAX_SYMBOL_LEN];
614+
const char *reason_str;
616615
struct nlattr *attr;
617616
void *hdr;
618617
int rc;
@@ -630,19 +629,10 @@ static int net_dm_packet_report_fill(struct sk_buff *msg, struct sk_buff *skb,
630629
goto nla_put_failure;
631630

632631
rcu_read_lock();
633-
subsys = u32_get_bits(cb->reason, SKB_DROP_REASON_SUBSYS_MASK);
634-
if (subsys < SKB_DROP_REASON_SUBSYS_NUM)
635-
list = rcu_dereference(drop_reasons_by_subsys[subsys]);
636-
subsys_reason = cb->reason & ~SKB_DROP_REASON_SUBSYS_MASK;
637-
if (!list ||
638-
subsys_reason >= list->n_reasons ||
639-
!list->reasons[subsys_reason] ||
640-
strlen(list->reasons[subsys_reason]) > NET_DM_MAX_REASON_LEN) {
641-
list = rcu_dereference(drop_reasons_by_subsys[SKB_DROP_REASON_SUBSYS_CORE]);
642-
subsys_reason = SKB_DROP_REASON_NOT_SPECIFIED;
643-
}
644-
if (nla_put_string(msg, NET_DM_ATTR_REASON,
645-
list->reasons[subsys_reason])) {
632+
reason_str = drop_reason_lookup(cb->reason);
633+
if (unlikely(!reason_str))
634+
reason_str = drop_reason_lookup(SKB_DROP_REASON_NOT_SPECIFIED);
635+
if (nla_put_string(msg, NET_DM_ATTR_REASON, reason_str)) {
646636
rcu_read_unlock();
647637
goto nla_put_failure;
648638
}

net/core/skbuff.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,11 @@ static const struct drop_reason_list drop_reasons_core = {
139139
.n_reasons = ARRAY_SIZE(drop_reasons),
140140
};
141141

142-
const struct drop_reason_list __rcu *
142+
static const struct drop_reason_list __rcu *
143143
drop_reasons_by_subsys[SKB_DROP_REASON_SUBSYS_NUM] = {
144144
[SKB_DROP_REASON_SUBSYS_CORE] = RCU_INITIALIZER(&drop_reasons_core),
145145
};
146-
EXPORT_SYMBOL(drop_reasons_by_subsys);
147146

148-
#ifdef CONFIG_TRACEPOINTS
149147
const char *drop_reason_lookup(unsigned long long value)
150148
{
151149
unsigned long long subsys_id = value >> SKB_DROP_REASON_SUBSYS_SHIFT;
@@ -162,7 +160,9 @@ const char *drop_reason_lookup(unsigned long long value)
162160
return NULL;
163161
return subsys->reasons[reason];
164162
}
163+
EXPORT_SYMBOL(drop_reason_lookup);
165164

165+
#ifdef CONFIG_TRACEPOINTS
166166
void drop_reason_show(struct seq_file *m)
167167
{
168168
u32 subsys_id;

0 commit comments

Comments
 (0)