diff options
author | Kozlov Dmitry <xeb@mail.ru> | 2012-03-07 20:19:49 +0400 |
---|---|---|
committer | Kozlov Dmitry <xeb@mail.ru> | 2012-03-07 20:19:49 +0400 |
commit | fc8e1ddf2df2e71534f1f2b77dbe5ba6ebf4b745 (patch) | |
tree | 99cd3e4cf0cb21461121a3cd5b9fca58067fa45c /accel-pppd/ctrl | |
parent | cf40442a413d04379711bd73a52372d3a3264ea4 (diff) | |
download | accel-ppp-fc8e1ddf2df2e71534f1f2b77dbe5ba6ebf4b745.tar.gz accel-ppp-fc8e1ddf2df2e71534f1f2b77dbe5ba6ebf4b745.zip |
pppoe: fix per-interface PADI limiting
Diffstat (limited to 'accel-pppd/ctrl')
-rw-r--r-- | accel-pppd/ctrl/pppoe/pppoe.c | 9 | ||||
-rw-r--r-- | accel-pppd/ctrl/pppoe/pppoe.h | 1 |
2 files changed, 10 insertions, 0 deletions
diff --git a/accel-pppd/ctrl/pppoe/pppoe.c b/accel-pppd/ctrl/pppoe/pppoe.c index ad363c8e..e1bc4021 100644 --- a/accel-pppd/ctrl/pppoe/pppoe.c +++ b/accel-pppd/ctrl/pppoe/pppoe.c @@ -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; } diff --git a/accel-pppd/ctrl/pppoe/pppoe.h b/accel-pppd/ctrl/pppoe/pppoe.h index ff0fc788..248ea409 100644 --- a/accel-pppd/ctrl/pppoe/pppoe.h +++ b/accel-pppd/ctrl/pppoe/pppoe.h @@ -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; |