Subject: Re: [PATCH net-next 08/10] netdev-genl: use struct genl_info for reply construction

From: Jiri Pirko <[email-masked]>
Date: Thu, 10 Aug 2023 11:10:21 +0200

Wed, Aug 09, 2023 at 08:26:46PM CEST, [email-masked] wrote:

[...]

>@@ -41,6 +41,7 @@ netdev_nl_dev_fill(struct net_device *netdev, struct sk_buff *rsp,
> static void
> netdev_genl_dev_notify(struct net_device *netdev, int cmd)
> {
>+	GENL_INFO_NTF(info, &netdev_nl_family, cmd);

These macros declaring and defining struct on stack always introduce
some level of obfuscation to the code. Again, as I suggested in the
reply to the previous patch, would it be nicer to have initializer
helper instead? Something like:

	struct genl_info info;

	genl_info_nft(&info, &netdev_nl_family, cmd);

> 	struct sk_buff *ntf;
> 
> 	if (!genl_has_listeners(&netdev_nl_family, dev_net(netdev),
>@@ -51,7 +52,7 @@ netdev_genl_dev_notify(struct net_device *netdev, int cmd)
> 	if (!ntf)
> 		return;
> 
>-	if (netdev_nl_dev_fill(netdev, ntf, 0, 0, 0, cmd)) {
>+	if (netdev_nl_dev_fill(netdev, ntf, &info)) {
> 		nlmsg_free(ntf);
> 		return;
> 	}

[...]