Skip to content

Commit d5d427c

Browse files
JoePerchesdavem330
authored andcommitted
neighbour: Convert NEIGH_PRINTK to neigh_dbg
Update debugging messages to a more current style. Emit these debugging messages at KERN_DEBUG instead of KERN_DEFAULT. Add and use neigh_dbg(level, fmt, ...) macro Add dynamic_debug capability via pr_debug Convert embedded function names to "%s: ", __func__ Signed-off-by: Joe Perches <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 057dad6 commit d5d427c

File tree

1 file changed

+20
-29
lines changed

1 file changed

+20
-29
lines changed

net/core/neighbour.c

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,13 @@
3939
#include <linux/string.h>
4040
#include <linux/log2.h>
4141

42+
#define DEBUG
4243
#define NEIGH_DEBUG 1
43-
44-
#define NEIGH_PRINTK(x...) printk(x)
45-
#define NEIGH_NOPRINTK(x...) do { ; } while(0)
46-
#define NEIGH_PRINTK1 NEIGH_NOPRINTK
47-
#define NEIGH_PRINTK2 NEIGH_NOPRINTK
48-
49-
#if NEIGH_DEBUG >= 1
50-
#undef NEIGH_PRINTK1
51-
#define NEIGH_PRINTK1 NEIGH_PRINTK
52-
#endif
53-
#if NEIGH_DEBUG >= 2
54-
#undef NEIGH_PRINTK2
55-
#define NEIGH_PRINTK2 NEIGH_PRINTK
56-
#endif
44+
#define neigh_dbg(level, fmt, ...) \
45+
do { \
46+
if (level <= NEIGH_DEBUG) \
47+
pr_debug(fmt, ##__VA_ARGS__); \
48+
} while (0)
5749

5850
#define PNEIGH_HASHMASK 0xF
5951

@@ -246,7 +238,7 @@ static void neigh_flush_dev(struct neigh_table *tbl, struct net_device *dev)
246238
n->nud_state = NUD_NOARP;
247239
else
248240
n->nud_state = NUD_NONE;
249-
NEIGH_PRINTK2("neigh %p is stray.\n", n);
241+
neigh_dbg(2, "neigh %p is stray\n", n);
250242
}
251243
write_unlock(&n->lock);
252244
neigh_cleanup_and_release(n);
@@ -542,7 +534,7 @@ struct neighbour *__neigh_create(struct neigh_table *tbl, const void *pkey,
542534
lockdep_is_held(&tbl->lock)));
543535
rcu_assign_pointer(nht->hash_buckets[hash_val], n);
544536
write_unlock_bh(&tbl->lock);
545-
NEIGH_PRINTK2("neigh %p is created.\n", n);
537+
neigh_dbg(2, "neigh %p is created\n", n);
546538
rc = n;
547539
out:
548540
return rc;
@@ -725,7 +717,7 @@ void neigh_destroy(struct neighbour *neigh)
725717
dev_put(dev);
726718
neigh_parms_put(neigh->parms);
727719

728-
NEIGH_PRINTK2("neigh %p is destroyed.\n", neigh);
720+
neigh_dbg(2, "neigh %p is destroyed\n", neigh);
729721

730722
atomic_dec(&neigh->tbl->entries);
731723
kfree_rcu(neigh, rcu);
@@ -739,7 +731,7 @@ EXPORT_SYMBOL(neigh_destroy);
739731
*/
740732
static void neigh_suspect(struct neighbour *neigh)
741733
{
742-
NEIGH_PRINTK2("neigh %p is suspected.\n", neigh);
734+
neigh_dbg(2, "neigh %p is suspected\n", neigh);
743735

744736
neigh->output = neigh->ops->output;
745737
}
@@ -751,7 +743,7 @@ static void neigh_suspect(struct neighbour *neigh)
751743
*/
752744
static void neigh_connect(struct neighbour *neigh)
753745
{
754-
NEIGH_PRINTK2("neigh %p is connected.\n", neigh);
746+
neigh_dbg(2, "neigh %p is connected\n", neigh);
755747

756748
neigh->output = neigh->ops->connected_output;
757749
}
@@ -852,7 +844,7 @@ static void neigh_invalidate(struct neighbour *neigh)
852844
struct sk_buff *skb;
853845

