All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: "m m" <olsajiri@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-net@vger.kernel.org,
	netdev@vger.kernel.org
Subject: Re: netlink - notify when the socket gets closed
Date: Fri, 5 Dec 2008 19:56:24 -0800	[thread overview]
Message-ID: <20081205195624.95ea1866.akpm@linux-foundation.org> (raw)
In-Reply-To: <35476bd20812050017y70c3c729v450cdc3d0c1188de@mail.gmail.com>

(cc netdev@vger.kernel.org)

On Fri, 5 Dec 2008 09:17:51 +0100 "m m" <olsajiri@gmail.com> wrote:

> Hi,
> 
> I'm using netlink in my module. Based on the communication,
> this module dynamically creates some internal structure, which
> needs to be destroyed when the user level socket is closed (or
> the application dies).
> 
> I found I could use the netlink_register_notifier function to register
> NETLINK_URELEASE callback during the netlink_release function.
> But since my module uses the multicast netlink socket communication,
> it wont be called:
> 
> static int netlink_release(struct socket *sock)
> {
>         ...
> 
>         if (nlk->pid && !nlk->subscriptions) {
>                 struct netlink_notify n = {
>                                                 .net = sock_net(sk),
>                                                 .protocol = sk->sk_protocol,
>                                                 .pid = nlk->pid,
>                                           };
>                 atomic_notifier_call_chain(&netlink_chain,
>                                 NETLINK_URELEASE, &n);
>         }
>         ...
> 
> Whats the reason this callback is not called for multicast sockets?
> 
> To workaround it I created simple misc device which the user application
> opens before creating the netlink socket. This way I get some callbacks
> inside the module when the application dies, at least.. pretty ugly :)
> 
> Is there a netlink mechanism to be notified when the netlink socket is
> closed on the user level side? (when using multicast communication)
> 
> Or is there any other design I could use, since I think I'm not alone in
> using internal module data which needs to be removed once the application dies.


  reply	other threads:[~2008-12-06  3:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-05  8:17 netlink - notify when the socket gets closed m m
2008-12-06  3:56 ` Andrew Morton [this message]
2008-12-06 14:58   ` Patrick McHardy
2008-12-06 18:10     ` m m
2008-12-07 16:04       ` Patrick McHardy

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=20081205195624.95ea1866.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-net@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=olsajiri@gmail.com \
    /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 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.