devlink: extend devlink_nl_put_nested_handle() with attrtype arg
authorJiri Pirko <jiri@nvidia.com>
Wed, 13 Sep 2023 07:12:37 +0000 (09:12 +0200)
committerDavid S. Miller <davem@davemloft.net>
Sun, 17 Sep 2023 13:01:46 +0000 (14:01 +0100)
As the next patch is going to call this helper with need to fill another
type of nested attribute, pass it over function arg.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/devlink/devl_internal.h
net/devlink/linecard.c
net/devlink/netlink.c

index fbf00de1accfeb93b921ec6dd97f9c7d8885d03f..53449dbd65456940d1f5cdbfc1172746fc85cd99 100644 (file)
@@ -146,7 +146,7 @@ devlink_nl_put_handle(struct sk_buff *msg, struct devlink *devlink)
 }
 
 int devlink_nl_put_nested_handle(struct sk_buff *msg, struct net *net,
-                                struct devlink *devlink);
+                                struct devlink *devlink, int attrtype);
 int devlink_nl_msg_reply_and_new(struct sk_buff **msg, struct genl_info *info);
 
 /* Notify */
index 688e89daee6a9e0ee37269d6ebcf90ad7c969370..36170f466878af67df4facc393917e5c843de969 100644 (file)
@@ -114,7 +114,8 @@ static int devlink_nl_linecard_fill(struct sk_buff *msg,
 
        if (linecard->nested_devlink &&
            devlink_nl_put_nested_handle(msg, devlink_net(devlink),
-                                        linecard->nested_devlink))
+                                        linecard->nested_devlink,
+                                        DEVLINK_ATTR_NESTED_DEVLINK))
                goto nla_put_failure;
 
        genlmsg_end(msg, hdr);
index 48b5cfc2842fa549a5e7b0f420588d44c58aea94..499304d9de497da36bf0b1654b182bcc8a195f14 100644 (file)
@@ -83,11 +83,11 @@ static const struct nla_policy devlink_nl_policy[DEVLINK_ATTR_MAX + 1] = {
 };
 
 int devlink_nl_put_nested_handle(struct sk_buff *msg, struct net *net,
-                                struct devlink *devlink)
+                                struct devlink *devlink, int attrtype)
 {
        struct nlattr *nested_attr;
 
-       nested_attr = nla_nest_start(msg, DEVLINK_ATTR_NESTED_DEVLINK);
+       nested_attr = nla_nest_start(msg, attrtype);
        if (!nested_attr)
                return -EMSGSIZE;
        if (devlink_nl_put_handle(msg, devlink))