removed time-based PPP phase state machine hacks from PPPoE dans PPPoL2TP

Our PPP phase state machine is now clean, we can safely remove time based
hacks in PPPoE dans PPPoL2TP.
This commit is contained in:
Sylvain Rochet 2012-07-24 22:50:17 +02:00
parent 59567b43b0
commit c58c27ed8b
4 changed files with 10 additions and 42 deletions

View File

@ -109,7 +109,6 @@ PACK_STRUCT_END
#define PPPOE_STATE_PADI_SENT 1
#define PPPOE_STATE_PADR_SENT 2
#define PPPOE_STATE_SESSION 3
#define PPPOE_STATE_CLOSING 4
/* passive */
#define PPPOE_STATE_PADO_SENT 1

View File

@ -154,7 +154,6 @@
#define PPPOL2TP_STATE_ICRQ_SENT 2
#define PPPOL2TP_STATE_ICCN_SENT 3
#define PPPOL2TP_STATE_DATA 4
#define PPPOL2TP_STATE_CLOSING 5
#define PPPOL2TP_CB_STATE_UP 0 /* PPPoL2TP link is UP */
#define PPPOL2TP_CB_STATE_DOWN 1 /* PPPo2TP link is DOWN - normal condition */

View File

@ -113,7 +113,6 @@ static char pppoe_error_tmp[PPPOE_ERRORSTRING_LEN];
/* management routines */
static int pppoe_do_disconnect(struct pppoe_softc *);
static void pppoe_abort_connect(struct pppoe_softc *);
static void pppoe_clear_softc(struct pppoe_softc *, const char *);
@ -780,9 +779,6 @@ pppoe_timeout(void *arg)
}
sys_timeout(PPPOE_DISC_TIMEOUT * (1 + sc->sc_padr_retried), pppoe_timeout, sc);
break;
case PPPOE_STATE_CLOSING:
pppoe_do_disconnect(sc);
break;
default:
return; /* all done, work in peace */
}
@ -821,30 +817,15 @@ pppoe_connect(struct pppoe_softc *sc)
/* disconnect */
void
pppoe_disconnect(struct pppoe_softc *sc)
{
if (sc->sc_state < PPPOE_STATE_SESSION) {
return;
}
/*
* Do not call pppoe_disconnect here, the upper layer state
* machine gets confused by this. We must return from this
* function and defer disconnecting to the timeout handler.
*/
sc->sc_state = PPPOE_STATE_CLOSING;
sys_timeout(20, pppoe_timeout, sc);
}
static int
pppoe_do_disconnect(struct pppoe_softc *sc)
{
int err;
if (sc->sc_state < PPPOE_STATE_SESSION) {
err = EBUSY;
} else {
return EBUSY;
}
PPPDEBUG(LOG_DEBUG, ("pppoe: %c%c%"U16_F": disconnecting\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num));
err = pppoe_send_padt(sc->sc_ethif, sc->sc_session, (const u8_t *)&sc->sc_dest);
}
/* cleanup softc */
sc->sc_state = PPPOE_STATE_INITIAL;

View File

@ -72,7 +72,6 @@
#endif /* PPPOL2TP_AUTH_SUPPORT */
/* Prototypes for procedures local to this file. */
static void pppol2tp_do_disconnect(pppol2tp_pcb *l2tp);
static void pppol2tp_input(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port);
static void pppol2tp_dispatch_control_packet(pppol2tp_pcb *l2tp, struct ip_addr *addr, u16_t port,
struct pbuf *p, u16_t len, u16_t tunnel_id, u16_t session_id, u16_t ns, u16_t nr);
@ -197,22 +196,12 @@ void pppol2tp_reconnect(pppol2tp_pcb *l2tp) {
/* Disconnect */
void pppol2tp_disconnect(pppol2tp_pcb *l2tp) {
if (l2tp->phase == PPPOL2TP_STATE_CLOSING) {
if (l2tp->phase < PPPOL2TP_STATE_DATA) {
return;
}
l2tp->our_ns++;
pppol2tp_send_stopccn(l2tp, l2tp->our_ns);
/*
* Do not call pppol2tp_disconnect here, the upper layer state
* machine gets confused by this. We must return from this
* function and defer disconnecting to the timeout handler.
*/
l2tp->phase = PPPOL2TP_STATE_CLOSING;
sys_timeout(20, pppol2tp_timeout, l2tp);
}
static void pppol2tp_do_disconnect(pppol2tp_pcb *l2tp) {
pppol2tp_clear(l2tp);
l2tp->link_status_cb(l2tp->ppp, PPPOL2TP_CB_STATE_DOWN); /* notify upper layers */
@ -410,7 +399,11 @@ static void pppol2tp_dispatch_control_packet(pppol2tp_pcb *l2tp, struct ip_addr
if (l2tp->phase < PPPOL2TP_STATE_DATA) {
pppol2tp_abort_connect(l2tp);
} else if (l2tp->phase == PPPOL2TP_STATE_DATA) {
pppol2tp_disconnect(l2tp);
/* Don't disconnect here, we let the LCP Echo/Reply find the fact
* that PPP session is down. Asking the PPP stack to end the session
* require strict checking about the PPP phase to prevent endless
* disconnection loops.
*/
}
return;
}
@ -608,10 +601,6 @@ static void pppol2tp_timeout(void *arg) {
sys_timeout(PPPOL2TP_CONTROL_TIMEOUT, pppol2tp_timeout, l2tp);
break;
case PPPOL2TP_STATE_CLOSING:
pppol2tp_do_disconnect(l2tp);
break;
default:
return; /* all done, work in peace */
}