]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
devlink: region: snapshot IDs: consolidate error values
authorPrzemek Kitszel <przemyslaw.kitszel@intel.com>
Wed, 23 Oct 2024 13:09:04 +0000 (15:09 +0200)
committerJakub Kicinski <kuba@kernel.org>
Tue, 29 Oct 2024 23:52:57 +0000 (16:52 -0700)
Consolidate error codes for too big message size.

Current code is written to return -EINVAL when tailroom in the skb msg
would be exhausted precisely when it's time to nest, and return -EMSGSIZE
in all other "not enough space" conditions.

Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Reviewed-by: Joe Damato <jdamato@fastly.com>
Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Link: https://patch.msgid.link/20241023131248.27192-5-przemyslaw.kitszel@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/devlink/region.c

index 0a75a2fbd4d78b224efbb95a5880db1f1a63d772..63fb297f6d6785cd2d7f488b563e3a2f7dc3fefd 100644 (file)
@@ -77,7 +77,7 @@ static int devlink_nl_region_snapshot_id_put(struct sk_buff *msg,
 
        snap_attr = nla_nest_start_noflag(msg, DEVLINK_ATTR_REGION_SNAPSHOT);
        if (!snap_attr)
-               return -EINVAL;
+               return -EMSGSIZE;
 
        err = nla_put_u32(msg, DEVLINK_ATTR_REGION_SNAPSHOT_ID, snapshot->id);
        if (err)
@@ -102,7 +102,7 @@ static int devlink_nl_region_snapshots_id_put(struct sk_buff *msg,
        snapshots_attr = nla_nest_start_noflag(msg,
                                               DEVLINK_ATTR_REGION_SNAPSHOTS);
        if (!snapshots_attr)
-               return -EINVAL;
+               return -EMSGSIZE;
 
        list_for_each_entry(snapshot, &region->snapshot_list, list) {
                err = devlink_nl_region_snapshot_id_put(msg, devlink, snapshot);