diag: fix netlink API attributes
Subsystems (4)
PATCH 1/1 diag: fix netlink API attributes
The first netlink attribute (value 0) must always be defined as none/unspec. This is correctly done in inet_diag.h, but other diag interfaces are broken.
Libraries like libnl skip this kind of attributes, thus it's never reported to the application.
---
Ok, I know that this patch change the API, but it's really painful to have such broken API, is it really mandatory to live with this?
And the question is: how to avoid to have the same mistake in the next diag API?
include/uapi/linux/netlink_diag.h | 1 + include/uapi/linux/packet_diag.h | 1 + include/uapi/linux/unix_diag.h | 1 + 3 files changed, 3 insertions(+)
include/uapi/linux/netlink_diag.h +1 -0
@@ -33,6 +33,7 @@ struct netlink_diag_ring { };enum { +NETLINK_DIAG_NONE ,NETLINK_DIAG_MEMINFO ,NETLINK_DIAG_GROUPS ,NETLINK_DIAG_RX_RING ,
include/uapi/linux/packet_diag.h +1 -0
@@ -29,6 +29,7 @@ struct packet_diag_msg { };enum { +PACKET_DIAG_UNSPEC ,PACKET_DIAG_INFO ,PACKET_DIAG_MCLIST ,PACKET_DIAG_RX_RING ,
include/uapi/linux/unix_diag.h +1 -0
@@ -31,6 +31,7 @@ struct unix_diag_msg { };enum { +UNIX_DIAG_NONE ,UNIX_DIAG_NAME ,UNIX_DIAG_VFS ,UNIX_DIAG_PEER ,
Signature · 1 line
1.8.4.1
Quoted 8 lines · Nicolas Dichtel
The first netlink attribute (value 0) must always be defined as none/unspec. This is correctly done in
inet_diag.h, but other diag interfaces are broken.Libraries like libnl skip this kind of attributes, thus it's never reported to the application.
CC Thomas Graf <[email protected]>Signed-off-by Nicolas Dichtel <[email protected]>
First of all, thanks for the notification Nicolas. I'll fix libnl to pass through these attributes.
I think the fix you propose is no an option as it breaks backwards compatiblity with existing user space. We cannot change the value of existing attributes.
RFC PATCH v2 1/1 diag: warn about missing first netlink attribute
The first netlink attribute (value 0) must always be defined as none/unspec. This is correctly done in inet_diag.h, but other diag interfaces are wrong.
Because we cannot change an existing API, I add a comment to point the mistake and avoid to propagate it in a new diag API in the future.
---
v2: just warn about the missing attribute
If patch is approved, I will submit it when the net-next tree opens.
include/uapi/linux/netlink_diag.h | 1 + include/uapi/linux/packet_diag.h | 1 + include/uapi/linux/unix_diag.h | 1 + 3 files changed, 3 insertions(+)
include/uapi/linux/netlink_diag.h +1 -0
@@ -33,6 +33,7 @@ struct netlink_diag_ring { };enum { +/* NETLINK_DIAG_NONE, standard nl API requires this attribute! */ NETLINK_DIAG_MEMINFO ,NETLINK_DIAG_GROUPS ,NETLINK_DIAG_RX_RING ,
include/uapi/linux/packet_diag.h +1 -0
@@ -29,6 +29,7 @@ struct packet_diag_msg { };enum { +/* PACKET_DIAG_NONE, standard nl API requires this attribute! */ PACKET_DIAG_INFO ,PACKET_DIAG_MCLIST ,PACKET_DIAG_RX_RING ,
include/uapi/linux/unix_diag.h +1 -0
@@ -31,6 +31,7 @@ struct unix_diag_msg { };enum { +/* UNIX_DIAG_NONE, standard nl API requires this attribute! */ UNIX_DIAG_NAME ,UNIX_DIAG_VFS ,UNIX_DIAG_PEER ,
Signature · 1 line
1.8.4.1
David Miller
maintainerRe: [RFC PATCH v2] diag: warn about missing first netlink attribute
From: Nicolas Dichtel <[email protected]>
Date: Thu, 28 Nov 2013 18:31:05 +0100
Quoted 6 lines
The first netlink attribute (value 0) must always be defined as none/unspec. This is correctly done in
inet_diag.h, but other diag interfaces are wrong.Because we cannot change an existing API, I add a comment to point the mistake and avoid to propagate it in a new diag API in the future.
Quoted 7 lines
CC Thomas Graf <[email protected]>Signed-off-by Nicolas Dichtel <[email protected]>---
v2: just warn about the missing attribute
If patch is approved, I will submit it when the net-next tree opens.
Indeed we can't change it, and documenting it like this is also a good idea.
I hope Thomas agrees.
Re: [RFC PATCH v2] diag: warn about missing first netlink attribute
In reply to Nicolas DichtelQuoted 6 lines · Nicolas Dichtel
The first netlink attribute (value 0) must always be defined as none/unspec. This is correctly done in
inet_diag.h, but other diag interfaces are wrong.Because we cannot change an existing API, I add a comment to point the mistake and avoid to propagate it in a new diag API in the future.
Quoted 7 lines
CC Thomas Graf <[email protected]>Signed-off-by Nicolas Dichtel <[email protected]>---
v2: just warn about the missing attribute
If patch is approved, I will submit it when the net-next tree opens.
Re: [RFC PATCH v2] diag: warn about missing first netlink attribute
From: Thomas Graf <[email protected]>
Date: Thu, 28 Nov 2013 22:09:09 +0000
Quoted 11 lines · Nicolas Dichtel
Quoted 10 lines
The first netlink attribute (value 0) must always be defined as none/unspec. This is correctly done in
inet_diag.h, but other diag interfaces are wrong.Because we cannot change an existing API, I add a comment to point the mistake and avoid to propagate it in a new diag API in the future.
CC Thomas Graf <[email protected]>Signed-off-by Nicolas Dichtel <[email protected]>---
Quoted 5 lines
Quoted 3 lines
v2: just warn about the missing attribute
If patch is approved, I will submit it when the net-next tree opens.
Acked-by Thomas Graf <[email protected]>
Applied, thanks.
Quoted 4 lines · Thomas Graf
Quoted 3 lines · Nicolas Dichtel
The first netlink attribute (value 0) must always be defined as none/unspec. This is correctly done in
inet_diag.h, but other diag interfaces are broken.
Quoted 8 lines
Quoted 5 lines
Libraries like libnl skip this kind of attributes, thus it's never reported to the application.
CC Thomas Graf <[email protected]>Signed-off-by Nicolas Dichtel <[email protected]>First of all, thanks for the notification Nicolas. I'll fix libnl to pass through these attributes.
Fine :)
Thank you!
Quoted 4 lines
I think the fix you propose is no an option as it breaks backwards compatiblity with existing user space. We cannot change the value of existing attributes.
Yes, I was just wondering how to fix it.
It also breaks the patch you've proposed in this thread:
http://thread.gmane.org/gmane.linux.network/251478/focus=252764
Hence, aligning attributes on 64-bits is still unresolved :(
Quoted 8 lines · Nicolas Dichtel
Quoted 7 lines · Thomas Graf
Quoted 6 lines · Nicolas Dichtel
The first netlink attribute (value 0) must always be defined as none/unspec. This is correctly done in
inet_diag.h, but other diag interfaces are broken.Libraries like libnl skip this kind of attributes, thus it's never reported to the application.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
CC Thomas Graf <[email protected]>Signed-off-by Nicolas Dichtel <[email protected]>First of all, thanks for the notification Nicolas. I'll fix libnl to pass through these attributes.
Fine :)
Thank you!
Fixed in:
commit 6a8d90f5fec48b6e376ff29ccf3e0c620a41e758
Author: Thomas Graf <[email protected]> Date: Thu Nov 28 23:14:38 2013 +0100
attr: Allow attribute type 0
{netlink,packet,unix}_diag use attribute type 0 for valid attributes. The value was reserved and usage was prohibited by the protocol but we can't undo the breakge.
Make libnl accept attribute type 0 to allow parsing these attributes.
Quoted 8 lines
Quoted 3 lines
I think the fix you propose is no an option as it breaks backwards compatiblity with existing user space. We cannot change the value of existing attributes.
Yes, I was just wondering how to fix it.
It also breaks the patch you've proposed in this thread:
http://thread.gmane.org/gmane.linux.network/251478/focus=252764Hence, aligning attributes on 64-bits is still unresolved :(
Unfortunately I ran into other places where an attribute type 0 was used. Therefore the idea of using NLA_UNSPEC (0) to insert padding attributes doesn't work. We would need to find another way to insert padding. I'll be glad to share the WIP patch if somebody else would like to continue the work.
Quoted 29 lines · Thomas Graf
Quoted 8 lines · Nicolas Dichtel
Quoted 7 lines · Thomas Graf
Quoted 6 lines · Nicolas Dichtel
The first netlink attribute (value 0) must always be defined as none/unspec. This is correctly done in
inet_diag.h, but other diag interfaces are broken.Libraries like libnl skip this kind of attributes, thus it's never reported to the application.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
CC Thomas Graf <[email protected]>Signed-off-by Nicolas Dichtel <[email protected]>First of all, thanks for the notification Nicolas. I'll fix libnl to pass through these attributes.
Fine :)
Thank you!Fixed in:
commit
6a8d90f5fec48b6e376ff29ccf3e0c620a41e758Author: Thomas Graf <[email protected]> Date: Thu Nov 28 23:14:38 2013 +0100attr: Allow attribute type 0
{netlink,packet,unix}_diag use attribute type 0 for valid attributes. The value was reserved and usage was prohibited by the protocol but we can't undo the breakge.
Quoted 5 lines
Make libnl accept attribute type 0 to allow parsing these attributes.
Reported-by Nicolas Dichtel <[email protected]>Signed-off-by Thomas Graf <[email protected]>
I think the following patch is also needed (not based on HEAD):
From 8aa4397d43fbd34deea9ed11677c04b460895f15 Mon Sep 17 00:00:00 2001
From: Samuel Gauthier <[email protected]>
Date: Fri, 29 Nov 2013 09:15:34 +0100
Subject: [PATCH] attr: Allow attribute type 0 parsing
The commit 6a8d90f5fec4 "attr: Allow attribute type 0" intended to allow the parsing of {netlink,packet,unix}_diag, even if they are using type 0 for valid attributes.
It lacked this part in nla_parse.
--- lib/attr.c | 4 ---- 1 file changed, 4 deletions(-)
lib/attr.c +0 -4
@@ -250,10 +250,6 @@ int nla_parse(struct nlattr *tb[], int maxtype, struct nlattr *head, int len,nla_for_each_attr (nla, head, len, rem) {int type =nla_type (nla); -/* Padding attributes */ -if (type ==0 ) -continue ; -if (type > maxtype)continue ;
Signature · 1 line
1.8.0
Quoted 7 lines · Nicolas Dichtel
I think the following patch is also needed (not based on HEAD):
From
8aa4397d43fbd34deea9ed11677c04b460895f15Mon Sep 17 00:00:00 2001
From: Samuel Gauthier <[email protected]>
Date: Fri, 29 Nov 2013 09:15:34 +0100
Subject: [PATCH] attr: Allow attribute type 0 parsing
Quoted 7 lines
The commit
6a8d90f5fec4"attr: Allow attribute type 0" intended to allow the parsing of {netlink,packet,unix}_diag, even if they are using type 0 for valid attributes.It lacked this part in
nla_parse.Signed-off-by Samuel Gauthier <[email protected]>
Good catch, applied, thanks!