Linux HAM/Amateur Radio development
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@conectiva.com.br>
To: Jeroen Vreeken <pe1rxq@amsat.org>
Cc: linux-hams@vger.kernel.org, ralf@linux-mips.org
Subject: Re: [PATCH] ax25_cb refcounting & waitqueue usage
Date: Mon, 7 Jul 2003 14:25:04 -0300	[thread overview]
Message-ID: <20030707172503.GC5292@conectiva.com.br> (raw)
In-Reply-To: <20030707192340.A219@jeroen.pe1rxq.ampr.org>

Em Mon, Jul 07, 2003 at 07:23:40PM +0200, Jeroen Vreeken escreveu:
> On 2003.07.07 15:37:10 +0200 Arnaldo Carvalho de Melo wrote:
> > Em Sun, Jul 06, 2003 at 07:27:34PM +0200, Jeroen Vreeken escreveu:
> > > Hi,
> > > 
> > > Second patch for this weekend...
> > > This patch does two things, it adds reference counting to the ax25_cb
> > > structure (until now only the ax25_cb list was protected, not the parts
> > > using it) and it fixes an oops on interrupted socket syscalls. (e.g.
> > > pressing Ctrl-C while in the connect function) The waitqueue was not
> > > removed from the list and caused an oops in the socket release.
> > > 
> > > I have had only a quick look at Steven's patch but I don't think the
> > two
> > > will clash...
> > 
> > Hey, why not use sk->refcnt by means of sock_hold/sock_put? Current
> > sources
> > even do that implicitely when you do a sk_add_node (sock_hold) and a
> > sk_del_node{_init} (sock_put)... Now it is just a matter of doing a
> > sock_hold
> > when searching in some list and then dropping the refcnt when done using
> > the
> > sock returned by the search function.
> 
> Unfortunatly the ax25_cbs are not directly related to a sock structure...
> Sometimes they don't even have them, e.g. when you do ip in connected mode
> or netrom and rose interlinks. In those cases you can even share an ax25_cb
> between a socket and those protocols in which case you absolutly need the
> refcounting....
> Consider the following:
> 
> - ip datagram is send to ax25 layer.
> - ax25 layer uses a lookup in the ax25_cb list to find an existing
> connection
> - list code locks, searches, unlocks, returns
> ***** preempt/interrupt/other processor
> - application closes socket
> - ax25_cb is removed from the list (again with proper list locking)
> - ax25_cb is freed
> ***** preempt/interrupt/other processor back to ip handling routine
> - ip handling routine uses ax25_cb
> - BOOM!

Got it, i.e. the fact that ax25_cb structs are not directly always associated
with a struct sock, the scenario above is the same for struct sock refcounting,
so may I suggest that you use the same arquitecture of list handling in struct
sock? i.e. use hlist and have a ax25_cb_add, ax25_cb_del{_init} that does the
refcounting, etc, so that it "looks like" what we have for struct sock and that
way a casual ax25 hacker can take advantage of what he learnt from studying
struct sock handling? I plan to attack the list searching problem in a general
way, i.e. abstracting more the search in a bsearch(3) way, using inlines and
macros so that all the protocols have a more consistent implementation.

- Arnaldo

  reply	other threads:[~2003-07-07 17:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-06 17:27 [PATCH] ax25_cb refcounting & waitqueue usage Jeroen Vreeken
2003-07-07 13:37 ` Arnaldo Carvalho de Melo
2003-07-07 17:23   ` Jeroen Vreeken
2003-07-07 17:25     ` Arnaldo Carvalho de Melo [this message]
2003-07-08 22:52       ` Jeroen Vreeken
2003-07-09 17:06         ` Jeroen Vreeken

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030707172503.GC5292@conectiva.com.br \
    --to=acme@conectiva.com.br \
    --cc=linux-hams@vger.kernel.org \
    --cc=pe1rxq@amsat.org \
    --cc=ralf@linux-mips.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox