From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: Alexander Aring <alex.aring@gmail.com>,
Stefan Schmidt <stefan@datenfreihafen.org>,
linux-wpan@vger.kernel.org,
"David S. Miller" <davem@davemloft.net>,
Paolo Abeni <pabeni@redhat.com>,
Eric Dumazet <edumazet@google.com>,
netdev@vger.kernel.org, David Girault <david.girault@qorvo.com>,
Romuald Despres <romuald.despres@qorvo.com>,
Frederic Blain <frederic.blain@qorvo.com>,
Nicolas Schodet <nico@ni.fr.eu.org>,
Guilhem Imberton <guilhem.imberton@qorvo.com>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Subject: Re: [PATCH wpan-next 1/6] ieee802154: Add support for user scanning requests
Date: Fri, 10 Feb 2023 11:18:43 +0100 [thread overview]
Message-ID: <20230210111843.0817d0d3@xps-13> (raw)
In-Reply-To: <20230203201923.6de5c692@kernel.org>
Hi Stefan, Jakub,
kuba@kernel.org wrote on Fri, 3 Feb 2023 20:19:23 -0800:
> On Tue, 29 Nov 2022 17:00:41 +0100 Miquel Raynal wrote:
> > +static int nl802154_trigger_scan(struct sk_buff *skb, struct genl_info *info)
> > +{
> > + struct cfg802154_registered_device *rdev = info->user_ptr[0];
> > + struct net_device *dev = info->user_ptr[1];
> > + struct wpan_dev *wpan_dev = dev->ieee802154_ptr;
> > + struct wpan_phy *wpan_phy = &rdev->wpan_phy;
> > + struct cfg802154_scan_request *request;
> > + u8 type;
> > + int err;
> > +
> > + /* Monitors are not allowed to perform scans */
> > + if (wpan_dev->iftype == NL802154_IFTYPE_MONITOR)
>
> extack ?
Thanks for pointing at it, I just did know about it. I did convert
most of the printk's into extack strings. Shall I keep both or is fine
to just keep the extack thing?
For now I've dropped the printk's, please tell me if this is wrong.
>
> > + return -EPERM;
Stefan, do you prefer a series of patches applying on top of your
current next or should I re-roll the entire series (scan + beacons)?
I am preparing a series applying on top of the current list of applied
patches. This means next PR to net maintainers will include this patch
as it is today + fixes on top. If this is fine for both parties, I will
send these (including the other changes discussed with Alexander). Just
let me know.
Sorry btw for the delay, I really had to finish other activities before
switching back.
> > +
> > + request = kzalloc(sizeof(*request), GFP_KERNEL);
> > + if (!request)
> > + return -ENOMEM;
> > +
> > + request->wpan_dev = wpan_dev;
> > + request->wpan_phy = wpan_phy;
> > +
> > + type = nla_get_u8(info->attrs[NL802154_ATTR_SCAN_TYPE]);
>
> what checks info->attrs[NL802154_ATTR_SCAN_TYPE] is not NULL?
>
> > + switch (type) {
> > + case NL802154_SCAN_PASSIVE:
> > + request->type = type;
> > + break;
> > + default:
> > + pr_err("Unsupported scan type: %d\n", type);
> > + err = -EINVAL;
>
> extack (printfs are now supported)
>
> > + goto free_request;
> > + }
> > +
> > + if (info->attrs[NL802154_ATTR_PAGE]) {
> > + request->page = nla_get_u8(info->attrs[NL802154_ATTR_PAGE]);
> > + if (request->page > IEEE802154_MAX_PAGE) {
>
> bound check should be part of the policy NLA_POLICY_MAX()
I just improved the policies to make these checks useless and simplify a
lot the code there, thanks as well for pointing at it.
> > + pr_err("Invalid page %d > %d\n",
> > + request->page, IEEE802154_MAX_PAGE);
> > + err = -EINVAL;
>
> extack
>
> > + goto free_request;
> > + }
> > + } else {
> > + /* Use current page by default */
> > + request->page = wpan_phy->current_page;
> > + }
> > +
> > + if (info->attrs[NL802154_ATTR_SCAN_CHANNELS]) {
> > + request->channels = nla_get_u32(info->attrs[NL802154_ATTR_SCAN_CHANNELS]);
> > + if (request->channels >= BIT(IEEE802154_MAX_CHANNEL + 1)) {
>
> policy as well
>
> > + pr_err("Invalid channels bitfield %x ≥ %lx\n",
> > + request->channels,
> > + BIT(IEEE802154_MAX_CHANNEL + 1));
> > + err = -EINVAL;
> > + goto free_request;
> > + }
> > + } else {
> > + /* Scan all supported channels by default */
> > + request->channels = wpan_phy->supported.channels[request->page];
> > + }
> > +
> > + if (info->attrs[NL802154_ATTR_SCAN_PREAMBLE_CODES] ||
> > + info->attrs[NL802154_ATTR_SCAN_MEAN_PRF]) {
> > + pr_err("Preamble codes and mean PRF not supported yet\n");
>
> NLA_REJECT also in policy
>
> > + err = -EINVAL;
> > + goto free_request;
> > + }
> > +
> > + if (info->attrs[NL802154_ATTR_SCAN_DURATION]) {
> > + request->duration = nla_get_u8(info->attrs[NL802154_ATTR_SCAN_DURATION]);
> > + if (request->duration > IEEE802154_MAX_SCAN_DURATION) {
> > + pr_err("Duration is out of range\n");
> > + err = -EINVAL;
> > + goto free_request;
> > + }
> > + } else {
> > + /* Use maximum duration order by default */
> > + request->duration = IEEE802154_MAX_SCAN_DURATION;
> > + }
> > +
> > + if (wpan_dev->netdev)
> > + dev_hold(wpan_dev->netdev);
>
> Can we put a tracker in the request and use netdev_hold() ?
I'll look into it.
Thanks,
Miquèl
next prev parent reply other threads:[~2023-02-10 10:18 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-29 16:00 [PATCH wpan-next 0/6] IEEE 802.15.4 passive scan support Miquel Raynal
2022-11-29 16:00 ` [PATCH wpan-next 1/6] ieee802154: Add support for user scanning requests Miquel Raynal
2022-12-04 22:44 ` Alexander Aring
2022-12-05 9:57 ` Miquel Raynal
2022-12-07 13:27 ` Alexander Aring
2022-12-07 13:44 ` Miquel Raynal
2022-12-08 2:22 ` Alexander Aring
2023-02-04 4:19 ` Jakub Kicinski
2023-02-10 10:18 ` Miquel Raynal [this message]
2023-02-10 10:26 ` Stefan Schmidt
2023-02-10 10:35 ` Miquel Raynal
2023-02-10 18:59 ` Jakub Kicinski
2023-02-10 22:47 ` Miquel Raynal
2023-02-06 1:39 ` Alexander Aring
2023-02-06 9:12 ` Miquel Raynal
2023-02-07 0:33 ` Alexander Aring
2023-02-07 12:55 ` Alexander Aring
2023-02-07 12:57 ` Alexander Aring
2023-02-13 17:35 ` Miquel Raynal
2023-02-14 13:34 ` Alexander Aring
2023-02-14 13:53 ` Alexander Aring
2023-02-14 14:06 ` Miquel Raynal
2023-02-14 14:46 ` Miquel Raynal
2023-02-17 4:37 ` Alexander Aring
2023-02-17 8:49 ` Miquel Raynal
2023-02-17 4:34 ` Alexander Aring
2023-02-17 9:02 ` Miquel Raynal
2023-02-21 2:43 ` Alexander Aring
2023-02-10 17:21 ` Miquel Raynal
2023-02-12 20:15 ` Alexander Aring
2023-02-13 10:15 ` Miquel Raynal
2023-02-14 13:51 ` Alexander Aring
2023-02-14 14:28 ` Miquel Raynal
2023-02-17 4:46 ` Alexander Aring
2023-02-17 8:52 ` Miquel Raynal
2023-02-21 2:54 ` Alexander Aring
2023-02-21 3:05 ` Alexander Aring
2023-02-24 13:57 ` Miquel Raynal
2022-11-29 16:00 ` [PATCH wpan-next 2/6] ieee802154: Define a beacon frame header Miquel Raynal
2022-11-29 16:00 ` [PATCH wpan-next 3/6] ieee802154: Introduce a helper to validate a channel Miquel Raynal
2022-11-29 16:00 ` [PATCH wpan-next 4/6] mac802154: Prepare forcing specific symbol duration Miquel Raynal
2022-11-29 16:00 ` [PATCH wpan-next 5/6] mac802154: Add MLME Tx locked helpers Miquel Raynal
2022-11-29 16:00 ` [PATCH wpan-next 6/6] mac802154: Handle passive scanning Miquel Raynal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230210111843.0817d0d3@xps-13 \
--to=miquel.raynal@bootlin.com \
--cc=alex.aring@gmail.com \
--cc=davem@davemloft.net \
--cc=david.girault@qorvo.com \
--cc=edumazet@google.com \
--cc=frederic.blain@qorvo.com \
--cc=guilhem.imberton@qorvo.com \
--cc=kuba@kernel.org \
--cc=linux-wpan@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nico@ni.fr.eu.org \
--cc=pabeni@redhat.com \
--cc=romuald.despres@qorvo.com \
--cc=stefan@datenfreihafen.org \
--cc=thomas.petazzoni@bootlin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.