driver/ramlog: Implement the rate limiting function for ramlog driver.

Limit the maximum number of log entries allowed within
the specified time interval in seconds.

Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
This commit is contained in:
yukangzhi
2025-05-27 18:07:11 +08:00
committed by Xiang Xiao
parent 6538477fa5
commit 6ccc2fc7c8
3 changed files with 187 additions and 2 deletions
+11
View File
@@ -88,6 +88,11 @@
#define SYSLOGIOC_SETFILTER _SYSLOGIOC(0x0002)
/* Set/Get syslog ratelimit */
#define SYSLOGIOC_SETRATELIMIT _SYSLOGIOC(0x0003)
#define SYSLOGIOC_GETRATELIMIT _SYSLOGIOC(0x0004)
#define SYSLOG_CHANNEL_NAME_LEN 32
#define SYSLOG_CHANNEL_DISABLE 0x01
@@ -127,6 +132,12 @@ struct syslog_channel_ops_s
syslog_close_t sc_close; /* Channel close callback */
};
struct syslog_ratelimit_s
{
unsigned int interval; /* The interval in seconds */
unsigned int burst; /* The max allowed note number during interval */
};
struct syslog_channel_info_s
{
char sc_name[SYSLOG_CHANNEL_NAME_LEN];