854846
NEIGH_CACHE_STAT_INC(neigh->tbl, res_failed);
855-
NEIGH_PRINTK2("neigh %p is failed.\n", neigh);
847+
neigh_dbg(2, "neigh %p is failed\n", neigh);
856848
neigh->updated = jiffies;
857849

858850
/* It is very thin place. report_unreachable is very complicated
@@ -904,17 +896,17 @@ static void neigh_timer_handler(unsigned long arg)
904896
if (state & NUD_REACHABLE) {
905897
if (time_before_eq(now,
906898
neigh->confirmed + neigh->parms->reachable_time)) {
907-
NEIGH_PRINTK2("neigh %p is still alive.\n", neigh);
899+
neigh_dbg(2, "neigh %p is still alive\n", neigh);
908900
next = neigh->confirmed + neigh->parms->reachable_time;
909901
} else if (time_before_eq(now,
910902
neigh->used + neigh->parms->delay_probe_time)) {
911-
NEIGH_PRINTK2("neigh %p is delayed.\n", neigh);
903+
neigh_dbg(2, "neigh %p is delayed\n", neigh);
912904
neigh->nud_state = NUD_DELAY;
913905
neigh->updated = jiffies;
914906
neigh_suspect(neigh);
915907
next = now + neigh->parms->delay_probe_time;
916908
} else {
917-
NEIGH_PRINTK2("neigh %p is suspected.\n", neigh);
909+
neigh_dbg(2, "neigh %p is suspected\n", neigh);
918910
neigh->nud_state = NUD_STALE;
919911
neigh->updated = jiffies;
920912
neigh_suspect(neigh);
@@ -923,14 +915,14 @@ static void neigh_timer_handler(unsigned long arg)
923915
} else if (state & NUD_DELAY) {
924916
if (time_before_eq(now,
925917
neigh->confirmed + neigh->parms->delay_probe_time)) {
926-
NEIGH_PRINTK2("neigh %p is now reachable.\n", neigh);
918+
neigh_dbg(2, "neigh %p is now reachable\n", neigh);
927919
neigh->nud_state = NUD_REACHABLE;
928920
neigh->updated = jiffies;
929921
neigh_connect(neigh);
930922
notify = 1;
931923
next = neigh->confirmed + neigh->parms->reachable_time;
932924
} else {
933-
NEIGH_PRINTK2("neigh %p is probed.\n", neigh);
925+
neigh_dbg(2, "neigh %p is probed\n", neigh);
934926
neigh->nud_state = NUD_PROBE;
935927
neigh->updated = jiffies;
936928
atomic_set(&neigh->probes, 0);
@@ -997,7 +989,7 @@ int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb)
997989
return 1;
998990
}
999991
} else if (neigh->nud_state & NUD_STALE) {
1000-
NEIGH_PRINTK2("neigh %p is delayed.\n", neigh);
992+
neigh_dbg(2, "neigh %p is delayed\n", neigh);
1001993
neigh->nud_state = NUD_DELAY;
1002994
neigh->updated = jiffies;
1003995
neigh_add_timer(neigh,
@@ -1320,8 +1312,7 @@ int neigh_resolve_output(struct neighbour *neigh, struct sk_buff *skb)
13201312
out:
13211313
return rc;
13221314
discard:
1323-
NEIGH_PRINTK1("neigh_resolve_output: dst=%p neigh=%p\n",
1324-
dst, neigh);
1315+
neigh_dbg(1, "%s: dst=%p neigh=%p\n", __func__, dst, neigh);
13251316
out_kfree_skb:
13261317
rc = -EINVAL;
13271318
kfree_skb(skb);
@@ -1498,7 +1489,7 @@ void neigh_parms_release(struct neigh_table *tbl, struct neigh_parms *parms)
14981489
}
14991490
}
15001491
write_unlock_bh(&tbl->lock);
1501-
NEIGH_PRINTK1("neigh_parms_release: not found\n");
1492+
neigh_dbg(1, "%s: not found\n", __func__);
15021493
}
15031494
EXPORT_SYMBOL(neigh_parms_release);
15041495

0 commit comments

Comments
 (0)