Commit 93c3975f authored by Markus Lassila's avatar Markus Lassila Committed by Benjamin Cabé
Browse files

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: default avatarMarkus Lassila <markus.lassila@nordicsemi.no>
parent 0090ca6d
Loading
Loading
Loading
Loading
+17 −0
Changes for subsys/net/l2/ppp/ppp_l2.c: 17 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -238,6 +238,19 @@ static int ppp_up(struct net_if *iface)
	return 0;
}

static void ppp_lcp_close_async(struct ppp_context *ctx)
{
	if (ppp_lcp == NULL) {
		ppp_change_phase(ctx, PPP_DEAD);
	}

	if (ctx->phase == PPP_DEAD) {
		return;
	}

	ppp_lcp->close(ctx, "L2 Disabled");
}

static int ppp_lcp_close(struct ppp_context *ctx)
{
	if (ppp_lcp == NULL) {
@@ -486,6 +499,10 @@ static void net_ppp_mgmt_evt_handler(struct net_mgmt_event_callback *cb, uint32_
	if ((mgmt_event == NET_EVENT_IF_DOWN) && (!net_if_is_carrier_ok(iface))) {
		ppp_lcp_lower_down_async(ctx);
	}
	if ((mgmt_event == NET_EVENT_IF_DOWN && net_if_is_carrier_ok(iface) &&
	     net_if_is_dormant(iface))) {
		ppp_lcp_close_async(ctx);
	}
}

void net_ppp_init(struct net_if *iface)