my diff is to make pppx(4) have the same "idle-timeout"
functionality.  I strongly think pppx(4) must have the same
functionalities of pppac(4) because I don't see any reason to have
any difference between pppx(4) and pppac(4).

Your pseudo code is suggesting another thing.  You would like to
change the existing behavior of pppac(4)?  Then, what is a problem you
concern.  I'd like you to provide what is the relation of my diff or a
background of the code.

On Tue, 11 Aug 2020 01:20:45 +0300
Vitaliy Makkoveev <m...@openbsd.org> wrote:
> 
> 
>> On 10 Aug 2020, at 19:53, Vitaliy Makkoveev <m...@openbsd.org> wrote:
>> 
>> We are doing all wrong :)
>> 
>> We can just unlink pppx(4) related session from `pipex_session_list' if
>> it's time expired. But since this unlinked session is still exists in
>> pppx(4) layer we can access through pppx_get_closed() without any
>> search. We should only add flag to session which identifies it as
>> pppx(4) related.
>> 
>> I hope you like this idea.
>> 
>> ---- cut begin ----
>> Static void
>> pipex_timer(void *ignored_arg)
>> {
>>        struct pipex_session *session, *session_tmp;
>> 
>>        timeout_add_sec(&pipex_timer_ch, pipex_prune);
>> 
>>        NET_LOCK();
>>        /* walk through */
>>        LIST_FOREACH_SAFE(session, &pipex_session_list, session_list,
>>            session_tmp) {
>>                switch (session->state) {
>>                case PIPEX_STATE_OPENED:
>>                        if (session->timeout_sec == 0)
>>                                continue;
>> 
>>                        session->stat.idle_time++;
>>                        if (session->stat.idle_time < session->timeout_sec)
>>                                continue;
>> 
>>                      if (session->pppx_session)
>>                              pipex_unlink_session(session);
>>                      else
>>                              pipex_notify_close_session(session);
>>                        break;
>>      /* ... */
>> }
>> 
>> pppx_get_closed(struct pppx_dev *pxd, struct pipex_session_list_req *req)
>> {
>>      struct pppx_if *pxi;
>> 
>>      pxi = pppx_if_find(pxd, req->pdr_session_id, req->pdr_protocol);
>>      if (pxi == NULL)
>>              return (EINVAL);
>> 
>>      memset(req, 0, sizeof(*req));
>>      if (session->state == PIPEX_STATE_CLOSED) {
>>              req->plr_ppp_id[req->plr_ppp_id_count++] = session->ppp_id;
>>              pppx_if_destroy(pxi);   
>>      }
>> 
>>      return 0;
>> }
> 
> Sorry for noise. I should avoid to write pseudo code.

Reply via email to