Implement ratelimiting for debug messages. For now, allow at most
one message per second. In the future might add a sysctl knob for each socket family to fine tune this. MFC after: 1 week
This commit is contained in:
parent
5a19634aa0
commit
4fa708ef20
@ -118,6 +118,8 @@ static struct mtx ng_btsocket_hci_raw_sockets_mtx;
|
||||
static u_int32_t ng_btsocket_hci_raw_token;
|
||||
static struct mtx ng_btsocket_hci_raw_token_mtx;
|
||||
static struct ng_btsocket_hci_raw_sec_filter *ng_btsocket_hci_raw_sec_filter;
|
||||
static struct timeval ng_btsocket_hci_raw_lasttime;
|
||||
static int ng_btsocket_hci_raw_curpps;
|
||||
|
||||
/* Sysctl tree */
|
||||
SYSCTL_DECL(_net_bluetooth_hci_sockets);
|
||||
@ -141,19 +143,23 @@ SYSCTL_INT(_net_bluetooth_hci_sockets_raw, OID_AUTO, queue_drops, CTLFLAG_RD,
|
||||
|
||||
/* Debug */
|
||||
#define NG_BTSOCKET_HCI_RAW_INFO \
|
||||
if (ng_btsocket_hci_raw_debug_level >= NG_BTSOCKET_INFO_LEVEL) \
|
||||
if (ng_btsocket_hci_raw_debug_level >= NG_BTSOCKET_INFO_LEVEL && \
|
||||
ppsratecheck(&ng_btsocket_hci_raw_lasttime, &ng_btsocket_hci_raw_curpps, 1)) \
|
||||
printf
|
||||
|
||||
#define NG_BTSOCKET_HCI_RAW_WARN \
|
||||
if (ng_btsocket_hci_raw_debug_level >= NG_BTSOCKET_WARN_LEVEL) \
|
||||
if (ng_btsocket_hci_raw_debug_level >= NG_BTSOCKET_WARN_LEVEL && \
|
||||
ppsratecheck(&ng_btsocket_hci_raw_lasttime, &ng_btsocket_hci_raw_curpps, 1)) \
|
||||
printf
|
||||
|
||||
#define NG_BTSOCKET_HCI_RAW_ERR \
|
||||
if (ng_btsocket_hci_raw_debug_level >= NG_BTSOCKET_ERR_LEVEL) \
|
||||
if (ng_btsocket_hci_raw_debug_level >= NG_BTSOCKET_ERR_LEVEL && \
|
||||
ppsratecheck(&ng_btsocket_hci_raw_lasttime, &ng_btsocket_hci_raw_curpps, 1)) \
|
||||
printf
|
||||
|
||||
#define NG_BTSOCKET_HCI_RAW_ALERT \
|
||||
if (ng_btsocket_hci_raw_debug_level >= NG_BTSOCKET_ALERT_LEVEL) \
|
||||
if (ng_btsocket_hci_raw_debug_level >= NG_BTSOCKET_ALERT_LEVEL && \
|
||||
ppsratecheck(&ng_btsocket_hci_raw_lasttime, &ng_btsocket_hci_raw_curpps, 1)) \
|
||||
printf
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -103,6 +103,8 @@ static struct mtx ng_btsocket_l2cap_sockets_mtx;
|
||||
static LIST_HEAD(, ng_btsocket_l2cap_rtentry) ng_btsocket_l2cap_rt;
|
||||
static struct mtx ng_btsocket_l2cap_rt_mtx;
|
||||
static struct task ng_btsocket_l2cap_rt_task;
|
||||
static struct timeval ng_btsocket_l2cap_lasttime;
|
||||
static int ng_btsocket_l2cap_curpps;
|
||||
|
||||
/* Sysctl tree */
|
||||
SYSCTL_DECL(_net_bluetooth_l2cap_sockets);
|
||||
@ -127,19 +129,23 @@ SYSCTL_INT(_net_bluetooth_l2cap_sockets_seq, OID_AUTO, queue_drops,
|
||||
|
||||
/* Debug */
|
||||
#define NG_BTSOCKET_L2CAP_INFO \
|
||||
if (ng_btsocket_l2cap_debug_level >= NG_BTSOCKET_INFO_LEVEL) \
|
||||
if (ng_btsocket_l2cap_debug_level >= NG_BTSOCKET_INFO_LEVEL && \
|
||||
ppsratecheck(&ng_btsocket_l2cap_lasttime, &ng_btsocket_l2cap_curpps, 1)) \
|
||||
printf
|
||||
|
||||
#define NG_BTSOCKET_L2CAP_WARN \
|
||||
if (ng_btsocket_l2cap_debug_level >= NG_BTSOCKET_WARN_LEVEL) \
|
||||
if (ng_btsocket_l2cap_debug_level >= NG_BTSOCKET_WARN_LEVEL && \
|
||||
ppsratecheck(&ng_btsocket_l2cap_lasttime, &ng_btsocket_l2cap_curpps, 1)) \
|
||||
printf
|
||||
|
||||
#define NG_BTSOCKET_L2CAP_ERR \
|
||||
if (ng_btsocket_l2cap_debug_level >= NG_BTSOCKET_ERR_LEVEL) \
|
||||
if (ng_btsocket_l2cap_debug_level >= NG_BTSOCKET_ERR_LEVEL && \
|
||||
ppsratecheck(&ng_btsocket_l2cap_lasttime, &ng_btsocket_l2cap_curpps, 1)) \
|
||||
printf
|
||||
|
||||
#define NG_BTSOCKET_L2CAP_ALERT \
|
||||
if (ng_btsocket_l2cap_debug_level >= NG_BTSOCKET_ALERT_LEVEL) \
|
||||
if (ng_btsocket_l2cap_debug_level >= NG_BTSOCKET_ALERT_LEVEL && \
|
||||
ppsratecheck(&ng_btsocket_l2cap_lasttime, &ng_btsocket_l2cap_curpps, 1)) \
|
||||
printf
|
||||
|
||||
/*
|
||||
|
@ -118,6 +118,8 @@ static struct mtx ng_btsocket_l2cap_raw_token_mtx;
|
||||
static LIST_HEAD(, ng_btsocket_l2cap_rtentry) ng_btsocket_l2cap_raw_rt;
|
||||
static struct mtx ng_btsocket_l2cap_raw_rt_mtx;
|
||||
static struct task ng_btsocket_l2cap_raw_rt_task;
|
||||
static struct timeval ng_btsocket_l2cap_raw_lasttime;
|
||||
static int ng_btsocket_l2cap_raw_curpps;
|
||||
|
||||
/* Sysctl tree */
|
||||
SYSCTL_DECL(_net_bluetooth_l2cap_sockets);
|
||||
@ -146,19 +148,23 @@ SYSCTL_INT(_net_bluetooth_l2cap_sockets_raw, OID_AUTO, queue_drops,
|
||||
|
||||
/* Debug */
|
||||
#define NG_BTSOCKET_L2CAP_RAW_INFO \
|
||||
if (ng_btsocket_l2cap_raw_debug_level >= NG_BTSOCKET_INFO_LEVEL) \
|
||||
if (ng_btsocket_l2cap_raw_debug_level >= NG_BTSOCKET_INFO_LEVEL && \
|
||||
ppsratecheck(&ng_btsocket_l2cap_raw_lasttime, &ng_btsocket_l2cap_raw_curpps, 1)) \
|
||||
printf
|
||||
|
||||
#define NG_BTSOCKET_L2CAP_RAW_WARN \
|
||||
if (ng_btsocket_l2cap_raw_debug_level >= NG_BTSOCKET_WARN_LEVEL) \
|
||||
if (ng_btsocket_l2cap_raw_debug_level >= NG_BTSOCKET_WARN_LEVEL && \
|
||||
ppsratecheck(&ng_btsocket_l2cap_raw_lasttime, &ng_btsocket_l2cap_raw_curpps, 1)) \
|
||||
printf
|
||||
|
||||
#define NG_BTSOCKET_L2CAP_RAW_ERR \
|
||||
if (ng_btsocket_l2cap_raw_debug_level >= NG_BTSOCKET_ERR_LEVEL) \
|
||||
if (ng_btsocket_l2cap_raw_debug_level >= NG_BTSOCKET_ERR_LEVEL && \
|
||||
ppsratecheck(&ng_btsocket_l2cap_raw_lasttime, &ng_btsocket_l2cap_raw_curpps, 1)) \
|
||||
printf
|
||||
|
||||
#define NG_BTSOCKET_L2CAP_RAW_ALERT \
|
||||
if (ng_btsocket_l2cap_raw_debug_level >= NG_BTSOCKET_ALERT_LEVEL) \
|
||||
if (ng_btsocket_l2cap_raw_debug_level >= NG_BTSOCKET_ALERT_LEVEL && \
|
||||
ppsratecheck(&ng_btsocket_l2cap_raw_lasttime, &ng_btsocket_l2cap_raw_curpps, 1)) \
|
||||
printf
|
||||
|
||||
/*****************************************************************************
|
||||
|
@ -71,19 +71,23 @@ MALLOC_DEFINE(M_NETGRAPH_BTSOCKET_RFCOMM, "netgraph_btsocks_rfcomm",
|
||||
|
||||
/* Debug */
|
||||
#define NG_BTSOCKET_RFCOMM_INFO \
|
||||
if (ng_btsocket_rfcomm_debug_level >= NG_BTSOCKET_INFO_LEVEL) \
|
||||
if (ng_btsocket_rfcomm_debug_level >= NG_BTSOCKET_INFO_LEVEL && \
|
||||
ppsratecheck(&ng_btsocket_rfcomm_lasttime, &ng_btsocket_rfcomm_curpps, 1)) \
|
||||
printf
|
||||
|
||||
#define NG_BTSOCKET_RFCOMM_WARN \
|
||||
if (ng_btsocket_rfcomm_debug_level >= NG_BTSOCKET_WARN_LEVEL) \
|
||||
if (ng_btsocket_rfcomm_debug_level >= NG_BTSOCKET_WARN_LEVEL && \
|
||||
ppsratecheck(&ng_btsocket_rfcomm_lasttime, &ng_btsocket_rfcomm_curpps, 1)) \
|
||||
printf
|
||||
|
||||
#define NG_BTSOCKET_RFCOMM_ERR \
|
||||
if (ng_btsocket_rfcomm_debug_level >= NG_BTSOCKET_ERR_LEVEL) \
|
||||
if (ng_btsocket_rfcomm_debug_level >= NG_BTSOCKET_ERR_LEVEL && \
|
||||
ppsratecheck(&ng_btsocket_rfcomm_lasttime, &ng_btsocket_rfcomm_curpps, 1)) \
|
||||
printf
|
||||
|
||||
#define NG_BTSOCKET_RFCOMM_ALERT \
|
||||
if (ng_btsocket_rfcomm_debug_level >= NG_BTSOCKET_ALERT_LEVEL) \
|
||||
if (ng_btsocket_rfcomm_debug_level >= NG_BTSOCKET_ALERT_LEVEL && \
|
||||
ppsratecheck(&ng_btsocket_rfcomm_lasttime, &ng_btsocket_rfcomm_curpps, 1)) \
|
||||
printf
|
||||
|
||||
#define ALOT 0x7fff
|
||||
@ -191,6 +195,8 @@ static LIST_HEAD(, ng_btsocket_rfcomm_session) ng_btsocket_rfcomm_sessions;
|
||||
static struct mtx ng_btsocket_rfcomm_sessions_mtx;
|
||||
static LIST_HEAD(, ng_btsocket_rfcomm_pcb) ng_btsocket_rfcomm_sockets;
|
||||
static struct mtx ng_btsocket_rfcomm_sockets_mtx;
|
||||
static struct timeval ng_btsocket_rfcomm_lasttime;
|
||||
static int ng_btsocket_rfcomm_curpps;
|
||||
|
||||
/* Sysctl tree */
|
||||
SYSCTL_DECL(_net_bluetooth_rfcomm_sockets);
|
||||
|
@ -102,6 +102,8 @@ static LIST_HEAD(, ng_btsocket_sco_pcb) ng_btsocket_sco_sockets;
|
||||
static LIST_HEAD(, ng_btsocket_sco_rtentry) ng_btsocket_sco_rt;
|
||||
static struct mtx ng_btsocket_sco_rt_mtx;
|
||||
static struct task ng_btsocket_sco_rt_task;
|
||||
static struct timeval ng_btsocket_sco_lasttime;
|
||||
static int ng_btsocket_sco_curpps;
|
||||
|
||||
/* Sysctl tree */
|
||||
SYSCTL_DECL(_net_bluetooth_sco_sockets);
|
||||
@ -126,19 +128,23 @@ SYSCTL_INT(_net_bluetooth_sco_sockets_seq, OID_AUTO, queue_drops,
|
||||
|
||||
/* Debug */
|
||||
#define NG_BTSOCKET_SCO_INFO \
|
||||
if (ng_btsocket_sco_debug_level >= NG_BTSOCKET_INFO_LEVEL) \
|
||||
if (ng_btsocket_sco_debug_level >= NG_BTSOCKET_INFO_LEVEL && \
|
||||
ppsratecheck(&ng_btsocket_sco_lasttime, &ng_btsocket_sco_curpps, 1)) \
|
||||
printf
|
||||
|
||||
#define NG_BTSOCKET_SCO_WARN \
|
||||
if (ng_btsocket_sco_debug_level >= NG_BTSOCKET_WARN_LEVEL) \
|
||||
if (ng_btsocket_sco_debug_level >= NG_BTSOCKET_WARN_LEVEL && \
|
||||
ppsratecheck(&ng_btsocket_sco_lasttime, &ng_btsocket_sco_curpps, 1)) \
|
||||
printf
|
||||
|
||||
#define NG_BTSOCKET_SCO_ERR \
|
||||
if (ng_btsocket_sco_debug_level >= NG_BTSOCKET_ERR_LEVEL) \
|
||||
if (ng_btsocket_sco_debug_level >= NG_BTSOCKET_ERR_LEVEL && \
|
||||
ppsratecheck(&ng_btsocket_sco_lasttime, &ng_btsocket_sco_curpps, 1)) \
|
||||
printf
|
||||
|
||||
#define NG_BTSOCKET_SCO_ALERT \
|
||||
if (ng_btsocket_sco_debug_level >= NG_BTSOCKET_ALERT_LEVEL) \
|
||||
if (ng_btsocket_sco_debug_level >= NG_BTSOCKET_ALERT_LEVEL && \
|
||||
ppsratecheck(&ng_btsocket_sco_lasttime, &ng_btsocket_sco_curpps, 1)) \
|
||||
printf
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user