mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
LinuxKPI: add net_ratelimit()
Add a net_ratelimit() compat implementation based on ppsratecheck(). Add a sysctl to allow tuning of the number of messages. Sponsored-by: The FreeBSD Foundation MFC-after: 2 weeks Reviewed-by: hselasky Differential Revision: https://reviews.freebsd.org/D29399
This commit is contained in:
parent
a9f0367b04
commit
bc042266b2
2 changed files with 25 additions and 0 deletions
|
|
@ -76,4 +76,14 @@ sock_release(struct socket *so)
|
|||
soclose(so);
|
||||
}
|
||||
|
||||
|
||||
int linuxkpi_net_ratelimit(void);
|
||||
|
||||
static inline int
|
||||
net_ratelimit(void)
|
||||
{
|
||||
|
||||
return (linuxkpi_net_ratelimit());
|
||||
}
|
||||
|
||||
#endif /* _LINUX_NET_H_ */
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/rwlock.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stack.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/user.h>
|
||||
|
||||
#include <vm/vm.h>
|
||||
|
|
@ -99,6 +100,12 @@ int linuxkpi_debug;
|
|||
SYSCTL_INT(_compat_linuxkpi, OID_AUTO, debug, CTLFLAG_RWTUN,
|
||||
&linuxkpi_debug, 0, "Set to enable pr_debug() prints. Clear to disable.");
|
||||
|
||||
static struct timeval lkpi_net_lastlog;
|
||||
static int lkpi_net_curpps;
|
||||
static int lkpi_net_maxpps = 99;
|
||||
SYSCTL_INT(_compat_linuxkpi, OID_AUTO, net_ratelimit, CTLFLAG_RWTUN,
|
||||
&lkpi_net_maxpps, 0, "Limit number of LinuxKPI net messages per second.");
|
||||
|
||||
MALLOC_DEFINE(M_KMALLOC, "linux", "Linux kmalloc compat");
|
||||
|
||||
#include <linux/rbtree.h>
|
||||
|
|
@ -2511,6 +2518,14 @@ linux_dump_stack(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
linuxkpi_net_ratelimit(void)
|
||||
{
|
||||
|
||||
return (ppsratecheck(&lkpi_net_lastlog, &lkpi_net_curpps,
|
||||
lkpi_net_maxpps));
|
||||
}
|
||||
|
||||
#if defined(__i386__) || defined(__amd64__)
|
||||
bool linux_cpu_has_clflush;
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in a new issue