* [PATCH net-next 3/4] 6lowpan: the two bytes of u16 tag needs to be stored/accessed the other way around
@ 2012-06-11 4:39 Tony Cheneau
2012-06-12 18:07 ` Alexander Smirnov
0 siblings, 1 reply; 3+ messages in thread
From: Tony Cheneau @ 2012-06-11 4:39 UTC (permalink / raw)
To: netdev, linux-zigbee-devel; +Cc: alex.bluesman.smirnov
Or else, tag values, as displayed with a trafic analyser, such a
Wireshark, are not properly displayed (e.g. 0x01 00 insted of 0x00 01,
and so on). ---
net/ieee802154/6lowpan.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
index af4f29b..af2f12e 100644
--- a/net/ieee802154/6lowpan.c
+++ b/net/ieee802154/6lowpan.c
@@ -307,7 +307,7 @@ static u16 lowpan_fetch_skb_u16(struct sk_buff *skb)
BUG_ON(!pskb_may_pull(skb, 2));
- ret = skb->data[0] | (skb->data[1] << 8);
+ ret = (skb->data[0] << 8) | skb->data[1];
skb_pull(skb, 2);
return ret;
}
@@ -1002,8 +1002,8 @@ lowpan_skb_fragmentation(struct sk_buff *skb)
/* first fragment header */
head[0] = LOWPAN_DISPATCH_FRAG1 | (payload_length & 0x7);
head[1] = (payload_length >> 3) & 0xff;
- head[2] = tag & 0xff;
- head[3] = tag >> 8;
+ head[2] = tag >> 8;
+ head[3] = tag & 0xff;
err = lowpan_fragment_xmit(skb, head, header_length, 0, 0);
--
1.7.3.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next 3/4] 6lowpan: the two bytes of u16 tag needs to be stored/accessed the other way around
2012-06-11 4:39 [PATCH net-next 3/4] 6lowpan: the two bytes of u16 tag needs to be stored/accessed the other way around Tony Cheneau
@ 2012-06-12 18:07 ` Alexander Smirnov
2012-06-13 4:42 ` Tony Cheneau
0 siblings, 1 reply; 3+ messages in thread
From: Alexander Smirnov @ 2012-06-12 18:07 UTC (permalink / raw)
To: Tony Cheneau
Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
2012/6/11 Tony Cheneau <tony.cheneauh-jNfjcPZKvDhg9hUCZPvPmw@public.gmane.org>:
> Or else, tag values, as displayed with a trafic analyser, such a
> Wireshark, are not properly displayed (e.g. 0x01 00 insted of 0x00 01,
> and so on). ---
> net/ieee802154/6lowpan.c | 6 +++---
> 1 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
> index af4f29b..af2f12e 100644
> --- a/net/ieee802154/6lowpan.c
> +++ b/net/ieee802154/6lowpan.c
> @@ -307,7 +307,7 @@ static u16 lowpan_fetch_skb_u16(struct sk_buff *skb)
>
> BUG_ON(!pskb_may_pull(skb, 2));
>
> - ret = skb->data[0] | (skb->data[1] << 8);
> + ret = (skb->data[0] << 8) | skb->data[1];
This function aimed to obtain u16 from skb, why did you change the
byte-order here instead of 'tag' variable byte-shifting? Will this
code work properly on the both little and big-endian machines? Please
rework this to keep order properly for all the architectures.
> skb_pull(skb, 2);
> return ret;
> }
> @@ -1002,8 +1002,8 @@ lowpan_skb_fragmentation(struct sk_buff *skb)
> /* first fragment header */
> head[0] = LOWPAN_DISPATCH_FRAG1 | (payload_length & 0x7);
> head[1] = (payload_length >> 3) & 0xff;
> - head[2] = tag & 0xff;
> - head[3] = tag >> 8;
> + head[2] = tag >> 8;
> + head[3] = tag & 0xff;
>
> err = lowpan_fragment_xmit(skb, head, header_length, 0, 0);
>
> --
> 1.7.3.4
>
>
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next 3/4] 6lowpan: the two bytes of u16 tag needs to be stored/accessed the other way around
2012-06-12 18:07 ` Alexander Smirnov
@ 2012-06-13 4:42 ` Tony Cheneau
0 siblings, 0 replies; 3+ messages in thread
From: Tony Cheneau @ 2012-06-13 4:42 UTC (permalink / raw)
To: Alexander Smirnov; +Cc: netdev, linux-zigbee-devel
Hello Alexander,
Please see my response inline.
Le Tue, 12 Jun 2012 22:07:12 +0400,
Alexander Smirnov <alex.bluesman.smirnov@gmail.com> a écrit :
> 2012/6/11 Tony Cheneau <tony.cheneauh@amnesiak.org>:
> > Or else, tag values, as displayed with a trafic analyser, such a
> > Wireshark, are not properly displayed (e.g. 0x01 00 insted of 0x00
> > 01, and so on). ---
> > net/ieee802154/6lowpan.c | 6 +++---
> > 1 files changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
> > index af4f29b..af2f12e 100644
> > --- a/net/ieee802154/6lowpan.c
> > +++ b/net/ieee802154/6lowpan.c
> > @@ -307,7 +307,7 @@ static u16 lowpan_fetch_skb_u16(struct sk_buff
> > *skb)
> >
> > BUG_ON(!pskb_may_pull(skb, 2));
> >
> > - ret = skb->data[0] | (skb->data[1] << 8);
> > + ret = (skb->data[0] << 8) | skb->data[1];
>
> This function aimed to obtain u16 from skb, why did you change the
> byte-order here instead of 'tag' variable byte-shifting?
This probably reflects my lack of practice in writing/reading network
code. I witnessed in my network that the byte order was wrong when
sending/receiving packet (using Wireshark) and though it would be a
quick fix. Also, I assumed skb->data would store data using network
ordering, so that skb->data[0] would have been the MSB and
skb->data[1] would have been the LSB. I'll look more into that.
> Will this
> code work properly on the both little and big-endian machines?
I haven't checked that. But, just for clarification, if my changes are
not working properly on both architectures, it means that the original
code doesn't either, right?
> Please
> rework this to keep order properly for all the architectures.
I will read some more network code to see how it is handled in other
part of the kernel and rewrite the patch accordingly (if at all
needed).
Thank you for your advises.
> > skb_pull(skb, 2);
> > return ret;
> > }
> > @@ -1002,8 +1002,8 @@ lowpan_skb_fragmentation(struct sk_buff *skb)
> > /* first fragment header */
> > head[0] = LOWPAN_DISPATCH_FRAG1 | (payload_length & 0x7);
> > head[1] = (payload_length >> 3) & 0xff;
> > - head[2] = tag & 0xff;
> > - head[3] = tag >> 8;
> > + head[2] = tag >> 8;
> > + head[3] = tag & 0xff;
> >
> > err = lowpan_fragment_xmit(skb, head, header_length, 0, 0);
> >
> > --
> > 1.7.3.4
> >
> >
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
Regards,
Tony
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-06-13 4:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-11 4:39 [PATCH net-next 3/4] 6lowpan: the two bytes of u16 tag needs to be stored/accessed the other way around Tony Cheneau
2012-06-12 18:07 ` Alexander Smirnov
2012-06-13 4:42 ` Tony Cheneau
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).