Skip to content

Commit a0b6106

Browse files
miquelraynalStefan-Schmidt
authored andcommitted
ieee802154: Convert scan error messages to extack
Instead of printing error messages in the kernel log, let's use extack. When there is a netlink error returned that could be further specified with a string, use extack as well. Apply this logic to the very recent scan/beacon infrastructure. Fixes: ed3557c ("ieee802154: Add support for user scanning requests") Fixes: 9bc1145 ("ieee802154: Add support for user beaconing requests") Suggested-by: Jakub Kicinski <[email protected]> Signed-off-by: Miquel Raynal <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stefan Schmidt <[email protected]>
1 parent 648324c commit a0b6106

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

net/ieee802154/nl802154.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,9 +1407,15 @@ static int nl802154_trigger_scan(struct sk_buff *skb, struct genl_info *info)
14071407
u8 type;
14081408
int err;
14091409

1410-
/* Monitors are not allowed to perform scans */
1411-
if (wpan_dev->iftype == NL802154_IFTYPE_MONITOR)
1410+
if (wpan_dev->iftype == NL802154_IFTYPE_MONITOR) {
1411+
NL_SET_ERR_MSG(info->extack, "Monitors are not allowed to perform scans");
14121412
return -EPERM;
1413+
}
1414+
1415+
if (!nla_get_u8(info->attrs[NL802154_ATTR_SCAN_TYPE])) {
1416+
NL_SET_ERR_MSG(info->extack, "Malformed request, missing scan type");
1417+
return -EINVAL;
1418+
}
14131419

14141420
request = kzalloc(sizeof(*request), GFP_KERNEL);
14151421
if (!request)
@@ -1424,7 +1430,7 @@ static int nl802154_trigger_scan(struct sk_buff *skb, struct genl_info *info)
14241430
request->type = type;
14251431
break;
14261432
default:
1427-
pr_err("Unsupported scan type: %d\n", type);
1433+
NL_SET_ERR_MSG_FMT(info->extack, "Unsupported scan type: %d", type);
14281434
err = -EINVAL;
14291435
goto free_request;
14301436
}
@@ -1576,12 +1582,13 @@ nl802154_send_beacons(struct sk_buff *skb, struct genl_info *info)
15761582
struct cfg802154_beacon_request *request;
15771583
int err;
15781584

1579-
/* Only coordinators can send beacons */
1580-
if (wpan_dev->iftype != NL802154_IFTYPE_COORD)
1585+
if (wpan_dev->iftype != NL802154_IFTYPE_COORD) {
1586+
NL_SET_ERR_MSG(info->extack, "Only coordinators can send beacons");
15811587
return -EOPNOTSUPP;
1588+
}
15821589

15831590
if (wpan_dev->pan_id == cpu_to_le16(IEEE802154_PANID_BROADCAST)) {
1584-
pr_err("Device is not part of any PAN\n");
1591+
NL_SET_ERR_MSG(info->extack, "Device is not part of any PAN");
15851592
return -EPERM;
15861593
}
15871594

0 commit comments

Comments
 (0)