Skip to content

Commit 93c3975

Browse files
MarkusLassilakartben
authored andcommitted
net: l2: ppp: Terminate connection with dormant
When PPP net_if is changed to dormant, the PPP connection is terminated asynchronously. This is used so that the driver can terminate the PPP connection gracefully. Note: net_if_down() is not used as it would require synchronous operation which would block the system workqueue thus causing deadlock. Signed-off-by: Markus Lassila <markus.lassila@nordicsemi.no>
1 parent 0090ca6 commit 93c3975

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

subsys/net/l2/ppp/ppp_l2.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,19 @@ static int ppp_up(struct net_if *iface)
238238
return 0;
239239
}
240240

241+
static void ppp_lcp_close_async(struct ppp_context *ctx)
242+
{
243+
if (ppp_lcp == NULL) {
244+
ppp_change_phase(ctx, PPP_DEAD);
245+
}
246+
247+
if (ctx->phase == PPP_DEAD) {
248+
return;
249+
}
250+
251+
ppp_lcp->close(ctx, "L2 Disabled");
252+
}
253+
241254
static int ppp_lcp_close(struct ppp_context *ctx)
242255
{
243256
if (ppp_lcp == NULL) {
@@ -486,6 +499,10 @@ static void net_ppp_mgmt_evt_handler(struct net_mgmt_event_callback *cb, uint32_
486499
if ((mgmt_event == NET_EVENT_IF_DOWN) && (!net_if_is_carrier_ok(iface))) {
487500
ppp_lcp_lower_down_async(ctx);
488501
}
502+
if ((mgmt_event == NET_EVENT_IF_DOWN && net_if_is_carrier_ok(iface) &&
503+
net_if_is_dormant(iface))) {
504+
ppp_lcp_close_async(ctx);
505+
}
489506
}
490507

491508
void net_ppp_init(struct net_if *iface)

0 commit comments

Comments
 (0)