提交 fc8e1ddf 编写于 作者: K Kozlov Dmitry

pppoe: fix per-interface PADI limiting

上级 cf40442a
......@@ -723,6 +723,7 @@ static int check_padi_limit(struct pppoe_serv_t *serv, uint8_t *addr)
if ((ts.tv_sec - padi->ts.tv_sec) * 1000 + (ts.tv_nsec - padi->ts.tv_nsec) / 1000000 > 1000) {
list_del(&padi->entry);
mempool_free(padi);
serv->padi_cnt--;
__sync_sub_and_fetch(&total_padi_cnt, 1);
} else
break;
......@@ -767,6 +768,7 @@ static void pppoe_recv_PADI(struct pppoe_serv_t *serv, uint8_t *pack, int size)
struct pppoe_tag *service_name_tag = NULL;
int n, service_match = 0;
struct delayed_pado_t *pado;
struct timespec ts;
__sync_add_and_fetch(&stat_PADI_recv, 1);
......@@ -775,6 +777,13 @@ static void pppoe_recv_PADI(struct pppoe_serv_t *serv, uint8_t *pack, int size)
if (check_padi_limit(serv, ethhdr->h_source)) {
__sync_add_and_fetch(&stat_PADI_drop, 1);
if (conf_verbose) {
clock_gettime(CLOCK_MONOTONIC, &ts);
if (ts.tv_sec - 60 >= serv->last_padi_limit_warn) {
log_warn("pppoe: discarding overlimit PADI packets on interface %s\n", serv->ifname);
serv->last_padi_limit_warn = ts.tv_sec;
}
}
return;
}
......
......@@ -87,6 +87,7 @@ struct pppoe_serv_t
struct list_head padi_list;
int padi_cnt;
int padi_limit;
time_t last_padi_limit_warn;
};
extern int conf_verbose;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册