public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [PATCH 1/6] alfred: Reduce MAX_PAYLOAD by the size of the UDP header
@ 2015-05-31 11:35 Sven Eckelmann
  2015-05-31 11:35 ` [B.A.T.M.A.N.] [PATCH 2/6] alfred: Make buffer size check before sending explicit Sven Eckelmann
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Sven Eckelmann @ 2015-05-31 11:35 UTC (permalink / raw)
  To: b.a.t.m.a.n

The len field in the UDP header is 16 bit long. It can therefore store a
value of up to (2 ** 16 - 1). This value is currently used for MAX_PAYLOAD.
But the UDP len field not only stores the payload length but also the udp
header itself. Thus the length of MAX_PAYLOAD has to be reduced by the
size of udphdr to make sure that the payload can still be sent.

Reported-by: Hans-Werner Hilse <hwhilse@gmail.com>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 alfred.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/alfred.h b/alfred.h
index 8fc8ab1..7c308e5 100644
--- a/alfred.h
+++ b/alfred.h
@@ -26,4 +26,5 @@
 #include <net/ethernet.h>
 #include <netinet/in.h>
+#include <netinet/udp.h>
 #include <stdint.h>
 #include <time.h>
@@ -138,5 +139,5 @@ struct globals {
 #define debugFree(ptr, num)	free(ptr)
 
-#define MAX_PAYLOAD ((1 << 16) - 1)
+#define MAX_PAYLOAD ((1 << 16) - 1 - sizeof(struct udphdr))
 
 extern const struct in6_addr in6addr_localmcast;
-- 
2.1.4


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

end of thread, other threads:[~2015-06-01 17:56 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-31 11:35 [B.A.T.M.A.N.] [PATCH 1/6] alfred: Reduce MAX_PAYLOAD by the size of the UDP header Sven Eckelmann
2015-05-31 11:35 ` [B.A.T.M.A.N.] [PATCH 2/6] alfred: Make buffer size check before sending explicit Sven Eckelmann
2015-06-01 17:23   ` Sven Eckelmann
2015-05-31 11:35 ` [B.A.T.M.A.N.] [PATCH 3/6] alfred: Don't push data when nothing is available Sven Eckelmann
2015-05-31 11:35 ` [B.A.T.M.A.N.] [PATCH 4/6] alfred: Check buffer size before pushing data over unix socket Sven Eckelmann
2015-05-31 11:35 ` [B.A.T.M.A.N.] [PATCH 5/6] alfred: First check only push_data header length Sven Eckelmann
2015-05-31 11:36 ` [B.A.T.M.A.N.] [PATCH 6/6] alfred: Drop small push_data packets early Sven Eckelmann
2015-06-01 17:56 ` [B.A.T.M.A.N.] [PATCH 1/6] alfred: Reduce MAX_PAYLOAD by the size of the UDP header Simon Wunderlich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox