Re: [PATCH net v2] net: hdlc_ppp: Fix issues when mod_timer is called while timer is running

From: Xie He
Date: Tue Dec 29 2020 - 13:21:52 EST


On Tue, Dec 29, 2020 at 12:10 AM Hillf Danton <hdanton@xxxxxxxx> wrote:
>
> >The code path that calls add_timer is for sending keep-alive packets
> >when operating in the OPENED state. If we have just changed to the
> >OPENED state in ppp_cp_event, we should wait for the amount of time
> >set by the (2nd) mod_timer call in ppp_cp_event, before firing the
>
> What if your change also covers the first case of mod_timer() in
> ppp_cp_event()?

Yes, for the 1st mod_timer call in ppp_cp_event, the situation is the
same. If it is called, it means we are sending out a Configure Request
or Terminate Request. In this case, we should wait for the amount of
time set by this mod_timer call, before firing the timer. We shouldn't
fire the timer immediately because this is not the intention of this
mod_timer call.

> >timer. We shouldn't fire the timer immediately after we change to the
> >OPENED state. This is not the intention of the (2nd) mod_timer call in
> >ppp_cp_event. Therefore aborting ppp_timer is the correct solution.
> >
> Given an expiring timer, is it the right time to call ppp_tx_flush() in
> addition to add/mod_timer()?

Do you mean when we are aborting ppp_timer, whether we need to call
ppp_tx_flush in the aborted ppp_timer? I don't think so. Because when
ppp_rx (which directly or indirectly calls ppp_cp_event) releases the
lock, it will call ppp_tx_flush. So we don't need to call it again.