From: Alexander Aring <aahringo@redhat.com>
To: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Alexander Aring <alex.aring@gmail.com>,
Stefan Schmidt <stefan@datenfreihafen.org>,
linux-wpan@vger.kernel.org,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, 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 04/11] mac802154: Handle associating
Date: Tue, 4 Jul 2023 07:34:15 -0400 [thread overview]
Message-ID: <CAK-6q+g_0LZ_OPZtCjAsL8Vn6TiTKM5RUzQTxK7GDzuEEVNSEg@mail.gmail.com> (raw)
In-Reply-To: <CAK-6q+ibbYBbvbGK9ehJJoaJAw4hubh6Ff=q2P4mq+Z07ZgR0A@mail.gmail.com>
Hi,
On Sat, Jun 3, 2023 at 6:09 AM Alexander Aring <aahringo@redhat.com> wrote:
>
> Hi,
>
> On Thu, Jun 1, 2023 at 11:50 AM Miquel Raynal <miquel.raynal@bootlin.com> wrote:
> >
> > Joining a PAN officially goes by associating with a coordinator. This
> > coordinator may have been discovered thanks to the beacons it sent in
> > the past. Add support to the MAC layer for these associations, which
> > require:
> > - Sending an association request
> > - Receiving an association response
> >
> > The association response contains the association status, eventually a
> > reason if the association was unsuccessful, and finally a short address
> > that we should use for intra-PAN communication from now on, if we
> > required one (which is the default, and not yet configurable).
> >
> > Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> > ---
> > include/linux/ieee802154.h | 1 +
> > include/net/cfg802154.h | 1 +
> > include/net/ieee802154_netdev.h | 5 ++
> > net/ieee802154/core.c | 14 ++++
> > net/mac802154/cfg.c | 72 ++++++++++++++++++
> > net/mac802154/ieee802154_i.h | 19 +++++
> > net/mac802154/main.c | 2 +
> > net/mac802154/rx.c | 9 +++
> > net/mac802154/scan.c | 127 ++++++++++++++++++++++++++++++++
> > 9 files changed, 250 insertions(+)
> >
> > diff --git a/include/linux/ieee802154.h b/include/linux/ieee802154.h
> > index 140f61ec0f5f..c72bd76cac1b 100644
> > --- a/include/linux/ieee802154.h
> > +++ b/include/linux/ieee802154.h
> > @@ -37,6 +37,7 @@
> > IEEE802154_FCS_LEN)
> >
> > #define IEEE802154_PAN_ID_BROADCAST 0xffff
> > +#define IEEE802154_ADDR_LONG_BROADCAST 0xffffffffffffffffULL
> > #define IEEE802154_ADDR_SHORT_BROADCAST 0xffff
> > #define IEEE802154_ADDR_SHORT_UNSPEC 0xfffe
> >
> > diff --git a/include/net/cfg802154.h b/include/net/cfg802154.h
> > index 3b9d65455b9a..dd0964d351cd 100644
> > --- a/include/net/cfg802154.h
> > +++ b/include/net/cfg802154.h
> > @@ -502,6 +502,7 @@ struct wpan_dev {
> > struct mutex association_lock;
> > struct ieee802154_pan_device *parent;
> > struct list_head children;
> > + unsigned int association_generation;
> > };
> >
> > #define to_phy(_dev) container_of(_dev, struct wpan_phy, dev)
> > diff --git a/include/net/ieee802154_netdev.h b/include/net/ieee802154_netdev.h
> > index ca8c827d0d7f..e26ffd079556 100644
> > --- a/include/net/ieee802154_netdev.h
> > +++ b/include/net/ieee802154_netdev.h
> > @@ -149,6 +149,11 @@ struct ieee802154_assoc_req_pl {
> > #endif
> > } __packed;
> >
> > +struct ieee802154_assoc_resp_pl {
> > + __le16 short_addr;
> > + u8 status;
> > +} __packed;
> > +
> > enum ieee802154_frame_version {
> > IEEE802154_2003_STD,
> > IEEE802154_2006_STD,
> > diff --git a/net/ieee802154/core.c b/net/ieee802154/core.c
> > index cd69bdbfd59f..8bf01bb7e858 100644
> > --- a/net/ieee802154/core.c
> > +++ b/net/ieee802154/core.c
> > @@ -198,6 +198,18 @@ void wpan_phy_free(struct wpan_phy *phy)
> > }
> > EXPORT_SYMBOL(wpan_phy_free);
> >
> > +static void cfg802154_free_peer_structures(struct wpan_dev *wpan_dev)
> > +{
> > + mutex_lock(&wpan_dev->association_lock);
> > +
> > + if (wpan_dev->parent)
> > + kfree(wpan_dev->parent);
> > +
> > + wpan_dev->association_generation++;
> > +
> > + mutex_unlock(&wpan_dev->association_lock);
> > +}
> > +
> > int cfg802154_switch_netns(struct cfg802154_registered_device *rdev,
> > struct net *net)
> > {
> > @@ -293,6 +305,8 @@ static int cfg802154_netdev_notifier_call(struct notifier_block *nb,
> > rdev->opencount++;
> > break;
> > case NETDEV_UNREGISTER:
> > + cfg802154_free_peer_structures(wpan_dev);
> > +
>
> I think the comment below is not relevant here, but I have also no
> idea if this is still the case.
>
> > /* It is possible to get NETDEV_UNREGISTER
> > * multiple times. To detect that, check
> > * that the interface is still on the list
> > diff --git a/net/mac802154/cfg.c b/net/mac802154/cfg.c
> > index 5c3cb019f751..89112d2bcee7 100644
> > --- a/net/mac802154/cfg.c
> > +++ b/net/mac802154/cfg.c
> > @@ -315,6 +315,77 @@ static int mac802154_stop_beacons(struct wpan_phy *wpan_phy,
> > return mac802154_stop_beacons_locked(local, sdata);
> > }
> >
> > +static int mac802154_associate(struct wpan_phy *wpan_phy,
> > + struct wpan_dev *wpan_dev,
> > + struct ieee802154_addr *coord)
> > +{
> > + struct ieee802154_local *local = wpan_phy_priv(wpan_phy);
> > + u64 ceaddr = swab64((__force u64)coord->extended_addr);
> > + struct ieee802154_sub_if_data *sdata;
> > + struct ieee802154_pan_device *parent;
> > + __le16 short_addr;
> > + int ret;
> > +
> > + ASSERT_RTNL();
> > +
> > + sdata = IEEE802154_WPAN_DEV_TO_SUB_IF(wpan_dev);
> > +
> > + if (wpan_dev->parent) {
> > + dev_err(&sdata->dev->dev,
> > + "Device %8phC is already associated\n", &ceaddr);
> > + return -EPERM;
> > + }
> > +
> > + parent = kzalloc(sizeof(*parent), GFP_KERNEL);
> > + if (!parent)
> > + return -ENOMEM;
> > +
> > + parent->pan_id = coord->pan_id;
> > + parent->mode = coord->mode;
> > + if (parent->mode == IEEE802154_SHORT_ADDRESSING) {
> > + parent->short_addr = coord->short_addr;
> > + parent->extended_addr = cpu_to_le64(IEEE802154_ADDR_LONG_BROADCAST);
>
> There is no IEEE802154_ADDR_LONG_BROADCAST (extended address) address.
> The broadcast address is always a short address 0xffff. (Talkin about
> destination addresses).
>
> Just to clarify we can have here two different types/length of mac
> addresses being used, whereas the extended address is always present.
> We have the monitor interface set to an invalid extended address
> 0x0...0 (talking about source address) which is a reserved EUI64 (what
> long/extended address is) address, 0xffff...ffff is also being
> reserved. Monitors get their address from the socket interface.
>
> If there is a parent, an extended address is always present and known.
I want to weaken this, we can also have only the short address of the
neighbor. But it depends on assoc/deassoc, I would think the extended
address should be known. If you look on air and make per neighbor
stats... you can see a neighbor with either a short or extended
address being used. Map them to one neighbor if using a short address
is only possible if you know the mapping... (but this is so far I see
not the case here).
We need some kind of policy here, but with assoc/deassoc we should
always know this mapping.
- Alex
next prev parent reply other threads:[~2023-07-04 11:35 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-01 15:48 [PATCH wpan-next 00/11] ieee802154: Associations between devices Miquel Raynal
2023-06-01 15:48 ` [PATCH wpan-next 01/11] ieee802154: Let PAN IDs be reset Miquel Raynal
2023-06-01 15:48 ` [PATCH wpan-next 02/11] ieee802154: Internal PAN management Miquel Raynal
2023-06-01 15:48 ` [PATCH wpan-next 03/11] ieee802154: Add support for user association requests Miquel Raynal
2023-06-01 15:48 ` [PATCH wpan-next 04/11] mac802154: Handle associating Miquel Raynal
2023-06-02 15:54 ` Simon Horman
2023-08-18 14:17 ` Miquel Raynal
2023-06-03 10:09 ` Alexander Aring
2023-07-04 11:34 ` Alexander Aring [this message]
2023-09-01 15:01 ` Miquel Raynal
2023-09-01 15:31 ` Miquel Raynal
2023-06-01 15:48 ` [PATCH wpan-next 05/11] ieee802154: Add support for user disassociation requests Miquel Raynal
2023-06-01 15:48 ` [PATCH wpan-next 06/11] mac802154: Handle disassociations Miquel Raynal
2023-06-03 11:30 ` Alexander Aring
2023-08-21 9:02 ` Miquel Raynal
2023-06-01 15:48 ` [PATCH wpan-next 07/11] mac802154: Handle association requests from peers Miquel Raynal
2023-06-03 11:28 ` Alexander Aring
2023-08-21 8:52 ` Miquel Raynal
2023-09-01 15:45 ` Miquel Raynal
2023-09-01 16:25 ` Miquel Raynal
2023-06-01 15:48 ` [PATCH wpan-next 08/11] ieee802154: Add support for limiting the number of associated devices Miquel Raynal
2023-06-01 15:48 ` [PATCH wpan-next 09/11] mac802154: Follow " Miquel Raynal
2023-06-01 15:48 ` [PATCH wpan-next 10/11] mac802154: Handle disassociation notifications from peers Miquel Raynal
2023-06-01 15:48 ` [PATCH wpan-next 11/11] ieee802154: Give the user the association list 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=CAK-6q+g_0LZ_OPZtCjAsL8Vn6TiTKM5RUzQTxK7GDzuEEVNSEg@mail.gmail.com \
--to=aahringo@redhat.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=miquel.raynal@bootlin.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).