Skip to content

Commit 4855e8d

Browse files
ssharkscarlescufi
authored andcommitted
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: #41627 Signed-off-by: Sjors Hettinga <[email protected]>
1 parent ae9380d commit 4855e8d

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

subsys/net/l2/ppp/lcp.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,11 @@ static void lcp_finished(struct ppp_fsm *fsm)
206206
lcp.fsm);
207207

208208
ppp_link_terminated(ctx);
209+
210+
/* take the remainder down */
211+
ppp_mgmt_raise_carrier_off_event(ctx->iface);
212+
213+
net_if_carrier_down(ctx->iface);
209214
}
210215

211216
#if defined(CONFIG_NET_L2_PPP_OPTION_MRU)

subsys/net/l2/ppp/ppp_l2.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,10 @@ static int ppp_send(struct net_if *iface, struct net_pkt *pkt)
190190
return ret;
191191
}
192192

193-
static void ppp_lower_down(struct ppp_context *ctx)
193+
static void ppp_close(struct ppp_context *ctx)
194194
{
195195
if (ppp_lcp) {
196-
ppp_lcp->lower_down(ctx);
196+
ppp_lcp->close(ctx, "Shutdown");
197197
}
198198
}
199199

@@ -230,7 +230,7 @@ static int ppp_enable(struct net_if *iface, bool state)
230230
ctx->is_enabled = state;
231231

232232
if (!state) {
233-
ppp_lower_down(ctx);
233+
ppp_close(ctx);
234234

235235
if (ppp->stop) {
236236
ppp->stop(net_if_get_device(iface));
@@ -284,11 +284,15 @@ static void carrier_on_off(struct k_work *work)
284284
ppp_mgmt_raise_carrier_on_event(ctx->iface);
285285
net_if_up(ctx->iface);
286286
} else {
287-
ppp_lower_down(ctx);
288-
ppp_change_phase(ctx, PPP_DEAD);
287+
if (ppp_lcp) {
288+
ppp_lcp->close(ctx, "Shutdown");
289+
/* signaling for the carrier off event is done from the LCP callback */
290+
} else {
291+
ppp_change_phase(ctx, PPP_DEAD);
289292

290-
ppp_mgmt_raise_carrier_off_event(ctx->iface);
291-
net_if_carrier_down(ctx->iface);
293+
ppp_mgmt_raise_carrier_off_event(ctx->iface);
294+
net_if_carrier_down(ctx->iface);
295+
}
292296
}
293297
}
294298

0 commit comments

Comments
 (0)