diff mbox

netlink: use TID instead of PID for automatic id assignment

Message ID alpine.LNX.2.01.1010312013100.20872@obet.zrqbmnf.qr
State Rejected, archived
Delegated to: David Miller
Headers show

Commit Message

Jan Engelhardt Oct. 31, 2010, 7:14 p.m. UTC
parent 3985c7ce85039adacdf882904ca096f091d39346 (v2.6.36-9871-g3985c7c)
commit 183ded547d51508f23f6c18a999f6c165e66c99e
Author: Jan Engelhardt <jengelh@medozas.de>
Date:   Sun Oct 31 20:09:36 2010 +0100

netlink: use TID instead of PID for automatic id assignment

This makes it easier to identify processes in the output of `ss -af
netlink` - as I see no reason to force negative space numbers upon
all but the first socket in a thread group.

Turns out this reverts v2.6.15-rc4~65.

Cc: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
---
 net/netlink/af_netlink.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Herbert Xu Nov. 1, 2010, 2:25 a.m. UTC | #1
On Sun, Oct 31, 2010 at 08:14:00PM +0100, Jan Engelhardt wrote:
> parent 3985c7ce85039adacdf882904ca096f091d39346 (v2.6.36-9871-g3985c7c)
> commit 183ded547d51508f23f6c18a999f6c165e66c99e
> Author: Jan Engelhardt <jengelh@medozas.de>
> Date:   Sun Oct 31 20:09:36 2010 +0100
> 
> netlink: use TID instead of PID for automatic id assignment
> 
> This makes it easier to identify processes in the output of `ss -af
> netlink` - as I see no reason to force negative space numbers upon
> all but the first socket in a thread group.
> 
> Turns out this reverts v2.6.15-rc4~65.
> 
> Cc: Herbert Xu <herbert@gondor.apana.org.au>
> Signed-off-by: Jan Engelhardt <jengelh@medozas.de>

Nack.  Sockets are typically shared amongst threads so using the
ID of the thread that created it doesn't make much sense when
all the threads in that group use it to send/receive messages.

In any case, this field should not be relied on (please google
the thread "netlink nlmsg_pid supposed to be pid or tid?") as
anybody can claim your PID in the netlink name space.

Cheers,
Jan Engelhardt Nov. 1, 2010, 8:27 a.m. UTC | #2
On Monday 2010-11-01 03:25, Herbert Xu wrote:
>> 
>> netlink: use TID instead of PID for automatic id assignment
>> 
>> This makes it easier to identify processes in the output of `ss -af
>> netlink` - as I see no reason to force negative space numbers upon
>> all but the first socket in a thread group.
>> 
>> Turns out this reverts v2.6.15-rc4~65.
>> 
>> Cc: Herbert Xu <herbert@gondor.apana.org.au>
>> Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
>
>Nack.  Sockets are typically shared amongst threads so using the
>ID of the thread that created it doesn't make much sense when
>all the threads in that group use it to send/receive messages.

That would be fine, because they are in the same process.

>In any case, this field should not be relied on (please google
>the thread "netlink nlmsg_pid supposed to be pid or tid?") as
>anybody can claim your PID in the netlink name space.

I am aware of that. But then it raises the question why we are
giving the first socket a non-negative value in the first place.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 478181d..568d07c 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -545,7 +545,7 @@  static int netlink_autobind(struct socket *sock)
 	struct hlist_head *head;
 	struct sock *osk;
 	struct hlist_node *node;
-	s32 pid = task_tgid_vnr(current);
+	s32 pid = task_pid_vnr(current);
 	int err;
 	static s32 rover = -4097;