* [B.A.T.M.A.N.] [PATCH next] batman-adv: Fix endianness errors for network coding
@ 2013-03-14 20:30 Martin Hundebøll
2013-03-16 10:09 ` Marek Lindner
0 siblings, 1 reply; 2+ messages in thread
From: Martin Hundebøll @ 2013-03-14 20:30 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Martin Hundebøll
Add a htonl() in network_coding.c when reading the sequence number
from received ogm_packet, to avoid wrong byte ordering when comparing
with a host value. This bug was introduced in
3ed7ada3f0bbcd058567bc0a8f9729a73eba7db6 ("batman-adv: network coding -
detect coding nodes and remove these after timeout").
Change the type of coded_packet->coded_len from uint16 to __be16 to
avoid wrong assumptions about endianness in later uses. Introduced in
c3289f3650d34b60296000a629c99f2488f7c3dd ("batman-adv: network coding -
code and transmit packets if possible").
Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Martin Hundebøll <martin@hundeboll.net>
---
network-coding.c | 2 +-
packet.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/network-coding.c b/network-coding.c
index 5728079..086c107 100644
--- a/network-coding.c
+++ b/network-coding.c
@@ -654,7 +654,7 @@ static bool batadv_can_nc_with_orig(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node,
struct batadv_ogm_packet *ogm_packet)
{
- if (orig_node->last_real_seqno != ogm_packet->seqno)
+ if (orig_node->last_real_seqno != ntohl(ogm_packet->seqno))
return false;
if (orig_node->last_ttl != ogm_packet->header.ttl + 1)
return false;
diff --git a/packet.h b/packet.h
index a079958..a51ccfc 100644
--- a/packet.h
+++ b/packet.h
@@ -308,7 +308,7 @@ struct batadv_coded_packet {
uint8_t second_source[ETH_ALEN];
uint8_t second_orig_dest[ETH_ALEN];
__be32 second_crc;
- uint16_t coded_len;
+ __be16 coded_len;
};
#endif /* _NET_BATMAN_ADV_PACKET_H_ */
--
1.8.1.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [B.A.T.M.A.N.] [PATCH next] batman-adv: Fix endianness errors for network coding
2013-03-14 20:30 [B.A.T.M.A.N.] [PATCH next] batman-adv: Fix endianness errors for network coding Martin Hundebøll
@ 2013-03-16 10:09 ` Marek Lindner
0 siblings, 0 replies; 2+ messages in thread
From: Marek Lindner @ 2013-03-16 10:09 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Martin Hundebøll
On Friday, March 15, 2013 04:30:21 Martin Hundebøll wrote:
> Add a htonl() in network_coding.c when reading the sequence number
> from received ogm_packet, to avoid wrong byte ordering when comparing
> with a host value. This bug was introduced in
> 3ed7ada3f0bbcd058567bc0a8f9729a73eba7db6 ("batman-adv: network coding -
> detect coding nodes and remove these after timeout").
>
> Change the type of coded_packet->coded_len from uint16 to __be16 to
> avoid wrong assumptions about endianness in later uses. Introduced in
> c3289f3650d34b60296000a629c99f2488f7c3dd ("batman-adv: network coding -
> code and transmit packets if possible").
>
> Reported-by: Fengguang Wu <fengguang.wu@intel.com>
> Signed-off-by: Martin Hundebøll <martin@hundeboll.net>
> ---
> network-coding.c | 2 +-
> packet.h | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
Applied in revision a67d520.
Thanks,
Marek
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-03-16 10:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-14 20:30 [B.A.T.M.A.N.] [PATCH next] batman-adv: Fix endianness errors for network coding Martin Hundebøll
2013-03-16 10:09 ` Marek Lindner
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).