All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: AX.25 unaccepted socket makes problems
@ 2003-05-28 12:29 Tihomir Heidelberg
  0 siblings, 0 replies; 6+ messages in thread
From: Tihomir Heidelberg @ 2003-05-28 12:29 UTC (permalink / raw)
  To: thomas; +Cc: linux-hams

Hi,

>> also I think that skb->sk->pair should be set to NULL, because from this
>> point the pair (listening socket) does not exist any more and reference
>> to this can cause problem, right ?
>
>hmm. the listening socket exists as long the userspace application does
>listen().
>but i do not really understand the sk->pair concept.

yap, but I am talking about when listening socket is going to be
destroyed and there are some unaccepted connections made by listening
socket (lets call them CHILDs)... those CHILDs keeps living in kernel after
listening socket is destroyed... CHILDs have sk->pair pointing
to its listening socket (I really do not know who use/need that sk->pair)
but after listening socket is destroyed I think that CHILDs must not have
a reference to it anymore...

> also i have problems in understanding the concept in ax25_destroy_socket():
> skb->sk->dead is set to 1, then ax25_start_heartbeat() is called, which
> is a timer (which expires in +5s).

yap, CHILDs are destroyed after +5s (heardbeat expirity), I really do not
know why they are destroyed this way with a delay ?! Why dont we call
ax25_destroy_socket recursivly to destroy all CHILDs ? Anyone know the
reason ? They are anyway destroyed the same way on heardbeat exipirity.

> if we set it to skb->sk->state = TCP_LISTEN and our state is
> AX25_STATE_0, then this timer will call ax25_destroy_socket() again.

again, but first time it destroyed listening socket, and from timer it
destroy unaccepted socket...

> potentially running ax25_std_heartbeat_expiry(), which will use
> ax25->sk->... we have just free'd.

no, timer is handling nondestroyed socket (the CHILD)

> i have done this (interested in?). after the observation that when
> ax25rtd is running, the oops problem on ax25 cb's (which are independend
> of the ax25 route list) occorued.

yup, but when ax25_route_list is unprotected, it get broken, it is very
probably that new element in ax25_list is at memory which was used a bit
ago in ax25_route_list, anyone know if ax25_route_list also get broken
when ax25_list is broken ?

73 de Tihomir, 9a4gl@9a0tcp.ampr.org


^ permalink raw reply	[flat|nested] 6+ messages in thread
* AX.25 unaccepted socket makes problems
@ 2003-05-27 16:17 Tihomir Heidelberg
  2003-05-28  0:04 ` Thomas Osterried
  0 siblings, 1 reply; 6+ messages in thread
From: Tihomir Heidelberg @ 2003-05-27 16:17 UTC (permalink / raw)
  To: linux-hams

Hi linux-hams,

finaly I found a way how to produce AX.25 kernel get mad,
I mean, when "cat /proc/net/ax25" produce segmentation fault,
and everything got unstable.

If your program bind ax.25 socket for listening, other station
connects to that listening socket and if listening socket dies
without accepting new connection from you program, after short
period the things got mad...

In ax25_destroy_socket function (af_ax25.c), there is a while
loop for dequeuing those unaccepted connections and preparing
them to die when heardbeat catch them. Also, there is code in
ax25_std_heartbeat_expiry function (ax25_std_timer.c) that
should destroy those connections, unfortunately those connection
are NOT destroyed here ! A condition:
        (ax25->sk->state == TCP_LISTEN && ax25->sk->dead)
is not true because state of those connections are not
TCP_LISTEN. State is TCP_ESTABLISHED or TCP_CLOSE, depending if
other end disconnected or not. Cannot get the reason why
segmentation fault is happening, but hope someone else can find
a reason when problem is reproducable.

To avoid this problem I added to ax25_destroy_socket function
(af_ax25.c) following:
        if (skb->sk != ax25->sk) {
+               skb->sk->state     = TCP_LISTEN;
+               if (!skb->sk->dead) {
+                       skb->sk->state_change(skb->sk);
+               }
                skb->sk->dead  = 1;
                ax25_start_heartbeat(skb->sk->protinfo.ax25);
                skb->sk->protinfo.ax25->state = AX25_STATE_0;
        }

I am pretty sure that this is not the way how problem should be
fixed, there should be a different way how to mark socket for
destroying, but at least, I got rid of this problem.

Also, some months ago I mention here that regulary I get this
AX.25 kernel behavior after few days of running 9A0TCP gateway
machine. I noticed that very often ax25d died or had to restart
ax25d because it was not handling connections. Think this
bind/non-accept kernel problem is very probably the reason.

Anyone agree with me ? Can anyone make a resonable patch/fix
for this problem ? Maybe setting skb->sk->destroy to 1 is right
way ?

73 de Tihomir Heidelberg, 9a4gl@9a0tcp.ampr.org

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2003-05-28 12:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-05-28 12:29 AX.25 unaccepted socket makes problems Tihomir Heidelberg
  -- strict thread matches above, loose matches on Subject: below --
2003-05-27 16:17 Tihomir Heidelberg
2003-05-28  0:04 ` Thomas Osterried
2003-05-28  6:46   ` Tihomir Heidelberg
2003-05-28 10:20     ` Steven Whitehouse
2003-05-28 10:25     ` Thomas Osterried

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.