39
39
#include <linux/string.h>
40
40
#include <linux/log2.h>
41
41
42
+ #define DEBUG
42
43
#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)
57
49
58
50
#define PNEIGH_HASHMASK 0xF
59
51
@@ -246,7 +238,7 @@ static void neigh_flush_dev(struct neigh_table *tbl, struct net_device *dev)
246
238
n -> nud_state = NUD_NOARP ;
247
239
else
248
240
n -> nud_state = NUD_NONE ;
249
- NEIGH_PRINTK2 ( "neigh %p is stray. \n" , n );
241
+ neigh_dbg ( 2 , "neigh %p is stray\n" , n );
250
242
}
251
243
write_unlock (& n -> lock );
252
244
neigh_cleanup_and_release (n );
@@ -542,7 +534,7 @@ struct neighbour *__neigh_create(struct neigh_table *tbl, const void *pkey,
542
534
lockdep_is_held (& tbl -> lock )));
543
535
rcu_assign_pointer (nht -> hash_buckets [hash_val ], n );
544
536
write_unlock_bh (& tbl -> lock );
545
- NEIGH_PRINTK2 ( "neigh %p is created. \n" , n );
537
+ neigh_dbg ( 2 , "neigh %p is created\n" , n );
546
538
rc = n ;
547
539
out :
548
540
return rc ;
@@ -725,7 +717,7 @@ void neigh_destroy(struct neighbour *neigh)
725
717
dev_put (dev );
726
718
neigh_parms_put (neigh -> parms );
727
719
728
- NEIGH_PRINTK2 ( "neigh %p is destroyed. \n" , neigh );
720
+ neigh_dbg ( 2 , "neigh %p is destroyed\n" , neigh );
729
721
730
722
atomic_dec (& neigh -> tbl -> entries );
731
723
kfree_rcu (neigh , rcu );
@@ -739,7 +731,7 @@ EXPORT_SYMBOL(neigh_destroy);
739
731
*/
740
732
static void neigh_suspect (struct neighbour * neigh )
741
733
{
742
- NEIGH_PRINTK2 ( "neigh %p is suspected. \n" , neigh );
734
+ neigh_dbg ( 2 , "neigh %p is suspected\n" , neigh );
743
735
744
736
neigh -> output = neigh -> ops -> output ;
745
737
}
@@ -751,7 +743,7 @@ static void neigh_suspect(struct neighbour *neigh)
751
743
*/
752
744
static void neigh_connect (struct neighbour * neigh )
753
745
{
754
- NEIGH_PRINTK2 ( "neigh %p is connected. \n" , neigh );
746
+ neigh_dbg ( 2 , "neigh %p is connected\n" , neigh );
755
747
756
748
neigh -> output = neigh -> ops -> connected_output ;
757
749
}
@@ -852,7 +844,7 @@ static void neigh_invalidate(struct neighbour *neigh)
852
844
struct sk_buff * skb ;
853
845
854
846
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 );
856
848
neigh -> updated = jiffies ;
857
849
858
850
/* It is very thin place. report_unreachable is very complicated
@@ -904,17 +896,17 @@ static void neigh_timer_handler(unsigned long arg)
904
896
if (state & NUD_REACHABLE ) {
905
897
if (time_before_eq (now ,
906
898
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 );
908
900
next = neigh -> confirmed + neigh -> parms -> reachable_time ;
909
901
} else if (time_before_eq (now ,
910
902
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 );
912
904
neigh -> nud_state = NUD_DELAY ;
913
905
neigh -> updated = jiffies ;
914
906
neigh_suspect (neigh );
915
907
next = now + neigh -> parms -> delay_probe_time ;
916
908
} else {
917
- NEIGH_PRINTK2 ( "neigh %p is suspected. \n" , neigh );
909
+ neigh_dbg ( 2 , "neigh %p is suspected\n" , neigh );
918
910
neigh -> nud_state = NUD_STALE ;
919
911
neigh -> updated = jiffies ;
920
912
neigh_suspect (neigh );
@@ -923,14 +915,14 @@ static void neigh_timer_handler(unsigned long arg)
923
915
} else if (state & NUD_DELAY ) {
924
916
if (time_before_eq (now ,
925
917
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 );
927
919
neigh -> nud_state = NUD_REACHABLE ;
928
920
neigh -> updated = jiffies ;
929
921
neigh_connect (neigh );
930
922
notify = 1 ;
931
923
next = neigh -> confirmed + neigh -> parms -> reachable_time ;
932
924
} else {
933
- NEIGH_PRINTK2 ( "neigh %p is probed. \n" , neigh );
925
+ neigh_dbg ( 2 , "neigh %p is probed\n" , neigh );
934
926
neigh -> nud_state = NUD_PROBE ;
935
927
neigh -> updated = jiffies ;
936
928
atomic_set (& neigh -> probes , 0 );
@@ -997,7 +989,7 @@ int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb)
997
989
return 1 ;
998
990
}
999
991
} 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 );
1001
993
neigh -> nud_state = NUD_DELAY ;
1002
994
neigh -> updated = jiffies ;
1003
995
neigh_add_timer (neigh ,
@@ -1320,8 +1312,7 @@ int neigh_resolve_output(struct neighbour *neigh, struct sk_buff *skb)
1320
1312
out :
1321
1313
return rc ;
1322
1314
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 );
1325
1316
out_kfree_skb :
1326
1317
rc = - EINVAL ;
1327
1318
kfree_skb (skb );
@@ -1498,7 +1489,7 @@ void neigh_parms_release(struct neigh_table *tbl, struct neigh_parms *parms)
1498
1489
}
1499
1490
}
1500
1491
write_unlock_bh (& tbl -> lock );
1501
- NEIGH_PRINTK1 ( "neigh_parms_release : not found\n" );
1492
+ neigh_dbg ( 1 , "%s : not found\n", __func__ );
1502
1493
}
1503
1494
EXPORT_SYMBOL (neigh_parms_release );
1504
1495
0 commit comments