troglobit / pimd

PIM-SM/SSM multicast routing for UNIX and Linux
http://troglobit.com/projects/pimd/
BSD 3-Clause "New" or "Revised" License
197 stars 87 forks source link

logit(): rate-limit only what is being logged #69

Closed apoikos closed 8 years ago

apoikos commented 8 years ago

Hi,

There's a small bug in the syslog rate-limiting logic: it takes into account all messages with severity other than LOG_DEBUG, regardless of whether they would actually be logged or not (according to the --loglevel setting). By default, this means that the unprinted LOG_INFO messages might cause pimd to enter a period of slience, although it actually hasn't printed anything. This is an example from a real system:

# grep pimd /var/log/syslog
Feb 12 12:58:54 sparrow pimd[1121]: pimd version 2.3.0 starting ...
Feb 12 12:59:54 sparrow pimd[1122]: logging too fast, shutting up for 10 minutes
Feb 12 13:09:54 sparrow pimd[1122]: logging enabled again after rate limiting
Feb 12 13:10:54 sparrow pimd[1122]: logging too fast, shutting up for 10 minutes
Feb 12 13:20:54 sparrow pimd[1122]: logging enabled again after rate limiting
Feb 12 13:21:54 sparrow pimd[1122]: logging too fast, shutting up for 10 minutes
Feb 12 13:31:54 sparrow pimd[1122]: logging enabled again after rate limiting
Feb 12 13:32:54 sparrow pimd[1122]: logging too fast, shutting up for 10 minutes
Feb 12 13:42:54 sparrow pimd[1122]: logging enabled again after rate limiting
Feb 12 13:43:54 sparrow pimd[1122]: logging too fast, shutting up for 10 minutes
Feb 12 13:53:54 sparrow pimd[1122]: logging enabled again after rate limiting
Feb 12 13:54:54 sparrow pimd[1122]: logging too fast, shutting up for 10 minutes

As you can see, pimd rate-limits its syslog output although nothing has been logged. What has not been logged are approx. 200 LOG_INFO messages regarding group joins.

Fix this by taking syslog_level into account before bumping log_nmsgs.

troglobit commented 8 years ago

Awesome, thanks! :+1: