Skip to content

Commit 79985b1

Browse files
SeppoTakalorlubos
authored andcommitted
[nrf fromlist] net: l2: ppp: Allow PPP to transtition ESTABLISH->DEAD
When remote peer have closed the PPP link normally, the PPP stack on Zephyr side switches back to ESTABLISH phase to be ready for next handshake. When calling net_if_down() on the interface, it should not try to initiate LCP link termination, but instead go directly to DEAD phase. See https://datatracker.ietf.org/doc/html/rfc1661#section-3.2 Upstream PR #: 99078 Signed-off-by: Seppo Takalo <[email protected]>
1 parent 39f9f79 commit 79985b1

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

subsys/net/l2/ppp/fsm.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ struct net_if *ppp_fsm_iface(struct ppp_fsm *fsm)
5353
return ctx->iface;
5454
}
5555

56+
static bool ppp_fsm_is_dead(struct ppp_fsm *fsm)
57+
{
58+
struct ppp_context *ctx = ppp_fsm_ctx(fsm);
59+
60+
return ctx->phase == PPP_DEAD;
61+
}
62+
5663
static void fsm_send_configure_req(struct ppp_fsm *fsm, bool retransmit)
5764
{
5865
struct net_pkt *pkt = NULL;
@@ -246,6 +253,10 @@ void ppp_fsm_close(struct ppp_fsm *fsm, const uint8_t *reason)
246253

247254
case PPP_STOPPING:
248255
ppp_change_state(fsm, PPP_CLOSING);
256+
if (ppp_fsm_is_dead(fsm)) {
257+
fsm->retransmits = 0;
258+
k_work_reschedule(&fsm->timer, K_NO_WAIT);
259+
}
249260
break;
250261

251262
default:

subsys/net/l2/ppp/lcp.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,12 @@ static void lcp_open(struct ppp_context *ctx)
163163
static void lcp_close(struct ppp_context *ctx, const uint8_t *reason)
164164
{
165165
if (ctx->phase != PPP_DEAD) {
166-
ppp_change_phase(ctx, PPP_TERMINATE);
166+
if (ctx->phase == PPP_ESTABLISH) {
167+
/* Link is not established yet, so we can go directly to DEAD */
168+
ppp_change_phase(ctx, PPP_DEAD);
169+
} else {
170+
ppp_change_phase(ctx, PPP_TERMINATE);
171+
}
167172
}
168173

169174
ppp_fsm_close(&ctx->lcp.fsm, reason);

0 commit comments

Comments
 (0)