All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bluetooth-next] ieee802154: handle datagram variables as u16
@ 2015-10-01  6:03 Alexander Aring
  2015-10-01 11:38 ` Marcel Holtmann
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Aring @ 2015-10-01  6:03 UTC (permalink / raw)
  To: linux-wpan; +Cc: kernel, Alexander Aring

This reverts commit 9abc378c66e3d6f437eed77c1c534cbc183523f7
("ieee802154: 6lowpan: change datagram var types").

The reason is that I forgot the IPv6 fragmentation here. Our MTU of
lowpan interface is 1280 and skb->len should not above of that. If we
reach a payload above 1280 in IPv6 header then we have a IPv6
fragmentation above 802.15.4 6LoWPAN fragmentation. The type "u16" was
fine, instead I added now a WARN_ON_ONCE if skb->len is above MTU which
should never happen otherwise IPv6 on minimum MTU size is broken.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 net/ieee802154/6lowpan/6lowpan_i.h  |  4 ++--
 net/ieee802154/6lowpan/reassembly.c |  2 +-
 net/ieee802154/6lowpan/tx.c         | 10 ++++++----
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/net/ieee802154/6lowpan/6lowpan_i.h b/net/ieee802154/6lowpan/6lowpan_i.h
index 10d44d0..b4e17a7 100644
--- a/net/ieee802154/6lowpan/6lowpan_i.h
+++ b/net/ieee802154/6lowpan/6lowpan_i.h
@@ -18,7 +18,7 @@ typedef unsigned __bitwise__ lowpan_rx_result;
 
 struct lowpan_create_arg {
 	u16 tag;
-	unsigned int d_size;
+	u16 d_size;
 	const struct ieee802154_addr *src;
 	const struct ieee802154_addr *dst;
 };
@@ -29,7 +29,7 @@ struct lowpan_frag_queue {
 	struct inet_frag_queue	q;
 
 	u16			tag;
-	unsigned int		d_size;
+	u16			d_size;
 	struct ieee802154_addr	saddr;
 	struct ieee802154_addr	daddr;
 };
diff --git a/net/ieee802154/6lowpan/reassembly.c b/net/ieee802154/6lowpan/reassembly.c
index af663cb..12e8cf4 100644
--- a/net/ieee802154/6lowpan/reassembly.c
+++ b/net/ieee802154/6lowpan/reassembly.c
@@ -37,7 +37,7 @@ static struct inet_frags lowpan_frags;
 static int lowpan_frag_reasm(struct lowpan_frag_queue *fq,
 			     struct sk_buff *prev, struct net_device *ldev);
 
-static unsigned int lowpan_hash_frag(u16 tag, unsigned int d_size,
+static unsigned int lowpan_hash_frag(u16 tag, u16 d_size,
 				     const struct ieee802154_addr *saddr,
 				     const struct ieee802154_addr *daddr)
 {
diff --git a/net/ieee802154/6lowpan/tx.c b/net/ieee802154/6lowpan/tx.c
index 5736302..62a21f6 100644
--- a/net/ieee802154/6lowpan/tx.c
+++ b/net/ieee802154/6lowpan/tx.c
@@ -137,8 +137,8 @@ lowpan_xmit_fragment(struct sk_buff *skb, const struct ieee802154_hdr *wpan_hdr,
 
 static int
 lowpan_xmit_fragmented(struct sk_buff *skb, struct net_device *ldev,
-		       const struct ieee802154_hdr *wpan_hdr,
-		       unsigned int dgram_size, unsigned int dgram_offset)
+		       const struct ieee802154_hdr *wpan_hdr, u16 dgram_size,
+		       u16 dgram_offset)
 {
 	__be16 frag_tag;
 	u8 frag_hdr[5];
@@ -203,7 +203,7 @@ err:
 }
 
 static int lowpan_header(struct sk_buff *skb, struct net_device *ldev,
-			 unsigned int *dgram_size, unsigned int *dgram_offset)
+			 u16 *dgram_size, u16 *dgram_offset)
 {
 	struct wpan_dev *wpan_dev = lowpan_dev_info(ldev)->wdev->ieee802154_ptr;
 	struct ieee802154_addr sa, da;
@@ -253,10 +253,12 @@ netdev_tx_t lowpan_xmit(struct sk_buff *skb, struct net_device *ldev)
 {
 	struct ieee802154_hdr wpan_hdr;
 	int max_single, ret;
-	unsigned int dgram_size, dgram_offset;
+	u16 dgram_size, dgram_offset;
 
 	pr_debug("package xmit\n");
 
+	WARN_ON_ONCE(skb->len > IPV6_MIN_MTU);
+
 	/* We must take a copy of the skb before we modify/replace the ipv6
 	 * header as the header could be used elsewhere
 	 */
-- 
2.6.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH bluetooth-next] ieee802154: handle datagram variables as u16
  2015-10-01  6:03 [PATCH bluetooth-next] ieee802154: handle datagram variables as u16 Alexander Aring
@ 2015-10-01 11:38 ` Marcel Holtmann
  0 siblings, 0 replies; 2+ messages in thread
From: Marcel Holtmann @ 2015-10-01 11:38 UTC (permalink / raw)
  To: Alexander Aring; +Cc: linux-wpan, kernel

Hi Alex,

> This reverts commit 9abc378c66e3d6f437eed77c1c534cbc183523f7
> ("ieee802154: 6lowpan: change datagram var types").
> 
> The reason is that I forgot the IPv6 fragmentation here. Our MTU of
> lowpan interface is 1280 and skb->len should not above of that. If we
> reach a payload above 1280 in IPv6 header then we have a IPv6
> fragmentation above 802.15.4 6LoWPAN fragmentation. The type "u16" was
> fine, instead I added now a WARN_ON_ONCE if skb->len is above MTU which
> should never happen otherwise IPv6 on minimum MTU size is broken.
> 
> Signed-off-by: Alexander Aring <alex.aring@gmail.com>
> ---
> net/ieee802154/6lowpan/6lowpan_i.h  |  4 ++--
> net/ieee802154/6lowpan/reassembly.c |  2 +-
> net/ieee802154/6lowpan/tx.c         | 10 ++++++----
> 3 files changed, 9 insertions(+), 7 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-10-01 11:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-01  6:03 [PATCH bluetooth-next] ieee802154: handle datagram variables as u16 Alexander Aring
2015-10-01 11:38 ` Marcel Holtmann

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.