net: ppp: Properly terminate LCP state at modem side when closing down
Takes the modem state machine by calling lcp_close instead of lcp_down Using this method the LCP layer sends a TERMINATE_REQ to the modem and the network interface is only taken down when the LCP layer has properly finished. Moved the ppp_mgmt_raise_carrier_off_event and net_if_carrier_down to lcp.c to avoid breaking the interface. Tested on a real modem. Fixes: zephyrproject-rtos#41627 Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
This commit is contained in:
parent
ae9380d996
commit
4855e8ded1
|
@ -206,6 +206,11 @@ static void lcp_finished(struct ppp_fsm *fsm)
|
|||
lcp.fsm);
|
||||
|
||||
ppp_link_terminated(ctx);
|
||||
|
||||
/* take the remainder down */
|
||||
ppp_mgmt_raise_carrier_off_event(ctx->iface);
|
||||
|
||||
net_if_carrier_down(ctx->iface);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_NET_L2_PPP_OPTION_MRU)
|
||||
|
|
|
@ -190,10 +190,10 @@ static int ppp_send(struct net_if *iface, struct net_pkt *pkt)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static void ppp_lower_down(struct ppp_context *ctx)
|
||||
static void ppp_close(struct ppp_context *ctx)
|
||||
{
|
||||
if (ppp_lcp) {
|
||||
ppp_lcp->lower_down(ctx);
|
||||
ppp_lcp->close(ctx, "Shutdown");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -230,7 +230,7 @@ static int ppp_enable(struct net_if *iface, bool state)
|
|||
ctx->is_enabled = state;
|
||||
|
||||
if (!state) {
|
||||
ppp_lower_down(ctx);
|
||||
ppp_close(ctx);
|
||||
|
||||
if (ppp->stop) {
|
||||
ppp->stop(net_if_get_device(iface));
|
||||
|
@ -284,11 +284,15 @@ static void carrier_on_off(struct k_work *work)
|
|||
ppp_mgmt_raise_carrier_on_event(ctx->iface);
|
||||
net_if_up(ctx->iface);
|
||||
} else {
|
||||
ppp_lower_down(ctx);
|
||||
ppp_change_phase(ctx, PPP_DEAD);
|
||||
if (ppp_lcp) {
|
||||
ppp_lcp->close(ctx, "Shutdown");
|
||||
/* signaling for the carrier off event is done from the LCP callback */
|
||||
} else {
|
||||
ppp_change_phase(ctx, PPP_DEAD);
|
||||
|
||||
ppp_mgmt_raise_carrier_off_event(ctx->iface);
|
||||
net_if_carrier_down(ctx->iface);
|
||||
ppp_mgmt_raise_carrier_off_event(ctx->iface);
|
||||
net_if_carrier_down(ctx->iface);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue