Re: [PATCH wpan-next 07/11] mac802154: Handle association requests from peers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



miquel.raynal@xxxxxxxxxxx wrote on Fri, 1 Sep 2023 17:45:37 +0200:

> Hi Alexander,
> 
> > > > --- a/net/ieee802154/pan.c
> > > > +++ b/net/ieee802154/pan.c
> > > > @@ -66,3 +66,30 @@ cfg802154_device_is_child(struct wpan_dev *wpan_dev,
> > > >         return NULL;
> > > >  }
> > > >  EXPORT_SYMBOL_GPL(cfg802154_device_is_child);
> > > > +
> > > > +__le16 cfg802154_get_free_short_addr(struct wpan_dev *wpan_dev)
> > > > +{
> > > > +       struct ieee802154_pan_device *child;
> > > > +       __le16 addr;
> > > > +
> > > > +       lockdep_assert_held(&wpan_dev->association_lock);
> > > > +
> > > > +       do {
> > > > +               get_random_bytes(&addr, 2);      
> > > 
> > > This is combined with the max associations setting? I am not sure if
> > > this is the best way to get free values from a u16 value where we have
> > > some data structure of "given" addresses to a node. I recently was
> > > looking into idr/xarray data structure... maybe we can use something
> > > from there.    
> > 
> > I actually thought about using an increasing index, but the pseudo
> > random generator seemed appropriate because of its "unpredictability",
> > but there is not real use for that (besides maybe testing purposes). I
> > can definitely switch to another solution.  
> 
> I looked into this deeper. I didn't felt like idr would be so much
> useful, but I started converting the code to use ida instead (so the
> simplest approach, with no associated pointer). There are actually two
> use cases which clearly match better the random address mechanism.
> 
> a/ One can freely decide the short address of the coordinator (it is
> freely selectable by the user) but ida has no mechanism to handle this
> with an API which would prevent such "number to be used".
> 
> In practice, this could be workarounded "easily", even though the
> implementation would be dirty IMHO: getting an IDA, if it matches ours,
> just try again without freeing it. TBH I don't like much this idea.
> 
> b/ In case we ever want to support master handover, the ida solution
> does not work well...

c/ Technically speaking, leaf devices can connect to a PAN coordinator
which is not the top-level coordinator in case it is out of reach.
So the coordinator receiving the association request needs to allocate
a random address for this leaf device, without knowing all the
addresses the top-level coordinator already allocated. In case the
devices move or a coordinator detects two different devices within the
same PAN with the same short addres, it must trigger a realignment
procedure (not implemented yet). Therefore, following a linear scheme
when allocating children short addresses sounds like an endless source
of conflicts and realignments, whereas random addressing would prevent
most of these situations on regular sized networks?

> For now I've kept the current approach (actually adding a missing
> check), but if you know how to solve that I can either update the
> implementation or make a followup patch, especially since the current
> approach is not bounded (in the theoretical case where we have 65k
> devices in the same PAN).
> 
> I believe the allocation strategies are not set in stone anyway and can
> easily evolve.
> 
> Thanks,
> Miquèl




[Index of Archives]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux