All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Peter A. Bigot" <pab@pabigot.com>
To: linux-bluetooth@vger.kernel.org
Subject: how to cleanly shutdown an application using HCI_CHANNEL_USER
Date: Tue, 17 Aug 2021 15:07:17 -0700	[thread overview]
Message-ID: <e17b2044-62cb-cbf7-64b8-c647aa7f6ee7@pabigot.com> (raw)

I'm using an AF_BLUETOOTH socket bound with HCI_CHANNEL_USER from a
user-mode application with cap_net_admin=ep.  As expected this
requires the device be down, and brings the device up automatically.

When I close that socket and exit the application, the device appears
to remain up forever.  Which prevents me from re-starting the
application.

I tried to issue HCIDEVDOWN before closing, but that produces EBADFD
because ioctls cannot be performed with HCI_CHANNEL_RAW.

I can bring the interface down from within the application if, after
closing the socket, I wait a second or so, then create a new bound
HCI_CHANNEL_RAW socket and issue HCIDEVDOWN on it.

Is there some other way to cleanly shut down an application that used
HCI_CHANNEL_USER so that the device is returned to down state on exit?
Or is this supposed to happen automatically (I see code that suggests
it should)?

Kernel version is 5.11.0-7620-generic (System76), and I'm using go
1.16, if that's relevant.

Thanks!

Peter

             reply	other threads:[~2021-08-17 22:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-17 22:07 Peter A. Bigot [this message]
2021-08-19 15:01 ` how to cleanly shutdown an application using HCI_CHANNEL_USER Marcel Holtmann
2021-08-19 17:51   ` Luiz Augusto von Dentz
2021-08-23 20:32   ` Tedd Ho-Jeong An

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=e17b2044-62cb-cbf7-64b8-c647aa7f6ee7@pabigot.com \
    --to=pab@pabigot.com \
    --cc=linux-bluetooth@vger.kernel.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 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.