Linux IEEE 802.15.4 and 6LoWPAN development
 help / color / mirror / Atom feed
From: Simon Vincent <simon.vincent@xsilon.com>
To: Alexander Aring <alex.aring@gmail.com>
Cc: linux-wpan@vger.kernel.org
Subject: Re: Kernel crash when using multiple interfaces
Date: Fri, 15 May 2015 16:02:32 +0100	[thread overview]
Message-ID: <55560A88.1050903@xsilon.com> (raw)
In-Reply-To: <20150515142026.GA11157@omega>

I tried the solution you proposed but it did not work, it resulted in a 
kernel crash (bad paging request).

We require multiple 802.15.4 interfaces for routing between different 
802.15.4 networks. We have a 802.15.4 powerline phy (Hanadu [1]) and a 
802.15.4 radio phy (MRF24J40). On some boxes we have both phys and route 
using RPL between the powerline and radio networks.

[1] http://www.hanadu.org/

- Simon

On 15/05/15 15:20, Alexander Aring wrote:
> Hi Simon.
>
> On Fri, May 15, 2015 at 01:54:10PM +0100, Simon Vincent wrote:
>> I have found the Kernel crashes when multiple 802.15.4 interfaces are used
>> at the same time.
>> I have tracked it down in the kernel to net/mac802154/tx.c
>> The problem is the ieee802154_xmit_cb is a global variable so after it has
>> been assigned and added to the work queue it can be corrupted/changed by
>> another interface transmitting a packet.
>>
>> I have fixed it by allocating the structure on the heap. If this is a
>> satisfactory fix I can submit it as a patch.
>>
> first, thank you for finding this issue.
>
> Yes, with multiple interfaces this code have issues. When we declare
> ieee802154_xmit_cb per phy instead of one for every phy this should be
> fixed.
>
> Can you try the following? This should be a solution without calling kmalloc
> in this callback:
>
> diff --git a/net/mac802154/ieee802154_i.h b/net/mac802154/ieee802154_i.h
> index eec668f..c9b38c0 100644
> --- a/net/mac802154/ieee802154_i.h
> +++ b/net/mac802154/ieee802154_i.h
> @@ -28,11 +28,21 @@
>   
>   #include "llsec.h"
>   
> +
>   /* mac802154 device private data */
>   struct ieee802154_local {
>          struct ieee802154_hw hw;
>          const struct ieee802154_ops *ops;
>   
> +       /* xmit worker handler
> +        * TODO remove this xmit_sync is debprecated
> +        */
> +       struct ieee802154_xmit_cb {
> +               struct sk_buff *skb;
> +               struct work_struct work;
> +               struct ieee802154_local *local;
> +       } xmit_cb;
> +
>          /* ieee802154 phy */
>          struct wpan_phy *phy;
>   
> diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c
> index c62e956..afbddc0 100644
> --- a/net/mac802154/tx.c
> +++ b/net/mac802154/tx.c
> @@ -30,17 +30,6 @@
>   #include "ieee802154_i.h"
>   #include "driver-ops.h"
>   
> -/* IEEE 802.15.4 transceivers can sleep during the xmit session, so process
> - * packets through the workqueue.
> - */
> -struct ieee802154_xmit_cb {
> -       struct sk_buff *skb;
> -       struct work_struct work;
> -       struct ieee802154_local *local;
> -};
> -
> -static struct ieee802154_xmit_cb ieee802154_xmit_cb;
> -
>   static void ieee802154_xmit_worker(struct work_struct *work)
>   {
>          struct ieee802154_xmit_cb *cb =
> @@ -106,11 +95,11 @@ ieee802154_tx(struct ieee802154_local *local, struct sk_buff *skb)
>                  dev->stats.tx_packets++;
>                  dev->stats.tx_bytes += skb->len;
>          } else {
> -               INIT_WORK(&ieee802154_xmit_cb.work, ieee802154_xmit_worker);
> -               ieee802154_xmit_cb.skb = skb;
> -               ieee802154_xmit_cb.local = local;
> +               INIT_WORK(&local->xmit_cb.work, ieee802154_xmit_worker);
> +               local->xmit_cb.skb = skb;
> +               local->xmit_cb.local = local;
>   
> -               queue_work(local->workqueue, &ieee802154_xmit_cb.work);
> +               queue_work(local->workqueue, &local->xmit_cb.work);
>          }
>   
>          return NETDEV_TX_OK;
>
>
>
>
> I have anoother question? Which is your use case to use multiple
> interfaces? I am still searching for one... The most multiple interfaces
> can't be running because if the phy sets registers like (address
> filters, promiscuous mode, etc) we can't running another interface with
> different mac values (because we have only one registers in the phy).
>
> This means we have a lot of multiple wpan interfaces with the same mac
> address which represents one. See [0] which checks on different
> settings.
>
> The only one driver (which don't do any mac functionality) is the fakelb
> driver. This driver is compareable with a phy without any mac
> functionality.
>
> I was thinking about to remove the multiple interface support and only
> have one interface which can have different types, so you could morph
> node to monitor and backwards for example. But maybe there exists a
> real use-case for have multiple interfaces on one phy...
>
> - Alex
>
> [0] http://lxr.free-electrons.com/source/net/mac802154/iface.c#L165


  reply	other threads:[~2015-05-15 15:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-15 12:54 Kernel crash when using multiple interfaces Simon Vincent
2015-05-15 14:20 ` Alexander Aring
2015-05-15 15:02   ` Simon Vincent [this message]
2015-05-15 15:23     ` Alexander Aring
2015-05-16 15:33     ` Alexander Aring
2015-05-18 10:57       ` Simon Vincent
2015-05-18 14:00         ` Alexander Aring
2015-05-18 15:05           ` Simon Vincent
2015-05-18 15:37             ` Alexander Aring
2015-05-18 16:27               ` Alexander Aring
2015-05-19 11:18                 ` Simon Vincent
2015-05-15 15:28 ` Alexander Aring

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=55560A88.1050903@xsilon.com \
    --to=simon.vincent@xsilon.com \
    --cc=alex.aring@gmail.com \
    --cc=linux-wpan@vger.kernel.org \
    /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