[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z4Aj6KqkQGHXAQLK@google.com>
Date: Thu, 9 Jan 2025 19:30:48 +0000
From: Carlos Llamas <cmllamas@...gle.com>
To: Li Li <dualli@...omium.org>
Cc: dualli@...gle.com, corbet@....net, davem@...emloft.net,
edumazet@...gle.com, kuba@...nel.org, pabeni@...hat.com,
donald.hunter@...il.com, gregkh@...uxfoundation.org,
arve@...roid.com, tkjos@...roid.com, maco@...roid.com,
joel@...lfernandes.org, brauner@...nel.org, surenb@...gle.com,
arnd@...db.de, masahiroy@...nel.org, bagasdotme@...il.com,
horms@...nel.org, linux-kernel@...r.kernel.org,
linux-doc@...r.kernel.org, netdev@...r.kernel.org,
hridya@...gle.com, smoreland@...gle.com, kernel-team@...roid.com
Subject: Re: [PATCH v11 2/2] binder: report txn errors via generic netlink
On Thu, Jan 09, 2025 at 06:51:59PM +0000, Carlos Llamas wrote:
> Did you happen to look into netlink_register_notifier()? That seems like
> an option to keep the device vs netlink socket interface from mixing up.
> I believe we could check for NETLINK_URELEASE events and do the cleanup
> then. I'll do a quick try.
Yeah, this quick prototype worked for me. Although I haven't looked at
the api details closely.
diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 536be42c531e..fa2146cf02a7 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
+static int binder_netlink_notify(struct notifier_block *nb,
+ + + + unsigned long action,
+ + + + void *data)
+{
+ struct netlink_notify *n = data;
+ struct binder_device *device;
+
+ if (action != NETLINK_URELEASE)
+ + return NOTIFY_DONE;
+
+ hlist_for_each_entry(device, &binder_devices, hlist) {
+ + if (device->context.report_portid == n->portid)
+ + + pr_info("%s: socket released\n", __func__);
+ }
+
+ return NOTIFY_DONE;
+}
+
+static struct notifier_block binder_netlink_notifier = {
+ .notifier_call = binder_netlink_notify,
+};
+
static int __init binder_init(void)
{
+ int ret;
@@ -7244,6 +7259,8 @@ static int __init binder_init(void)
+ + goto err_init_binder_device_failed;
+ }
+ netlink_register_notifier(&binder_netlink_notifier);
+
+ return ret;
err_init_binder_device_failed:
With that change we get notified when the socket that registered the
report exits:
root@...ian:~# ./binder-netlink
report setup complete!
^C[ 63.682485] binder: binder_netlink_notify: socket released
I don't know if this would be the preferred approach to "install" a
notification callback with a netlink socket but it works. wdyt?
--
Carlos Llamas
Powered by blists - more mailing lists