All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Sven Eckelmann <sven@narfation.org>
Cc: b.a.t.m.a.n@lists.open-mesh.org
Subject: Re: [B.A.T.M.A.N.] [PATCHv2] batctl: Use netlink to replace some of debugfs
Date: Tue, 3 May 2016 15:08:57 +0200	[thread overview]
Message-ID: <20160503130857.GC16952@lunn.ch> (raw)
In-Reply-To: <3986955.uBauJeRErD@bentobox>

On Tue, May 03, 2016 at 02:54:26PM +0200, Sven Eckelmann wrote:
> On Tuesday 03 May 2016 14:47:19 Andrew Lunn wrote:
> > On Tue, May 03, 2016 at 02:26:34PM +0200, Sven Eckelmann wrote:
> > > On Tuesday 03 May 2016 14:20:46 Andrew Lunn wrote:
> > > [...]
> > > > There does not seem to be a way to say that BATADV_ATTR_VERSION is
> > > > also an NLA_STRING.
> > > 
> > > Please check "policy" in the link I gave you.
> > 
> > I did. And i still don't get how you can check the type.
> > 
> >   Andrew
> 
>    struct nla_policy {
>             uint16_t        type;
>             uint16_t        minlen;
>             uint16_t        maxlen;
>    };
> 
> there is an entry for type, minlen and maxlen. The type member is to check for
> the type. Here is an example how to check the type from batctl:
> 
>     static struct nla_policy info_data_link_policy[IFLA_MAX + 1] = {
>     	[IFLA_LINKINFO]	= { .type = NLA_NESTED },
> 	    [IFLA_LINK]	= { .type = NLA_U32 },
>     };
>     [...]
>     	ret = nlmsg_parse(n, sizeof(struct ifinfomsg), tb, IFLA_MAX,
>     			  info_data_link_policy);

Ah. Now i get it.

The problem is the overloaded 'type'. An attribute in a message has a
header which includes a type. It takes the value
e.g. BATADV_ATTR_VERSION. In nla_policy, we again have type, but this
time it takes e.g. NLA_U32.

Once you figure out type != type, it all becomes clear...

     Andrew


  reply	other threads:[~2016-05-03 13:08 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-02 20:56 [B.A.T.M.A.N.] [PATCHv2] batctl: Use netlink to replace some of debugfs Andrew Lunn
2016-05-03  7:07 ` Sven Eckelmann
2016-05-03 12:20   ` Andrew Lunn
2016-05-03 12:26     ` Sven Eckelmann
2016-05-03 12:47       ` Andrew Lunn
2016-05-03 12:54         ` Sven Eckelmann
2016-05-03 13:08           ` Andrew Lunn [this message]
2016-05-03 20:16     ` Marek Lindner
2016-05-03 20:30       ` Andrew Lunn
2016-05-03  9:47 ` Sven Eckelmann
2016-05-03  9:51 ` Sven Eckelmann
2016-05-03 10:30 ` Sven Eckelmann
2016-05-03 12:45   ` Andrew Lunn

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=20160503130857.GC16952@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=sven@narfation.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.