[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231011091624.4057e456@kernel.org>
Date: Wed, 11 Oct 2023 09:16:24 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Jiri Pirko <jiri@...nulli.us>
Cc: netdev@...r.kernel.org, nicolas.dichtel@...nd.com,
johannes@...solutions.net, fw@...len.de, pablo@...filter.org,
mkubecek@...e.cz, aleksander.lobakin@...el.com
Subject: Re: [RFC] netlink: add variable-length / auto integers
On Wed, 11 Oct 2023 15:46:47 +0200 Jiri Pirko wrote:
> >Thoughts?
>
> Hmm, I assume that genetlink.yaml schema should only allow uint and sint
> to be defined after this, so new genetlink implementations use just uint
> and sint, correct?
No, fixed types are still allowed, just discouraged.
> Than we have genetlink.yaml genetlink-legacy.yaml genetlink-legacy2.yaml
> ?
> I guess in the future there might be other changes to require new
> implemetation not to use legacy things. How does this scale?
>
> >This is completely untested. YNL to follow.
> >---
> > include/net/netlink.h | 62 ++++++++++++++++++++++++++++++++++--
> > include/uapi/linux/netlink.h | 5 +++
> > lib/nlattr.c | 9 ++++++
> > net/netlink/policy.c | 14 ++++++--
> > 4 files changed, 85 insertions(+), 5 deletions(-)
> >
> >diff --git a/include/net/netlink.h b/include/net/netlink.h
> >index 8a7cd1170e1f..523486dfe4f3 100644
> >--- a/include/net/netlink.h
> >+++ b/include/net/netlink.h
> >@@ -183,6 +183,8 @@ enum {
> > NLA_REJECT,
> > NLA_BE16,
> > NLA_BE32,
> >+ NLA_SINT,
>
> Why not just NLA_INT?
Coin toss. Signed types are much less common in netlink
so it shouldn't matter much.
> >+static inline int nla_put_uint(struct sk_buff *skb, int attrtype, u64 value)
> >+{
> >+ u64 tmp64 = value;
> >+ u32 tmp32 = value;
> >+
> >+ if (tmp64 == tmp32)
> >+ return nla_put_u32(skb, attrtype, tmp32);
>
> It's a bit confusing, perheps better just to use nla_put() here as well?
I want to underscore the equivalency to u32 for smaller types.
Powered by blists - more mailing lists