net: Add net_ratelimited_function and net_<level>_ratelimited macros
authorJoe Perches <joe@perches.com>
Sun, 13 May 2012 21:56:25 +0000 (21:56 +0000)
committerBen Hutchings <ben@decadent.org.uk>
Wed, 19 Jun 2013 01:16:44 +0000 (02:16 +0100)
commit3eddd6c470e225ba02d670a2c76d13cd05aabc0c
tree12a3ea458800262c063b1e5b4bc7b93ca23a163d
parenta1db4d774b1deab5a4f1a4a950c3523298ab4cd6
net: Add net_ratelimited_function and net_<level>_ratelimited macros

commit 3a3bfb61e64476ff1e4ac3122cb6dec9c79b795c upstream.

__ratelimit() can be considered an inverted bool test because
it returns true when not ratelimited.  Several tests in the
kernel tree use this __ratelimit() function incorrectly.

No net_ratelimit uses are incorrect currently though.

Most uses of net_ratelimit are to log something via printk or
pr_<level>.

In order to minimize the uses of net_ratelimit, and to start
standardizing the code style used for __ratelimit() and net_ratelimit(),
add a net_ratelimited_function() macro and net_<level>_ratelimited()
logging macros similar to pr_<level>_ratelimited that use the global
net_ratelimit instead of a static per call site "struct ratelimit_state".

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
include/linux/net.h