ieee802154: drop multiple lowpan support per wpan interface
Subsystems (2)
Alexander Aring
maintainerv3 cover ieee802154: drop multiple lowpan support per wpan interface
Hi,
this patch series contains two patches. At first we remove the multiple lowpan interface per wpan interface support. I don't see any use case for that, if somebody has an use case for it. Please report your use case.
Currently it's broken to update the wpan mac address while having a lowpan interface on the top. The first patch will introduce some easy mechanism to access the lowpan interface inside the lower mac802154 layer. When the mac802154 changes the mac address then it will updated also on the lowpan interface, if the wpan interface belongs to a lowpan interface.
Another idea would be maybe to react on the lowpan_device_event, when a wpan interface updates his address, but this doesn't work because the lowpan interface need to be down to update the mac setting, otherwise the SLAAC address will not be updated.
- Alex
changes since v3:
- remove "extern struct list_head lowpan_devices;" in net/ieee802154/6lowpan/6lowpan_i.h
- change commit messages that we remove multiple wpan interfaces per wpan interface only. When you have two or more wpan interface you can still have multiple lowpan interfaces.
changes since v2:
- fix handling in patch 2/2 that we will check at first that the lowpan interface is down. Otherwise we had return -EBUSY and wpan interface address was updated and not the lowpan interface address.
- change subject at patch 2/2 from "fix wpan mac setting while lowpan" to "fix wpan mac setting while lowpan is there". I don't use "up", because it was broken before, doesn't matter if the interface was up or down.
- add several tested-by and reviewed-by tags
Alexander Aring (2):
ieee802154: 6lowpan: remove multiple lowpan per wpan support
mac802154: fix wpan mac setting while lowpan is there
include/net/cfg802154.h | 3 ++ net/ieee802154/6lowpan/6lowpan_i.h | 8 ----- net/ieee802154/6lowpan/core.c | 67 +++++++++++--------------------------- net/ieee802154/6lowpan/rx.c | 38 +++++---------------- net/mac802154/iface.c | 15 +++++++++ 5 files changed, 45 insertions(+), 86 deletions(-)
Signature · 1 line
2.5.0
Alexander Aring
maintainerPATCH v3 1/2 ieee802154: 6lowpan: remove multiple lowpan per wpan support
We currently supports multiple lowpan interfaces per wpan interface. I never saw any use case into such functionality. We drop this feature now because it's much easier do deal with address changes inside the under laying wpan interface.
This patch removes the multiple lowpan interface and adds a lowpan_dev netdev pointer into the wpan_dev, if this pointer isn't null the wpan interface belongs to the assigned lowpan interface.
--- include/net/cfg802154.h | 3 ++ net/ieee802154/6lowpan/6lowpan_i.h | 8 ----- net/ieee802154/6lowpan/core.c | 67 +++++++++++--------------------------- net/ieee802154/6lowpan/rx.c | 38 +++++---------------- 4 files changed, 30 insertions(+), 86 deletions(-)
include/net/cfg802154.h +3 -0
@@ -173,6 +173,9 @@ struct wpan_dev {struct list_head list;struct net_device *netdev; +/* lowpan interface, set when the wpan_dev belongs to one lowpan_dev */ +struct net_device *lowpan_dev; +u32 identifier;/* MAC PIB */
net/ieee802154/6lowpan/6lowpan_i.h +0 -8
@@ -37,15 +37,9 @@ static inline u32 ieee802154_addr_hash(const struct ieee802154_addr *a) } } -struct lowpan_dev_record { -struct net_device *ldev; -struct list_head list; -}; -/* private device info */ struct lowpan_dev_info {struct net_device *real_dev;/* real WPAN device ptr */ -struct mutex dev_list_mtx;/* mutex for list ops */ u16 fragment_tag; };
@@ -55,8 +49,6 @@ lowpan_dev_info *lowpan_dev_info(const struct net_device *dev)return netdev_priv (dev); } -extern struct list_head lowpan_devices; -int lowpan_frag_rcv (struct sk_buff *skb,const u8 frag_type);void lowpan_net_frag_exit (void );int lowpan_net_frag_init (void );
net/ieee802154/6lowpan/core.c +19 -48
112 lines not on this page · raw message
net/ieee802154/6lowpan/rx.c +8 -30
@@ -15,36 +15,14 @@#include "6lowpan_i.h" -static int lowpan_give_skb_to_devices (struct sk_buff *skb, -struct net_device *dev) +static int lowpan_give_skb_to_device (struct sk_buff *skb, +struct net_device *dev) { -struct lowpan_dev_record *entry; -struct sk_buff *skb_cp; -int stat =NET_RX_SUCCESS ; - + skb->dev = dev->ieee802154_ptr->lowpan_dev; skb->protocol =htons (ETH_P_IPV6 ); skb->pkt_type =PACKET_HOST ; -rcu_read_lock (); -list_for_each_entry_rcu (entry, &lowpan_devices, list) -if (lowpan_dev_info (entry->ldev)->real_dev == skb->dev) { - skb_cp =skb_copy (skb,GFP_ATOMIC ); -if (!skb_cp) { -kfree_skb (skb); -rcu_read_unlock (); -return NET_RX_DROP ; - } - - skb_cp->dev = entry->ldev; - stat =netif_rx (skb_cp); -if (stat ==NET_RX_DROP ) -break ; - } -rcu_read_unlock (); - -consume_skb (skb); - -return stat; +return netif_rx (skb); } static int
@@ -109,7 +87,7 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,if (skb->data[0 ] ==LOWPAN_DISPATCH_IPV6 ) {/* Pull off the 1-byte of 6lowpan header. */ skb_pull (skb,1 ); -return lowpan_give_skb_to_devices (skb,NULL ); +return lowpan_give_skb_to_device (skb, dev); }else {switch (skb->data[0 ] &0xe0 ) {case LOWPAN_DISPATCH_IPHC :/* ipv6 datagram */
@@ -117,7 +95,7 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,if (ret <0 ) goto drop_skb; -return lowpan_give_skb_to_devices (skb,NULL ); +return lowpan_give_skb_to_device (skb, dev);case LOWPAN_DISPATCH_FRAG1 :/* first fragment header */ ret =lowpan_frag_rcv (skb,LOWPAN_DISPATCH_FRAG1 );if (ret ==1 ) {
@@ -125,7 +103,7 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,if (ret <0 ) goto drop_skb; -return lowpan_give_skb_to_devices (skb,NULL ); +return lowpan_give_skb_to_device (skb, dev); }else if (ret ==-1 ) {return NET_RX_DROP ; }else {
@@ -138,7 +116,7 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,if (ret <0 ) goto drop_skb; -return lowpan_give_skb_to_devices (skb,NULL ); +return lowpan_give_skb_to_device (skb, dev); }else if (ret ==-1 ) {return NET_RX_DROP ; }else {
Signature · 1 line
2.5.0
Alexander Aring
maintainerPATCH v3 2/2 mac802154: fix wpan mac setting while lowpan is there
In reply to Alexander AringIf we currently change the mac address inside the wpan interface while we have a lowpan interface on top of the wpan interface, the mac address setting doesn't reach the lowpan interface. The effect would be that the IPv6 lowpan interface has the old SLAAC address and isn't working anymore because the lowpan interface use in internal mechanism sometimes dev->addr which is the old mac address of the wpan interface.
This patch checks if a wpan interface belongs to lowpan interface, if yes then we need to check if the lowpan interface is down and change the mac address also at the lowpan interface. When the lowpan interface will be set up afterwards, it will use the correct SLAAC address which based on the updated mac address setting.
--- net/mac802154/iface.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
net/mac802154/iface.c +15 -0
@@ -125,6 +125,14 @@ static int mac802154_wpan_mac_addr(struct net_device *dev, void *p)if (netif_running (dev))return -EBUSY ; +/* lowpan need to be down for update +* SLAAC address after ifup +*/ +if (sdata->wpan_dev.lowpan_dev) { +if (netif_running (sdata->wpan_dev.lowpan_dev)) +return -EBUSY ; + } +ieee802154_be64_to_le64 (&extended_addr, addr->sa_data);if (!ieee802154_is_valid_extended_unicast_addr (extended_addr))return -EINVAL ;
@@ -132,6 +140,13 @@ static int mac802154_wpan_mac_addr(struct net_device *dev, void *p)memcpy (dev->dev_addr, addr->sa_data, dev->addr_len); sdata->wpan_dev.extended_addr = extended_addr; +/* update lowpan interface mac address when +* wpan mac has been changed +*/ +if (sdata->wpan_dev.lowpan_dev) +memcpy (sdata->wpan_dev.lowpan_dev->dev_addr, dev->dev_addr, + dev->addr_len); +return mac802154_wpan_update_llsec (dev); }
Signature · 1 line
2.5.0