diff options
author | Kozlov Dmitry <dima@server> | 2011-05-16 15:30:42 +0400 |
---|---|---|
committer | Kozlov Dmitry <dima@server> | 2011-05-16 15:30:42 +0400 |
commit | d2cb39985cd33f5678cad3e68b69cca51894bd58 (patch) | |
tree | f6a58e00a2bd993cb72f041bf71a82e799c39dc1 /accel-pppd/ppp | |
parent | cac666a65bef987c6004acb70bb17c0393cc335f (diff) | |
download | accel-ppp-d2cb39985cd33f5678cad3e68b69cca51894bd58.tar.gz accel-ppp-d2cb39985cd33f5678cad3e68b69cca51894bd58.zip |
ppp: discard packets with invalid id before passing it to fsm
ppp: default fsm timeout increased to 3 sec.
ppp: accept LCP TermReq/TermAck packets in terminating phase
Diffstat (limited to 'accel-pppd/ppp')
-rw-r--r-- | accel-pppd/ppp/ppp_ccp.c | 18 | ||||
-rw-r--r-- | accel-pppd/ppp/ppp_fsm.c | 2 | ||||
-rw-r--r-- | accel-pppd/ppp/ppp_ipcp.c | 18 | ||||
-rw-r--r-- | accel-pppd/ppp/ppp_lcp.c | 20 |
4 files changed, 35 insertions, 23 deletions
diff --git a/accel-pppd/ppp/ppp_ccp.c b/accel-pppd/ppp/ppp_ccp.c index 20ccd69..d40d21b 100644 --- a/accel-pppd/ppp/ppp_ccp.c +++ b/accel-pppd/ppp/ppp_ccp.c @@ -458,11 +458,11 @@ static int ccp_recv_conf_rej(struct ppp_ccp_t *ccp, uint8_t *data, int size) if (conf_ppp_verbose) log_ppp_info2("recv [CCP ConfRej id=%x", ccp->fsm.recv_id); - if (ccp->fsm.recv_id != ccp->fsm.id) { + /*if (ccp->fsm.recv_id != ccp->fsm.id) { if (conf_ppp_verbose) log_ppp_info2(": id mismatch ]\n"); return 0; - } + }*/ while (size > 0) { hdr = (struct ccp_opt_hdr_t *)data; @@ -496,11 +496,11 @@ static int ccp_recv_conf_nak(struct ppp_ccp_t *ccp, uint8_t *data, int size) if (conf_ppp_verbose) log_ppp_info2("recv [CCP ConfNak id=%x", ccp->fsm.recv_id); - if (ccp->fsm.recv_id != ccp->fsm.id) { + /*if (ccp->fsm.recv_id != ccp->fsm.id) { if (conf_ppp_verbose) log_ppp_info2(": id mismatch ]\n"); return 0; - } + }*/ while (size > 0) { hdr = (struct ccp_opt_hdr_t *)data; @@ -538,11 +538,11 @@ static int ccp_recv_conf_ack(struct ppp_ccp_t *ccp, uint8_t *data, int size) if (conf_ppp_verbose) log_ppp_info2("recv [CCP ConfAck id=%x", ccp->fsm.recv_id); - if (ccp->fsm.recv_id != ccp->fsm.id) { + /*if (ccp->fsm.recv_id != ccp->fsm.id) { if (conf_ppp_verbose) log_ppp_info2(": id mismatch ]\n"); return 0; - } + }*/ while (size > 0) { hdr = (struct ccp_opt_hdr_t *)data; @@ -609,7 +609,7 @@ static void ccp_recv(struct ppp_handler_t*h) struct ppp_ccp_t *ccp = container_of(h, typeof(*ccp), hnd); int r; - if (ccp->fsm.fsm_state == FSM_Initial || ccp->fsm.fsm_state == FSM_Closed || ccp->ppp->terminating) { + if (ccp->fsm.fsm_state == FSM_Initial || ccp->fsm.fsm_state == FSM_Closed || ccp->fsm.fsm_state == FSM_Opened || ccp->ppp->terminating) { if (conf_ppp_verbose) log_ppp_warn("CCP: discarding packet\n"); if (ccp->fsm.fsm_state == FSM_Closed || !conf_ccp) @@ -628,7 +628,11 @@ static void ccp_recv(struct ppp_handler_t*h) return; } + if ((hdr->code == CONFACK || hdr->code == CONFNAK || hdr->code == CONFREJ) && hdr->id != ccp->fsm.id) + return; + ccp->fsm.recv_id = hdr->id; + switch(hdr->code) { case CONFREQ: r = ccp_recv_conf_req(ccp, (uint8_t*)(hdr + 1), ntohs(hdr->len) - PPP_HDRLEN); diff --git a/accel-pppd/ppp/ppp_fsm.c b/accel-pppd/ppp/ppp_fsm.c index 0e27a78..01427a6 100644 --- a/accel-pppd/ppp/ppp_fsm.c +++ b/accel-pppd/ppp/ppp_fsm.c @@ -14,7 +14,7 @@ static int conf_max_terminate = 2; static int conf_max_configure = 10; static int conf_max_failure = 10; -static int conf_timeout = 1; +static int conf_timeout = 3; void send_term_req(struct ppp_fsm_t *layer); void send_term_ack(struct ppp_fsm_t *layer); diff --git a/accel-pppd/ppp/ppp_ipcp.c b/accel-pppd/ppp/ppp_ipcp.c index f8b2f48..8890f2c 100644 --- a/accel-pppd/ppp/ppp_ipcp.c +++ b/accel-pppd/ppp/ppp_ipcp.c @@ -434,11 +434,11 @@ static int ipcp_recv_conf_rej(struct ppp_ipcp_t *ipcp, uint8_t *data, int size) if (conf_ppp_verbose) log_ppp_info2("recv [IPCP ConfRej id=%x", ipcp->fsm.recv_id); - if (ipcp->fsm.recv_id != ipcp->fsm.id) { + /*if (ipcp->fsm.recv_id != ipcp->fsm.id) { if (conf_ppp_verbose) log_ppp_info2(": id mismatch ]\n"); return 0; - } + }*/ while (size > 0) { hdr = (struct ipcp_opt_hdr_t *)data; @@ -472,11 +472,11 @@ static int ipcp_recv_conf_nak(struct ppp_ipcp_t *ipcp, uint8_t *data, int size) if (conf_ppp_verbose) log_ppp_info2("recv [IPCP ConfNak id=%x", ipcp->fsm.recv_id); - if (ipcp->fsm.recv_id != ipcp->fsm.id) { + /*if (ipcp->fsm.recv_id != ipcp->fsm.id) { if (conf_ppp_verbose) log_ppp_info2(": id mismatch ]\n"); return 0; - } + }*/ while (size > 0) { hdr = (struct ipcp_opt_hdr_t *)data; @@ -512,11 +512,11 @@ static int ipcp_recv_conf_ack(struct ppp_ipcp_t *ipcp, uint8_t *data, int size) if (conf_ppp_verbose) log_ppp_info2("recv [IPCP ConfAck id=%x", ipcp->fsm.recv_id); - if (ipcp->fsm.recv_id != ipcp->fsm.id) { + /*if (ipcp->fsm.recv_id != ipcp->fsm.id) { if (conf_ppp_verbose) log_ppp_info2(": id mismatch ]\n"); return 0; - } + }*/ while (size > 0) { hdr = (struct ipcp_opt_hdr_t *)data; @@ -583,7 +583,7 @@ static void ipcp_recv(struct ppp_handler_t*h) struct ppp_ipcp_t *ipcp = container_of(h, typeof(*ipcp), hnd); int r; - if (ipcp->fsm.fsm_state == FSM_Initial || ipcp->fsm.fsm_state == FSM_Closed || ipcp->ppp->terminating) { + if (ipcp->fsm.fsm_state == FSM_Initial || ipcp->fsm.fsm_state == FSM_Closed || ipcp->fsm.fsm_state == FSM_Opened || ipcp->ppp->terminating) { if (conf_ppp_verbose) log_ppp_warn("IPCP: discarding packet\n"); return; @@ -599,8 +599,12 @@ static void ipcp_recv(struct ppp_handler_t*h) log_ppp_warn("IPCP: short packet received\n"); return; } + + if ((hdr->code == CONFACK || hdr->code == CONFNAK || hdr->code == CONFREJ) && hdr->id != ipcp->fsm.id) + return; ipcp->fsm.recv_id = hdr->id; + switch(hdr->code) { case CONFREQ: r = ipcp_recv_conf_req(ipcp,(uint8_t*)(hdr + 1), ntohs(hdr->len) - PPP_HDRLEN); diff --git a/accel-pppd/ppp/ppp_lcp.c b/accel-pppd/ppp/ppp_lcp.c index 279d815..56a3ca6 100644 --- a/accel-pppd/ppp/ppp_lcp.c +++ b/accel-pppd/ppp/ppp_lcp.c @@ -704,25 +704,29 @@ static void lcp_recv(struct ppp_handler_t*h) int r; char *term_msg; - if (lcp->fsm.fsm_state == FSM_Initial || lcp->fsm.fsm_state == FSM_Closed || lcp->ppp->terminating) { - /*if (conf_ppp_verbose) - log_ppp_warn("LCP: discaring packet\n"); - lcp_send_proto_rej(ccp->ppp, htons(PPP_CCP));*/ - return; - } - if (lcp->ppp->buf_size < PPP_HEADERLEN + 2) { log_ppp_warn("LCP: short packet received\n"); return; } - hdr = (struct lcp_hdr_t *)lcp->ppp->buf; + hdr = (struct lcp_hdr_t *)lcp->ppp->buf; if (ntohs(hdr->len) < PPP_HEADERLEN) { log_ppp_warn("LCP: short packet received\n"); return; } + if ((hdr->code == CONFACK || hdr->code == CONFNAK || hdr->code == CONFREJ) && hdr->id != lcp->fsm.id) + return; + + if (lcp->fsm.fsm_state == FSM_Initial || lcp->fsm.fsm_state == FSM_Closed || (lcp->ppp->terminating && (hdr->code != TERMACK && hdr->code != TERMREQ))) { + /*if (conf_ppp_verbose) + log_ppp_warn("LCP: discaring packet\n"); + lcp_send_proto_rej(ccp->ppp, htons(PPP_CCP));*/ + return; + } + lcp->fsm.recv_id = hdr->id; + switch(hdr->code) { case CONFREQ: r = lcp_recv_conf_req(lcp, (uint8_t*)(hdr + 1), ntohs(hdr->len) - PPP_HDRLEN); |