Subject: Re: [PATCH net] diag: fix netlink API attributes

From: Nicolas Dichtel <[email-masked]>
Date: Fri, 29 Nov 2013 09:28:44 +0100

Le 28/11/2013 23:19, Thomas Graf a écrit :
> On 11/28/13 at 06:37pm, Nicolas Dichtel wrote:
>> Le 28/11/2013 17:38, Thomas Graf a écrit :
>>> On 11/28/13 at 02:57pm, Nicolas Dichtel wrote:
>>>> 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-masked]>
>>>> Signed-off-by: Nicolas Dichtel <[email-masked]>
>>>
>>> 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-masked]>
> 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.
>
>      Reported-by: Nicolas Dichtel <[email-masked]>
>      Signed-off-by: Thomas Graf <[email-masked]>
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-masked]>
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.

Signed-off-by: Samuel Gauthier <[email-masked]>
---
  lib/attr.c | 4 ----
  1 file changed, 4 deletions(-)

diff --git a/lib/attr.c b/lib/attr.c
index 535f10c..1e2d57f 100644
--- a/lib/attr.c
+++ b/lib/attr.c
@@ -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;

-- 
1.8.0