diff mbox series

[ethtool,02/21] netlink: fix nest type grouping in parser

Message ID 66427ed9d01547b06bc7eb2b853a18108274f3eb.1590707335.git.mkubecek@suse.cz
State Accepted
Delegated to: John Linville
Headers show
Series netlink interface update for 5.7 release | expand

Commit Message

Michal Kubecek May 28, 2020, 11:21 p.m. UTC
Even if we are only interested in one nested attribute when using
PARSER_GROUP_NEST group type, the temporary buffer must contain proper
netlink header and have pointer to it and payload set up correctly for
libmnl composition functions to be able to track current message size.

Fixes: 9ee9d9517542 ("netlink: add basic command line parsing helpers")
Reported-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
---
 netlink/parser.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Andrew Lunn May 29, 2020, 2:28 p.m. UTC | #1
On Fri, May 29, 2020 at 01:21:17AM +0200, Michal Kubecek wrote:
> Even if we are only interested in one nested attribute when using
> PARSER_GROUP_NEST group type, the temporary buffer must contain proper
> netlink header and have pointer to it and payload set up correctly for
> libmnl composition functions to be able to track current message size.
> 
> Fixes: 9ee9d9517542 ("netlink: add basic command line parsing helpers")
> Reported-by: Andrew Lunn <andrew@lunn.ch>
> Signed-off-by: Michal Kubecek <mkubecek@suse.cz>

Tested-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
diff mbox series

Patch

diff --git a/netlink/parser.c b/netlink/parser.c
index d790abedd482..bd3526f31113 100644
--- a/netlink/parser.c
+++ b/netlink/parser.c
@@ -957,6 +957,10 @@  int nl_parser(struct nl_context *nlctx, const struct param_parser *params,
 		if (!buff)
 			goto out_free_buffs;
 		msgbuff = &buff->msgbuff;
+		ret = msg_init(nlctx, msgbuff, parser->group,
+			       NLM_F_REQUEST | NLM_F_ACK);
+		if (ret < 0)
+			goto out_free_buffs;
 
 		switch (group_style) {
 		case PARSER_GROUP_NEST:
@@ -966,10 +970,6 @@  int nl_parser(struct nl_context *nlctx, const struct param_parser *params,
 				goto out_free_buffs;
 			break;
 		case PARSER_GROUP_MSG:
-			ret = msg_init(nlctx, msgbuff, parser->group,
-				       NLM_F_REQUEST | NLM_F_ACK);
-			if (ret < 0)
-				goto out_free_buffs;
 			if (ethnla_fill_header(msgbuff,
 					       ETHTOOL_A_LINKINFO_HEADER,
 					       nlctx->devname, 0))