Skip to content

Commit fb81139

Browse files
Rick Jonesdavem330
authored andcommitted
net: add explicit logging and stat for neighbour table overflow
Add an explicit neighbour table overflow message (ratelimited) and statistic to make diagnosing neighbour table overflows tractable in the wild. Diagnosing a neighbour table overflow can be quite difficult in the wild because there is no explicit dmesg logged. Callers to neighbour code seem to use net_dbg_ratelimit when the neighbour call fails which means the "base message" is not emitted and the callback suppressed messages from the ratelimiting can end-up juxtaposed with unrelated messages. Further, a forced garbage collection will increment a stat on each call whether it was successful in freeing-up a table entry or not, so that statistic is only a hint. So, add a net_info_ratelimited message and explicit statistic to the neighbour code. Signed-off-by: Rick Jones <rick.jones2@hp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent a785403 commit fb81139

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

include/net/neighbour.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ struct neigh_statistics {
125125
unsigned long forced_gc_runs; /* number of forced GC runs */
126126

127127
unsigned long unres_discards; /* number of unresolved drops */
128+
unsigned long table_fulls; /* times even gc couldn't help */
128129
};
129130

130131
#define NEIGH_CACHE_STAT_INC(tbl, field) this_cpu_inc((tbl)->stats->field)

include/uapi/linux/neighbour.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ struct ndt_stats {
106106
__u64 ndts_rcv_probes_ucast;
107107
__u64 ndts_periodic_gc_runs;
108108
__u64 ndts_forced_gc_runs;
109+
__u64 ndts_table_fulls;
109110
};
110111

111112
enum {

net/core/neighbour.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,12 @@ static struct neighbour *neigh_alloc(struct neigh_table *tbl, struct net_device
274274
(entries >= tbl->gc_thresh2 &&
275275
time_after(now, tbl->last_flush + 5 * HZ))) {
276276
if (!neigh_forced_gc(tbl) &&
277-
entries >= tbl->gc_thresh3)
277+
entries >= tbl->gc_thresh3) {
278+
net_info_ratelimited("%s: neighbor table overflow!\n",
279+
tbl->id);
280+
NEIGH_CACHE_STAT_INC(tbl, table_fulls);
278281
goto out_entries;
282+
}
279283
}
280284

281285
n = kzalloc(tbl->entry_size + dev->neigh_priv_len, GFP_ATOMIC);
@@ -1849,6 +1853,7 @@ static int neightbl_fill_info(struct sk_buff *skb, struct neigh_table *tbl,
18491853
ndst.ndts_rcv_probes_ucast += st->rcv_probes_ucast;
18501854
ndst.ndts_periodic_gc_runs += st->periodic_gc_runs;
18511855
ndst.ndts_forced_gc_runs += st->forced_gc_runs;
1856+
ndst.ndts_table_fulls += st->table_fulls;
18521857
}
18531858

18541859
if (nla_put(skb, NDTA_STATS, sizeof(ndst), &ndst))
@@ -2717,12 +2722,12 @@ static int neigh_stat_seq_show(struct seq_file *seq, void *v)
27172722
struct neigh_statistics *st = v;
27182723

27192724
if (v == SEQ_START_TOKEN) {
2720-
seq_printf(seq, "entries allocs destroys hash_grows lookups hits res_failed rcv_probes_mcast rcv_probes_ucast periodic_gc_runs forced_gc_runs unresolved_discards\n");
2725+
seq_printf(seq, "entries allocs destroys hash_grows lookups hits res_failed rcv_probes_mcast rcv_probes_ucast periodic_gc_runs forced_gc_runs unresolved_discards table_fulls\n");
27212726
return 0;
27222727
}
27232728

27242729
seq_printf(seq, "%08x %08lx %08lx %08lx %08lx %08lx %08lx "
2725-
"%08lx %08lx %08lx %08lx %08lx\n",
2730+
"%08lx %08lx %08lx %08lx %08lx %08lx\n",
27262731
atomic_read(&tbl->entries),
27272732

27282733
st->allocs,
@@ -2739,7 +2744,8 @@ static int neigh_stat_seq_show(struct seq_file *seq, void *v)
27392744

27402745
st->periodic_gc_runs,
27412746
st->forced_gc_runs,
2742-
st->unres_discards
2747+
st->unres_discards,
2748+
st->table_fulls
27432749
);
27442750

27452751
return 0;

0 commit comments

Comments
 (0)