From: Jiri Pirko <jiri@resnulli.us>
To: Jakub Kicinski <kuba@kernel.org>
Cc: davem@davemloft.net, netdev@vger.kernel.org, edumazet@google.com,
pabeni@redhat.com, johannes@sipsolutions.net
Subject: Re: [PATCH net-next 07/10] genetlink: add genlmsg_iput() API
Date: Thu, 10 Aug 2023 18:42:29 +0200 [thread overview]
Message-ID: <ZNUTdSE3CcQbK07D@nanopsycho> (raw)
In-Reply-To: <20230810091336.40951430@kernel.org>
Thu, Aug 10, 2023 at 06:13:36PM CEST, kuba@kernel.org wrote:
>On Thu, 10 Aug 2023 11:07:41 +0200 Jiri Pirko wrote:
>> >+#ifdef __LITTLE_ENDIAN
>> >+#define __GENL_PTR_LOW(byte) ((void *)(unsigned long)(byte))
>> >+#else
>> >+#define __GENL_PTR_LOW(byte) \
>> >+ ((void *)((unsigned long)(byte) << (BITS_PER_LONG - 8)))
>> >+#endif
>> >+
>> >+/**
>> >+ * GENL_INFO_NTF() - define genl_info for notifications
>> >+ * @__name: name of declared variable
>> >+ * @__family: pointer to the genetlink family
>> >+ * @__cmd: command to be used in the notification
>> >+ */
>> >+#define GENL_INFO_NTF(__name, __family, __cmd) \
>> >+ struct genl_info __name = { \
>> >+ .family = (__family), \
>> >+ .genlhdr = (void *)&(__name.user_ptr[0]), \
>> >+ .user_ptr[0] = __GENL_PTR_LOW(__cmd), \
>>
>> Ugh. Took me some time to decypher what you do here. Having endian
>> specific code here seems quite odd to me. Why don't you have this as
>> static inline initializer function instead and use struct genlmsghdr
>> pointer to store cmd where it belong?
>>
>> static inline void genl_info_ntf(struct genl_info *info,
>> const struct genl_family *family, u8 cmd)
>> }
>> struct genlmsghdr *hdr = (void *) &info->user_ptr[0];
>>
>> info->family = family;
>> info->genlhdr = hdr;
>> hdr->cmd = cmd;
>> }
>
>Nice! The endian magic is easily the nastiest part of this series.
>I considered making genlhdr a struct (rather than a pointer) because
>it's actually smaller than a pointer on 64b. But dunno, feels kinda
>weird to have a copy of the struct and a pointer to nlh. Hence the
>magic.
>
>And I was trying to save the 2 LoC and provide the DEFINE_ style macro
>but on second thought your init helper is cleaner. I don't like the
>DEFINE_ shit myself. I'll just throw in a memset(0) in there, and maybe
>add a verb to the name - genl_info_init_nft()?
Yep, looks fine to me. Thanks!
next prev parent reply other threads:[~2023-08-10 16:42 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-09 18:26 [PATCH net-next 00/10] genetlink: provide struct genl_info to dumps Jakub Kicinski
2023-08-09 18:26 ` [PATCH net-next 01/10] genetlink: use push conditional locking info dumpit/done Jakub Kicinski
2023-08-09 20:56 ` Johannes Berg
2023-08-10 6:54 ` Jiri Pirko
2023-08-09 18:26 ` [PATCH net-next 02/10] genetlink: make genl_info->nlhdr const Jakub Kicinski
2023-08-10 8:22 ` Jiri Pirko
2023-08-09 18:26 ` [PATCH net-next 03/10] genetlink: remove userhdr from struct genl_info Jakub Kicinski
2023-08-09 20:59 ` Johannes Berg
2023-08-09 22:02 ` Jakub Kicinski
2023-08-10 8:26 ` Jiri Pirko
2023-08-09 18:26 ` [PATCH net-next 04/10] genetlink: add struct genl_info to struct genl_dumpit_info Jakub Kicinski
2023-08-10 8:33 ` Jiri Pirko
2023-08-09 18:26 ` [PATCH net-next 05/10] genetlink: use attrs from struct genl_info Jakub Kicinski
2023-08-09 21:04 ` Johannes Berg
2023-08-10 6:17 ` Miquel Raynal
2023-08-10 8:35 ` Jiri Pirko
2023-08-09 18:26 ` [PATCH net-next 06/10] genetlink: add a family pointer to " Jakub Kicinski
2023-08-09 18:26 ` [PATCH net-next 07/10] genetlink: add genlmsg_iput() API Jakub Kicinski
2023-08-10 9:07 ` Jiri Pirko
2023-08-10 16:13 ` Jakub Kicinski
2023-08-10 16:42 ` Jiri Pirko [this message]
2023-08-09 18:26 ` [PATCH net-next 08/10] netdev-genl: use struct genl_info for reply construction Jakub Kicinski
2023-08-10 9:10 ` Jiri Pirko
2023-08-09 18:26 ` [PATCH net-next 09/10] ethtool: netlink: simplify arguments to ethnl_default_parse() Jakub Kicinski
2023-08-10 9:12 ` Jiri Pirko
2023-08-09 18:26 ` [PATCH net-next 10/10] ethtool: netlink: always pass genl_info to .prepare_data Jakub Kicinski
2023-08-10 18:40 ` Vladimir Oltean
2023-08-10 8:30 ` [PATCH net-next 00/10] genetlink: provide struct genl_info to dumps Jiri Pirko
2023-08-10 16:14 ` Jakub Kicinski
2023-08-10 16:43 ` Jiri Pirko
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=ZNUTdSE3CcQbK07D@nanopsycho \
--to=jiri@resnulli.us \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=johannes@sipsolutions.net \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).